text
stringlengths
8
4.13M
use crate::{ openapi::{ generate::{ controller_info::ControllerInfo, crate_syn_browser::{Browser, Item, ItemKind, Module, UseScope}, type_info::TypeInfo, utils::{find_macro_attribute_flag, find_macro_attribute_named_value, get_serde_field}, }, ...
/// Supported virtual keys. /// /// Virtual keys represent the intended meaning of the key, and have no relation to where /// the key physically is on the keyboard. Use virtual key where the meaning of the key /// is most important (textual input). When meaning matters less, but physical location /// is more important ...
#![cfg(feature = "serde")] use bitarray::BitArray; #[test] fn bincode_serde_json_cycle() { let old_bits = vec![BitArray::new([0, 1, 2, 3, 255])]; let mut bdata = vec![]; bincode::serialize_into(&mut bdata, &old_bits).expect("failed to serialize with bincode"); let middle_bits: Vec<BitArray<5>> = ...
#[doc = "Register `SR` reader"] pub type R = crate::R<SR_SPEC>; #[doc = "Field `IFEM` reader - Input FIFO empty"] pub type IFEM_R = crate::BitReader; #[doc = "Field `IFNF` reader - Input FIFO not full"] pub type IFNF_R = crate::BitReader; #[doc = "Field `OFNE` reader - Output FIFO not empty"] pub type OFNE_R = crate::B...
/* * Binary array set (Rust) * * Copyright (c) 2022 Project Nayuki. (MIT License) * https://www.nayuki.io/page/binary-array-set * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software wi...
fn main() { cfg_aliases::cfg_aliases! { headless: { not(feature = "with_graphics") } } }
#![feature(prelude_import)] #![no_std] #[prelude_import] use std::prelude::v1::*; #[macro_use] extern crate std as std; extern crate proc_macro; use proc_macro::TokenStream; #[proc_macro_derive(Nothing)] pub fn nothing_derive(_input: TokenStream) -> TokenStream { TokenStream::new() } #[proc_macro_attribute] pub fn ...
/*! ```rudra-poc [target] crate = "stackvector" version = "1.0.8" [report] issue_date = 2021-02-19 issue_url = "https://github.com/Alexhuszagh/rust-stackvector/issues/2" rustsec_url = "https://github.com/RustSec/advisory-db/pull/847" rustsec_id = "RUSTSEC-2021-0048" [[bugs]] analyzer = "UnsafeDataflow" bug_class = "H...
mod navmesh_struct; pub use navmesh_struct::Navmesh; pub use navmesh_struct::NavmeshBuilder;
use std::fmt::Debug; #[derive(Debug)] enum List<T: Debug> { Cons(T, Rc<List<T>>), Nil, } impl<T: Debug> Drop for List<T> { fn drop(&mut self) { println!("Dropping List with data {:?}!", self); } } use self::List::{Cons, Nil}; use std::rc::Rc; fn main() { ref_counter_test(); } fn ref_cou...
//! # read subcommand //! //! Prints the license text to standard output. //! Will attempt to download if no file is found in the local //! file cache. //! //! Might consider using this command in conjunction with a pager: //! //! ```bash //! $ license read MIT //! MIT License Copyright (c) <year> <copyrigt holders> //...
use rand::Rng; use rocket::{FromForm, FromFormValue}; use serde_derive::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, Hash, Eq, PartialEq, FromForm, Copy, Clone)] pub struct Sensor { pub sensor_id: u16, pub sensor_type: SensorType, } impl Sensor { pub fn new(sensor_id: u16, sensor_type...
// pest. The Elegant Parser // Copyright (c) 2018 Dragoș Tiselice // // 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. All files in the project carrying such no...
use worker::ffi::{Schema_CommandRequest, Schema_CommandResponse, Schema_ComponentData, Schema_ComponentUpdate}; use ComponentBitField; use std::any::Any; use std::collections::HashMap; use std::fmt; use std::fmt::Debug; use std::hash::Hash; use std::ops::{Deref, DerefMut}; use worker::ComponentId; p...
use crate::client::Client as ViewClient; use crate::view::View; use crate::vix::CoreEvent; use futures::sync::mpsc::UnboundedReceiver; use futures::{Async, Future, Stream}; use std::collections::HashMap; use std::io::Write; use termion::event::Event; use tokio; use xrl::{Client, ClientResult, ModifySelection, ScrollTo,...
use std::collections::HashMap; use proc_macro2::TokenStream; use quote::{quote, ToTokens, TokenStreamExt}; use syn::{Ident, ItemEnum, LitStr}; pub struct Class { class_enum: ItemEnum, subclasses: HashMap<Ident, LitStr>, is_standard: bool, } impl Class { pub fn new(mut class_enum: ItemEnum, is_standar...
use std::convert::TryFrom; use std::io::prelude::*; use chrono::{DateTime, Local}; use crate::FloppyType; #[derive(Clone, Debug)] pub struct MapFile { start_time: Option<DateTime<Local>>, current_time: Option<DateTime<Local>>, current_pos: u64, status: Status, pass: u64, total_size: u64, b...
mod commands; mod directory; mod opts; mod shape; use std::fs::File; use std::io::Read; use anyhow::Result; use opts::Opts; #[cfg(test)] pub mod tests; pub const REPLACEABLE_NAME: &str = "{{__NAME__}}"; pub const REPLACEABLE_OUTPUT: &str = "{{__OUT__}}"; fn main() -> Result<(), anyhow::Error> { let opts = Opts...
// https://adventofcode.com/2017/day/19 use std::io::{BufRead, BufReader}; use std::fs::File; fn main() { let f = BufReader::new(File::open("input.txt").expect("Opening input.txt failed")); // Dump routing diagram to table let diagram = f.lines() .map(|line| line.expect("Invalid line").chars().co...
use std::collections::BTreeMap; #[allow(non_snake_case)] #[derive(Debug, RustcEncodable, RustcDecodable)] pub struct LabsKey { pub size: i32, pub strength: i32, pub alg: String, pub debianFlaw: Option<bool>, pub q: Option<i32>, } #[allow(non_snake_case)] #[derive(Debug, RustcEncodable, RustcDecoda...
use crate::common::*; pub(crate) fn logical_size_from_winit(size: winit::dpi::LogicalSize<u32>) -> LogicalSize { LogicalSize { width: size.width, height: size.height, } } pub(crate) fn logical_pos_from_winit(pos: winit::dpi::LogicalPosition<u32>) -> LogicalPosition { LogicalPosition { x: pos.x, y: pos.y } } p...
//! Main spinup for gitbot extern crate curl; extern crate rustc_serialize; mod codegen; use std::fs::File; use std::io::Read; use curl::http; use rustc_serialize::json; #[derive(RustcDecodable, RustcEncodable)] /// Represents a Bearer token from github that is saved to disk struct Bearer { access_token: String, ...
//! <https://github.com/EOSIO/eosio.cdt/blob/4985359a30da1f883418b7133593f835927b8046/libraries/eosiolib/core/eosio/symbol.hpp#L234-L337> use alloc::string::String; use crate::{NumBytes, Read, SymbolCode, Write}; use core::{ convert::TryFrom, fmt, str::FromStr, }; #[cfg(feature = "std")] use serde::{Deseria...
use anyhow::Result; use std::{iter::Flatten, vec}; #[derive(Clone, Debug)] struct Ring<T> { items: Vec<T>, } impl<T: Clone + PartialEq> Ring<T> { fn position(&self, to_find: &T) -> usize { // panic if we can't find the requested item self.items .iter() .position(|item| ...
use super::osgood; use super::V8; use std::convert; use std::env; use std::ffi::CString; use std::os::raw::c_char; use std::os::raw::c_int; mod local; pub use local::*; mod isolate; pub use isolate::*; mod handle_scope; pub use handle_scope::*; mod functioncallbackinfo; pub use functioncallbackinfo::*; mod script;...
#[doc = "Register `SDCMR` reader"] pub type R = crate::R<SDCMR_SPEC>; #[doc = "Register `SDCMR` writer"] pub type W = crate::W<SDCMR_SPEC>; #[doc = "Command mode\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[repr(u8)] pub enum MODE_AW { #[doc = "0: Normal Mode"] Normal = 0, #[doc = "...
fn main() { let age:u8 = 255; // 0 to 255 only allowed for u8 let weight:u8 = 256; //overflow value is 0 let height:u8 = 257; //overflow value is 1 let score:u8 = 258; //overflow value is 2 println!("age is {} ",age); println!("weight is {}",weight); println!("height is {}",he...
fn main() { let guess: u32 = 1; println!("{}", guess); println!("Add numbers {}", add_numbers(guess)); } fn add_numbers(x: u32) -> u32 { x + 1 }
pub fn reverse(x: i32) -> i32 { let mut big_x: i64 = x as i64; let mut neg = 1i64; let mut result = 0i64; if big_x < 0 { big_x = -big_x; neg = -1; } while big_x > 0 { let low_int = (big_x - (big_x / 10) * 10) as i64; big_x /= 10; result = result * 10 + low...
use std::i32; fn main() { proconio::input! { n: usize, a: [[i32; 3]; n] } let mut p_t = 0; let mut p_x1 = 0; let mut p_x2 = 0; let mut successed = true; for b in a { let t = b[0] - p_t; let x1 = b[1] - p_x1; let x2 = b[2] - p_x2; let dista...
use crate::schema::*; pub type Connection<C> = websub_sub::db::diesel2::Connection< C, subscriptions::id, subscriptions::hub, subscriptions::topic, subscriptions::secret, subscriptions::expires_at, >; pub type Pool<M> = websub_sub::db::diesel2::Pool< M, subscriptions::id, subscripti...
use crate::render::svg::*; use crate::shape::point::Point; use svg::Node; /// Area shape. #[derive(Clone)] pub struct Area { points: Vec<Point>, fill_color: String, stroke_color: String, } impl Area { /// Create a new Area. pub fn new(points: Vec<Point>, fill_color: &str, stroke_color: &str) -> Se...
use core::ptr; use core::mem; const AES_BASE: u32 = 0x10009000u32; #[derive(Clone, Copy)] #[allow(non_camel_case_types)] #[allow(dead_code)] enum Reg { CNT = 0x000, BLK_CNT = 0x006, FIFO_IN = 0x008, FIFO_OUT = 0x00C, KEY_SEL = 0x010, KEY_CNT = 0x011, CTR = 0x020, TWL_KEY0 = 0x040, ...
use std::time::SystemTime; fn main() { let sys_time = SystemTime::now(); // println!("{:?}",sys_time.tv_sec); let new_sys_time = SystemTime::now(); let difference = new_sys_time.duration_since(sys_time) .expect("Clock may have gone backwards"); println!("{:?}", difference); }
use std::sync::Arc; use std::sync::atomic::AtomicBool; use crate::builder::factories::SubsystemFactory; use crate::framework::Runnable; use crate::pinouts::digital::input::DigitalInput; use crate::sensors::digital::DigitalInputMonitor; pub struct DigitalMonitorFactory { update_field: Arc<AtomicBool>, input: B...
use wasm_bindgen::prelude::*; use wee_alloc::WeeAlloc; #[global_allocator] static ALLOC: WeeAlloc = WeeAlloc::INIT; #[wasm_bindgen(start)] pub fn main() -> siro_web::Result<()> { console_error_panic_hook::set_once(); let env = siro_web::Env::new()?; let mut app = env.mount::<()>("#app")?; app.rende...
use std::hash::Hash; use std::{collections::HashMap, fmt::Debug}; use petgraph::{ visit::{ depth_first_search, GraphRef, IntoNeighborsDirected, IntoNodeIdentifiers, VisitMap, Visitable, Walker, }, EdgeDirection::Outgoing, }; pub struct BiasedRevPostOrderDfs<TNode, TVisit> { stack: Vec...
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; #[derive(Clone, Copy, Debug)] pub struct Color { pub r: f32, pub g: f32, pub b: f32, } impl Color { pub fn to_rgb(&self) -> image::Rgb<u8> { image::Rgb([ (self.r * 256.0) as u8, (self.g * 25...
extern crate enumflags2; extern crate qtablepdf; use qtablepdf::config::{check_infiles, info, read_config}; use qtablepdf::pdf::Pdf; use qtablepdf::qtable::QTable; use qtablepdf::sample; use std::path::Path; use std::{env, time::Instant}; fn main() { const RELEASE: bool = true; let prognam: String; let mu...
#![allow(dead_code)] use text_io::read; fn putere_modul(a: usize, i: usize, p: usize) -> usize { let mut result = 1; for _ in 0..i { result = (result % p) * a; } return result % p; } fn gamal_tabel() { let p: usize = read!(); let puteri: Vec<usize> = (1..p).into_iter().collect(); ...
extern crate super_sniffle; use super_sniffle::test; fn main() { print!("Hello"); test(); }
use regex::Regex; use serde::{Deserialize, Serialize}; use crate::resolver::ResolveResponse; use crate::storage::local::LocalStorage; #[cfg(feature = "s3-storage")] use crate::storage::s3::S3Storage; use crate::types::{Query, Response, Result}; pub mod local; #[cfg(feature = "s3-storage")] pub mod s3; #[derive(Seria...
use bytes::{Buf, BufMut, Bytes, BytesMut}; use super::Frame; use crate::error::RSocketError; use crate::utils::{u24, Writeable}; #[inline] pub(crate) fn read_payload( flag: u16, bf: &mut BytesMut, ) -> crate::Result<(Option<Bytes>, Option<Bytes>)> { let m: Option<Bytes> = if flag & Frame::FLAG_METADATA !=...
fn main() { let x = 2usize as *const u32; // This must fail because alignment is violated let _ = unsafe { &*x }; //~ ERROR: tried to access memory with alignment 2, but alignment 4 is required }
//! Rusty Horde #![feature(drain,path_ext,plugin,slice_patterns)] #![plugin(peg_syntax_ext)] extern crate curl; extern crate docopt; extern crate libmultilog; extern crate librhd; #[macro_use] extern crate log; extern crate mio; extern crate mush as ssh2; extern crate rand; extern crate regex; extern crate repl; extern...
use crate::person::Person; use crate::user::{User, DbPrivilege}; use std::rc::Rc; use std::cell::RefCell; pub type DbConn = Rc<RefCell<Database>>; #[derive(Debug)] pub struct Database { persons: Vec<Person>, users: Vec<User>, } impl Database { pub fn new() -> Self { Self { persons: ve...
mod block_template; mod chain_reorg; mod estimate_fee_rate; mod estimator_process_block; mod estimator_track_tx; mod fetch_tx_for_rpc; mod fetch_txs; mod fetch_txs_with_cycles; mod fresh_proposals_filter; mod new_uncle; mod plug; mod submit_txs; mod tx_pool_info; pub use block_template::{ BlockTemplateBuilder, Blo...
use std::fmt; // 对于 《汉语拼音方案》 当中的声母表的补充说明 // `y` 和 `w` 在现代学说里面被称为 `零声母` , // 但是汉语拼音并不承认他的地位,所以它的出现与否应该按照 前缀补写规则 来。 /// 声母表 pub const INITIAL_TABLE: [char; 21] = [ 'b', 'c', 'ĉ', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 'ŝ', 't', 'x', 'z', 'ẑ', ]; /// 声母 #[derive(Debug, Partia...
use common::{BinarySerializable, VInt}; use std::cmp::max; use std::marker::PhantomData; static EMPTY: [u8; 0] = []; struct Layer<'a, T> { data: &'a [u8], cursor: &'a [u8], next_id: Option<u64>, _phantom_: PhantomData<T>, } impl<'a, T: BinarySerializable> Iterator for Layer<'a, T> { type Item = (...
/** Window Class Structures (Windows) / WNDCLASS structure (Windows) **/ extern crate std; use super::super::prelude::{ UINT , WNDPROC , CCINT , HINSTANCE , HICON , HCURSOR , HBRUSH , LPCTSTR , wapi , ToWindowTextConvertion , Application , Cursor , Icon , Text , WindowProcedure , Atom , Brush , ...
#![allow(unused_imports)] #![allow(unused_variables)] mod call; mod fuzzy_distance_cluster; mod fuzzy_point_map; use std::vec::Vec; use std::collections::{HashMap, BinaryHeap}; use crate::fuzzy_point_map::FuzzyPointMap; use crate::fuzzy_distance_cluster::FuzzyDistanceCluster; fn main() { let g_size = 15.0; let d...
// #![no_std] indicates that this program will not link to the standard // crate, std. Instead it will link to its subset: the core crate. #![no_std] // #![no_main] indicates that this program won't use the standard main // interface that most Rust programs use. The main (no pun intended) // reason to go with no_main ...
use crate::front_of_house::serving; pub struct Breakfast { pub toast: String, seasonal_fruit: String, } impl Breakfast { // Since fruit is private, we need this function to construct a Breakfast pub fn summer(toast: &str) -> Breakfast { Breakfast { toast: String::from(toast), ...
use common::{rsip, tokio::time::Instant}; use std::time::Duration; use super::super::TIMER_I; #[derive(Debug)] pub struct Confirmed { pub request: rsip::Request, pub entered_at: Instant, } impl Confirmed { pub fn should_terminate(&self) -> bool { self.entered_at.elapsed() > Duration::from_millis(...
use std::env; use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; fn parse_mass(line: std::io::Result<String>, input_filename: String) -> i32 { let mass_string = match line { Err(why) => panic!("Couldn't read line from {}: {}", input_filename, why), Ok(line) => line }; re...
use crate::session_ctx::SessionContext; use crate::socket::ws::ClientSocket; use anyhow::Result; use rustimate_core::profile::UserProfile; use rustimate_core::RequestMessage; use std::rc::Rc; use std::sync::RwLock; use uuid::Uuid; use web_sys::{Document, Window}; #[derive(Debug)] pub(crate) struct ClientContext { w...
use std::mem; use std::ops::Deref; use ffi; use eal::ProcType; use lcore; use memzone; // pub type RawMemConfig = ffi::rte_mem_config; // pub type RawMemConfigPtr = *mut ffi::rte_mem_config; // the structure for the memory configuration for the RTE. // pub struct MemoryConfig(RawMemConfigPtr); // impl From<RawMemC...
#[cfg(test)] mod test_cases { use unique::Unique; #[test] pub fn empty() { let nums = vec![]; let even: fn(&&usize) -> bool = |&&n| n % 2 == 0; assert_eq!(None, nums.iter().unique(even)); } #[test] pub fn unique_even() { let mut nums = vec![]; ...
error_chain! { errors { ProjectDirMissing { description("project directory is missing") } } }
use crate::util::CountryCode; use chrono::{DateTime, Utc}; use rosu_v2::prelude::{GameMode, GameMods, Grade, RankStatus}; use serde::{de, Deserialize, Deserializer}; #[derive(Deserialize)] pub struct ScraperScores { scores: Vec<ScraperScore>, } impl ScraperScores { pub fn get(self) -> Vec<ScraperScore> { ...
extern crate gcc; extern crate submodules; use gcc::Config; use std::env; fn main() { submodules::update() .init() .recursive() .run(); compile_library(); } fn compile_library() { println!("The ARM embedded toolchain must be available in the PATH"); env::set_var("CC", "arm-n...
extern crate futures; extern crate telegram_bot; extern crate tokio_core; extern crate rspotify; use rspotify::spotify::client::Spotify; use rspotify::spotify::model::playlist::PlaylistTrack; use rspotify::spotify::model::track::FullTrack; use rspotify::spotify::model::user::PrivateUser; use rspotify::spotify::oauth2...
#[doc = "Register `MTLISR` reader"] pub type R = crate::R<MTLISR_SPEC>; #[doc = "Register `MTLISR` writer"] pub type W = crate::W<MTLISR_SPEC>; #[doc = "Field `Q0IS` reader - Queue interrupt status"] pub type Q0IS_R = crate::BitReader; #[doc = "Field `Q0IS` writer - Queue interrupt status"] pub type Q0IS_W<'a, REG, con...
use newton_raphson::newton_raphson; use plot::line_dash; fn f(x: f32) -> f32 { x.powi(4) - 6.4 * x.powi(3) + 6.45 * x.powi(2) + 20.538 * x - 31.752 } fn df(x: f32) -> f32 { 4.0 * x.powi(3) - 19.2 * x.powi(2) + 12.9 * x + 20.538 } fn result(x: Vec<f32>) -> Vec<f32> { let mut data = Vec::new(); for i i...
use ast; use proc_macro2::Ident; use syn; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ImportedTypeKind { /// The definition of an imported type. Definition, /// A reference to an imported type. Reference, } /// Iterate over definitions of and references to imported types in the AST. pub trai...
// // Register interfaces for STM32L4x6 // // See ST reference manual RM0351 // #![no_std] pub mod firewall; pub mod flash; pub mod pwr; pub mod rcc; pub mod timer_opt; use crc; use gpio; use rng; use rtc; use timer; extern { #[link_name="stm32l4x6_CRC"] pub static CRC: crc::CRC; #[link_na...
use super::calc_avg_join_size; use crate::{error::VelociError, indices::*, persistence::*, type_info::TypeInfo, util::*}; use directory::Directory; use ownedbytes::OwnedBytes; use std::{self, cmp::Ordering::Greater, io, marker::PhantomData, path::PathBuf, u32}; use vint32::{iterator::VintArrayIterator, vint_array::VInt...
use std::cell::RefCell; use std::rc::Rc; use crate::treenode::TreeNode; pub fn preorder_traversal(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<i32> { fn core(root: Rc<RefCell<TreeNode>>, v: &mut Vec<i32>) { v.push(root.borrow().val); if let Some(left) = root.borrow().left.clone() { core...
use std::{fs, io, path::Path, error::Error}; use std::io::{BufRead, BufReader}; use std::fs::File; pub fn check_leng_vectors(vectors: &Vec<Vec<f32>>) -> bool{ let mut result = true; match vectors.len() { 0 => { return false; }, 1 => { return false; }, ...
#[macro_use] extern crate serde_derive; extern crate docopt; extern crate ro_scalar_set; extern crate rand; extern crate memmap; extern crate rayon; use docopt::Docopt; mod enumerations; mod evaluation; // use evaluation::WithGpu; mod traits; mod test; mod utility; use enumerations::*; const USAGE: &'static str = "...
#[macro_use] extern crate enum_from_derive; extern crate compiletest_rs as compiletest; use std::path::PathBuf; fn run_mode(mode: &'static str) { let mut config = compiletest::Config::default(); config.mode = mode.parse().expect("Invalid mode"); config.src_base = PathBuf::from(format!("tests/{}", mode));...
mod utils; use wasm_bindgen::prelude::*; // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global // allocator. #[cfg(feature = "wee_alloc")] #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; #[wasm_bindgen] pub fn add(a: f32,b: f32)-> f32 { let c: f32=a+b; r...
use std::io::{Cursor, Read, Seek, SeekFrom}; use anyhow::{anyhow, Result}; use byteorder::{LittleEndian, NativeEndian, ReadBytesExt, WriteBytesExt}; use las_rs::{point::Format, Header}; use las_rs::{raw, Builder, Vlr}; use laz::{ las::laszip::{LASZIP_RECORD_ID, LASZIP_USER_ID}, LasZipDecompressor, }; use pastu...
extern crate bindgen; use std::env; use std::path::Path; use std::path::PathBuf; static SPDK_INCLUDE_DIR: &'static str = "/usr/local/include"; fn generate_bindings() { let spdk_include_path = env::var("SPDK_INCLUDE").unwrap_or(SPDK_INCLUDE_DIR.to_string()); let output_path = env::var("OUT_DIR").unwrap(); ...
use crate::bus::Bus; use twz::device::{BusType, Device}; mod isa; mod pcie; pub fn create_bus(dev: Device) -> Option<Box<dyn Bus>> { let bt = BusType::from_u64(dev.get_device_hdr().bustype); match bt { BusType::Isa => Some(Box::new(isa::IsaBus::new(dev))), BusType::Pcie => Some(Box::new(pcie::PcieBus::new(dev))...
use crate::engine::basic_types::Event; use crate::engine::element::Element; use crate::engine::element::ElementData; use crate::engine::Component; use crate::engine::Renderer; pub struct BulletMover { speed: f32, } impl Component for BulletMover { fn on_collision(&mut self) -> Result<(), String> { ...
#[doc = "Register `MPCBB2_VCTR62` reader"] pub type R = crate::R<MPCBB2_VCTR62_SPEC>; #[doc = "Register `MPCBB2_VCTR62` writer"] pub type W = crate::W<MPCBB2_VCTR62_SPEC>; #[doc = "Field `B1984` reader - B1984"] pub type B1984_R = crate::BitReader; #[doc = "Field `B1984` writer - B1984"] pub type B1984_W<'a, REG, const...
#![allow(clippy::mutex_atomic)] use std::sync::{Arc, Condvar, Mutex}; #[derive(Clone)] pub struct CommandIsExecuting { opening_new_pane: Arc<(Mutex<bool>, Condvar)>, closing_pane: Arc<(Mutex<bool>, Condvar)>, } impl CommandIsExecuting { pub fn new() -> Self { CommandIsExecuting { openi...
use std::cmp::PartialEq; use std::io::Cursor; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; #[derive(Clone, Copy, Debug, PartialEq)] pub enum PktType { Telemetry = 0, Telecommand = 1, } #[derive(Debug)] pub struct PrimaryHeader { pub version_number: u8, pub packet_type: PktType, pub se...
#[macro_use] extern crate log; pub mod controller; pub mod webserver;
use std::fs::File; use std::io::ErrorKind; use std::io; use std::io::Read; use std::io::File; /** Topic: Error Handling **/ fn panic_example(name: &str) -> &str { if name.len() != 6 { panic!("The string is not equal to six!!!!!!!!!!!!"); } return name; } /** Topic: Result Type **/ // Simple usage ...
use crate::shared::list_node::ListNode; struct Solution; /// https://leetcode.com/problems/add-two-numbers/ impl Solution { /// 0 ms 2.1 MB pub fn add_two_numbers( l1: Option<Box<ListNode>>, l2: Option<Box<ListNode>>, ) -> Option<Box<ListNode>> { let mut carry = 0; let mut ...
/* Given a string with friends to visit in different states: ad3="John Daggett, 341 King Road, Plymouth MA Alice Ford, 22 East Broadway, Richmond VA Sal Carpenter, 73 6th Street, Boston MA" we want to produce a result that sorts the names by state and lists the name of the state followed by the name of each person res...
use support::{decl_module, decl_storage, StorageValue, StorageMap}; use codec::{Encode, Decode}; use runtime_io::blake2_128; use system::ensure_signed; use rstd::result; pub trait Trait: system::Trait { } #[derive(Encode, Decode, Default)] pub struct Kitty(pub [u8; 16]); decl_storage! { trait Store for Module<T: Tr...
#![allow(warnings)] use std::fs; use std::error; use std::fmt; use std::io::Cursor; use byteorder::*; use std::slice::SliceIndex; use std::convert::TryInto; pub mod phdr; pub mod shdr; pub mod segment; pub mod section; use segment::Segment; use section::Section; #[derive(Debug, Clone)] pub enum ParsingErro...
#[doc = "Reader of register MDMA_GISR0"] pub type R = crate::R<u32, super::MDMA_GISR0>; #[doc = "GIF0\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq)] pub enum GIF0_A { #[doc = "0: No interrupt generated by channel\r\n x"] B_0X0 = 0, #[doc = "1: Interrupt generated by channel...
extern crate whois; extern crate rustc_serialize; use whois::WhoIs; use rustc_serialize::json::Json; fn main() { let data = WhoIs::new("google.com").lookup(); let foo = &Json::from_str(&data.unwrap()).unwrap(); let object = foo.as_object().unwrap(); for (key, value) in object { println!("{}: {...
use crate::errors::*; use tempfile::NamedTempFile; use std::io::copy; // GET http://server.com/search/123 -> String(JSON) -> Vec<Struct> // [{ // name: "123", // url: jiji / id: 123 // }] type Url = String; const SERVER_URL: &str = "http://localhost:8000"; #[derive(Deserialize)] struct ServerResponse { ...
#![feature(test)] extern crate test; extern crate delight_book; use delight_book::chapter5::*; use delight_book::*; use std::mem::transmute; use std::borrow::BorrowMut; /// https://blog.knoldus.com/safe-way-to-access-private-fields-in-rust/ /// mod delight_book{ /// #[derive(Default)] /// pub struct c8{ /// ...
extern crate futures; extern crate log4rs; extern crate mta_status; extern crate net2; extern crate num_cpus; extern crate tokio_core; extern crate hyper; use tokio_core::reactor::Handle; use hyper::server::{Request, Response}; use hyper::{Method, StatusCode}; use hyper::server::Service; use hyper::header::Headers; u...
pub const FRAGMENT_SHADER_SOURCE: &str = r#" #version 310 es out highp vec4 FragColor; in highp vec3 color; void main() { // Set the fragment color to the color passed from the vertex shader FragColor = vec4(color, 1.0); } "#;
/* * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT license. */ use clap::{Parser, ValueEnum}; use std::path::PathBuf; use diskann::{ common::ANNResult, index::create_inmem_index, model::{ vertex::{DIM_104, DIM_128, DIM_256}, IndexConfiguration, IndexW...
use structopt::StructOpt; use typos_cli::config; arg_enum! { #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum Format { Silent, Brief, Long, Json, } } impl Format { pub(crate) fn reporter( self, stdout_palette: crate::report::Palette, stderr...
pub(crate) use std::{ collections::BTreeMap, env, fs, io::Write, iter, path::Path, process::{Command, Stdio}, str, }; pub(crate) use executable_path::executable_path; pub(crate) use just::unindent; pub(crate) use libc::{EXIT_FAILURE, EXIT_SUCCESS}; pub(crate) use test_utilities::{assert_stdout, tempdir, ...
use crate::enums::{Align, CallbackTrigger, Color, Damage, Event, Font, FrameType, Key, LabelType}; use crate::image::Image; use crate::prelude::*; use crate::utils::FlString; use fltk_sys::text::*; use std::{ ffi::{CStr, CString}, mem, os::raw, sync::atomic::{AtomicUsize, Ordering}, }; /// Defines the ...
use crate::grammar::ast::Parens; use crate::grammar::model::HasSourceReference; use crate::grammar::testing::TestingContext; use crate::grammar::tracing::input::OptionallyTraceable; #[test] fn test_basic() { let ctx = TestingContext::with(&["(ident)"]); ctx.test_output(Parens::parse, 0, |(rem, node)| { ...
use crate::brightnessconverter::BrightnessConversionType; pub struct Options { pub scale_config: ScaleConfig, pub brightness_convertion_algorithm: BrightnessConversionType, pub should_invert_colors: bool, } #[derive(Copy, Clone)] pub enum ScaleConfig { OriginalSize, FitToTerminal, FixedSize(u3...
//! Determinization and minimization of an NFA into the final DFA used by the engines. // NOTE: Some comments in this module are outdated, because the minimizer doesn't // actually produce minimal automata as of now - see #91. use super::nfa::{self, NfaState, NfaStateId}; use super::small_set::{SmallSet, SmallSet256};...
use raylib::prelude::*; pub struct Window { handle: RaylibHandle, thread: RaylibThread, } pub type DrawingContext<'a> = RaylibDrawHandle<'a>; pub use raylib::prelude::MouseButton; pub use raylib::prelude::KeyboardKey; pub struct WindowConfig { pub width: u32, pub height: u32, pub title: &'static...
mod math; mod tensor; mod utils; pub use self::math::*; pub use self::tensor::*; pub use self::utils::*;