text
stringlengths
8
4.13M
use crate::animation::{BlobAnims, BlobCurrentAnim, FireAnims, FrogAnims, JeanAnims}; use crate::component::{Animation, CoordinateSystem, Follow, Position, Sprite, Velocity}; use crate::image::{load_image, Image}; use randomize::PCG32; use std::collections::HashMap; use tiled::PropertyValue; use ultraviolet::{Vec2, Vec3...
use std::fs; use itertools::Itertools; pub fn valid_sums(numbers: &Vec<usize>) -> Vec<usize> { numbers.iter() .combinations(2) .filter(|c| !c.iter().all_equal()) .map(|c| c.into_iter().sum()) .collect() } pub fn day9(args: &[String]) -> i32 { println!("Day 9"...
extern crate rust_hawktracer; use rust_hawktracer::*; use std::ffi::CString; use std::fs::File; use std::io::Read; use std::os::raw::c_char; use std::thread; use pyo3::prelude::*; use s3::bucket::Bucket; use s3::credentials::Credentials; extern "C" { fn download_file(url: *const c_char, destination: *const c_cha...
use librhd; include!(concat!(env!("OUT_DIR"), "/version.rs")); pub fn version(verbose: bool, colorize: bool) -> String { match (verbose, colorize) { (true, true) => { format!("\x1b[32;1mrh {}\x1b[0m ({} {}) (built {})\nbinary: rh\n\ commit-hash: {}\ncommit-date: {}\nbuild-...
#[doc = "Register `APB1SMENR1` reader"] pub type R = crate::R<APB1SMENR1_SPEC>; #[doc = "Register `APB1SMENR1` writer"] pub type W = crate::W<APB1SMENR1_SPEC>; #[doc = "Field `TIM2SMEN` reader - TIM2 timer clocks enable during Sleep and Stop modes"] pub type TIM2SMEN_R = crate::BitReader; #[doc = "Field `TIM2SMEN` writ...
pub mod binary_xml_parser;
fn vectors() { let vect : Vec<i32> = Vec::new(); // vector with macro let mut v = vec![1, 2, 3]; // push elements to it v.push(4); // access to elements let second : &i32 = &v[1]; match v.get(1) { Some(s) => println!("{}", second), None => println!("No item at {} inde...
use itertools::Itertools; use std::collections::HashMap; use std::fs::File; use std::io::prelude::*; type PersonAnswers = HashMap<char, bool>; struct GroupAnswers { all: Vec<PersonAnswers>, } impl GroupAnswers { fn total_at_least_one(&self) -> usize { let alphabet = "abcdefghijklmnopqrstuvwxyz"; ...
use std::char; use rand; use std::time::Instant; fn main() { const MAX_ITEMS: usize = 10000; let mut arr: Vec<String> = vec!["".to_string(); MAX_ITEMS]; for _ in 0..MAX_ITEMS { for i in 0..MAX_ITEMS { // Initializing arr[i] = random_string(); } let index: ...
use actix::*; use quix::{self}; use quix::node::{NodeConfig, NodeController, Connect}; use actix::clock::Duration; use quix::global::{Global, Set}; #[test] fn test_nodes() { std::env::set_var("RUST_LOG", "info"); env_logger::init(); std::thread::spawn(|| { actix::run(async move { Global...
#[doc = "Register `RCC_RDLSICR` reader"] pub type R = crate::R<RCC_RDLSICR_SPEC>; #[doc = "Register `RCC_RDLSICR` writer"] pub type W = crate::W<RCC_RDLSICR_SPEC>; #[doc = "Field `LSION` reader - LSION"] pub type LSION_R = crate::BitReader; #[doc = "Field `LSION` writer - LSION"] pub type LSION_W<'a, REG, const O: u8> ...
use std::rc::Rc; use std::cell::RefCell; use std::cell::Ref; use std::cell::RefMut; pub struct List<T> { head: Link<T>, tail: Link<T>, } type Link<T> = Option<Rc<RefCell<Node<T>>>>; struct Node<T> { elem: T, next: Link<T>, prev: Link<T>, } impl<T> Node<T> { fn new(elem: T) -> Rc<RefCell<Self>> { Rc::new(Ref...
use libc::c_void; use ffi::object::{self, LLVMObjectFileRef, LLVMSymbolIteratorRef}; use cbox::CBox; use std::fmt; use std::iter::Iterator; use std::marker::PhantomData; use std::mem; use buffer::MemoryBuffer; use util; /// An external object file that has been parsed by LLVM. pub struct ObjectFile { obj: LLVMObje...
pub mod death; pub mod error;
use super::atom::btn::{self, Btn}; use super::atom::dropdown::{self, Dropdown}; use super::atom::fa; use super::atom::tab_btn::TabBtn; use super::atom::text::Text; use crate::libs::color::color_system; use crate::libs::random_id::U128Id; use crate::libs::select_list::SelectList; use crate::libs::type_id::type_id; use i...
#[cfg(not(feature = "loom"))] mod loom { pub use std::sync; } #[cfg(feature = "loom")] use loom; pub mod queue; use std::num::NonZeroUsize; use std::marker::PhantomData; use cache_padded::CachePadded; use per_thread_object::ThreadLocal; pub struct WfQueue<T: Queueable> { queue: queue::WfQueue, context:...
use std::net::SocketAddr; use bytes::Bytes; use futures::stream::SplitSink; use hydroflow::hydroflow_syntax; use hydroflow::lattices::Merge; use hydroflow::scheduled::graph::Hydroflow; use tokio_util::codec::LengthDelimitedCodec; use tokio_util::udp::UdpFramed; use crate::lattices::SealedSetOfIndexedValues; use crate...
#[cfg(feature = "extern")] pub mod ex; #[cfg(feature = "python")] pub mod py; mod test; use super::super::super:: { treloar_sums, treloar_sum_0_with_prefactor }; use std::f64::consts::PI; use crate::physics:: { PLANCK_CONSTANT, BOLTZMANN_CONSTANT }; use crate::physics::single_chain...
pub const RESET: &str = "\x1B[0m"; pub const BOLD: &str = "\x1B[1m"; pub const ITALIC: &str = "\x1B[3m"; pub const UNDERLINE: &str = "\x1B[4m"; pub const INVERSE: &str = "\x1B[7m"; pub const BLACK: &str = "\x1B[30m"; pub const RED: &str = "\x1B[31m"; pub const GREEN: &str = "\x1B[32m"; pub const YELLOW: &str = "\x1B[3...
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // 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>,...
use std::cmp::max; use crate::prelude::*; use super::Filter; #[derive(Clone, Debug)] pub struct BoxFilter { radius: Vector2f, radius_inv: Vector2f, } impl BoxFilter { pub fn new(radius: Vector2f) -> Self { Self { radius, radius_inv: Vector2f::new( float(1.0)...
use proconio::input; fn main() { input! { n:u32, } let mut ni = n; let mut sn = 0; while ni > 0 { sn += ni % 10; ni /= 10; } let ans = if n%sn == 0 {"Yes"} else {"No"}; println!("{}", ans); }
use std::fs::read_dir; use std::io::Write; use std::path::{self, Path}; use anyhow::Result; use structopt::StructOpt; use utility::{clap_cache_dir, remove_dir_contents}; use crate::datastore::CACHE_INFO_IN_MEMORY; /// List and remove all the cached contents. #[derive(StructOpt, Debug, Clone)] pub struct Cache { ...
use bs58; use byteorder::{ByteOrder, LittleEndian}; use ed25519_dalek::PublicKey; use multihash::Blake2b256; use rand_core::{OsRng, RngCore}; pub struct Wallet { seed: Vec<u8>, } impl Wallet { pub fn new() -> Wallet { let mut seed = [0u8; 32]; OsRng.fill_bytes(&mut seed); Wallet { seed: seed.to_...
#[doc = "Register `APB1LENR` reader"] pub type R = crate::R<APB1LENR_SPEC>; #[doc = "Register `APB1LENR` writer"] pub type W = crate::W<APB1LENR_SPEC>; #[doc = "Field `TIM2EN` reader - TIM2 clock enable Set and reset by software."] pub type TIM2EN_R = crate::BitReader; #[doc = "Field `TIM2EN` writer - TIM2 clock enable...
//! Target and related types. use super::channel; /// Standard target represents a channel names list and a channel group names /// list that together are suitable for use in the API calls. /// The value of this type is guaranteed to fulfill the standard invariants /// required by the API calls - that at least one ch...
pub mod decay; pub mod collide;
#[doc = "Reader of register HSEM_C2MISR"] pub type R = crate::R<u32, super::HSEM_C2MISR>; #[doc = "Reader of field `MISF0`"] pub type MISF0_R = crate::R<bool, bool>; #[doc = "Reader of field `MISF1`"] pub type MISF1_R = crate::R<bool, bool>; #[doc = "Reader of field `MISF2`"] pub type MISF2_R = crate::R<bool, bool>; #[...
use glium::{Surface, VertexBuffer}; use lazy_static::lazy_static; use send_wrapper::SendWrapper; mod shaders; mod textures; use crate::game::{Camera, ChunkPos, Grid, Tile, TilePos, CHUNK_SIZE}; const TILE_BATCH_SIZE: usize = 4096; #[derive(Debug, Copy, Clone)] struct Vertex2D { pos: [f32; 2], } glium::implement...
use log::*; use serde_json::Value; use tantivy::tokenizer::{BoxTokenFilter, TextAnalyzer, TokenizerManager}; use crate::tokenizer::alpha_num_only_filter_factory::AlphaNumOnlyFilterFactory; use crate::tokenizer::ascii_folding_filter_factory::AsciiFoldingFilterFactory; use crate::tokenizer::cang_jie_tokenizer_factory::C...
use super::{NodeID, NodeIDMask, TreeID}; use crate::dev::*; use bitvec::{order::Msb0, slice::AsBits}; use derive_more::{AsRef, From}; use std::{ convert::{AsRef, TryFrom, TryInto}, io::{Cursor, Write}, net::Ipv6Addr, str::FromStr, }; /// pub const ADDRESS_NETMASK: u16 = 200; /// pub const ADDRESS_PREFI...
use argonautica::{Error, Hasher,Verifier}; use std::error; use std::fmt; #[derive(Debug, Clone)] pub struct ExistingUserError; impl fmt::Display for ExistingUserError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "User already exists") } } impl error::Error for ExistingUserEr...
use serde::{Deserialize, Serialize}; use lazy_static::lazy_static; lazy_static! { pub static ref DEFAULT_LOCATION: String = { let mut home_dir = std::path::PathBuf::from(std::env::var("HOME").unwrap_or(String::from(""))); home_dir.push(".mvg.conf"); String::from(home_dir.to_str...
use rocksdb::{DBOptions, Writable, DB}; use super::tempdir_with_prefix; macro_rules! check_kv { ($db:expr, $key:expr, $val:expr) => { assert_eq!($db.get($key).unwrap().unwrap(), $val); }; ($db:expr, $cf:expr, $key:expr, $val:expr) => { assert_eq!($db.get_cf($cf, $key).unwrap().unwrap(), $v...
use serde::Deserialize; #[derive(Debug, Deserialize)] pub struct ListQueryOptions { pub offset: Option<usize>, pub limit: Option<usize>, } #[derive(Debug, Deserialize)] pub struct DeleteQueryOptions { pub soft: Option<bool>, }
use anyhow::{anyhow, bail, Context, Result}; use proc_macro2::TokenStream; use quote::{format_ident, quote}; #[derive(Eq, PartialEq, Clone, Debug)] enum Component { Constant(String), Parameter(String), } #[derive(Eq, PartialEq, Clone, Debug)] pub struct Template { components: Vec<Component>, } impl Templ...
use crate::kernel::{ context::PackedPtr, stream::proof, Context, KResult, State, Stepper, Store_, Table, Table_, Term, Theorem, Var_, }; use crate::mmb_visitor::MmbVisitor; use crate::statement_iter::StatementOwned; use mmb_parser::Mmb; use crate::kernel::stream::statement::Action; use std::collections::HashMa...
use crate::io::lcb::{AnalyticsCookie, QueryCookie}; use crate::io::request::*; use crate::io::lcb::callbacks::{analytics_callback, query_callback}; use couchbase_sys::*; use std::ffi::CString; use std::os::raw::c_void; use std::ptr; /// Helper method to turn a string into a tuple of CString and its length. #[inline]...
use super::util::SinkExt; use crate::buffers::Acker; use crate::event::{self, Event}; use futures::{future, Sink}; use serde::{Deserialize, Serialize}; use tokio::codec::{FramedWrite, LinesCodec}; use tokio::io; #[derive(Deserialize, Serialize, Debug)] #[serde(rename_all = "lowercase")] pub enum Target { Stdout, ...
pub mod days; use days::*; use std::time::Instant; use criterion::black_box; pub fn run(day: usize) { match day { 1 => day1::run(), 2 => day2::run(), 3 => day3::run(), 4 => day4::run(), 5 => day5::run(), 6 => day6::run(), 7 => day7::run(), 8 => day8::...
use crate::physics_system::PhysicsSystem; use crate::types::EntityHandle; use crate::force::Force; use core::fmt::Debug; use downcast_rs::{Downcast, impl_downcast}; /// A way to send forces into the system that are applied to each object separately (i.e. rather than applying them to pairs of colliding pairs or anythi...
use slog::Logger; use warp::Filter; use crate::handlers::{ activate_protocol, bake_block_with_client, bake_block_with_client_arbitrary, get_wallets, handle_rejection, init_client_data, start_node_with_config, stop_node, }; use crate::node_runner::LightNodeRunnerRef; use crate::tezos_client_runner::{ BakeRe...
extern crate websocket; // websocket = "~0.12.2" use std::string::String; use websocket::client::request::Url; use websocket::{Client, Message, Sender, Receiver}; fn main() { let url = Url::parse("wss://ws.binaryws.com/websockets/v3").unwrap(); let request = Client::connect(url).unwrap(); let response ...
use apllodb_sql_parser::ApllodbSqlParser; use apllodb_test_support::setup::setup_test_logger; use ctor::ctor; #[ctor] fn test_setup() { setup_test_logger(); } // https://rust-lang.github.io/api-guidelines/interoperability.html#data-structures-implement-serdes-serialize-deserialize-c-serde #[cfg(feature = "serde")...
/*! ```rudra-poc [target] crate = "crayon" version = "0.7.1" [report] issue_url = "https://github.com/shawnscode/crayon/issues/87" issue_date = 2020-08-31 rustsec_url = "https://github.com/RustSec/advisory-db/pull/371" rustsec_id = "RUSTSEC-2020-0037" [[bugs]] analyzer = "Manual" guide = "UnsafeDestructor" bug_class ...
pub use self::{ below_zero::BelowZero, block_bounced_transform::BouncedBlock, bounce::Bounce, paddle::PaddleSystem, }; mod below_zero; mod block_bounced_transform; mod bounce; mod paddle;
// 17.12 BiNode // As doubly-linked lists are a nightmare in Rust, I often implement them with // shared owned storage in a Vec<Node>, and use `usize` as pointers. struct Node { val: i32, node1: Option<usize>, node2: Option<usize>, } trait Tree { fn instance(&self, storage: &mut Vec<Node>) -> usize; ...
use self::rcb::RCBLL; #[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Radio Control Bus (RCB) controller"] pub rcb: RCB, _reserved1: [u8; 3768usize], #[doc = "0x1000 - Bluetooth Low Energy Link Layer"] pub blell: BLELL, _reserved2: [u8; 38140usize], #[doc = ...
#[cfg(test)] mod tests { use bbqueue::{BBBuffer, Consumer, GrantR, GrantW, Producer}; enum Potato<'a, const N: usize> { Tx((Producer<'a, N>, u8)), Rx((Consumer<'a, N>, u8)), TxG(GrantW<'a, N>), RxG(GrantR<'a, N>), Idle, Done, } #[cfg(not(feature = "shor...
use actix_service::{Service, Transform}; use actix_web::{dev::ServiceRequest, dev::ServiceResponse, Error, HttpMessage}; use futures::{ future::{ok, Ready}, Future, }; use slog::info; use std::{ pin::Pin, task::{Context, Poll}, }; use time::OffsetDateTime; pub struct Logger(slog::Logger); impl Logger ...
use crate::config::ContainerOpts; use crate::errors::Errcode; use crate::hostname::set_container_hostname; use crate::mounts::setmountpoint; use nix::unistd::{Pid, close, execve}; use nix::sched::{CloneFlags, clone}; use nix::sys::signal::Signal; use std::ffi::CString; fn child(config: ContainerOpts) -> isize { ...
use std::fs::File; use std::io::Read; use crate::rover::{Orientation, Position, Rover}; use crate::simulation::{Grid, Instruction}; const RADIX: u32 = 10; pub fn read_input() -> (Grid, Vec<Rover>, Vec<Vec<Instruction>>) { let data = match open_file() { Err(error) => panic!("Couldn't read file: {:?}", err...
#![deny(warnings)] #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; #[macro_use] extern crate serde; #[macro_use] extern crate failure; #[macro_use] extern crate diesel; #[cfg(feature = "python")] extern crate cpython; use actix::prelude::*; pub mod api; mod build_info; mod config; mod db; ...
use std::cmp::Ordering; use crate::{AnyBin, AnyStr}; impl<TBin> Eq for AnyStr<TBin> where TBin: AnyBin {} impl<TBin> PartialEq for AnyStr<TBin> where TBin: AnyBin, { fn eq(&self, other: &Self) -> bool { self.as_str() == other.as_str() } } impl<TBin> PartialEq<str> for AnyStr<TBin> where TBin...
extern crate docopt; use std::io::{self, Write}; use std::process; use docopt::Docopt; use csv; use std::fs; use std::path::Path; use std::error::Error; static USAGE: &'static str = " Usage: city-pop [options] <data-path> <city> city-pop --help Options: -h, --help Show this usage message. "; #[derive(Debug, Ru...
use crate::bitfield::BitField; /// A single bucket within a hopscotch hashed hashmap. #[derive(Clone, Debug)] pub struct Bucket<K, V, B> { /// Key, value, ideal hash position triplet. pub data: Option<(K, V, usize)>, /// A bitfield representing the next <sizeof bitfield> buckets in the hashmap (including t...
pub const SCREEN_WIDTH: u32 = 1920 / 4; pub const SCREEN_HEIGHT: u32 = 1080 / 4; pub const FPS: f64 = 1000.0 / 60.0;
//! Association requester module //! //! The module provides an abstraction for a DICOM association //! in which this application entity is the one requesting the association. //! See [`ClientAssociationOptions`](self::ClientAssociationOptions) //! for details and examples on how to create an association. use std::{ ...
use std::{ alloc::{self, AllocError}, ptr::NonNull, }; pub struct LinearAllocator { begin: *mut u8, current: *mut u8, end: *mut u8, } impl LinearAllocator { const ALIGNMENT: usize = 16; pub fn new(cap: usize) -> Self { unsafe { let cap = aligned_size(cap, 16); ...
fn main() { let mut x = 100 ; println!("x is {}", x ); x = 200 ; println!("x is {}", x ); let name = get_person_name(); let mut age = get_person_age(); // // 個々に色々な処理が入る // 年齢が50以上だったら、50に入れ直す if age > 50 { age = 50 ; } // println!("name is {}, age {}", na...
// 2019-04-10 // Le smart pointer le plus habituel est la Box<T>, qui garde de la donnée sur // le tas plutôt que sur la pile. C'est tout. On s'en sert : // quand on ne connaît pas la taille d'un type à la compilation // quand on a beaucoup de donnée dont on veut transférer l'ownership mais // sans que...
/* * A sample API conforming to the draft standard OGC API - Features - Part 1: Core * * This is a sample OpenAPI definition that conforms to the conformance classes \"Core\", \"GeoJSON\", \"HTML\" and \"OpenAPI 3.0\" of the draft standard \"OGC API - Features - Part 1: Core\". This example is a generic OGC API Fea...
#[doc = "Register `IER` reader"] pub type R = crate::R<IER_SPEC>; #[doc = "Register `IER` writer"] pub type W = crate::W<IER_SPEC>; #[doc = "Field `ADRDYIE` reader - ADRDYIE"] pub type ADRDYIE_R = crate::BitReader; #[doc = "Field `ADRDYIE` writer - ADRDYIE"] pub type ADRDYIE_W<'a, REG, const O: u8> = crate::BitWriter<'...
pub trait Float { fn sqrt(self) -> Self; fn recip(self) -> Self; } macro_rules! impl_float { ($($t:ident),*) => { $(impl Float for $t { #[inline] fn sqrt(self) -> $t { self.sqrt() } #[inline] fn recip(self) -> $t { ...
use riddle_image::*; use std::env; use std::fs::File; const OUT_FILE: &str = "image-distance-field.out.png"; const FIELD_SCALE: f64 = 20.0; fn main() -> Result<(), ImageError> { let png_bytes = include_bytes!("sample.png"); let png_img = Image::load(&png_bytes[..], ImageFormat::Png)?; println!("+ Image Loaded...")...
#[doc = "Register `BSRR` writer"] pub type W = crate::W<BSRR_SPEC>; #[doc = "Port x set bit y (y= 0..15)\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum BS0W_AW { #[doc = "1: Sets the corresponding ODx bit"] Set = 1, } impl From<BS0W_AW> for bool { #[inline(always)] fn from(...
#[doc = "Register `CFGR` reader"] pub type R = crate::R<CFGR_SPEC>; #[doc = "Register `CFGR` writer"] pub type W = crate::W<CFGR_SPEC>; #[doc = "Field `CKSEL` reader - Clock selector"] pub type CKSEL_R = crate::BitReader; #[doc = "Field `CKSEL` writer - Clock selector"] pub type CKSEL_W<'a, REG, const O: u8> = crate::B...
use std::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, Not}; /// A bit-board for Score Four /// /// ``` /// use score_four::BitBoard; /// /// let b = BitBoard::new(0b1000_1000_1000_1000); // 4 beads in the most lower level /// /// assert_eq!(b.popcnt(), 4); /// ``` /// #[derive(PartialEq, PartialOrd, Clone, Copy, De...
use crate::{ gui::{make_dropdown_list_option, BuildContext, EditorUiNode, Ui, UiMessage, UiNode}, make_relative_path, scene::commands::{ camera::{ SetCameraPreviewCommand, SetColorGradingEnabledCommand, SetColorGradingLutCommand, SetExposureCommand, SetFovCommand, SetZFarComm...
#[doc = "Register `SR` reader"] pub type R = crate::R<SR_SPEC>; #[doc = "Register `SR` writer"] pub type W = crate::W<SR_SPEC>; #[doc = "Field `DAC1RDY` reader - DAC channel1 ready status bit This bit is set and cleared by hardware."] pub type DAC1RDY_R = crate::BitReader; #[doc = "Field `DORSTAT1` reader - DAC channel...
// // imports // use hw::max31855::Thermocouple; use hw::gpio::{Pin, Direction, State}; use std::time::{Instant, Duration}; use std::thread::sleep; // // constants // const HEAT_THRESHOLD: f32 = 0.5; // start heating when we fall this far below the temperature const COOL_THRESHOLD: f32 = 0.0; // start cooling when we ...
use anyhow::{bail, Context, Result}; use fs_err as fs; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::path::Path; /// The `[lib]` section of a Cargo.toml #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(rename_all = "kebab-case")] pub(crate) struct CargoTomlLib { pub(crate) cra...
use std::{ fmt, }; use amethyst::{ core::transform::components::Transform, }; use crate::resources::RenderConfig; use super::{ ChunkIndex, Planet, GameWorldError, TileError, }; /// The Index of a tile in a [Chunk](struct.Chunk.html). /// Used to calculate the render-position of a tile, /// and to figu...
fn main() { let (mut ans, mut max_cnt) = (0, 0); for i in 1..1_000_001 { let mut cnt = 0; let mut tmp: i64 = i; while tmp != 1 { if tmp % 2 == 1 { tmp += tmp * 2 + 1; } else { tmp /= 2; } cnt += 1; } ...
#[doc = "Reader of register STGENR_CNTCVL"] pub type R = crate::R<u32, super::STGENR_CNTCVL>; #[doc = "Reader of field `CNTCVL_L_32`"] pub type CNTCVL_L_32_R = crate::R<u32, u32>; impl R { #[doc = "Bits 0:31 - CNTCVL_L_32"] #[inline(always)] pub fn cntcvl_l_32(&self) -> CNTCVL_L_32_R { CNTCVL_L_32_R...
extern crate makeiter; use makeiter::{make_iter,FuncIter}; pub fn main() { println!("{}", FuncIter::new(|| Some(3u)).next()); println!("{}", make_iter(|| Some(3u)).next()); }
pub mod index; pub mod images;
#[doc = "Register `GRXSTSP_Device` reader"] pub type R = crate::R<GRXSTSP_DEVICE_SPEC>; #[doc = "Field `EPNUM` reader - Endpoint number"] pub type EPNUM_R = crate::FieldReader; #[doc = "Field `BCNT` reader - Byte count"] pub type BCNT_R = crate::FieldReader<u16>; #[doc = "Field `DPID` reader - Data PID"] pub type DPID_...
use typehack::peano::*; pub type Idx = usize; pub struct CCons<N> { idx: Idx, next: N, } pub struct CNil; pub trait At<I: Nat> { fn at(&self) -> Idx; } impl<N> At<Z> for CCons<N> { fn at(&self) -> Idx { self.idx } } impl<I: Nat, N: At<I>> At<S<I>> for CCons<N> { fn at(&self) -...
use crate::hash::HashFunction; use std::convert::TryInto; /// The internal SHA256 digest. On output this internal digest will be converted to an /// array of u8s. type InternalDigest = [u32; 8]; /// Initial digest value. const H: InternalDigest = [ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b...
mod client; mod data_type; mod export; mod mitm; mod report; mod style; use std::{env::current_dir, path::PathBuf}; use anyhow::{anyhow, Context}; use chrono::Local; use console::style; use dialoguer::{Confirm, Input, Select}; use reqwest::Url; use crate::{ client::Client, export::export_csv, mitm::tap_f...
#[macro_export] macro_rules! try_or( ($e:expr) => ( match $e { Ok(e) => e, Err(e) => return Err(e) } ); ($e:expr, $c:expr) => ( match $e { Ok(e) => e, Err(e) => { return Err(($c)(e)) } } ); ...
extern crate ncurses; extern crate eventual; use ncurses::*; use eventual::Timer; use std::env; use std::str::FromStr; fn main() { let args : Vec<String> = env::args().collect(); if args.len() < 2 { print_usage(); return; } run(&args) } fn run(args: &Vec<String>) { let mut cols ...
use super::callable::{push_callable, Callable}; use super::class::{push_class_builder, Builder}; use super::error::{ErrorKind, Result}; use super::privates; use super::types::{FromDuktape, ToDuktape, Type}; use duktape_sys::{self as duk, duk_context}; use std::ffi::CStr; use std::fmt; use std::ptr; use typemap::TypeMap...
use anyhow::Context; use stark_hash::StarkHash; fn main() -> Result<(), anyhow::Error> { tracing_subscriber::fmt::init(); if std::env::args().count() != 2 { let me = std::env::args() .next() .map(std::borrow::Cow::Owned) .unwrap_or(std::borrow::Cow::Borrowed("me"));...
#[allow(dead_code)] mod robust_arduino; mod json_models; mod arduino_helper; mod crane; mod grabber; mod motor; mod logger; mod ultrasonic; extern crate websocket; extern crate serial; extern crate serde_json; use serde_json::{Value}; use std::thread; use arduino_helper::*; use robust_arduino::*; use crane::*; use gr...
#![feature(arbitrary_self_types)] #![feature(type_alias_impl_trait)] #![feature(stmt_expr_attributes)] #![feature(proc_macro_hygiene)] pub use ak::*; use std::time::SystemTime; struct Payload(usize); impl Message for Payload { type Result = (); } struct Node { id: usize, limit: usize, next: Option<...
pub trait FromPrimitive { fn from_bool(t: bool) -> Self; fn from_usize(t: usize) -> Self; fn from_u8(t: u8) -> Self; fn from_u16(t: u16) -> Self; fn from_u32(t: u32) -> Self; fn from_u64(t: u64) -> Self; fn from_isize(t: isize) -> Self; fn from_i8(t: i8) -> Self; fn from_i16(t: i...
use ::*; macro_rules! selector_as_ptr { ($x:expr) => { match $x.as_c_str() { None => std::ptr::null(), Some(s) => s.as_ptr(), } }; } mod keys; mod mouse; mod wheel; mod touch; pub mod webgl; mod css; pub use self::keys::*; pub use self::mouse::*; pub use self::wheel::*...
use ken2ken::{client::Client, listener::Listener}; use std::io::{self, Write}; use std::net::TcpStream; use std::thread::spawn; fn main() -> std::io::Result<()> { let listener = Listener::new(); println!("Hosting ken2ken on port {}", listener.port); spawn(move || listener.listen()); let stdin = io::s...
pub mod misc_parameters; pub use misc_parameters::MiscParameters;
fn main() { let a = { let mut line = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.trim_end().parse().unwrap() }; let stdout = solve(a); stdout.iter().for_each(|s| { println!("{}", s); }) } fn solve(a: u32) -> Vec<String> { let mut buf = Ve...
use crate::float::Float; use crate::matrix::M3; use crate::numeric::Numeric; use crate::vector::{Cross, FloatVector, Vector, V3}; use std::ops::{Add, Deref, Div, Mul, Sub}; impl<T> Deref for V3<T> where T: Numeric, { type Target = [T; 3]; fn deref(&self) -> &Self::Target { &self.0 } } impl<T>...
pub fn count_and_say(n: i32) -> String { let mut result = "1".to_string(); for _ in 1..n { let mut vec = Vec::<(usize, char)>::new(); let c: Vec<char> = result.chars().collect(); let mut ref_pos = 0; let mut curr_pos = 0; loop { if curr_pos >= c.len() { ...
use crate::components::Codeblock; use crate::with_raw_code; use material_yew::list::GraphicType; use material_yew::{MatButton, MatListItem, MatSelect, WeakComponentLink}; use yew::prelude::*; pub struct Select { link: ComponentLink<Self>, natural_menu_width: bool, select_link: WeakComponentLink<MatSelect>,...
pub mod game_map; #[derive(Default)] pub struct DeltaTime(pub std::time::Duration); #[derive(Default)] pub struct CameraCenter { pub x: i32, pub y: i32, } pub struct Player { pub ent: specs::Entity, } #[derive(Default)] pub struct PendingAction(pub Option<super::input::Action>);
#[doc = "Register `DDRPHYC_DTDR1` reader"] pub type R = crate::R<DDRPHYC_DTDR1_SPEC>; #[doc = "Register `DDRPHYC_DTDR1` writer"] pub type W = crate::W<DDRPHYC_DTDR1_SPEC>; #[doc = "Field `DTBYTE4` reader - DTBYTE4"] pub type DTBYTE4_R = crate::FieldReader; #[doc = "Field `DTBYTE4` writer - DTBYTE4"] pub type DTBYTE4_W<...
//! This is documentation for the `examplez` crate. /// uno contains example #1 pub mod numberz; /// pig_latin translates strings to [Pig Latin](https://en.wikipedia.org/wiki/Pig_Latin). pub mod pig_latin; pub mod company;
/* * 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...
/* chapter 4 primitive types functions */ fn main() { fn foo(n: i32) -> i32 { n } let a: fn(i32) -> i32 = foo; let b = a(8); println!("{}", b); } // output should be: /* 8 */