text
stringlengths
8
4.13M
use sioctl::Sioctl; fn main() { let s = Sioctl::new(); println!("Initial state of controls:"); for control in s.controls() { println!("{:?}", control); } println!(""); println!("Watching for changes (press Enter to exit):"); let mut watcher = s.watch(|control| println!("{:?}", co...
use sycamore::prelude::*; #[component(Nav<G>)] fn nav() -> Template<G> { template! { nav(class="fixed top-0 z-50 px-8 w-full \ backdrop-filter backdrop-blur-sm backdrop-saturate-150 bg-opacity-80 \ bg-gray-100 border-b border-gray-400") { div(class="flex flex-row justify-between...
use std::borrow::Cow; use std::fmt::{Display, self}; use std::ops::Deref; use std::str::{self, FromStr}; use http::ByteStr; use Url; use url::ParseError as UrlError; use Error; /// The Request-URI of a Request's StartLine. /// /// From Section 5.3, Request Target: /// > Once an inbound connection is obtained, the cl...
use crate::types::*; use crate::objects::{get_static_objects, get_weapons, scenery_data}; use wasm_bindgen::prelude::*; #[wasm_bindgen] extern { fn alert(s: &str); } #[wasm_bindgen] impl Game { pub fn new() -> Game { crate::utils::set_panic_hook(); Game { data :vec![], ...
use std::collections::HashSet; #[derive(Debug)] pub struct LifeBoard { pub x_size: usize, pub y_size: usize, board: Box<[bool]>, pub active: HashSet<(usize, usize)> } impl LifeBoard { pub fn new(x: usize, y: usize) -> LifeBoard { return LifeBoard { x_size: x, y_size...
use errors::*; use hex; use libsodacrypt; use net::endpoint::Endpoint; use net::event::{ClientEvent, Event}; use net::http; use net::message; use rmp_serde; use std; use std::io::{Read, Write}; #[derive(Debug, Clone, PartialEq)] pub enum SessionState { New, WaitPing, Ready, } pub struct SessionClient { ...
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved // mod key_trait; pub use key_trait::HasKeyForVariants; mod fingerprints; pub use fingerprints::build_fingerprint; /// A short string that uniquely identifies all glTF objects other than `Mesh` `Primitives`. pub type MeldKey = String; /// A flo...
#![allow(non_snake_case)] use anyhow::Result; use dirs; use serde_derive::{Deserialize, Serialize}; use serde_json::json; use base64::encode; use std::collections::HashMap; use std::fs::{create_dir, remove_dir_all, File}; use std::io::{Read, Write}; use std::path::Path; use std::process::{Command, Stdio}; use std::st...
use async_trait::async_trait; use rbatis::crud::CRUDTable; use mav::{ChainType, NetType, WalletType, CTrue}; use mav::kits::sql_left_join_get_b; use mav::ma::{Dao, MEeeChainToken, MEeeChainTokenDefault, MEeeChainTokenShared, MWallet, MSubChainBasicInfo, MAccountInfoSyncProg, MEeeChainTokenAuth}; use crate::{Chain2Wal...
pub struct Solution; impl Solution { pub fn is_palindrome(s: String) -> bool { if s.is_empty() { return true; } let bytes = s.as_bytes(); let mut i = 0; let mut j = bytes.len() - 1; while i < j { while i < j && !bytes[i].is_ascii_alphanumeric(...
use super::{Cons, List, Nil}; use crate::{ common::*, functional::Func, maybe::{Just, Maybe, Nothing}, stepper::{Curr, Next, Stepper}, tuple::{Get0, Get1, Tuple2}, }; typ! { pub fn IsEmpty<list>(list: List) -> Bit { match list { #[generics(head, tail: List)] Cons...
use super::GameState; use crate::{ calc::*, constants::*, debug, engine::{input::InputEvent, world::WorldCameraExt, Engine, Game}, game::{self as game, components, physics}, mapfile::MapFile, mq, physics::*, render::{self as render, components::Camera}, soldier::Soldier, Weap...
use crate::languages::{get_langague_or, Language}; use actix_web::HttpRequest; use std::env; pub fn get_current_directory() -> String { if let Ok(current_directory) = env::current_dir() { let mut current_directory: String = current_directory.to_str().unwrap_or("").to_string(); if !current_director...
#[path = "with_list_options/with_async_false.rs"] mod with_async_false; #[path = "with_list_options/with_async_true.rs"] mod with_async_true; #[path = "with_list_options/without_async.rs"] mod without_async; test_stdout!(with_invalid_option, "{caught, error, badarg}\n");
use crate::{AsObject, PyObject, VirtualMachine}; use itertools::Itertools; use std::{ cell::RefCell, ptr::{null, NonNull}, thread_local, }; thread_local! { pub(super) static VM_STACK: RefCell<Vec<NonNull<VirtualMachine>>> = Vec::with_capacity(1).into(); static VM_CURRENT: RefCell<*const VirtualMach...
use crate::util::async_manager; use async_channel::{bounded, Receiver, Sender}; use futures::{future::Future, StreamExt}; use futures_timer::Delay; use std::{ sync::{ atomic::{AtomicBool, Ordering}, Arc, }, time::Duration, }; pub enum PingMessage { Ping, StartTimer, StopTimer, End, } fn ping_tim...
use std::borrow::Cow; use std::convert::TryInto; use std::mem; use byteorder::BigEndian; use time::{date, offset, Date, NumericalDuration, OffsetDateTime, PrimitiveDateTime, Time}; use crate::decode::Decode; use crate::encode::Encode; use crate::io::Buf; use crate::postgres::protocol::TypeId; use crate::postgres::{Pg...
use std::io; use failure::Fail; #[derive(Fail, Debug)] pub enum Error { #[fail(display = "IO error: {}", _0)] Io(#[cause] io::Error), #[fail(display = "bincode error: {}", _0)] Serde(#[cause] bincode::Error), } impl From<io::Error> for Error { fn from(err: io::Error) -> Error { Error::Io(e...
// Copyright (c) 2018 Aigbe Research // // Compliance: // 3GPP TS 33.401 version 12.13.0 Release 12 // 3GPP TS 33.220 V12.3.0 // 3GPP TS 35.215 V15.0.0 (2018-06) // Table A.7-1: Algorithm type distinguishers pub const ALGO_TYPE_NAS_ENC: u8 = 1; pub const ALGO_TYPE_NAS_INT: u8 = 2; pub const ALGO_TYPE_RRC_EN...
#![no_std] #![no_main] extern crate pine64_hal as hal; use core::fmt::Write; use hal::ccu::Clocks; use hal::console_writeln; use hal::pac::{ccu::CCU, hstimer::HSTIMER, pio::PIO, uart0::UART0, uart_common::NotConfigured}; use hal::prelude::*; use hal::serial::Serial; use hal::timer::Timer; fn kernel_entry() -> ! { ...
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
use std::io; use std::fs::{DirEntry, metadata}; use {ScanDir}; /// Checks for rules of the entry /// /// Keep in sync with documentation of ScanDir class itself pub fn matches(s: &ScanDir, entry: &DirEntry, name: &String) -> Result<bool, io::Error> { if !name_matches(s, name) { return Ok(false); }...
use crate::libbb::appletlib::applet_name; use libc; pub unsafe fn freeramdisk_main( mut _argc: libc::c_int, mut argv: *mut *mut libc::c_char, ) -> libc::c_int { let mut fd: libc::c_int = 0; fd = crate::libbb::xfuncs_printf::xopen(crate::libbb::single_argv::single_argv(argv), 0o2i32); // Act like freeramdisk,...
pub(crate) use decl::make_module; #[pymodule(name = "itertools")] mod decl { use crate::{ builtins::{ int, tuple::IntoPyTuple, PyGenericAlias, PyInt, PyIntRef, PyList, PyTuple, PyTupleRef, PyTypeRef, }, common::{ lock::{PyMutex, PyRwLock, PyRwLockWriteGua...
use crate::core::error::Error; use openexr_sys as sys; use std::cmp::{Eq, PartialEq}; use std::fmt::Debug; use std::mem::MaybeUninit; use std::os::raw::{c_int, c_uint}; type Result<T, E = Error> = std::result::Result<T, E>; /// Bit packing variants /// #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum TimeCodePac...
use crate::controlled::DropResult; use crate::time::GameTime; use core::time::Duration; pub struct LockDelay { accumulated_time: Duration, prev_lock_time: Option<GameTime>, num_resets: u32, } const LOCK_DELAY: Duration = Duration::from_millis(500); const ALLOWED_RESETS: u32 = 5; impl LockDelay { pub ...
use crate::{ast::nodes::FunctionDeclaration, runtime::{Runtime, nodes::{FunctionCall, FunctionCallType}}}; pub fn parse_function_declaration(runtime: &mut Runtime, statement: &FunctionDeclaration) { let current_scope = runtime.current_scope(); let name = statement.id.name.to_string(); let params = sta...
pub mod header; pub mod message_types; pub mod options;
use structopt::StructOpt; use std::fmt::{self, Display, Formatter}; #[derive(StructOpt)] #[structopt(name = "app")] pub struct AppArgs { #[structopt(subcommand)] pub command: Command, } #[derive(StructOpt)] pub enum Command { /// add operation #[structopt(name = "add")] Add(Elements), /// tim...
#![allow(dead_code)] extern crate kalmanfilter; extern crate nalgebra as na; extern crate num; extern crate rand; mod helpers; use kalmanfilter::nt; use na::{Real, DVector}; use helpers::model::*; #[test] fn compare_continuous_discrete() { let dt = 0.001; let eps = 1e-12; let sim_time = 20usize; let...
use serde_json::json; mod common; #[actix_rt::test] async fn create_index_lazy_by_pushing_documents() { let mut server = common::Server::with_uid("movies"); // 1 - Add documents let body = json!([{ "title": "Test", "comment": "comment test" }]); let url = "/indexes/movies/documents?...
pub mod types; use std::cell::RefCell; use std::rc::Rc; use types::errors::{CursorError as ce, TowerError as te}; use types::{Cursor, Disk, Tower}; #[derive(Debug)] pub struct Game { pub towers: [Rc<RefCell<Tower>>; 3], pub cursor: Cursor, moves: u32, disks: u8, } impl Game { pub fn new(disks: u8...
use fraction::Fraction; use projecteuler::fraction; fn main() { dbg!(min_product_sum(2)); dbg!(min_product_sum(64)); dbg!(solve(2, 6)); dbg!(solve(2, 12000)); } fn solve(low: usize, high: usize) -> usize { let mut values = Vec::new(); for i in low..=high { let min = min_product_sum(i);...
#![allow(clippy::comparison_chain)] #![allow(clippy::collapsible_if)] use std::cmp::Reverse; use std::cmp::{max, min}; use std::collections::{BTreeSet, HashMap, HashSet}; use std::fmt::Debug; use itertools::Itertools; use whiteread::parse_line; const ten97: usize = 1000_000_007; /// 2の逆元 mod ten97.割りたいときに使う const in...
// First we define the datatype for all of our tokens: String // We chose string instead of some complex type because it is simple struct TokenType(String); //Now we define the a structure for the tokens themselves struct Token { Type : TokenType, Literal : String, } //Now we define the values for all of ou...
use std::process::exit; use termbin::cmd::Cmd; fn main() { if let Err(e) = Cmd::from_args().run() { eprintln!("error: {}", e); exit(2); } }
// Copyright 2017 Dasein Phaos aka. Luxko // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except a...
//! To run this code, clone the rusty_engine repository and run the command: //! //! cargo run --release --example keyboard_state use std::f32::consts::PI; use rusty_engine::prelude::*; fn main() { let mut game = Game::new(); let mut race_car = game.add_sprite("Race Car", SpritePreset::RacingCarGreen); ...
extern crate dot_vox; extern crate structopt; use structopt::StructOpt; use dot_vox::load; use gobs::cubic_surface_extractor::extract_cubic_mesh; use gobs::raw_volume::RawVolume; use gobs::raw_volume_sampler::RawVolumeSampler; use gobs::region::Region; use gobs::volume::Volume; use std::fs::File; use std::io::{self, ...
impl_database_ext! { sqlx::sqlite::Sqlite { bool, i32, i64, f32, f64, String, Vec<u8>, }, ParamChecking::Weak, feature-types: _info => None, row = sqlx::sqlite::SqliteRow }
//! Curve used for interpolation (e.g. gradients) use serde_derive::{Deserialize, Serialize}; use std::fmt::Debug; pub trait CurveNode: Copy + Clone + std::ops::Mul<f32, Output = Self> + std::ops::Add<Output = Self> + Debug + std::ops::Sub<Output = Self> { } #[derive(Debug, Clone, Serialize, D...
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors. // // 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 ...
// Day 5 use std::error::Error; use std::fs; use std::process; fn main() { let input_filename = "input.txt"; if let Err(e) = run(input_filename) { println!("Application error: {}", e); process::exit(1); } } fn run(filename: &str) -> Result<(), Box<dyn Error>> { // Read the input file ...
use super::component_prelude::*; pub type CheckpointId = usize; pub struct Checkpoint { pub applied: bool, pub id: CheckpointId, pub respawn_anchor: AmethystAnchor, } impl Checkpoint { pub fn new(id: CheckpointId, respawn_anchor: AmethystAnchor) -> Self { Self { ...
extern crate libc; extern crate unicode_normalization; use std::env::args as env_args; use std::io::Write; use std::process::exit; use std::error::Error as StdError; mod caesar; mod args; mod error; use args::Args; use error::Error; fn usage() { print!( r#" Caesar encrypter tool Encrypt options: -k, --key <ke...
extern crate web_sys; extern crate virtual_filesystem; mod utils; use wasm_bindgen::prelude::*; use virtual_filesystem::virtual_filesystem::shell::{CommandError, Shell}; use virtual_filesystem::virtual_filesystem_core::logger::LoggerRepository; macro_rules! log { ( $( $t:tt )* ) => { web_sys::console::l...
use icell::{runtime::Runtime, write_all}; #[test] fn create() { let owner = Runtime::owner(); assert_eq!(std::mem::size_of_val(&owner), 6); } #[test] #[cfg(feature = "std")] fn create_once_with_reuse() { icell::runtime_id!(type Once(());); icell::global_reuse!(type OnceReuse(Once)); type Runtime ...
pub mod physics; pub mod renderable;
#![feature( const_fn, link_llvm_intrinsics, allocator_api, naked_functions, )] extern crate nabi; #[macro_use] mod print; pub mod abi; mod types; mod handle; mod wasm; mod process; mod channel; mod event; // mod mutex; // mod dlmalloc; pub mod interrupt; pub mod driver; pub use handle::Handle; pub us...
#![cfg_attr(not(feature = "std"), no_std)] use ink_lang as ink; pub use self::newomegastorage::NewOmegaStorage; pub use self::newomegastorage::CommanderData; pub use self::newomegastorage::PlayerData; /// Isolated storage for all things which should be considered player progress. /// This module should only ever chan...
use binary_search::BinarySearch; use procon_reader::ProconReader; fn main() { let stdin = std::io::stdin(); let mut rd = ProconReader::new(stdin.lock()); let n: usize = rd.get(); let m: usize = rd.get(); let a: Vec<i32> = rd.get_vec(n); let mut b: Vec<i32> = rd.get_vec(m); let mut ans = (...
/// An enumeration of different triplet feels. #[repr(u8)] #[derive(Debug,Clone,PartialEq,Eq)] pub enum TripletFeel { None, Eighth, Sixteenth } pub(crate) fn get_triplet_feel(value: i8) -> TripletFeel { match value { 0 => TripletFeel::None, 1 => TripletFeel::Eighth, 2 => TripletFeel::Sixtee...
// This file is Copyright its original authors, visible in version control // history. // // This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE // or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // You may...
pub mod evaluator; pub mod cutoff; pub mod input; pub mod maximum; pub mod panic; pub mod sensor; pub mod smooth; pub mod step; pub use input::cutoff::Cutoff; pub use input::input::Input; pub use input::maximum::Maximum; pub use input::sensor::SensorInput; pub use input::panic::Panic; pub use input::smooth::Smooth; pu...
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors. // // 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 ...
use super::context::Context; use crate::graphql_schema::resolver::{Member, Team}; mod members; mod teams; pub struct QueryRoot; #[juniper::object(Context = Context)] impl QueryRoot { fn members(context: &Context) -> Vec<Member> { QueryRoot::members_impl(context) } fn teams(context: &Context) -> V...
macro_rules! number_infix_operator { ($left:ident, $right:ident, $process:ident, $checked:ident, $infix:tt) => {{ use anyhow::*; use num_bigint::BigInt; use liblumen_alloc::erts::exception::*; use liblumen_alloc::erts::process::trace::Trace; use liblumen_alloc::erts::term::p...
extern crate rand; extern crate crypto; use rand::seq::SliceRandom; use crypto::sha2::Sha256; use crypto::digest::Digest; const BASE_STR: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; const STRETCHING: u32 = 1024; fn genelate_random_string() -> String { let mut rng = &mut rand::thread_...
use crate::error::Diagnostic; #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Default)] pub struct Index { pub line: usize, pub column: usize, pub byte: usize, } fn idx_min(a: Index, b: Index) -> Index { if a.byte < b.byte { a } else { b } } fn idx_max(a: Index, b: Index) ->...
use std::thread; use std::net::{TcpListener, TcpStream, Shutdown}; use std::io::{Read, Write}; use std::str; fn handle_client(mut stream: TcpStream){ let mut data = [0 as u8; 50]; // using 50 byte buffer for receiving data while match stream.read(&mut data) { Ok(size) => { // reply to cli...
use std::str; use std::io::{Read, stdin}; use crate::{constants, editor_visual}; pub(crate) fn editor_read_key() -> Option<String> { let mut input_buffer = [0; constants::INPUT_BUFFER_SIZE]; while stdin().read_exact(&mut input_buffer).is_err() {} match str::from_utf8(& input_buffer) { Ok(inpu...
use console::style; fn main() { for i in 0..=255 { print!("{:03} ", style(i).color256(i)); if i % 16 == 15 { println!(); } } for i in 0..=255 { print!("{:03} ", style(i).black().on_color256(i)); if i % 16 == 15 { println!(); } } }...
use std::fmt; // Sedgewick edition (~30% faster than Cormen's one) // p.251 /// Insertion sort. /// /// Time complexity: /// /// * best: Ω(n) /// * avg: Θ(n^2) /// * worst: O(n^2) /// /// Space complexity: /// /// * O(1) pub fn sort<T: Ord + fmt::Debug>(input: &mut Vec<T>) { for i in 1...
{{#*inline "choice_ids"~}} ({{~#each arguments}}{{this.[1].def.keys.IdType}},{{/each~}}) {{/inline~}} /// Stores the domains of each variable. #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct DomainStore { {{#each choices}} {{name}}: Arc<FxHashMap<{{>choice_ids this}}, {{>value_type....
extern crate serde; extern crate serde_json; include!(concat!(env!("OUT_DIR"), "/serde_types.rs")); extern crate ring; extern crate webpki; extern crate untrusted; extern crate base64; extern crate hex_slice; // XXX REMOVE #[macro_use] extern crate error_chain; pub mod challenge; pub mod registration; pub use self...
// Workaround for clippy bug. #![allow(clippy::unnecessary_wraps)] mod lexer; use lexer::{Lexer, Token, Keyword}; use crate::{Value, Label, Type, LargeKeyMap, Module, Instruction, IntPredicate, BinaryOp, Map, Function, UnaryOp, Cast}; impl Keyword { fn to_type(&self) -> Option<Type> { Some(ma...
use crate::gl_wrapper::texture_2d::Texture2D; use crate::gl_wrapper::rbo::RBO; #[derive(Debug)] pub enum DepthStencilTarget { Texture2D(Texture2D), RBO(RBO) } #[derive(Debug)] pub struct FBO { id: u32, pub(crate) color_texture: Texture2D, depth_stencil_target: DepthStencilTarget, } impl FBO { ...
use super::Transform; use crate::{ event, event::{Event, Value}, topology::config::{DataType, TransformConfig, TransformContext, TransformDescription}, }; use bytes::Bytes; use lru::LruCache; use serde::{Deserialize, Serialize}; use string_cache::DefaultAtom as Atom; #[derive(Deserialize, Serialize, Debug,...
use proto::mesos as pb; /// Callback interface to be implemented by frameworks' executors. Note that /// only one callback will be invoked at a time, so it is not recommended that /// you block within a callback because it may cause a deadlock. /// /// Each callback includes a reference to the executor driver that was...
use serde::{Deserialize, Serialize}; use super::name::Name; #[derive(Serialize, Deserialize, Debug)] pub struct PermissionLevel { pub actor: Name, pub permission: Name, }
extern crate clear_on_drop; extern crate libsecp256k1; extern crate quickcheck; extern crate rand; extern crate secp256k1; #[macro_use(quickcheck)] extern crate quickcheck_macros; use libsecp256k1::curve::*; use libsecp256k1::schnorr::{schnorr_verify, SchnorrSignature}; use libsecp256k1::*; use rand::thread_rng; use s...
use std::time::Duration; use async_trait::async_trait; use std::future::Future; use tokio::time::error::Elapsed; /// An extension trait to add wall-clock execution timeouts to a future running /// in a tokio runtime. /// /// Uses [tokio::time::timeout] internally to apply the timeout. #[async_trait] pub trait FutureT...
use serde::de::Error as SerdeError; use serde::{Deserialize, Deserializer}; use alacritty_config_derive::{ConfigDeserialize, SerdeReplace}; /// Maximum scrollback amount configurable. pub const MAX_SCROLLBACK_LINES: u32 = 100_000; /// Struct for scrolling related settings. #[derive(ConfigDeserialize, Copy, Clone, De...
extern crate csv; extern crate rustc_serialize; pub mod fileformat; pub mod types;
fn main() { let db = std::fs::read_to_string("input") .unwrap() .trim() .lines() .map(|line| { let mut tokens = line.split([':', '-', '"', ' ',].as_ref()); let low = tokens.next().unwrap().parse::<usize>().unwrap(); let high = tokens.next().unwrap(...
pub mod bubble; pub mod gnome; pub mod quicksort; pub mod insert; pub mod select; pub mod merge; pub mod quick3; macro_rules! sorting_test { ($($name:ident: $algorithm:expr,)*) => { $( #[cfg(test)] mod $name { #[test] fn should_sort_sorted() { ...
use crate::nat_type::{Inc, Nat, N0}; pub trait Comparison { type Neg: Comparison; const VALUE: i8; } pub struct LessThan; pub struct GreaterThan; pub struct Equal; impl Comparison for LessThan { type Neg = GreaterThan; const VALUE: i8 = -1; } impl Comparison for GreaterThan { type Neg = LessThan...
#[macro_use] extern crate serde_derive; extern crate toml; extern crate i3ipc; use std::collections::BTreeMap; use std::{fs, env}; use i3ipc::{I3Connection, I3EventListener, Subscription}; use i3ipc::reply::NodeType; use i3ipc::event::{Event, WindowEventInfo, inner::WindowChange}; #[derive(Debug, Deserialize)] struct...
extern crate byteorder; extern crate libc; #[macro_use] extern crate plugkit; use std::io::{Cursor, Error, ErrorKind}; use byteorder::BigEndian; use plugkit::reader::ByteReader; use plugkit::layer::{Confidence, Layer}; use plugkit::context::Context; use plugkit::worker::Worker; use plugkit::variant::Value; use plugki...
use crate::compiling::v1::assemble::prelude::*; macro_rules! tuple { ($slf:expr, $variant:ident, $c:ident, $span:expr, $($var:ident),*) => {{ let guard = $c.scopes.push_child($span)?; let mut it = $slf.items.iter(); $( let ($var, _) = it.next().ok_or_else(|| CompileError::new($spa...
use join::Join; use rand::{rngs::SmallRng, RngCore, SeedableRng}; use std::{ alloc, cmp::{self, Ordering}, fmt::{self, Formatter}, ptr, }; struct Node<T> { x: T, priority: u64, parent: *mut Node<T>, left: *mut Node<T>, right: *mut Node<T>, size: usize, } pub struct Treap<T> { ...
pub mod application; mod window; mod keyboard;
use kincaid::syllables_in_text; use kincaid::WORD_PATTERN; use regex::Regex; use std::collections::HashMap; use std::collections::HashSet; use std::fs; #[macro_use] extern crate lazy_static; const DICTIONARY_PATH: &str = "tests/cmudict.txt"; const PRONUNCIATION_PATTERN: &str = r"((?:[\w\n]+ ?)+)"; const VOWEL_PATTER...
use clap::Clap; use std::error::Error; mod show_usb; pub use self::show_usb::*; // From Cargo.toml const PKG_NAME: &str = env!("CARGO_PKG_NAME"); const VERSION: &str = env!("CARGO_PKG_VERSION"); pub(crate) trait SubApp { fn process(&mut self) -> Result<(), Box<dyn Error>>; } #[derive(Clap, Debug)] #[clap(name =...
use crate::measure; use std::cmp; use std::io::BufRead; pub fn run(input: impl BufRead) { let trees = read_trees(input); measure::duration(|| { println!("* Part 1: {}", count_visible(&trees)); }); measure::duration(|| { println!("* Part 2: {}", max_scenic_score(&trees)); }); } fn...
use clap::{Clap, FromArgMatches, IntoApp}; use humansize::{file_size_opts, FileSize}; use std::io::Read; use std::path::PathBuf; mod passes; #[derive(Clap, Debug)] #[clap()] struct CommandLineOpts { /// Input file to optimize. By default will use STDIN. input: Option<PathBuf>, /// Output file. Required. ...
// Copyright 2021 Datafuse Labs. // // 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 to ...
//! Unwinding for targets without unwind support //! //! Since we can't raise exceptions on these platforms, they simply abort use core::intrinsics; use super::ErlangPanic; pub unsafe fn cause(_ptr: *mut u8) -> *mut ErlangPanic { intrinsics::abort() } pub unsafe fn cleanup(_ptr: *mut u8) { intrinsics::abort(...
// Copyright 2021 Datafuse Labs. // // 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 agre...
// Copyright 2018 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // dummy main. We do not copy this binary to fuchsia, only tests. fn main() {} #[cfg(test)] mod tests { use fidl_fuchsia_diagnostics_inspect::{ ...
use nabi; use abi; use handle::Handle; pub struct Channel(Handle); impl Channel { pub const INITIAL: ReadChannel = ReadChannel(Handle(0)); pub fn create() -> nabi::Result<(WriteChannel, ReadChannel)> { let (mut handle_tx, mut handle_rx) = (0, 0); let res: nabi::Result<u32> = unsafe { ...
use std::os::unix::process::ExitStatusExt; use std::process::{ExitStatus, Stdio}; use std::sync::Arc; use tokio::process::Command; use tokio::sync::{Notify, OnceCell}; use common::job_status::Completed; use common::output_event::Stream as OutputStream; use common::*; use crate::client_cert::ClientName; use crate::out...
use core::{ convert::TryFrom, fmt::{Debug, Display}, mem::MaybeUninit, ops::{Index, IndexMut}, }; /// Static Vector, for when a vector would be nice but there is no dynamic memory allocation. pub struct SVec<T, const N: usize> { inner: [MaybeUninit<T>; N], length: usize, } /// Standard debug, print the debug in...
//! Describes CUDA-enabled GPUs. use telamon::codegen::Function; use telamon::device; use telamon::ir::{self, Type}; use telamon::model::{self, HwPressure}; use telamon::search_space::*; use fxhash::FxHashMap; use std::io::Write; use crate::printer::X86printer; /// Represents CUDA GPUs. #[derive(Clone)] pub struct C...
extern crate time; use std::thread; use std::sync::mpsc; use std::sync::mpsc::{SyncSender, Receiver}; use std::io::prelude::*; use std::fs::File; use std::vec::Vec; use time::PreciseTime; const TOTAL : i32 = 10000000; fn id(input : Receiver<i32>, output : SyncSender<i32>) { for _ in 1..TOTAL { let x = in...
use crate::common::types::{TspResult, VertexId, Weight}; use crate::common::utils::{ cmp, into_undirected_graph_tab, read_lines, to_edges_from_xy_position, vertices, }; use crate::week2::types::{EnumSet, VertexSubset}; use itertools::Itertools; use rayon::prelude::*; use std::collections::HashMap; use std::f64::MAX...
pub(crate) mod mock; pub(crate) mod skipped; use std::{ fmt::{Debug, Display}, sync::Arc, }; use async_trait::async_trait; use data_types::PartitionId; /// A source of partitions, noted by [`PartitionId`](data_types::PartitionId). /// /// Specifically finds a subset of the given partitions, /// usually by pe...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)] #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))] pub struct ADRENTRY { pub ulReserved1: u...
use super::unit_data::UnitType; use nanoserde::DeRon; fn load_units() -> Vec<UnitType> { let units: Vec<UnitType> = DeRon::deserialize_ron(include_str!("../assets/Units.ron")).unwrap(); units } lazy_static! { pub static ref UNIT_TYPES: Vec<UnitType> = load_units(); }
use crate::{Filter, NodeIterator, SourceCode, ValidationError, Validator}; use tree_sitter::Node; #[allow(unused_macros)] macro_rules! assert_some { ($expression:expr) => { match $expression { Some(item) => item, None => panic!("assertion failed: Option instance is not some"), ...