text stringlengths 8 4.13M |
|---|
use rink::{load, one_line};
command!(calc(_ctx, msg, args) {
let mut ctx = load()?;
ctx.short_output = true;
let output = match one_line(&mut ctx, &args.full()) {
Ok(r) => r, Err(e) => e
};
msg.reply(&output)?;
});
|
use crate::components::{
Bot, CarryComponent, EnergyComponent, OwnedEntity, PositionComponent, Resource,
};
use crate::indices::{EntityId, UserId};
use crate::scripting_api::OperationResult;
use crate::storage::views::View;
use crate::tables::traits::Table;
use serde::{Deserialize, Serialize};
use tracing::debug;
... |
use std::fs;
use aoc20::days::day7;
#[test]
fn day7_parse_bag() {
assert_eq!(day7::Bag::parse("1 wavy maroon bag"),
Some(day7::Bag::new(String::from("wavy maroon"), 1))
);
assert_eq!(day7::Bag::parse("5 clear tan bags."),
Some(day7::Bag::new(String::from("clear tan"), 5))
);
assert_... |
#[doc = "Reader of register PWR_CTRL_SM_ST"]
pub type R = crate::R<u32, super::PWR_CTRL_SM_ST>;
#[doc = "Reader of field `PWR_CTRL_SM_CURR_STATE`"]
pub type PWR_CTRL_SM_CURR_STATE_R = crate::R<u8, u8>;
impl R {
#[doc = "Bits 0:3 - This register reflects the current state of the LL Power Control FSM 4'h0 - IDLE 4'h1... |
use super::super::super::super::{awesome, btn, modeless, text};
use super::super::super::state::{chat, dicebot, Modal, Modeless};
use super::Msg;
use crate::{
block::{self, chat::item::Sender, BlockId},
model::{self},
Color, Resource,
};
use kagura::prelude::*;
use wasm_bindgen::JsCast;
mod common {
pu... |
use volatile::Volatile;
// VGA text buffer address
const VGA_ADDRESS: usize = 0xb8000;
// Text buffer width and height
const VGA_BUF_WIDTH: usize = 80;
const VGA_BUF_HEIGHT: usize = 25;
// Struct that represents a single character, each is 2 bytes
// See https://en.wikipedia.org/wiki/VGA-compatible_text_mode#Text_bu... |
pub struct EventBuilder {
pending_event: EventBuilderState,
}
/// Event data sent by server
#[derive(Debug, PartialEq, Clone)]
pub struct Event {
/// Represents message `id` field. Default "".
pub id: String,
/// Represents message `event` field. Default "message".
pub type_: String,
/// Repres... |
#![allow(non_upper_case_globals, non_camel_case_types, non_snake_case)]
#[macro_use]
extern crate cfg_if;
cfg_if! {
if #[cfg(feature = "gen")] {
// include!(concat!(env!("OUT_DIR"), "/config.rs"));
include!(concat!(env!("OUT_DIR"), "/raw.rs"));
} else {
// include!("config.rs");
... |
use rand::Rng;
use genetic_architecture::{Chromosome, Gamete, GeneticArchitecture, Individual};
pub struct UniformSampler {
}
pub trait IndividualSampler {
fn sample<R: Rng>(&mut self, genetic_architecture: &GeneticArchitecture, rng: &mut R) -> Individual;
}
impl UniformSampler {
pub fn new() -> UniformSam... |
mod CapriCore;
mod gltfimporttest;
mod ShapelVRM;
use std::io::Error;
const WINDOW_WIDTH: u32 = 800;
const WINDOW_HEIGHT: u32 = 800;
use winapi::um::winnt::{HRESULT, LPCWSTR};
use winapi::shared::minwindef::{LPARAM, LRESULT, UINT, WPARAM, HINSTANCE, FALSE, TRUE};
use winapi::shared::windef::{HICON, HWND, RECT, HWND... |
//mod client;
//mod model;
//
//pub use self::client::get;
//pub use self::model::RequestParameters;
|
#[doc = "Register `QUADSPI_FCR` writer"]
pub type W = crate::W<QUADSPI_FCR_SPEC>;
#[doc = "Field `CTEF` writer - CTEF"]
pub type CTEF_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>;
#[doc = "Field `CTCF` writer - CTCF"]
pub type CTCF_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>;
#[doc = "Field `CSMF` ... |
use proc_macro2::TokenStream;
use crate::util::{ ident_from_str };
use crate::attributes::{ get_field_type, ParentDataType, FieldDataType, get_expose_attribute };
mod derivable;
pub mod from_bits;
pub mod from_bytes;
pub mod from_reader;
pub mod from_slice;
use derivable::{ Derivable, get_derivable};
///Collects th... |
use rand::prelude::*;
use crate::data::EOByte;
/// used for encoding/decoding packet data
///
/// Packets are encrypted in three steps:
/// 1. Flipping
/// 2. Interleaving
/// 3. "dickwinding"
///
/// ## Flipping
/// Each byte of the packet has their most significant bits flipped
/// ```text
/// for i in 0..length {
... |
use crate::renderer::managers::FontDetails;
use crate::renderer::managers::TextDetails;
use crate::renderer::renderer::Renderer;
use crate::renderer::TextureManager;
use crate::ui::text_character::CharacterSizeManager;
use crate::ui::CanvasAccess;
use rider_config::Config;
use rider_config::ConfigAccess;
use rider_conf... |
#[doc = "Register `ETH_DMAC0RxDLAR` reader"]
pub type R = crate::R<ETH_DMAC0RX_DLAR_SPEC>;
#[doc = "Register `ETH_DMAC0RxDLAR` writer"]
pub type W = crate::W<ETH_DMAC0RX_DLAR_SPEC>;
#[doc = "Field `RDESLA` reader - Start of Receive List"]
pub type RDESLA_R = crate::FieldReader<u32>;
#[doc = "Field `RDESLA` writer - Sta... |
// ---------------------------------------------------------------------
// Config Reader
// ---------------------------------------------------------------------
// Copyright (C) 2007-2021 The NOC Project
// See LICENSE for details
// ---------------------------------------------------------------------
use super::Fi... |
#[macro_use]
extern crate synom;
pub mod parser;
pub mod ast;
use std::ops::Deref;
use synom::IResult;
use synom::space::*;
use self::ast::*;
use self::parser::*;
/// Parse a VMF string, returning the list of parsed blocks
pub fn parse<'a, I, K>(input: &'a I) -> Result<Vec<Block<K>>, &'static str> where I: 'a + Der... |
/*
* Copyright 2020 Damian Peckett <damian@pecke.tt>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applica... |
pub fn test() {
println!("Hello, world!");
let s: String = "hello, world".to_string();
println!("{}", first_space_index(&s));
println!("{}", first_word_slice("slice first word"));
println!("{}", second_word_slice("slice second word"));
println!("{}", second_word_slice_2("shouldbeempty"));
pr... |
//! The `write_stage` module implements the TPU's write stage. It
//! writes entries to the given writer, which is typically a file or
//! stdout, and then sends the Entry to its output channel.
use bank::Bank;
use cluster_info::ClusterInfo;
use counter::Counter;
use entry::Entry;
use ledger::{Block, LedgerWriter};
us... |
fn main() {
const INPUT_ROW: usize = 2978;
const INPUT_COL: usize = 3083;
let mut row = 1;
let mut col = 1;
let mut val: u64 = 20151125;
while !(row == INPUT_ROW && col == INPUT_COL) {
val = (val * 252533) % 33554393;
if row == 1 {
row = col + 1;
col = 1;... |
extern crate gilrs;
use self::gilrs::Gilrs;
use pixel::*;
use ssd1327::*;
pub struct Context {
pub display: SSD1327,
pub gilrs: Gilrs,
pub pixel: Pixel,
}
impl Context {
pub fn new(filename: &'static str) -> Context {
Context {
display: SSD1327::new(filename),
gilrs: G... |
use ferris_base;
mod utils;
#[test]
fn nominal() {
let start = vec![
"🦀..........",
"🚀..........",
"Ro==Wi......",
"Fe==U ......",
];
let inputs = vec![ferris_base::core::direction::Direction::DOWN];
let end = vec![
"............",
"🚀..........",
... |
use super::*;
use crate::utils::leak_value;
/**
The root module of a dynamic library,
which may contain other modules,function pointers,and static references.
For an example of a type implementing this trait you can look
at either the example in the readme for this crate,
or the `example/example_*_interface` crate... |
use crate::libs::gapi::gapi;
use crate::libs::idb;
use crate::libs::random_id;
use crate::libs::skyway::Peer;
use crate::model::config::Config;
use js_sys::Promise;
use std::rc::Rc;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen_futures::JsFuture;
pub async fn initialize() -> Option<(
Con... |
extern crate advent_of_code_2017_day_14;
use advent_of_code_2017_day_14::*;
#[test]
fn part_1_example() {
let input = "flqrgnkx";
assert_eq!(solve_puzzle_part_1(input), "8108");
}
#[test]
fn part_2_example() {
let input = "flqrgnkx";
assert_eq!(solve_puzzle_part_2(input), "1242");
}
|
use libc::{c_int, c_void};
#[link(name = "elevatormagic")]
extern {
pub fn issue_override_code(code: c_int);
pub fn poll_override_code() -> c_int;
pub fn poll_override_input_floor() -> c_int;
pub fn poll_override_error() -> c_int;
pub fn poll_override_session() -> *const c_void;
pub fn free_override_... |
use failure::Error;
use rocket::State;
use crate::Context;
use crate::SID;
//
// a users links
//
#[get("/<username>")]
pub fn all(ctx: State<Context>, username: String) -> Result<String, Error> {
Ok("foo".to_string())
}
//
// add a link
//
#[post("/<username>")]
pub fn create(ctx: State<Context>, sid: SID, u... |
use crate::exchange::{Exchange, interface::private::AggressiveOrderType};
use crate::history::{
parser::EventProcessor,
types::{HistoryEventBody, OrderOrigin},
};
use crate::lags::interface::NanoSecondGenerator;
use crate::order::{LimitOrder, Order};
use crate::trader::Trader;
use crate::types::{Direction, Orde... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Sku {
pub family: sku::Family,
pub name: sku::Name,
}
pub mod sku {
use super::*;
#[derive(Clone, D... |
use crate::brick::BrickType;
use crate::render::ImageFrame;
use sdl2::rect::Rect;
use serde::{Deserialize, Serialize};
/// Which image to render when calling `render_image`. This module
/// maps the image to the appropriate location in the larger texture.
#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq)... |
use std::ops::Range;
use ash::version::DeviceV1_0;
use ash::vk;
use crate::map_vk_error;
use crate::vulkan::{Device, VkError};
pub struct Image {
handle: vk::Image,
format: vk::Format,
requirements: vk::MemoryRequirements,
memory_range: Range<u64>,
}
pub struct ImageView {
handle: vk::ImageView,... |
#[doc = "Reader of register DDRCTRL_DFIUPD2"]
pub type R = crate::R<u32, super::DDRCTRL_DFIUPD2>;
#[doc = "Writer for register DDRCTRL_DFIUPD2"]
pub type W = crate::W<u32, super::DDRCTRL_DFIUPD2>;
#[doc = "Register DDRCTRL_DFIUPD2 `reset()`'s with value 0x8000_0000"]
impl crate::ResetValue for super::DDRCTRL_DFIUPD2 {
... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct RegistrationDefinition {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub properties: Option<... |
use std::rc::Rc;
use super::scope::{Scope, ScopeId};
use std::fmt::Display;
use super::types::{Type, TypeKind};
use crate::syntax::{
ast::{Item, Ptr, Ident, AstNode},
token::{Position}
};
#[derive(Debug, Clone, PartialEq)]
pub enum ItemState {
Resolved,
Active,
Unresolved,
}
#[derive(Debug, Clone... |
use hydroflow::util::cli::{ConnectedDemux, ConnectedDirect, ConnectedSink, ConnectedSource};
use hydroflow::util::{deserialize_from_bytes, serialize_to_bytes};
use hydroflow_datalog::datalog;
#[hydroflow::main]
async fn main() {
let mut ports = hydroflow::util::cli::init().await;
let vote_to_participant_source... |
pub fn crc_clp2(mut x: i32) -> i32 {
x = x - 1;
x = x | (x >> 1);
x = x | (x >> 2);
x = x | (x >> 4);
x = x | (x >> 8);
x = x | (x >> 16);
return x + 1;
}
#[cfg_attr(not(target_arch = "x86_64"),test_case)]
#[cfg_attr(not(target_arch = "riscv64"),test)]
fn test_crc_clp2() {
assert_eq!(cr... |
use crate::data::{encode_number, EOByte, EOInt};
#[derive(Debug, Default)]
pub struct ClientSequencer {
sequence_start: EOInt,
sequence_increment: EOInt,
}
impl ClientSequencer {
pub fn set_init_sequence(&mut self, s1: EOInt, s2: EOInt) {
self.sequence_start = ((s1 as i32) * 7 - 11 + (s2 as i32) -... |
/*!
```rudra-poc
[target]
crate = "rusb"
version = "0.6.5"
indexed_version = "0.6.0"
[report]
issue_url = "https://github.com/a1ien/rusb/issues/44"
issue_date = 2020-12-18
rustsec_url = "https://github.com/RustSec/advisory-db/pull/580"
rustsec_id = "RUSTSEC-2020-0098"
[[bugs]]
analyzer = "SendSyncVariance"
bug_class ... |
pub mod bit;
pub mod fft;
pub mod lazysegtree;
pub mod lis;
pub mod math;
pub mod maxflow;
pub mod modint;
pub mod perm;
pub mod search;
pub mod segtree;
pub mod slice;
pub mod unionfind;
|
/*!
```rudra-poc
[target]
crate = "conqueue"
version = "0.3.0"
[[target.peer]]
crate = "crossbeam-utils"
version = "0.8.0"
[report]
issue_url = "https://github.com/longshorej/conqueue/issues/9"
issue_date = 2020-11-24
rustsec_url = "https://github.com/RustSec/advisory-db/pull/672"
rustsec_id = "RUSTSEC-2020-0117"
[[... |
pub fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
read::<String>()
.split_whitespace()
.map(|e| e.parse().ok().unwrap())
.collect()
}... |
pub mod buf_tcpstream;
pub mod command;
|
pub fn rotate(input: &str, key: i8) -> String {
let mut output: String = String::new();
let rotate_key = match key {
x if x >= 0 => key,
_rest => {
26 + key
}
};
let start_lowercase = b'a';
let end_lowercase = b'z';
let lowercase_letters = (start_lowercase.... |
use std::{iter, sync::Arc};
use crate::tests::helpers::fixtures::get_language;
use tree_sitter::{Language, Node, Parser, Point, Query, QueryCursor, TextProvider, Tree};
fn parse_text(text: impl AsRef<[u8]>) -> (Tree, Language) {
let language = get_language("c");
let mut parser = Parser::new();
parser.set_... |
use std::io::prelude::*;
use std::{fs::File, io::BufReader};
use crate::solver::Solver;
pub struct Solution;
impl Solver for Solution {
type Input = Vec<u32>;
type Output1 = u32;
type Output2 = u32;
fn parse_input(&self, file: File) -> Self::Input {
BufReader::new(file)
.lines()
... |
pub mod sd;
use std::io;
use std::path::Path;
pub use fat32::traits;
use fat32::vfat::{self, Shared, VFat};
use self::sd::Sd;
use pi::mutex::Mutex;
pub struct FileSystem(Mutex<Option<Shared<VFat>>>);
impl FileSystem {
/// Returns an uninitialized `FileSystem`.
///
/// The file system must be initialize... |
// implements linear algebra math submodule
pub fn svd(/*matrix*/) /*-> (S,V,D)*/ {
}
pub fn determinant(/*matrix*/) -> f64 {
return 1.0;
}
pub fn inverse(/*matrix*/) /*-> matrix*/ {
}
pub fn transpose(/*matrix*/) /*-> matrix*/ {
}
pub fn eigen(/*matrix*/) /*-> (eigenvectors, eigenvalues)*/ {
}
pub fn diago... |
use crate::cartridge::Cartridge;
use crate::interrupts::InterruptFlag;
use crate::interrupts::INTERRUPT_FLAG_ADDR;
const DIVIDER_ADDR: u16 = 0xff04;
const COUNTER_ADDR: u16 = 0xff05;
const MODULO_ADDR: u16 = 0xff06;
const TIMER_CONTROL_ADDR: u16 = 0xff07;
pub struct MMU {
pub memory: [u8; 65536],
c... |
pub fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
read::<String>()
.split_whitespace()
.map(|e| e.parse().ok().unwrap())
.collect()
}... |
extern crate turtle;
use std::fs::File;
// use std::io::{Write, Error};
// mod turtle::ast;
fn main() {
use std::io::*;
let mut source = String::new();
match std::env::args().nth(1) {
Some(filename) => {
File::open(&filename)
.expect(&format!("Can't open {}", &filena... |
use bio::io::fasta;
use std::collections::HashMap;
use std::collections::HashSet;
use std::path::Path;
pub fn run(filename: &str) {
let table: HashMap<&str, &str> = [
("UUU", "F"),
("CUU", "L"),
("AUU", "I"),
("GUU", "V"),
("UUC", "F"),
("CUC", "L"),
("AUC",... |
use std::{
fs::File,
io::{self, BufRead, BufReader, BufWriter, Write},
os::unix::prelude::FromRawFd,
path::PathBuf,
};
use arguably::ArgParser;
#[derive(Debug, Clone)]
struct Options {
input: Option<PathBuf>,
output: Option<PathBuf>,
}
impl Options {
pub fn parse() -> std::io::Result<Opti... |
#[doc = "Register `CLRFR` reader"]
pub type R = crate::R<CLRFR_SPEC>;
#[doc = "Register `CLRFR` writer"]
pub type W = crate::W<CLRFR_SPEC>;
#[doc = "Field `CPERF` reader - Clear the preamble error flag"]
pub type CPERF_R = crate::BitReader;
#[doc = "Field `CPERF` writer - Clear the preamble error flag"]
pub type CPERF_... |
use std::iter;
fn main() {
println!("First solution: {}", find_fuel_min(|n| n));
println!("Second solution: {}", find_fuel_min(|n| n * (n + 1) / 2));
}
fn find_fuel_min(cost: fn(i64) -> i64) -> i64 {
let mut min = i64::MAX;
let crabs = input();
for i in 0..3000 {
let fuel = crabs
... |
extern crate schedme;
extern crate time;
use schedme::Scheduler;
use time::Duration;
fn main() {
let scheduler = Scheduler::new();
scheduler.keep_it();
// scheduler.add_task(Task { name: "abra" }, Duration::minutes(5));
} |
fn main() {
if let Err(e) = catr::get_args().and_then(catr::run) {
eprintln!("{}", e);
std::process::exit(1);
}
}
|
use crate::graphs::Graph;
use crate::map_model::TrafficControl;
use cgmath::MetricSpace;
use cgmath::Vector2;
use serde::{Deserialize, Serialize};
use slotmap::new_key_type;
new_key_type! {
pub struct NavNodeID;
}
#[derive(Clone, Copy, Serialize, Deserialize)]
pub struct NavNode {
pub pos: Vector2<f32>,
p... |
extern crate gcc;
fn main() {
let sources = &[
"../../../rt/rust_builtin.c",
"../../../rt/rust_android_dummy.c"
];
gcc::compile_library("librust_builtin.a", sources);
}
|
use tokio::prelude::*;
use std::net::SocketAddr;
use failure::ResultExt;
mod proto;
pub struct ZooKeeper {}
impl ZooKeeper {
pub connect(addr: &SocketAddr) -> impl Future<Item = Self, Error = failure::Error> {
tokio::net::TcpStream::connect(addr: &SocketAddr).and_then(|stream| {
})
... |
//! REST API of the node
mod server;
pub mod v0;
pub use self::server::{Error, Server};
use crate::blockchain::BlockchainR;
use crate::fragment::Logs;
use crate::settings::start::{Error as ConfigError, Rest};
use std::sync::{Arc, Mutex};
pub struct Context {
pub stats_counter: v0::node::stats::StatsCounter,
... |
#[macro_use]
extern crate clap;
extern crate image;
extern crate imageproc;
extern crate rusttype;
use clap::App;
use std::iter::Iterator;
use image::{DynamicImage, GenericImageView, Rgba};
use imageproc::drawing::draw_text_mut;
use rusttype::{Font, FontCollection, Scale, Rect, point};
const TITLE: &str = "LGTM";
con... |
impl PacketConfig for Radio<'_> {
pub fn packet_rssi(&self) -> u8 {
// let freq = self.frequency.get() as f64;
let rssi_base;
if freq < 868E6 {
rssi_base = 164;
} else {
rssi_base = 157;
}
self.register_return(RegMap::RegPktRssiValue) - rssi_ba... |
use futures::{Future, Stream};
use tokio::timer::Interval;
use std::time::{Duration, Instant};
pub(crate) fn timeloop<F: FnMut(Instant) -> bool>(
func: F,
period: Duration,
) -> impl Future<Item = (), Error = ()> {
Interval::new(Instant::now(), period)
.map_err(move |e| {
error!(
target: "server",
"A ... |
use crate::{ import::*, * };
/// A futures 0.3 Sink/Stream of [WsMessage]. Created with [WsMeta::connect](crate::WsMeta::connect).
///
/// ## Closing the connection
///
/// When this is dropped, the connection closes, but you should favor calling one of the close
/// methods on [WsMeta](crate::WsMeta), which allow yo... |
use super::font::Font;
use crate::graphics::drawable::Drawable;
use crate::graphics::canvas::Canvas;
use crate::graphics::color::Color;
use wasm_bindgen::JsValue;
const PX_STR: &str = "px";
/// A struct representing the style of a [Text](struct.Text.html).
pub struct TextStyle {
/// Italic
pub italic: bool,
... |
use appData::AppData;
use std::thread;
use std::thread::JoinHandle;
use std::sync::{Mutex,Arc,RwLock,Weak};
use std::io::{self, ErrorKind};
use std::rc::Rc;
use mio::*;
use mio::tcp::*;
use slab::Slab;
use std::net::SocketAddr;
use server::{Server,DisconnectionReason,DisconnectionSource};
use packet::{ClientToServ... |
use std::io;
use std::fmt;
/// An RFC1035 `<domain-name>` (sequence of labels)
///
#[deriving(PartialEq,Eq,Hash,Clone)]
pub struct Name {
labels: Vec<String>,
}
impl Name {
pub fn new() -> Name {
Name { labels: Vec::new() }
}
/// Parse a byte slice containing an already-decompressed name.
... |
#[macro_use]
extern crate criterion;
#[macro_use]
extern crate lazy_static;
extern crate lab;
extern crate rand;
use criterion::Criterion;
use rand::distributions::Standard;
use rand::Rng;
lazy_static! {
static ref LABS: Vec<lab::Lab> = {
let rand_seed = [0u8; 32];
let rng: rand::rngs::StdRng = ra... |
pub fn eval_rpn(tokens: Vec<String>) -> i32 {
let mut stack = vec![];
for token in tokens {
match token.as_str() {
"+" => {
let a = stack.pop().unwrap();
let b = stack.pop().unwrap();
stack.push(b + a);
},
"-" => {
... |
/// see https://github.com/hecrj/iced/blob/0.2/examples/progress_bar/src/main.rs
use std::char;
use iced::widget::slider;
use iced::{Column, Element, Row, Sandbox, Settings, Slider, Text};
use itertools::izip;
type Num = u32;
const DECIMAL: u32 = 10;
struct State {
format: String,
digits: Vec<Num>,
slide... |
mod eddington;
mod polar_eddington;
mod polar_schwarzschild;
mod schwarzschild;
pub trait Mass {
fn mass() -> f64;
}
pub use self::eddington::EddingtonFinkelstein;
pub use self::polar_eddington::{NearPole0EF, NearPolePiEF};
pub use self::polar_schwarzschild::{NearPole0Schw, NearPolePiSchw};
pub use self::schwarzs... |
use std::fs::File;
use std::fs::metadata;
use std::io::prelude::*;
use std::io::BufReader;
use crate::parsing::args::*;
pub fn parse_file(config: &Config) -> (f64, f64) {
if !metadata(&config.file).expect("error: A problem occured with the file").is_file() {
panic!("error: The file should be a file, I mean a... |
use proc_macro::TokenStream;
use quote::quote;
#[proc_macro_derive(U8Enum)]
pub fn derive_enum_variant_count(input: TokenStream) -> TokenStream {
let syn_item: syn::DeriveInput = syn::parse(input).unwrap();
let len = match syn_item.data {
syn::Data::Enum(enum_item) => enum_item.variants.len(),
... |
// ===============================================================================================
// Imports
// ===============================================================================================
use super::state::*;
use memory::*;
use spin::{Mutex, RwLock};
// ==========================================... |
#![feature(use_extern_macros)]
#![feature(custom_attribute)]
extern crate erased_serde;
extern crate futures;
extern crate hyper;
#[macro_use]
extern crate serde;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate serde_json;
extern crate tokio_core;
mod message;
mod protocol;
mod hubproxy;
mod connecti... |
use std::cell::RefCell;
use std::path::Path;
use std::rc::Rc;
use storage::StorageBuilderFn;
use svm_layout::Layout;
use svm_storage::account::{AccountKVStore, AccountStorage};
use svm_storage::kv::StatefulKV;
use svm_types::{AccountAddr, State};
use crate::{env, storage};
use crate::{Config, DefaultRuntime, Env};
u... |
// Copyright 2020 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
use super::{collateral_penalty_for_deal_activation_missed, DealProposal, DealState};
use crate::{BalanceTable, DealID, OptionalEpoch, SetMultimap};
use address::Address;
use cid::Cid;
use clock::ChainEpoch;
use encoding::Cbor;
use ipld_amt... |
use actix::prelude::*;
use futures::future::*;
use crate::opentracing::Span;
impl Handler<super::ingestor::IngestEvents<Span>> for super::ingestor::Ingestor {
type Result = ();
fn handle(
&mut self,
msg: super::ingestor::IngestEvents<Span>,
_ctx: &mut Context<Self>,
) -> Self::Res... |
use artell_domain::scheduler::SchedulerRepository;
#[derive(Error, Debug)]
pub enum Error {
#[error(transparent)]
Others(#[from] anyhow::Error),
}
pub async fn system_update_scheduler(
scheduler_repo: impl SchedulerRepository,
) -> Result<(), Error> {
if let Some(mut scheduler) = scheduler_repo.find()... |
use crate::models::report::Report;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Veiculo {
pub id: String, // Placa
pub chasis: String,
pub km_atual: i64,
pub relatorios: Vec<Report>,
}
impl Veiculo {
pub fn verificar(&mut self) -> Result<(()), St... |
// When will I Retire?
use std::io::{stdin,stdout,Write};
fn main() {
const CURRENT_YEAR: i32 = 2020;
println!("What is your age? ");
let mut age_str = String::new();
let _ = stdout().flush();
stdin()
.read_line(&mut age_str)
.expect("error: could not read stdin");
age_str = age... |
use totsu::prelude::*;
use totsu::operator::MatBuild;
use totsu::logger::PrintLogger;
use totsu::problem::ProbQP;
use rand::prelude::*;
use rand_xoshiro::rand_core::SeedableRng;
use rand_xoshiro::Xoshiro256StarStar;
type LA = FloatGeneric<f64>;
type AMatBuild = MatBuild<LA, f64>;
type AProbQP = ProbQP<LA, f64>;
type ... |
use cssparser::{ToCss, RGBA};
use std::fmt;
pub struct Hex<'a> {
rgba: &'a RGBA,
}
impl<'a> From<&'a RGBA> for Hex<'a> {
fn from(rgba: &'a RGBA) -> Self {
Hex { rgba }
}
}
impl<'a> ToCss for Hex<'a> {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
where
W: fmt::Write,
{
... |
use std::fmt;
use std::iter::Cloned;
use std::mem;
use std::ops::Index;
use std::ops::IndexMut;
use std::ops::Range;
use std::ops::RangeFrom;
use std::ops::RangeTo;
use std::slice;
use crate::data::*;
pub type LineSize = u16;
#[ derive (Eq, PartialEq) ]
#[ repr (transparent) ]
pub struct Line {
cells: [Cell],
}
im... |
use crate::address::{PAddr, VAddr};
use core::ptr;
use kerla_utils::once::Once;
use x86::io::outb;
#[repr(u8)]
#[derive(Copy, Clone)]
#[allow(unused)]
enum VgaColor {
Black = 0,
Blue = 1,
Green = 2,
Cyan = 3,
Red = 4,
Purple = 5,
Brown = 6,
Gray = 7,
DarkGray = 8,
LightBlue = ... |
// Copyright 2018-2020, Wayfair GmbH
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed... |
#[macro_export]
macro_rules! hashmap {
( $( $k: expr => $v: expr ),* $(,)? ) => {
{
let mut kvpair = std::collections::HashMap::new();
$(
kvpair.insert($k, $v);
)*
kvpair
}
};
}
|
#[doc = "Register `SECSR` reader"]
pub type R = crate::R<SECSR_SPEC>;
#[doc = "Field `SECBSY` reader - busy flag BSY flag indicates that a FLASH memory is busy by an operation (write, erase, option byte change, OBK operations, PUF operation). It is set at the beginning of a Flash memory operation and cleared when the o... |
#[doc = "Reader of register MIS"]
pub type R = crate::R<u32, super::MIS>;
impl R {}
|
use std::env;
use std::fs;
fn main(){
let args : Vec<String> = env::args().collect();
if args.len() < 2 {
return;
}
let input = fs::read_to_string(&args[1]).unwrap()
.strip_suffix('\n').unwrap()
.parse::<i32>().unwrap();
let mut elves = Vec::<i32>::new();
for i in 1..in... |
use std::{collections::HashMap, env, fs, io, path::Path};
use serde_derive::{Deserialize, Serialize};
use bincode::{deserialize_from};
#[derive(Debug, Clone, Default, Copy, Serialize, Deserialize)]
#[repr(C)]
pub struct CondStmtBase {
pub cmpid: u32,
pub context: u32,
pub order: u32,
pub belong: u32, /... |
use http::header::CONTENT_TYPE;
pub use http::status::StatusCode;
pub use hyper::Body;
/// An HTTP response with a streaming body.
pub type Response = hyper::Response<Body>;
pub trait IntoResponse: Send + Sized {
fn into_response(self) -> Response;
}
impl IntoResponse for () {
fn into_response(self) -> Respo... |
// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4)
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
// DO NOT EDIT
use SocketAddressEnumerator;
use ffi;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::mem;
use std::ptr;
glib_wrapper! {
... |
#[cfg(any(target_os = "android"))]
use backtrace::Backtrace;
use common::*;
use components::*;
use gfx_h::{
load_atlas_image, Canvas, GeometryData, GlyphVertex, ParticlesData,
TextData, TextVertexBuffer, WorldTextData,
};
use glyph_brush::*;
#[cfg(any(target_os = "android"))]
use log::trace;
use nphysics2d::wor... |
use std::{error::Error, fs::File, io};
use rustyline::{error::ReadlineError, Editor};
use thiserror::Error;
use crate::{
eval::eval,
ident::identify,
parser::parse,
typeck::typeck,
prelude::*,
};
const HISTORY_FILE: &'static str = ".odlang_history";
#[derive(Debug, Error)]
pub enum HistoryError ... |
use std::collections::{HashMap, HashSet};
use std::io::{BufReader, BufRead, Error};
use std::fs::File;
fn read_input() -> Result<Vec<String>, Error> {
let file = File::open("input/day02.txt").unwrap();
BufReader::new(file).lines().collect::<_>()
}
fn count(s: &str) -> HashMap<char, u32> {
let mut counts =... |
extern crate clap;
use clap::App;
use clap::Arg;
use clap::SubCommand;
use std::env;
/// Command line interface.
pub fn main() {
let query_arg = Arg::with_name("QUERY")
.help("SQL statement to prepare")
.required(true);
let params_arg = Arg::with_name("PARAMS")
.help("The values for th... |
use crate::resources::spawner::DespawnEffect;
use oxygengine::prelude::*;
#[derive(Debug, Copy, Clone)]
pub struct Death(pub DespawnEffect);
impl Component for Death {
type Storage = VecStorage<Self>;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.