text
stringlengths
8
4.13M
use std::fs::File; use std::io::{BufRead, BufReader}; use std::num::ParseIntError; use std::str::FromStr; enum Action { Cut(i64), Deal(u64), NewStack, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] struct ParseActionError; impl From<ParseIntError> for ParseActionError { fn from(_err: ParseIntEr...
// Copyright (c) The diem-devtools Contributors // SPDX-License-Identifier: MIT OR Apache-2.0 use crate::{ partition::{Partitioner, PartitionerBuilder}, test_list::TestBinary, }; use aho_corasick::AhoCorasick; use anyhow::bail; use serde::{Deserialize, Serialize}; use std::{fmt, str::FromStr}; /// Whether to ...
use anyhow::{Context, Result}; use sightglass_data::{Format, Measurement}; use sightglass_upload::{upload, upload_package, MeasurementPackage}; use std::{ fs::File, io::{self, BufReader, Read}, }; use structopt::StructOpt; /// Upload benchmark output to an ElasticSearch server; accepts raw benchmark /// result...
#![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 ErrorResponseLinkedStorage { #[serde(default, skip_serializing_if = "Option::is_none")] pub error: Option<e...
// thread 'rustc' panicked at 'no entry found for key' // prusti-interface/src/environment/polonius_info.rs:1169:9 #[derive(Clone)] struct Foo<'a> { x: &'a i32, } fn bar(foo: &Foo) { let _ = Foo { ..foo.clone() }; } fn main() {} /* thread 'rustc' panicked at 'no entry found for key', prusti-inte...
/* * Datadog API V1 Collection * * Collection of all Datadog Public endpoints. * * The version of the OpenAPI document: 1.0 * Contact: support@datadoghq.com * Generated by: https://openapi-generator.tech */ /// EventQueryDefinition : The event query. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)...
use std::ffi::CString; use libc::c_void; use raw; use gs::effect; pub trait InputSource: Sized { fn id() -> &'static str; fn new(/* settings, obs_source */) -> Self; fn width(&self) -> u32; fn height(&self) -> u32; fn render(&self, effect: Option<&mut effect::Effect>); fn register() { u...
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}; use serde::{Serialize, Deserialize}; #[derive(Serialize, Deserialize)] /// A 2-dimensional vector, holding 2 values of the same type. #[derive(Debug, Copy, Clone, PartialEq, Default)] pub struct Vec2<T> { pub x: T, pub y: T, }...
use std::{error, fmt}; #[derive(Copy, Clone, Debug)] pub enum Error { Init, Start, Stop, Cleanup, Task, } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { write!(f, "Error: {:?}.", self) } } impl error::Error for Error { fn descri...
use super::event::{new_data_event, new_fin_event, new_window_update_event, Event}; use super::message::ConnectRequest; use bytes::BytesMut; use std::pin::Pin; use std::sync::atomic::{AtomicBool, AtomicI32, AtomicU32, Ordering}; use std::sync::Arc; use std::sync::Mutex; use std::task::{Context, Poll, Waker}; use std::t...
use crate::error::RPCError; use ckb_dao::DaoCalculator; use ckb_fee_estimator::MAX_CONFIRM_BLOCKS; use ckb_jsonrpc_types::{ Capacity, DryRunResult, EstimateResult, OutPoint, Script, Transaction, Uint64, }; use ckb_logger::error; use ckb_shared::{shared::Shared, Snapshot}; use ckb_store::ChainStore; use ckb_types::{...
use std::fmt; #[derive(Clone)] pub struct Password(String); impl fmt::Debug for Password { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Password(..)") } } impl Password { pub fn new(inner: String) -> Self { Password(inner) } pub unsafe fn take(self) -> St...
//! Handles the multiboot2 information structure. mod boot_loader_name; mod framebuffer_info; pub use self::boot_loader_name::get_bootloader_name; pub use self::framebuffer_info::get_vga_info; /// Represents a tag in the information structure. #[repr(C)] struct BasicTag { tag_type: u32, size: u32 } /// Repre...
//! `synmap` provides utilities for parsing multi-file crates into `syn` AST //! nodes, and resolving the spans attached to those nodes into raw source text, //! and line/column information. //! //! The primary entry point for the crate is the `SourceMap` type, which stores //! mappings from byte offsets to file inform...
// https://adventofcode.com/2017/day/13 use std::io::{BufRead, BufReader}; use std::fs::File; fn main() { // Read input to a map of name -> connections let f = BufReader::new(File::open("input.txt").expect("Opening input.txt failed")); let mut layers = Vec::new(); for line in f.lines() { let r...
// By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. // // What is the 10 001st prime number? fn main() { let limit = 10001; let mut values: Vec<i64> = Vec::new(); let mut i = 1; while values.len() <= limit { if is_prime(&i) { value...
// This file is part of Substrate. // Copyright (C) 2018-2021 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // 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 // // ht...
#[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; extern crate rusoto_core; extern crate rusoto_route53; extern crate rusoto_sts; extern crate rusoto_s3; use std::collections::HashMap; // Sub-modules for parsing tinydns and interacting with AWS pub mod tinydns; pub mod r53; pub mod ...
use babylon::prelude::*; #[macro_use] extern crate lazy_static; use std::sync::Mutex; lazy_static! { static ref GAME: Mutex<Game> = Mutex::new(Game::new()); } struct Game { time: f64, scene: Scene, shape: Vec<Sphere>, } impl Game { fn new() -> Self { Game { scene: Scene::creat...
use chrono::{DateTime, Utc}; use super::resource::{ResourceKind, CResourceUpdate, SResourceUpdate}; use super::criterion::Criterion; /// Client -> server messages, deserialize only #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(tag = "type")] #[serde(deny_unknown_fields...
use rps::moves::Move; use ::game_state::GameState; /// List of commands that clients send to server #[derive(Debug, Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable)] pub enum ClientCommand { Ping, JoinNewGame, MakeMove(u32, Move), } /// List of commands that server sends to clients #[derive(Deb...
use core::marker::PhantomData; use core::ptr::NonNull; use core::{mem, ptr}; pub mod raw; mod run_queue; pub(crate) mod timer; mod timer_queue; mod util; mod waker; use crate::interrupt::{Interrupt, InterruptExt}; use crate::time::Alarm; #[must_use = "Calling a task function does nothing on its own. You must pass th...
#![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 OperationsListResult { #[serde(default, skip_serializing_if = "Vec::is_empty")] pub value: Vec<Operation>, ...
struct Solution(); // use std::collections::HashMap; // impl Solution { // pub fn majority_element(nums: Vec<i32>) -> i32 { // let mut map:HashMap<i32,u32>=HashMap::new(); // let length=nums.len(); // let half_length=(length+1)/2; // for i in 0..length{ // match map.get_...
/* * cd C:\Users\むずでょ\source\repos\practice-rust\tokio * cargo check --example ep4-read * cargo build --example ep4-read * cargo run --example ep4-read * * [Reading and Writing Data](https://tokio.rs/docs/io/reading_writing_data/) */ use futures::executor::block_on; use std::fs::File; use std::io; use std::io::p...
//! WMATA-defined codes for each MetroRail station. use crate::{ error::Error, rail::{client::responses, line::Line, traits::NeedsStation}, requests::Fetch, }; use serde::{ de::{Deserializer, Error as SerdeError}, Deserialize, }; use std::{error, fmt, str::FromStr}; /// Every MetroRail station code...
use std::io fn main(){ println!("H"); println!("e"); println!("l"); println!("l"); println!("o"); println!(" "); println!("H"); println!("a"); println!("c"); println!("k"); println!("t"); println!("o"); println!("b"); println!("e"); println!("r"); println!("fest!"); }
pub mod bson_decode; pub mod bson_encode; pub mod find_many; pub mod find_one; pub mod gridfs_download; pub mod gridfs_multi_download; pub mod gridfs_multi_upload; pub mod gridfs_upload; pub mod insert_many; pub mod insert_one; pub mod json_multi_export; pub mod json_multi_import; pub mod run_command; use std::{ c...
use crate::HitRecord; use crate::HittableList; use crate::Object; use crate::Ray; use crate::AABB; use std::sync::Arc; extern crate rand; use rand::Rng; pub struct BvhNode { pub box_: AABB, pub left: Arc<dyn Object>, pub right: Arc<dyn Object>, } impl BvhNode { pub fn new_(b: AABB, l: Arc<dyn Object>,...
use rltk::{ RGB, Rltk, RandomNumberGenerator }; use std::cmp::{ min, max }; use super::Rect; #[derive(PartialEq, Copy, Clone)] pub enum TileType { Wall, Floor } /// Makes a map with solid boundaires and 400 randomly placed wall. It won't be pretty. pub fn new_map_test() -> Vec<TileType...
extern crate openssl; use std::str; use openssl::hash::{hash, MessageDigest}; fn main() { let data: &[u8] = b"Hello, world"; let digest = hash(MessageDigest::sha256(), &data); println!("{}", str::from_utf8(data).ok().unwrap()); println!("hash: {:?}", digest); }
// q0017_letter_combinations_of_a_phone_number struct Solution; impl Solution { pub fn letter_combinations(digits: String) -> Vec<String> { let map = vec![ vec![b'a', b'b', b'c'], vec![b'd', b'e', b'f'], vec![b'g', b'h', b'i'], vec![b'j', b'k', b'l'], ...
#[doc = "Reader of register CMDCTL"] pub type R = crate::R<u32, super::CMDCTL>; #[doc = "Writer for register CMDCTL"] pub type W = crate::W<u32, super::CMDCTL>; #[doc = "Register CMDCTL `reset()`'s with value 0"] impl crate::ResetValue for super::CMDCTL { type Type = u32; #[inline(always)] fn reset_value() ...
use std::alloc::{alloc, dealloc, Layout}; use std::ffi::OsString; use std::io::{stderr, Write}; use std::mem::MaybeUninit; use std::os::windows::ffi::OsStringExt; use std::ptr::null_mut; use std::sync::Mutex; use std::thread::sleep; use std::time::Duration; use std::{mem, ptr, slice}; use windows::core::PSTR; use wind...
fn main() { { let mut xx = String::from("hello"); // 注意必须是可变变量 println!("{:?}", xx); let some = &mut xx; // 赋值给变量一个道理 some.push_str(" god"); println!("{:?}", xx); } }
use actix_web::{delete, get, post, put, web, HttpResponse, Responder}; use serde_json::json; use crate::error_handler::CustomError; use crate::dogs::{Dog, Dogs}; #[get("/dogs")] async fn find_all() -> Result<HttpResponse, CustomError> { let dogs = Dogs::find_all()?; Ok(HttpResponse::Ok().json(dogs)) } #[get("...
use rand::rngs::ThreadRng; use rand::Rng; use std::rc::Rc; use crate::material::{dielectric::Dielectric, lambertian::Lambertian, metal::Metal, Material}; use crate::shape::{moving_sphere::MovingSphere, shape_list::ShapeList, sphere::Sphere}; use crate::texture::checkers::Checkers; use crate::vec3::{Color, Point3, Vec3...
//! //! This module gives a handler for the page fault exception. //! use super::InterruptStackFrame; bitflags! { flags PageFaultErrorCode: usize { const PROTECTION_VIOLATION = 1 << 0, const WRITE = 1 << 1, const USER_MODE = 1 << 2, const MALFORMED_TABLE = 1 << 3, const INS...
mod input; mod log; pub use log::Level; use crossterm::cursor::MoveTo; use crossterm::event::{self, Event as TermEvent, EventStream, KeyCode, KeyEvent, KeyModifiers}; use crossterm::style::{Color, Print, PrintStyledContent, ResetColor, SetForegroundColor, Stylize}; use crossterm::terminal::{ self, Clear, ClearTyp...
//! A [Latin square](https://en.wikipedia.org/wiki/Latin_square) is a //! n × n array filled with n different symbols, each occurring exactly once in //! each row and exactly once in each column. use crate::ExactCover; use std::collections::HashSet; /// Instance of a Latin square puzzle. #[derive(Debug)] pub struct ...
use super::{Addr, MemoryArena}; use common::is_power_of_2; use std::mem; const MAX_BLOCK_LEN: u32 = 1u32 << 15; const FIRST_BLOCK: u32 = 4u32; #[inline] pub fn jump_needed(len: u32) -> Option<usize> { match len { 0...3 => None, 4...MAX_BLOCK_LEN => { if is_power_of_2(len as usize) { ...
//! # Provider tests //! //! This is a dummy crate that implements tests (wycheproof) for now on the //! [RustCrypto traits](https://github.com/RustCrypto/traits) API for different //! providers. //! //! Tested providers: //! * hacspec //! * evercrypt
use std::path::{Path}; use std::fs::{File, Metadata, canonicalize}; use std::io::{BufRead, Read, Write, Result}; use std::cmp::min; use std::borrow::Cow; use std::fmt; use regex::Regex; use crate::ast::*; use crate::grammar::*; use crate::parser::*; use crate::io::*; pub trait HttpHandler { fn handle<F>(&mut self...
// This file is part of Substrate. // Copyright (C) 2018-2020 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // 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 // // ht...
//! Types which are needed to use the input system independent from the root `riddle` crate. mod platform_system; pub use platform_system::*;
use ::Asn1DerError; /// A wrapper around a DER value #[derive(Debug, Clone, Eq, PartialEq)] pub struct DerValue { /// The value pub data: Vec<u8> } impl DerValue { /// DER-deserializes the data from `source` pub fn deserialize<'a>(mut source: impl Iterator<Item = &'a u8>, len: impl Into<usize>) -> Result<Self, ...
// no restriction on the order of function defs fn main() { call_fn_later(100); } fn is_divisible_by(lhs: u32, rhs: u32) -> bool { if rhs == 0 { return false; } // expression so return is not needed lhs % rhs == 0 } fn void_fn(n: u32) -> () { if is_divisible_by(n, 15) { println!("div by 15"); ...
#![feature(proc_macro_hygiene, decl_macro)] extern crate postgres; extern crate postgres_types; #[macro_use] extern crate rocket; #[macro_use] extern crate rocket_contrib; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; use std::fs; use postgres::{Client, Error, NoTls}; mod model...
pub mod sqlitedb; pub mod yamldb; use crate::Target; use std::error::Error; pub trait Db<T: Error> { fn init(&self) -> Result<usize, T>; fn targets(&self) -> Result<Vec<Target>, T>; }
use crate::MyApp; use seed::{*, prelude::*}; use crate::traits::component_trait::{ActionComponent, Component}; use crate::messages::{Msg, StateChangeMessage}; use super::todo_item_component::TodoItemComponent; use super::add_item_component::AddItemComponent; //The container for the todo items pub struct ToDoContainerC...
use std::{ io, pin::Pin, task::{Context, Poll}, }; use futures_util::ready; use crate::{ io::Stream as InnerStream, }; struct Guard<'a> { buf: &'a mut Vec<u8>, len: usize, } impl Drop for Guard<'_> { fn drop(&mut self) { unsafe { self.buf.set_len(self.len); } ...
//! Borrows a slice of bytes of the input document. //! //! Choose this implementation if: //! //! 1. You already have the data loaded in-memory and it is properly aligned. //! //! ## Performance characteristics //! //! This type of input is the fastest to process for the engine, //! since there is no additional overhe...
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum Player { First, Second, } impl Player { fn next_player(&mut self) { *self = match self { Player::First => Player::Second, Player::Second => Player::First, } } } pub type Cell = Option<Player>; pub type ...
/* * Slack Web API * * One way to interact with the Slack platform is its HTTP RPC-based Web API, a collection of methods requiring OAuth 2.0-based user, bot, or workspace tokens blessed with related OAuth scopes. * * The version of the OpenAPI document: 1.7.0 * * Generated by: https://openapi-generator.tech *...
#[allow(non_snake_case)] #[allow(dead_code)] pub fn Question5() { let student_data: (&str , i8 , &str , &str ) = ("Farhan Aziz",24,"IOT051142","6:45 to 9:45"); let (name , age , roll_number , class) = student_data; println!("Student Name = {}",name ); println!("Student Age = {}", age); pr...
/* * Copyright Stalwart Labs Ltd. See the COPYING * file at the top-level directory of this distribution. * * Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or * https://www.apache.org/licenses/LICENSE-2.0> or the MIT license * <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your * optio...
fn main() { let start = std::time::Instant::now(); let data = std::fs::read_to_string("../2021-06/input.txt").expect("Unable to create String from input.txt"); println!("Read file in {:?}", start.elapsed()); let start = std::time::Instant::now(); let timers = parse(&data); //println!("timer = {...
use jni::objects::{JClass, JObject}; use jni::JNIEnv; use jni::sys::{jboolean, jlong, jbyte}; use parity_bn::Fq; #[no_mangle] #[allow(non_snake_case)] pub extern "system" fn Java_org_ethereum_crypto_altbn128_Fp_newFq( env: JNIEnv, _class: JClass, bytes: JObject, ret: JObject, ) -> jboolean { let ve...
use super::{Animation, TimingAnimation}; pub struct LinearTiming<T: TimingAnimation> { animation: T, start_value: f64, end_value: f64, current_value: f64 } impl<T: TimingAnimation> LinearTiming<T> { pub fn new(animation: T, start_value: f64, end_value: f64) -> Self { return LinearTiming { ...
#[doc = "Reader of register SCR"] pub type R = crate::R<u32, super::SCR>; #[doc = "Writer for register SCR"] pub type W = crate::W<u32, super::SCR>; #[doc = "Register SCR `reset()`'s with value 0"] impl crate::ResetValue for super::SCR { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { ...
use certmaster::cert_issuer::CertIssuer; use certmaster::certificate::{self, Certificate}; use certmaster::consts::labels::{CACHED, CERT_ISSUER, MANAGED_BY_KEY, MANAGED_BY_VALUE}; use certmaster::store::Store; use futures::prelude::*; use kube::{ api::{Api, ListParams}, Client, }; use kube_runtime::watcher; use...
use csv; use finox::roses; use hound; use std::error::Error; use std::f32::consts::PI; use std::i16; #[derive(Default, Debug, Clone, PartialEq, serde_derive::Serialize, serde_derive::Deserialize)] #[serde(rename_all = "camelCase")] pub struct Row { pub symbol: String, pub t: String, pub x: f64, pub v: ...
use lazy_static::lazy_static; fn gen_page(title: &str, body: &str) -> String { format!( r#" <!DOCTYPE html> <html lang = "en"> <head> <meta charset = "utf8"> <title>{}</title> </head> <body> {} <...
//! Acquires a [`Read`] instance and reads it in on-demand in a buffer. //! All of the bytes read are kept in memory. //! //! Choose this implementation if: //! //! 1. You have a [`Read`] source that might contain relatively large amounts //! of data. //! 2. You want to run the JSONPath query on the input and then disc...
#![warn(clippy::pedantic)] use heroku_nodejs_utils::inv::{Inventory, BUCKET, REGION}; use heroku_nodejs_utils::nodebin_s3; use std::convert::TryFrom; const FAILED_EXIT_CODE: i32 = 1; fn main() { let args: Vec<String> = std::env::args().collect(); if args.len() < 2 { eprintln!("$ list_versions <node|y...
#![feature(try_from)] extern crate telegram_bot; extern crate regex; extern crate chrono; #[macro_use] extern crate log; extern crate env_logger; extern crate typemap; mod manager; mod bot; mod message; mod error; mod send; mod handler; mod model; mod chat_room; use telegram_bot::*; fn main() { env_logger::init...
// 16.16 Sub Sort fn sub_sort(array: &[i32]) -> (usize, usize) { // Returns inclusive bounds of minimal subarray that, if sorted, // makes so that the whole array is sorted. // Returns (0,0) if already sorted. // O(n) time, O(3n) space. I suspect it could be improved to O(n) time, // O(1) space. ...
use serde::ser::Serialize; use std::collections::HashMap; struct ContextBuilder(tera::Context); #[derive(Copy, Clone, Debug, PartialEq)] enum Target { Scalar, Sse2, Wasm32, CoreSimd, } impl ContextBuilder { pub fn new() -> Self { Self(tera::Context::new()) } fn new_tvecn_swizzle_...
use itertools::{EitherOrBoth::*, Itertools as _}; use std::cmp::Ordering; pub fn cmp_ignore_case_ascii(a: &str, b: &str) -> bool { a.bytes() .zip_longest(b.bytes()) .map(|ab| match ab { Left(_) => Ordering::Greater, Right(_) => Ordering::Less, Both(a, b) => { ...
use super::IDT_SIZE; extern { static _asm_irq_handler_array: [u64, ..IDT_SIZE as uint]; } pub fn get_irq_handler(num: u16) -> u64 { _asm_irq_handler_array[num as uint] }
pub fn run() { println!("{}", sum(44, 52)); // closure sum let closure_sum = |x: i32, y: i32| x + y; println!("Closure sum: {}", closure_sum(44, 52)); } fn sum(x: i32, y: i32) -> i32 { // don not semicolon to return; x + y }
use handlebars::Handlebars; pub mod helpers; pub fn handlebars() -> Handlebars { let mut handlebars = Handlebars::new(); handlebars.register_helper("comma-list", Box::new(helpers::comma_delimited_list_helper)); handlebars.register_helper("equal", Box::new(helpers::equal_helper)); handlebars.register_h...
//! //! # `Code Section` //! //! +----------------+----------------+-------------+--------------+--------------+----------+ //! | | | | | | | //! | Code Kind | Flags | Gas Mode | SVM Version | Code Length | Code | //! | ...
use crate::Rule; use serde::Deserialize; #[derive(Clone, Deserialize)] pub struct Config { pub rules: std::vec::Vec<Rule>, pub enabled: bool, } impl Default for Config { fn default() -> Self { Config::default_config() } } impl Config { fn default_config() -> Self { Config { ...
use types::{SharedMut, Stereo, Wrap}; use dsp::{ ControllableLink, Filter, SignalFlow, SignalLink, SignalSink, SignalSource, SoftLimiter, VoiceManager, }; use event::{ControlEvent, Controllable}; use rb::{Producer, RbProducer}; pub struct Flow { source: VoiceManager, links: Vec<SharedMut<ControllableL...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - control register 1"] pub cr1: CR1, #[doc = "0x04 - control register 2"] pub cr2: CR2, #[doc = "0x08 - interrupt and status register"] pub isr: ISR, #[doc = "0x0c - interrupt and status clear register"] pub c...
use crate::types::*; /// Specification of a foreign key #[derive(Debug, Clone)] pub struct TableForeignKey { pub(crate) name: Option<String>, pub(crate) table: Option<DynIden>, pub(crate) ref_table: Option<DynIden>, pub(crate) columns: Vec<DynIden>, pub(crate) ref_columns: Vec<DynIden>, pub(cra...
#![allow(dead_code)] use crate::*; use days::day05::{Data, Context}; use std::convert::{TryFrom}; use image::ImageBuffer; use ndarray::Array2; use crate::helper::dir::{Dir}; use geo::Point; const DAY: usize = 11; #[derive(Clone, Copy)] pub enum Color { Black, White } impl TryFrom<u8> for Color { type Er...
#[cfg(test)] #[path = "../../../tests/unit/solver/population/rosomaxa_test.rs"] mod rosomaxa_test; use super::super::rand::prelude::SliceRandom; use super::*; use crate::algorithms::gsom::{get_network_state, Input, Network, NetworkConfig, NodeLink, Storage}; use crate::algorithms::nsga2::Objective; use crate::algorith...
pub mod command { extern crate inflector; use crate::builders::{ csharp::CSharpBuilder, go::GoBuilder, java::JavaBuilder, node::NodeBuilder, python::PythonBuilder, rust::RustBuilder, scala::ScalaBuilder, Application, ProjectBuilder, }; use crate::{check_command, get_templates, get_user_...
use common::{BitSet, TinySet}; use docset::{DocSet, SkipResult}; use std::cmp::Ordering; use DocId; /// A `BitSetDocSet` makes it possible to iterate through a bitset as if it was a `DocSet`. /// /// # Implementation detail /// /// Skipping is relatively fast here as we can directly point to the /// right tiny bitset ...
use std::cell::{Cell, RefCell}; use silkenweb_reactive::signal::{ReadSignal, Signal}; use wasm_bindgen::{prelude::Closure, JsCast, JsValue}; use crate::window; pub fn queue_update(x: impl 'static + FnOnce()) { RENDER.with(|r| r.queue_update(x)); } /// Run a closure after the next render. pub fn after_render(x: ...
pub enum Colour { Info = 0x4287db, Warn = 0xeb8934, Error = 0xcf130c, }
#![allow(dead_code)] mod composite; pub use self::composite::{CompositeEncoder, CompositeDecoder}; #[cfg(feature="simdcompression")] mod compression_simd; #[cfg(feature="simdcompression")] pub use self::compression_simd::{BlockEncoder, BlockDecoder}; #[cfg(not(feature="simdcompression"))] mod compression_nosimd; #...
#[doc = "Register `SR2` reader"] pub type R = crate::R<SR2_SPEC>; #[doc = "Register `SR2` writer"] pub type W = crate::W<SR2_SPEC>; #[doc = "Field `IRS` reader - IRS"] pub type IRS_R = crate::BitReader; #[doc = "Field `IRS` writer - IRS"] pub type IRS_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>; #[doc = "Fie...
use common::console_utils::Timer; use wasm_bindgen::prelude::*; #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; /// Calculate the sum of the fuel requirements for all of the modules on the spacecraft. /// See: https://adventofcode.com/2019/day/1 #[wasm_bindgen] pub fn part1(input: &...
use papergrid::{ config::Entity, records::{ExactRecords, PeekableRecords}, }; use crate::{ grid::records::{Records, RecordsMut}, settings::{CellOption, TableOption}, }; /// A structure to handle special chars. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct Charset; impl Char...
//! Currently we use only 64Mb physical memory //! Physical memory layout looks like: //! [1] [0x0, 0x600000): Initially mapped space, Kernel starts at 0x100000 //! [2] [0x600000, 0x800000): Contiguous kernel memory, contains page table //! //! Virtual memory layout looks like: //! [1] [0xFFFFFFFF80000000, 0xFFFFFFFF80...
/* Copyright 2019-2023 Didier Plaindoux 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...
extern crate protobuf; extern crate serde_yaml; #[macro_use] extern crate serde_derive; mod xchain; pub mod encoder; pub mod errors; pub mod ocall; pub mod sgx_ocall; pub mod protos;
pub mod widgets; use glium::index::PrimitiveType::TriangleStrip; use glium::{DrawParameters, VertexBuffer, IndexBuffer, Surface, Frame}; use universe::game::Game; use render::Window; use render::Vertex; pub struct Gui{ pub buttons: Vec<widgets::Button> } impl Gui{ pub fn draw_gui(&self, target: &mut Frame, ...
use std::{io, process, fmt, fs, mem}; use std::fs::File; use std::path::{Path, PathBuf}; use std::sync::{Arc, RwLock}; use std::fmt::Write; use std::str::FromStr; use bitcoin::{PublicKey, Script}; use bitcoin::hashes::hex::FromHex; use liquid_rpc as rpc; use error::Error; use utils::{self, RegexUtils}; use runner::{...
use std::os::raw::c_char; extern { pub fn strlen(s: *const c_char) -> usize; } #[cfg(test)] mod test { use super::*; #[test] fn strlen_test() { use std::ffi::CString; let rust_str = "I'll be back"; let null_terminated = CString::new(rust_str).unwrap(); unsafe { ...
use super::{path_offset, socket_addr}; use crate::sys::unix::net::new_socket; use crate::sys::unix::UnixStream; use crate::unix::SourceFd; use crate::{event, Interest, Registry, Token}; use std::ffi::OsStr; use std::os::unix::ffi::OsStrExt; use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; use std::os::un...
mod length_prefixed_vec; mod local_context; mod message_utils; mod raft_utils; mod response_types; mod utils; pub use length_prefixed_vec::LengthPrefixedVec; pub use local_context::LocalContext; pub use message_utils::{ access_type, accessed_inode, distribution_requirement, raft_group, request_locks, AccessType, ...
use crate::instruction::Instruction; use crate::state::State; use std::io::{BufRead, BufReader, BufWriter, Write}; use std::net::TcpListener; pub struct Debugger { debug_continue: bool, break_address: Option<u16>, } #[derive(PartialEq, Debug)] enum Command { Continue, Registers, Flags, Disasse...
extern crate winapi; use winapi::um::objbase::*; use winapi::um::mmdeviceapi::*; use winapi::um::endpointvolume::*; use winapi::shared::*; use winapi::Interface; fn get_device_enumerator() -> *mut IMMDeviceEnumerator { let cls_mm_device_enum : guiddef::GUID = CLSID_MMDeviceEnumerator; let iid_imm_device_enume...
#![crate_name = "tar"] #![crate_type = "lib"] #![license = "MIT"] use std::io::fs::File; use std::collections::hashmap::HashMap; pub struct Tar { filepath: &'static str, pub fields: HashMap<&'static str, uint>, pub field_size: HashMap<uint, uint> } pub fn new(filepath: &'static str) -> Tar { let mut ...
#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct Instruction(pub u8); impl Instruction { }
pub mod combinators; pub mod primitives; #[derive(Debug, Clone)] pub struct ParseError { pub input: String, pub expected: String, pub fatal: bool, } #[derive(Debug, Clone)] pub struct ParseSuccess<A> { pub value: A, pub next: String, } pub type ParseResult<A> = Result<ParseSuccess<A>, ParseError>...