text
stringlengths
8
4.13M
use proconio::{input, marker::Chars}; fn main() { input! { n: usize, s: Chars, }; let t = s.iter().filter(|&&ch| ch == 'T').count(); let a = s.iter().filter(|&&ch| ch == 'A').count(); if t > a { println!("T"); } else if t < a { println!("A"); } else if s[n ...
use mongodb::{Client, ThreadedClient}; use mongodb::db::ThreadedDatabase; pub fn establish_connection() -> mongodb::coll::Collection { let client = Client::connect("mongo", 27017) .expect("Failed to initialize standalone client."); client.db("test").collection("tmp") }
#[macro_use] extern crate criterion; extern crate geo; use geo::prelude::*; fn criterion_benchmark(c: &mut criterion::Criterion) { c.bench_function("vincenty distance f32", |bencher| { let a = geo::Point::<f32>::new(17.107558, 48.148636); let b = geo::Point::<f32>::new(16.372477, 48.208810); ...
use piston_window::{rectangle, Context, G2d}; use piston_window::types::Color; // use std::cmp; use game::GAME_SIZE; const TILE_COLOR: Color = [(15.0/255.0), (20.0/255.0), (45.0/255.0), 1.0]; const PLAYER1_TILE_COLOR: Color = [(20.0/255.0), 0.75, (45.0/255.0), 1.0]; const PLAYER2_TILE_COLOR: Color = [(15.0/255.0), (4...
extern crate piston; extern crate glutin_window; extern crate graphics; extern crate opengl_graphics; use piston::window::WindowSettings; use glutin_window::GlutinWindow; use piston::event_loop::{Events, EventSettings, EventLoop}; use opengl_graphics::{OpenGL, GlGraphics, Filter, TextureSettings, GlyphCache}; use pi...
use sqs_executor::{ cache::NopCache, event_handler::{ CompletedEvents, EventHandler, }, }; use crate::{ generator::OSQueryGenerator, metrics::OSQueryGeneratorMetrics, tests::utils, }; #[tokio::test] async fn test_subgraph_generation_process_create() { let metrics = OSQueryG...
use super::utills::{get_points, started_check}; use prelude::*; use serenity::framework::standard::CreateGroup; use store::UsersInfo; use utills::{success, warn}; struct GiveCommand; impl Command for GiveCommand { fn execute(&self, ctx: &mut Context, msg: &Message, mut args: Args) -> CommandResult { let target ...
use crate::Vec3; use crate::vec3::{self, Point3}; use crate::color::{Color}; use crate::perlin::{Perlin}; pub trait Texture { fn value(&self, u: f32, v: f32, p: &Point3) -> Color; } pub struct SolidColor { color: Color } impl SolidColor { pub fn new_from_color(c: Color) -> Self { SolidColor { col...
//! Configuration. use std::{collections::HashMap, fs::File, io::Read, path::Path}; use serde_derive::Deserialize; #[derive(Debug, Deserialize)] pub struct Config { pub fcm: FcmConfig, pub apns: ApnsConfig, pub hms: Option<HashMap<String, HmsConfig>>, pub threema_gateway: Option<ThreemaGatewayConfig>...
use crate::render::{RenderSubsystem, ReconfigureEvent, Framebuffer}; pub struct BloomSubsystem { pub max_octaves: u32, pub framebuffer_bloom_temp: Framebuffer, pub framebuffers_bloom_levels: Vec<Framebuffer>, } impl BloomSubsystem { pub fn new() -> BloomSubsystem { BloomSubsystem { max_octaves: 6, frame...
use core::cmp; use core::fmt; use core::marker::PhantomData; use core::mem; use core::ptr::NonNull; #[cfg(not(feature = "std"))] use alloc::boxed::Box; use crate::{Reclaim, Record}; //////////////////////////////////////////////////////////////////////////////////////////////////// // Retired ///////////////////////...
#![no_main] #![feature(start)] extern crate olin; use anyhow::{anyhow, Result}; use olin::{entrypoint, env, runtime, stdio, time}; use std::io::Write; entrypoint!(); fn main() -> Result<()> { let mut out = stdio::out(); if let Ok(url) = env::get("GEMINI_URL") { write!(out, "20 text/gemini\n# WebAsse...
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[cfg(feature = "ApplicationModel_Resources_Core")] pub mod Core; #[cfg(feature = "ApplicationModel_Resources_Management")] pub mod Management; #[link(name = "windows")] extern "system" {} pub type Resourc...
#![experimental] /// Packs a protocol command into a single string. #[experimental] pub fn pack(word: &str, args: &[&str]) -> String { // Escape all the arguments first. let mut vargs = args.iter() .map(|a| format_argument(*a)) .collect::<Vec<String>>(); // ...
pub mod window; pub use window::{Window,canvas::{Canvas,content::{Content,SimpleCamera}}}; pub mod camera; pub use camera::Camera;
pub const DEFINITE_ARTICLE: &str = "the"; const VOWELS: [char; 6] = ['a', 'e', 'i', 'o', 'u', 'y']; pub trait Display { fn name(&self) -> String; fn default_article(&self) -> &str { self.indefinite_article() } fn indefinite_article(&self) -> &str { let first = self.name().chars().nth(0)...
// public importable router pub mod router;
use criterion::{black_box, criterion_group, criterion_main, Criterion}; use day_16::{self, INPUT}; fn criterion_benchmark(c: &mut Criterion) { let valves = day_16::parser::parse(INPUT).unwrap(); let (processed_valves, initial_distances) = day_16::preprocess(valves.clone()); c.bench_function("day_16::parse...
#[doc = "Writer for register IC"] pub type W = crate::W<u32, super::IC>; #[doc = "Register IC `reset()`'s with value 0"] impl crate::ResetValue for super::IC { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { 0 } } #[doc = "Write proxy for field `FPIDCIC`"] pub struct FPIDCIC_...
#[derive(PartialEq, Debug)] struct Policy { byte: u8, min: u8, max: u8, } type ByteOccurences = [u8; 256]; fn parse_policy(policy: &str) -> Policy { let dash = policy.find('-').unwrap(); let space = policy.find(' ').unwrap(); let min: u8 = policy[..dash].parse().unwrap(); let max: u8 = pol...
use crate::scene::Scene; use crate::scene::triangle::Triangle; use crate::util::rng::get_rng; use rand::distributions::weighted::alias_method::WeightedIndex; use rand::distributions::WeightedError; use rand::Rng; use serde::export::fmt::Debug; use serde::export::Formatter; use core::fmt; #[derive(Debug)] pub enum Ligh...
// Copyright 2019 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. use { fuchsia_zircon::{self as zx, DurationNum}, std::ops, zerocopy::{AsBytes, FromBytes}, }; /// Representation of N IEEE 802.11 TimeUnits. /...
pub mod closures; pub mod collections; pub mod cow; pub mod cow_ii; pub mod display; pub mod fmt_arguments; pub mod generic_operators; pub mod hashing; pub mod indexes; pub mod io; pub mod iterators; pub mod operators; pub mod ops; pub mod concurrency;
#[doc = r"Value read from the register"] pub struct R { bits: u32, } #[doc = r"Value to write to the register"] pub struct W { bits: u32, } impl super::MIMR { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w...
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. #[allow(unused_mut)] pub fn serialize_structure_tag( mut writer: smithy_query::QueryValueWriter, input: &crate::model::Tag, ) { #[allow(unused_mut)] let mut scope_1 = writer.prefix("Key"); if let Some(var_2) = &input.ke...
//! The **official asciii Handbook**. //! //! This user documentation has been ripped off straight from the [original //! README](https://github.com/ascii-dresden/ascii-invoicer/), so please forgive if you find any //! mistakes or unimplemented material, //! please **[file an issue immediately](https://github.com/asci...
use std::net::SocketAddr; use crate::pipe::{pipes, Pipes}; use crate::traits::{Readable, Writable}; pub struct SessionMeta { peer_addr: SocketAddr, } impl SessionMeta { pub fn get_peer_addr(&self) -> &SocketAddr { &self.peer_addr } } pub(crate) type Session<U, D> = (SessionMeta, Pipes<U, D>); p...
#![allow(unused_unsafe)] /* origin: FreeBSD /usr/src/lib/msun/src/k_rem_pio2.c */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunSoft, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distrib...
use serde::{Deserialize, Serialize}; use saoleile_derive::NetworkEvent; use crate::event::NetworkEvent; use crate::scene::{Entity, Scene}; use crate::util::{Tick, Id}; #[derive(Clone, Debug, Deserialize, NetworkEvent, Serialize)] pub struct SnapshotEvent { pub authority: Id, pub is_correction: bool, pub ...
// Copyright (c) 2018-2022 Ministerio de Fomento // Instituto de Ciencias de la Construcción Eduardo Torroja (IETcc-CSIC) // 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 ...
extern crate clap; extern crate poe_api as poe; use clap::{App, Arg}; fn main() { let matches = App::new("PoE Character Window") .about("Path of Exile Character Window CLI.") .arg(Arg::with_name("ACCOUNT_NAME") .help("PoE Account Name") .required(true) .index(1)...
pub mod required; pub mod extra;
use proconio::input; fn main() { input! { mut a: [u64; 3], }; a.sort(); if a[0] + a[1] >= a[2] { println!("{}", a[2]); } else { println!("-1"); } }
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[repr(transparent)] #[doc(hidden)] pub struct ITargetedContentAction(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for ITargetedContentAction { type Vtable =...
use abstutil::{FileWithProgress, Timer}; use geom::{GPSBounds, HashablePt2D, LonLat, Polygon, Pt2D}; use map_model::{osm, raw_data, AreaType}; use osm_xml; use std::collections::{BTreeMap, HashMap, HashSet}; use std::fs::File; use std::io::{BufRead, BufReader}; pub fn extract_osm( osm_path: &str, maybe_clip_pa...
fn main() { let _v: Vec<i32> = Vec::new(); // type annotation required because no values inside let mut v = vec![1, 2, 3]; // type annotation not required println!("v = {:?}", v); // adding elements v.push(5); v.push(7); println!("v = {:?}", v); // reading elements // 1. via index...
use core::alloc::Layout; use core::ptr::NonNull; use crate::erts::exception::AllocResult; use crate::erts::process::alloc::*; use crate::erts::term::prelude::*; use super::{Generation, Sweep, Sweepable, Sweeper}; /// Represents a collection algorithm that sweeps for references in `Target` /// into `Source`, and movi...
use crate::{ResourceVersion, Tags, ViewPath}; use serde::{Deserialize, Serialize}; use smart_default::SmartDefault; #[derive(Debug, Serialize, Deserialize, SmartDefault, PartialEq, Clone)] #[serde(rename_all = "camelCase")] pub struct Script { /// Is this used in DragNDrop? Hopefully not! that would get messy. ...
use cosmwasm_std::StdError; use thiserror::Error; #[derive(Error, Debug)] pub enum ContractError { #[error("{0}")] Std(#[from] StdError), #[error("not enough deposit")] NotEnoughDeposit, #[error("wrong deposit coin")] WrongDepositCoin, #[error("plan not exists")] PlanNotExists, #[er...
use std::collections::{HashMap, HashSet, VecDeque}; use proconio::input; fn main() { input! { n: usize, ab: [(usize, usize); n], }; let mut g = HashMap::<usize, Vec<usize>>::new(); g.insert(1, Vec::new()); for (a, b) in ab { g.entry(a).or_insert(Vec::new()).push(b); ...
// Copyright 2015 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::cmp::Ordering; use std::default::Default; use async_trait::async_trait; use tokio::task::spawn_blocking; use tracing::{debug, info_span, warn, Instrument}; use h3ron::collections::{H3CellSet, HashMap}; use h3ron::iter::change_resolution; use h3ron::{H3Cell, Index}; use h3ron_polars::frame::H3DataFrame; use i...
pub use source::*; pub mod kbstat; mod mousestat; mod source;
//! The `Style` type is a simplified view of the various //! attributes offered by the `term` library. These are //! enumerated as bits so they can be easily or'd together //! etc. use std::default::Default; use term::{self, Terminal}; #[derive(Copy, Clone, Default, PartialEq, Eq)] pub struct Style { bits: u64, }...
use ifs::{Eqn, IFS}; use imgui::{ImGui, ImGuiCond, Ui}; /// State controllable by GUI /// /// Internally represents the IFS as an IFS struct but with all values scaled /// by 100 because ImGui slider_float's can't have a step specified yet #[derive(Debug, Clone)] pub struct State { pub sys: IFS, pub num_point...
pub mod compile; pub mod golang; pub mod rust;
use std::fs::File; use std::io::Read; use std::collections::HashSet; fn play(path: &str, players: usize) -> usize { let mut active = 0; let mut xs: Vec<i32> = vec![0; players]; let mut ys: Vec<i32> = vec![0; players]; let mut seen: HashSet<(i32, i32)> = HashSet::new(); seen.insert((0, 0)); for...
#![feature(plugin)] #![feature(custom_derive)] #![feature(extern_prelude)] #![plugin(rocket_codegen)] extern crate dotenv; extern crate rocket; extern crate regex; #[macro_use] extern crate mysql; extern crate rand; use rocket::fairing; use rocket::response::{Redirect,status}; use rand::{Rng}; mod db; mod documents;...
//! Parsing BER-encoded data. //! //! This modules provides the means to parse BER-encoded data. //! //! The basic idea is that for each type a function exists that knows how //! to decode one value of that type. For constructed types, this function //! in turn relies on similar functions provided for its consituent ty...
use std::fmt::Debug; use std::io; use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr}; use std::pin::Pin; use std::task::{Context, Poll}; /// A UDP socket. pub trait UdpSocket: Debug + Send + Sync { /// Returns the local address that this listener is bound to. /// /// This can be useful, for example, when bindi...
use std::io::{Read, Result as IOResult}; use crate::PrimitiveRead; pub struct StripHeader { pub indices_count: i32, pub index_offset: i32, pub verts_count: i32, pub vert_offset: i32, pub bones_count: i16, pub flags: u8, pub bone_state_changes_count: i32, pub bone_state_change_offset: i32 } impl S...
#![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate rocket; use rocket::http::Status; use rocket::response::Result; use rocket_json::catchers; #[get("/<status_code>")] fn error<'r>(status_code: u16) -> Result<'r> { Err(Status::raw(status_code)) } fn main() { rocket::ignite() .regis...
use std::sync::atomic::{ AtomicBool, Ordering, }; use std::sync::{ Arc, Condvar, Mutex, MutexGuard, }; use crossbeam_channel::{ unbounded, Sender, }; use instant::Duration; use legion::systems::Builder; use legion::{ Entity, Resources, World, }; use log::trace; use sourceren...
pub mod prelude { pub use super::camera::CameraSettings; pub use super::debug::DebugSettings; pub use super::enemies::{EnemiesSettings, EnemySettings}; pub use super::level_manager::{LevelManagerSettings, LevelSettings}; pub use super::misc::MiscSettings; pub use super::music::MusicSettings; ...
use super::db::Bank; use regex::Regex; use std::process::Command; lazy_static! { pub static ref DEVICE: String = get_devices().expect("未连接设备"); static ref RE_POSITION: Regex = Regex::new(r"\[(\d+),(\d+)\]\[(\d+),(\d+)\]").unwrap(); } #[cfg(target_os = "windows")] static ADB: &'static str = "./resource/ADB/adb"...
use crate::math::Vec3; use crate::Hittable; use crate::Material; use rand::RngCore; use rand_distr::{Distribution, Uniform, UnitDisc}; use std::sync::Arc; pub struct Ray { pub origin: Vec3, pub direction: Vec3, pub time: f64, } impl Ray { pub fn at(&self, t: f64) -> Vec3 { self.origin + t * se...
use std; use na::*; use math::*; use renderer::*; use alga::general::SupersetOf; pub struct VoxelGrid3<T : Real + Copy>{ pub a : T, pub size_x : usize, pub size_y : usize, pub size_z : usize, pub grid : Vec<T>, } impl<T : Real + SupersetOf<f32>> VoxelGrid3<T>{ pub fn vertices_x(&self) -> usi...
use std::collections::{HashMap, BTreeMap}; use std::error; use std::fmt; use std::io::Write; use std::io::Error as IOError; use serialize::json::Json; use template::{Template, TemplateElement, Parameter, HelperTemplate}; use template::TemplateElement::{RawString, Expression, Comment, HelperBlock, HTMLExpression, Helpe...
use bitcoin::util::address::Address; use bitcoin::util::bip32::ExtendedPubKey; use serde::Deserialize; #[derive(Deserialize)] pub struct HWIExtendedPubKey { pub xpub: ExtendedPubKey, } #[derive(Deserialize)] pub struct HWISignature { pub signature: String, } #[derive(Deserialize)] pub struct HWIAddress { ...
#[doc = "Reader of register IF1CRQ"] pub type R = crate::R<u32, super::IF1CRQ>; #[doc = "Writer for register IF1CRQ"] pub type W = crate::W<u32, super::IF1CRQ>; #[doc = "Register IF1CRQ `reset()`'s with value 0"] impl crate::ResetValue for super::IF1CRQ { type Type = u32; #[inline(always)] fn reset_value() ...
tonic::include_proto!("matchengine");
use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, Default)] pub struct MemoData { #[serde(rename="MemoData")] pub memo_data: String, } impl MemoData { pub fn new(memo_data: String) -> Self { MemoData { memo_data: memo_data, } } } #[derive(Seriali...
use std::str::FromStr; use anyhow::Result; use sqlx::{Connection, ConnectOptions}; use sqlx::sqlite::SqliteConnectOptions; use structopt::StructOpt; use tokio; #[derive(Debug, StructOpt)] #[structopt(name = "list_servants")] struct Options { #[structopt(short, long, default_value = "sqlite:database.sqlite3")] ...
use crate::load_function_ptrs; use crate::prelude::*; use std::os::raw::c_char; use std::os::raw::c_void; pub type PFN_vkDebugReportCallbackEXT = extern "system" fn( VkDebugReportFlagsEXT, VkDebugReportObjectTypeEXT, u64, usize, i32, *const c_char, *const c_char, *mut c_void, ) -> VkBo...
extern crate enum_ast; use self::ast::*; type FragmentId = u32; type BindId = u32; #[ast] mod ast { #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)] pub enum Step { Alternative(usize), Idx(usize), Fragment(FragmentId), StmtFragment(FragmentId), StmtI...
pub struct AreaLight {}
use crate::graphql::Context; use juniper::{FieldError, FieldResult, ID}; pub struct QueryUsers; #[juniper::graphql_object( Context = Context )] impl QueryUsers { /// Get a HOOMAN async fn getById(user_id: ID, context: &Context) -> FieldResult<super::User> { super::service::get_user(&context.client,...
use std::fmt::Display; use std::io; use std::io::BufRead; use std::ops::Deref; fn main() { let stdin = io::stdin(); let handle = stdin.lock(); let lines = handle.lines(); match compute(lines) { Ok(result) => println!("{}", result), Err(err) => eprintln!("Error: {}", err), }; } fn ...
use super::*; use crate::{calc::*, cvars::Config, physics::*}; pub fn follow_camera(world: &mut World, config: &Config) { for (_, (pos, rb_pos)) in world .query::<With<Camera, (Option<&mut Position>, Option<&RigidBodyPosition>)>>() .iter() { if let Some(rb_pos) = rb_pos { if...
pub enum StatFromType { Query = 1, /// Detect by host Host = 2, /// Detect base location query /// Detect base referer url Referer = 3, /// Detect base user-agent UserAgent = 4, } /// Request from pub struct StatFrom { /// name pub key: String, /// detect type pub detect...
use crate::mechanics::damage::DamageMultiplier; use crate::mechanics::Multiplier; mod effectiveness; #[derive(Debug, Eq, PartialEq, Hash)] pub enum MonsterType { FIRE, PLANT, WATER, } impl AsRef<MonsterType> for MonsterType { fn as_ref(&self) -> &MonsterType { self } } impl MonsterType {...
extern crate chrono; extern crate iso6937; extern crate nom; use std::fmt; use std::fs::File; use std::io; use std::io::prelude::*; use std::str; use codepage_strings::Coding; pub mod parser; use crate::parser::parse_stl_from_slice; pub use crate::parser::ParseError; // STL File #[derive(Debug)] pub struct Stl { ...
use std::collections::HashMap; struct Solution {} impl Solution { /// @param n : the number of nodes in the tree /// @param edges: [a_i, b_i] elements, describe an edge a -- b /// @return a list of all root nodes that form minimum height trees fn find_min_height_trees(n: i32, edges: Vec<Vec<i32>>) ...
#![allow(dead_code)] use block_on_proc::block_on; struct Tokio {} struct AsyncStd {} #[block_on("tokio")] impl Tokio { async fn test_async(&self) {} async fn test_async_static() {} async fn test_async_mut(&mut self) {} async fn test_async_arg(&self, _i: u8) {} async fn test_async_static_arg(_i...
use std::io::Read; use reqwest::StatusCode; use reqwest::blocking::Response; use crate::error::Result; #[derive(Debug, Clone)] pub struct Client { host: String, } impl Client { pub fn new(host: String) -> Self { Client { host } } // pub fn post(&self, endpoint: &str) ->...
//! Robust implementation of `GraphicsDisplay` using Google's Skia. //! From https://github.com/jazzfool/reclutch/ //! MIT licensed extern crate gl; use { skia_safe as sk, std::collections::HashMap, }; mod error; /// Contains information about an existing OpenGL framebuffer. #[derive(Debug, Clone, Copy)] pub...
//! A sound API that allows playing clips at given volumes //! //! On the desktop, currently all sounds are loaded into memory, but streaming sounds may be //! introduced in the future. On the web, it can be different from browser to browser use crate::{ Result, error::QuicksilverError, }; use futures::{Future...
use logos::Logos; #[derive(Logos, Debug, PartialEq)] pub(crate) enum Token { #[regex("[a-zA-Z]+", |lex| String::from(lex.slice()))] Identifier(String), #[regex("-?[0-9]+(.[0-9]+)?", |lex| lex.slice().parse())] Number(f64), #[regex(r#""[^"]*""#, |lex| String::from(lex.slice()))] VString(String)...
//! The DcMotor provides a uniform interface for using //! regular DC motors with no fancy controls or feedback. //! This includes LEGO MINDSTORMS RCX motors and LEGO Power Functions motors. /// The DcMotor provides a uniform interface for using /// regular DC motors with no fancy controls or feedback. /// This includ...
use super::InternalEvent; use metrics::counter; use std::fmt::Debug; #[derive(Debug)] pub struct WatchRequestInvoked; impl InternalEvent for WatchRequestInvoked { fn emit_metrics(&self) { counter!("k8s_watch_requests_invoked", 1); } } #[derive(Debug)] pub struct WatchRequestInvocationFailed<E> { ...
extern crate libc; use std::rc::Rc; use std::ptr; use std::string::raw::from_buf; use std::iter::Iterator; use self::libc::{c_int,c_char,c_uchar}; use git2::error::{GitError, get_last_error}; pub mod opaque { pub enum Config {} pub enum ConfigIterator {} } extern { fn git_config_free(obj: *mut self::opaq...
//or.rs - opcodes for xor and inclusive or dealt with! use super::addressing::{self, Operation}; use crate::memory::{RAM, *}; pub fn xor_immediate( operand: u8, pc_reg: &mut u16, accumulator: &mut u8, mut status_flags: &mut u8, cycles_until_next: &mut u8, ) { *accumulator = addressing::immedia...
pub mod card; pub use self::card::Suit; pub use self::card::Card; pub fn parse(cards: &str) -> Vec<Card> { cards .split(' ') .map(card::parse) .collect() } #[cfg(test)] mod tests { use super::*; #[test] fn it_parsers_string_into_a_card_list() { assert_eq!(parse("2H 4S...
use super::{Interceptor, InterceptorFuture, InterceptorObj}; use crate::{body::AsyncBody, error::Error}; use http::{Request, Response}; use std::{fmt, sync::Arc}; /// Execution context for an interceptor. pub struct Context<'a> { pub(crate) invoker: Arc<dyn Invoke + Send + Sync + 'a>, pub(crate) interceptors: ...
use std::fs::File; use std::io::{BufRead, BufReader}; use std::collections::HashMap; fn dfs(directs: &HashMap<String, Vec<String>>, ctr: &str, dist_com: i32) -> (i32, i32, i32) { let (mut tot_com, mut dist_you, mut dist_san) = (dist_com, -1, -1); if let Some(orbits) = directs.get(ctr) { for arnd in orbits {...
#![no_std] #![no_main] use core::sync::atomic::{AtomicUsize, Ordering}; use cortex_m_rt::entry; use defmt::*; use defmt_rtt as _; // global logger use panic_probe as _; use rp2040_pac as pac; #[defmt::timestamp] fn timestamp() -> u64 { static COUNT: AtomicUsize = AtomicUsize::new(0); // NOTE(no-CAS) `timestam...
use super::*; pub struct Camera { origin: Point3, lower_left_corner: Point3, horizontal: Point3, vertical: Point3, u: Point3, v: Point3, _w: Point3, lens_radius: f64, } impl Camera { pub fn new( lookfrom: Point3, lookat: Point3, vup: Point3, vfov: De...
extern crate calm_io; extern crate eyre; extern crate hidapi; extern crate indicatif; use std::fs::File; use std::io::Read; use argparse::{ArgumentParser, Print, Store}; use calm_io::stdoutln; use eyre::{Report, WrapErr}; use indicatif::{ProgressBar, ProgressStyle}; pub mod vb_prog { use super::{Report, WrapErr}...
pub(crate) mod lexer; pub(crate) mod parser;
#[doc = "Writer for register CSRL0"] pub type W = crate::W<u8, super::CSRL0>; #[doc = "Register CSRL0 `reset()`'s with value 0"] impl crate::ResetValue for super::CSRL0 { type Type = u8; #[inline(always)] fn reset_value() -> Self::Type { 0 } } #[doc = "Write proxy for field `RXRDY`"] pub struct ...
extern crate iptables; use iptables::error::{IPTError, IPTResult}; use iptables::IPTables; /// Behaves like new_chain except it does not produce an error when the chain already exists. pub fn new_chain(ipt: &IPTables, table: &str, chain: &str) -> IPTResult<()> { match ipt.new_chain(table, chain) { // Chai...
use std::io::IoResult; use std::io::fs::{mod, PathExtensions}; use std::sync::atomics; use std::{io, os}; use cargo::util::realpath; static CARGO_INTEGRATION_TEST_DIR : &'static str = "cargo-integration-tests"; local_data_key!(task_id: uint) static mut NEXT_ID: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT; pub ...
use lazy_static::lazy_static; use rand::random; use rayon::prelude::*; use std::io::Write; use std::ops::{Add, Mul, Not, Rem}; #[derive(Debug, Clone, Copy)] struct Vec3 { x: f32, y: f32, z: f32, } impl Vec3 { fn new_abc(a: f32, b: f32, c: f32) -> Self { Vec3 { x: a, y: b, z: c } } fn n...
use std::fmt::Display; struct Pair<T> { x: T, y: T, } impl<T> Pair<T> { fn new(x: T, y: T) -> Self { // Self is syntactic sugar for the current type, particularly useful with generic implementations Self { x, y, } } } impl<T: Display + PartialOrd> Pair<T> { ...
use super::{dump::dump_data_frames, InfluxRpcTest}; use async_trait::async_trait; use futures::{prelude::*, FutureExt}; use generated_types::aggregate::AggregateType; use std::sync::Arc; use test_helpers_end_to_end::{ maybe_skip_integration, GrpcRequestBuilder, MiniCluster, Step, StepTest, StepTestState, }; // Sta...
//! Module for API context management. //! //! This module defines traits and structs that can be used to manage //! contextual data related to a request, as it is passed through a series of //! hyper services. //! //! See the `context_tests` module below for examples of how to use. use crate::auth::{AuthData, Author...
static RAINBOW: [[u8; 3]; 12] = [[255, 0, 0], [255, 128, 0], [255, 255, 0], [128, 255, 0], [0, 255, 0], [0, 255, 128], [0, 255, 255], [0, 127, 255], [0, 0, 255], [128, 0, 255], [255, 0, 255], [255, 0, 128]]; use color::Color; pub fn get_rainbow_color(note: u8) -> Color { let rgb = RAINBOW[note as usize % 12 as us...
//! Defines `Range` and `HalfRange` types. use proc_macro2::TokenStream; use quote::quote; /// Returns the tokens defining `Range` and `HalfRange`. pub fn get() -> TokenStream { quote! { use std::fmt; /// Abstracts integer choices by a range. #[derive(Copy, Clone, PartialEq, Eq, Hash, Debu...
pub mod portfire; pub mod script; #[cfg(feature="tts")] pub mod tts;
pub mod consts;