text
stringlengths
8
4.13M
use hyper::{Client, Url}; use std::collections::BTreeSet; use semver::VersionReq; pub enum Target { None, Ref(String), Commit(String), Version(VersionReq) } pub struct Install { package: String, target: Target, dependencies: Option<BTreeSet<String>>, dev_dependencies: Option<BTreeSet<S...
// This is forked from the above actix-web-middleware-redirect-https to also support "www." prefix use actix_service::{Service, Transform}; use actix_web::{ dev::{ServiceRequest, ServiceResponse}, http, Error, HttpResponse, }; use futures::{ future::{ok, Either, FutureResult}, Poll, }; #[derive(Defaul...
use std::fmt::Display; fn main() { println!("{}", tpl(12, "気温", 22.4)) } fn tpl<TX: Display, TY: Display, TZ: Display>(x: TX, y: TY, z: TZ) -> String { format!("{}時の{}は{}", x, y, z) }
use super::{BinaryType, CloseEvent, Result, WebSocket, WebSocketMessage}; use crate::app::Orders; use std::marker::PhantomData; use std::rc::Rc; use wasm_bindgen::{closure::Closure, JsCast, JsValue}; use web_sys::MessageEvent; // ------ Callbacks ------ // `Callbacks` are used internally by `WebSocket` and `Builder`....
use super::super::super::rand::prelude::SliceRandom; use crate::construction::heuristics::InsertionContext; use crate::construction::heuristics::*; use crate::models::problem::Job; use crate::solver::mutation::recreate::Recreate; use crate::solver::mutation::{ConfigurableRecreate, PhasedRecreate}; use crate::solver::po...
#![feature(proc_macro_hygiene, decl_macro)] use myrias::{router, Config}; use rocket::{catchers, routes}; fn main() { std::env::set_var("ROCKET_CLI_COLORS", "off"); let config = Config::from_file("Config.toml"); rocket::ignite() .manage(config) .register(catchers![ router::not...
fn main() { manhanttanDistance(361527); fillSquares(361527); } fn manhanttanDistance(input: usize) { let mut total = 1; let mut level = 1; while total < input { level += 2; total = level * level; } let offset = total - input; let distance_from_input_to_corner = offset ...
header! { /// 'Origin' request header, /// part of [CORS](http://www.w3.org/TR/cors/#origin-request-header) /// /// The 'Origin' header indicates where the cross-origin request /// or preflight request originates from. /// /// # ABNF /// ```plain /// Origin = url /// ``` /// ...
use actix_web::{HttpResponse, web, post}; use serde::Serialize; use crate::appdata::AppData; use rand::Rng; use crate::common::Statistics; #[derive(Serialize)] #[serde(rename_all = "camelCase")] pub struct Response { status: u16, #[serde(skip_serializing_if = "Option::is_none")] new_uu...
use super::*; use std::path::Path; use variant_reader::VariantType; #[test] fn insertion_test() { let mut variants = read_indexed_vcf( Path::new("tests/resources/insertion.vcf.gz"), String::from("11"), 887340, 887350, ); let var = variants.pop().unwrap(); let allel = St...
use core::mem::size_of; use core::ptr; use core::slice; #[repr(packed)] #[derive(Clone, Copy, Debug, Default)] pub struct SDTHeader { pub signature: [u8; 4], pub length: u32, pub revision: u8, pub checksum: u8, pub oemid: [u8; 6], pub oemtableid: [u8; 8], pub oemrevision: u32, pub creat...
use actix_web::web::ServiceConfig; use actix_web::{delete, get, patch, post, web, Error, HttpResponse}; use crate::models::user::{RegisterUser, User}; use crate::db::{auth as db, PgPool}; pub fn endpoints(config: &mut ServiceConfig) { config.service(signup); } #[post("/api/auth/signup")] pub async fn signup(web::...
#[doc = "Register `BRR` reader"] pub type R = crate::R<BRR_SPEC>; #[doc = "Register `BRR` writer"] pub type W = crate::W<BRR_SPEC>; #[doc = "Field `BR0` reader - Port Reset bit"] pub type BR0_R = crate::BitReader<BR0W_A>; #[doc = "Port Reset bit\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub en...
use std::fs::File; use std::io::{self, BufRead}; fn valid_part1(line:&str) -> bool { let policy_passwd:Vec<&str> = line.split(":").take(2).collect(); let policy = policy_passwd[0]; let passwd = policy_passwd[1]; let policy_fs:Vec<&str> = policy.split(" ").take(2).collect(); let range:Vec<&str> = p...
pub mod sub; // 2. 这段放到单独文件, 并 pub mod pub mod hdl { pub fn say2(ss: &str) { println!("say2: {:?}", ss) } } pub fn say(ss: &str) { println!("say: {:?}", ss) }
mod common; use std::collections::HashSet; fn part1(entries: &[i32]) -> i32 { let set: HashSet<_> = entries.iter().copied().collect(); for e1 in entries { let e2 = 2020 - e1; if set.contains(&e2) { return e1 * e2; } } panic!("no matching entries found") } fn part2(...
#[doc = "Reader of register NEXT_CONN"] pub type R = crate::R<u32, super::NEXT_CONN>; #[doc = "Writer for register NEXT_CONN"] pub type W = crate::W<u32, super::NEXT_CONN>; #[doc = "Register NEXT_CONN `reset()`'s with value 0"] impl crate::ResetValue for super::NEXT_CONN { type Type = u32; #[inline(always)] ...
use crate::{Config, FormatOptions}; use crate::{Result, TaskpaperFile}; use path_absolutize::Absolutize; use std::cmp; use std::collections::HashMap; use std::ffi::OsStr; use std::path::{Path, PathBuf}; use walkdir::WalkDir; #[derive(Debug)] enum SortDir { Desc, Asc, } #[derive(Debug)] struct SortBy { key...
#![doc = "generated by AutoRust 0.1.0"] #![allow(unused_mut)] #![allow(unused_variables)] #![allow(unused_imports)] use super::{models, API_VERSION}; #[non_exhaustive] #[derive(Debug, thiserror :: Error)] #[allow(non_camel_case_types)] pub enum Error { #[error(transparent)] AvailabilityGroupListeners_Get(#[from...
use super::{Block, BlockId, Field}; use crate::resource::ResourceId; use crate::Promise; use std::collections::HashSet; use wasm_bindgen::prelude::*; #[derive(Clone)] pub struct Memo { name: String, text: String, tags: HashSet<BlockId>, } impl Memo { pub fn new() -> Self { Self { n...
// This file is part of Substrate. // Copyright (C) 2019-2020 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // ht...
/// A structure which represents 4 box sides. #[derive(Default, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct Sides<T> { /// Top side. pub top: T, /// Bottom side. pub bottom: T, /// Left side. pub left: T, /// Right side. pub right: T, } impl<T> Sides<T> { /// Cre...
use std::ops::Deref; use std::fmt::{self, Display}; use itertools::Itertools; use super::super::{LinedString, Environment, Elaborator, TermID, ThmID, SortID, Sort, Term, Thm}; use super::{AtomID, LispKind, LispVal, Uncons, InferTarget, Proc, ProcPos}; #[derive(Copy, Clone)] pub struct FormatEnv<'a> { pub source: &...
use byteorder::{ByteOrder, NativeEndian}; use crate::{ traits::{Emitable, Parseable}, DecodeError, Field, }; /// Byte/Packet throughput statistics #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct TcStatsBasic { /// number of seen bytes pub bytes: u64, /// number of seen packets pub pack...
use crate::domain::entities::{User, Task}; use rusqlite::{Connection, NO_PARAMS, types::ToSql}; pub trait SQLable { fn select() -> &'static str; fn insert() -> &'static str; fn create_table() -> &'static str; #[inline(always)] fn bind<F, T>(data: &Self, consumer: F) -> T where F: FnMut(&'static s...
#![allow(dead_code)] mod assembler; #[cfg(test)] mod tests { use super::assembler::assemble::SemanticError; use super::assembler::ast::*; use std::collections::HashMap; use combine::stream::position; use combine::EasyParser; use super::assembler::assemble::Encode; #[test] fn test_ju...
#![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate rocket; mod expenses; mod server; fn main() { if let Err(err) = server::run() { eprintln!("Error: {}", err); std::process::exit(1); } }
use std::collections::HashMap; pub fn parse(input: &str) -> HashMap<&str, &str> { input .split("&") .collect::<Vec<&str>>() .into_iter() .map(|entry| { let pair: Vec<_> = entry.split("=").collect(); (pair[0], pair[1]) }) .collect::<HashMap<&st...
use std::collections::BTreeSet; use pickpocket::batch::BatchApp; use pickpocket::Status; #[tokio::main] async fn main() { let app = BatchApp::default(); let mut ids: BTreeSet<&str> = BTreeSet::new(); let cache_reading_list = app.cache_client.list_all(); for line in app.file_lines() { let ur...
use crate::common::{ self, factories::prelude::*, snitches::{CoreSnitch, TransportSnitch}, }; use ::common::ipnetwork::IpNetwork; use ::common::rsip::{self, prelude::*}; use models::transport::RequestMsg; use sip_server::{ core::impls::{UserAgent, Registrar}, ReqProcessor, SipBuilder, SipManager, Tr...
fn multi_hello() -> (&'static str, i32) { ("Hello",42) } fn main() { let (str,num)=multi_hello(); println!("{},{}",str,num); }
#[doc = "Register `GCR` reader"] pub type R = crate::R<GCR_SPEC>; #[doc = "Register `GCR` writer"] pub type W = crate::W<GCR_SPEC>; #[doc = "Field `WW1RSC` reader - WWDG1 reset scope control"] pub type WW1RSC_R = crate::BitReader<WW1RSC_A>; #[doc = "WWDG1 reset scope control\n\nValue on reset: 0"] #[derive(Clone, Copy,...
#[doc = "Reader of register DDFT_CONFIG"] pub type R = crate::R<u32, super::DDFT_CONFIG>; #[doc = "Writer for register DDFT_CONFIG"] pub type W = crate::W<u32, super::DDFT_CONFIG>; #[doc = "Register DDFT_CONFIG `reset()`'s with value 0"] impl crate::ResetValue for super::DDFT_CONFIG { type Type = u32; #[inline(...
// This file is based on https://github.com/alce/tonic/blob/86bbb1d5a4844882dec81bef7c1a554bd9464adf/tonic-web/tonic-web/src/call.rs use std::mem; use std::pin::Pin; use std::task::{Context, Poll}; use std::{convert::TryInto, error::Error}; use byteorder::{BigEndian, ByteOrder}; use bytes::{Buf, BufMut, Bytes, BytesM...
#[doc = "Register `I2SCFGR` reader"] pub type R = crate::R<I2SCFGR_SPEC>; #[doc = "Register `I2SCFGR` writer"] pub type W = crate::W<I2SCFGR_SPEC>; #[doc = "Field `CHLEN` reader - Channel length (number of bits per audio channel)"] pub type CHLEN_R = crate::BitReader; #[doc = "Field `CHLEN` writer - Channel length (num...
use crate::Entity; pub trait Insert<E: Entity> { fn insert(&mut self, k: E::Key, v: E); } impl<E, T> Insert<E> for &mut T where E: Entity, T: Insert<E>, { fn insert(&mut self, k: E::Key, v: E) { (**self).insert(k, v) } }
use crate::{bool_to_option, event_details_into}; use gloo::events::EventListener; use js_sys::Object; use std::borrow::Cow; use wasm_bindgen::prelude::*; use web_sys::Element; use yew::prelude::*; #[wasm_bindgen(module = "/build/mwc-tab.js")] extern "C" { #[derive(Debug)] type Tab; #[wasm_bindgen(getter, ...
use multiaddr::{Multiaddr, Protocol}; fn is_ip(p:Protocol) -> bool { match p { Protocol::IP4 | Protocol::IP6 => true, _ => false, } } // Comment from go-multiaddr-net: // // "IsThinWaist returns whether a Multiaddr starts with "Thin Waist" Protocols. // This means: /{IP4, IP6}[/{TCP, UDP}]" fn...
//http://rustbyexample.com/fn/closures/input_parameters.html fn apply<F>(f: F) where F: FnOnce(){ f(); } pub fn input_param() { let greeting = "hello"; // let farewell = "goodbye".to_owned(); let diary = || { println!("I said {}", greeting); }; apply(diary); }
use std::path::PathBuf; use std::process::{Command, Stdio}; use rsh::State; // TODO "Error handling mother trucker, do you speak it?" pub fn exec(s: &State) -> i32 { let mut args = s.argv.iter(); let mut exec_path: Option<PathBuf> = None; let exec_name = args.next().unwrap().as_str(); 'outer: for pat...
use std::collections::HashMap; pub struct Response { pub version: String, pub response_phrase: String, pub response_code: i32, headers: HashMap<String, String>, pub body: Vec<u8>, } impl Response { pub fn new(version: &str, response_code: i32) -...
use super::SampleFitness; use std::hash::Hash; use std::collections::HashMap; impl<T> Hash for SampleFitness<T> where T: Hash { fn hash<H: std::hash::Hasher>(&self, state: &mut H) { self.sample.hash(state); } }
fn main() { let mut v: Vec<i32> = (0..=100).collect(); v.retain(|n| n % 3 != 0); println!("{:?}", v); }
use crossbeam::channel::unbounded; use std::fs; use std::path::PathBuf; use hshchk::hash_file_process::*; use hshchk::{HashFileFormat, HashType}; extern crate test_shared; // #[path = "../src/test/mod.rs"] // mod test; static HASHCHECK_SHA1_NAME: &str = "hshchk.sha1"; static HASHCHECK_MD5_NAME: &str = "hshchk.md5"; ...
use std::collections::HashSet; use std::fs::File; use std::io::{BufRead, BufReader}; use std::iter::FromIterator; use std::path::Path; fn main() -> Result<(), std::io::Error> { let input_path = Path::new("input.txt"); let reader = BufReader::new(File::open(&input_path)?); let input = reader .lines(...
/// Utility Code For Creating Disp Arrays (array + fat pointer) /// in LLVM use super::{extract_type_from_pointer, CodegenResult, Context, LLVMInstruction, Object, Type}; /// array_value_pointer should not be an actual pointer, but the /// index in the scope in which the pointer actually lives. pub fn create_array( ...
use super::Token; use proc_macro2::{Ident, Span}; use quote::ToTokens; use syn::punctuated::Punctuated; use syn::{ ImplItem, ImplItemConst, ImplItemMacro, ImplItemMethod, ImplItemType, ItemImpl, ItemTrait, TraitItem, TraitItemConst, TraitItemMacro, TraitItemMethod, TraitItemType, Visibility, }; fn convert_meth...
use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::net::SocketAddr; use tiny_http::{Response, Server}; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct ServerInfo { name: String, player_count: u8, max_players: u8, description: String, map: String, port: u16, ...
#[doc = "Register `OTPBLR_CUR` reader"] pub type R = crate::R<OTPBLR_CUR_SPEC>; #[doc = "Field `LOCKBL` reader - OTP block lock Block n corresponds to OTP 16-bit word 32 x n to 32 x n + 31. LOCKBL\\[n\\] = 1 indicates that all OTP 16-bit words in OTP Block n are locked and attempt to program them results in WRPERR. LOC...
//! A module which contains configuration options for a [`Grid`]. //! //! [`Grid`]: crate::grid::iterable::Grid mod borders_config; mod entity_map; mod formatting; mod offset; use std::collections::HashMap; use crate::color::{AnsiColor, StaticColor}; use crate::config::compact::CompactConfig; use crate::config::{ ...
use gl; use std; //TODO //Do a derive(GLResource) that adds gl_handle to types. //Is that even possible? #[derive(Debug, Default)] pub struct VertexArrayObj { gl_handle: u32, } #[derive(Debug, Default)] pub struct VertexBufferObj { gl_handle: u32, } impl VertexBufferObj { pub fn new() -> VertexBufferObj...
/// bindings for ARINC653P1-5 3.7.2.4 events pub mod basic { use crate::bindings::*; use crate::Locked; /// ARINC653P1-5 3.7.1 pub type EventName = ApexName; /// ARINC653P1-5 3.7.1 /// /// According to ARINC 653P1-5 this may either be 32 or 64 bits. /// Internally we will use 64-bit by...
pub mod tools; pub mod myerror;
#[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::PADREGL { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w m...
use crate::BufferedReader; use std::io::{BufWriter, Write}; use base64::encode; use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::RawStream; use nu_protocol::{ Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Valu...
use super::{ Check, }; use ident::Identifier; use ty::Ty; use stmt::{ Statement, fun::{ Fun, FunParam }, }; use ir::{ Chunk, }; use super::{ Typeck, Load, Unload, }; use ir::hir::HIRInstruction; use ir_traits::{ReadInstruction, WriteInstruction}; use notices::{ Di...
/// An enum to represent all characters in the MiscellaneousSymbolsandArrows block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum MiscellaneousSymbolsandArrows { /// \u{2b00}: '⬀' NorthEastWhiteArrow, /// \u{2b01}: '⬁' NorthWestWhiteArrow, /// \u{2b02}: '⬂' SouthEastWhiteArrow, ...
extern crate rsh; use std::env; fn main() { let mut argv = env::args(); // skip argv[0] argv.next(); let s = if let Some(path) = argv.next() { rsh::State::new(path) } else { rsh::State::default() }; rsh::run(s) }
//! Utility macros for code generation. #![macro_use] /// Applies `$fn` to an `VecCopy` mapping valid numeric data types by corresponding generic /// parameters. For example, passing an `VecCopy` containing data of type `u8` will cause this /// macro to call `$fn` with type parameter `u8` like `$fn::<u8>(buffer)`. /...
use crate::{RcAny, Wrc}; use config::{Config, Environment, File}; use lazy_static::lazy_static; use regex::Regex; use std::any::{type_name, TypeId}; use std::collections::HashMap; use std::env; use std::env::args; use std::marker::PhantomData; pub mod profiles { pub struct Default; pub struct Dev; pub stru...
use bytes::{ Bytes, Buf, BytesMut, BufMut }; #[derive(Debug, PartialEq, Clone)] pub struct NodeIDWithCallbackRequest { pub node_id : u8, pub callback : u8, } impl NodeIDWithCallbackRequest { pub fn encode(&self, dst: &mut BytesMut) { dst.put_u8(self.node_id); dst.put_u8(self.cal...
#[doc = "Register `HWCFGR2` reader"] pub type R = crate::R<HWCFGR2_SPEC>; #[doc = "Field `MASTERID1` reader - Hardware Configuration valid bus masters ID1"] pub type MASTERID1_R = crate::FieldReader; #[doc = "Field `MASTERID2` reader - Hardware Configuration valid bus masters ID2"] pub type MASTERID2_R = crate::FieldRe...
/** The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. */ pub fn execute() { let mut number : u64 = 3; let mut primes : Vec<u64> = Vec::new(); primes.push(2); while number < 2_000_000 { let prime = check_already_found_primes(number, &primes...
// Copyright 2016 FullContact, Inc // // 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 accordin...
use std::{io::Write, thread}; use std::{ops::Add, time}; fn main() { // print!("Hello"); // std::io::stdout().flush().unwrap(); // WTH Lol // thread::sleep(time::Duration::from_secs(2)); // println!(", world!"); let d1 = time::Duration::new(2, 0); let mut d2 = time::Duration::new(0, 0); wh...
use std::{sync::Arc, time::Duration, time::Instant}; use rodio::Sink; pub(crate) struct FadeKey { pub sink: Arc<Sink>, } impl std::hash::Hash for FadeKey { fn hash<H: std::hash::Hasher>(&self, state: &mut H) { std::ptr::hash(&*self.sink, state); } } impl std::cmp::PartialEq for FadeKey { fn eq(&self, other: &...
/********************************************** > File Name : circular_queue.rs > Author : lunar > Email : lunar_ubuntu@qq.com > Created Time : Tue 14 Dec 2021 10:05:05 AM CST > Location : Shanghai > Copyright@ https://github.com/xiaoqixian **********************************************/ st...
#![crate_name = "music_generator"] pub mod representations; pub use representations::note::Note; pub use representations::interval::Interval; /// There are 12 simi-tone notes in an octave. static NOTES_PER_OCTAVE: i32 = 12;
use ir::Value; /// A function argument pub struct Argument<'ctx>(Value<'ctx>); impl<'ctx> Argument<'ctx> { } impl_subtype!(Argument => Value);
use crate::{parser::*, val::Val}; use std::collections::BTreeMap; type Error = &'static str; #[derive(Debug, Default)] pub struct Environment { variables: BTreeMap<String, Val>, //functions : std::collections::HashMap<&str, _> } impl Environment { pub fn new() -> Environment { Environment { ...
use serde::Serialize; use crate::rocket_contrib::json::Json; #[derive(Serialize)] pub struct ApiStatus { status: String } #[get("/")] pub fn status() -> Json<ApiStatus> { Json(ApiStatus{ status: String::from("Up and running!") }) }
use std::error::Error; use std::net::{Ipv4Addr, SocketAddrV4}; use tokio::prelude::*; #[derive(Debug)] pub struct MixPeer { connection: SocketAddrV4, } impl MixPeer { // note that very soon `next_hop_address` will be changed to `next_hop_metadata` pub fn new(next_hop_address: [u8; 32]) -> MixPeer { ...
use std::sync::Arc; use super::{MainIndex, SynonymsIndex, WordsIndex, DocsWordsIndex, DocumentsIndex, CustomSettings}; #[derive(Clone)] pub struct RawIndex { pub main: MainIndex, pub synonyms: SynonymsIndex, pub words: WordsIndex, pub docs_words: DocsWordsIndex, pub documents: DocumentsIndex, p...
#![doc = "generated by AutoRust 0.1.0"] #![allow(unused_mut)] #![allow(unused_variables)] #![allow(unused_imports)] use crate::models::*; use reqwest::StatusCode; use snafu::{ResultExt, Snafu}; pub mod operations { use crate::models::*; use reqwest::StatusCode; use snafu::{ResultExt, Snafu}; pub async f...
struct Point { x: f32, y: f32 } impl Point { fn get_radius(&self) -> f32 { (self.x*self.x + self.y*self.y).sqrt() } } fn struct_method() { println!("struct_method -------------------"); let p = Point{x:3.2, y:1.2}; println!("radisu = {}", p.get_radius()); } fn say_hi() {println!...
use std::fs::File; use std::io; use std::io::Read; use zip::read::ZipFile; use log::*; /// Trait for read types that can report their size. pub trait LengthRead: Read { fn input_size(&self) -> io::Result<u64>; /// Read all bytes from a file, using its size to pre-allocate capacity. fn read_all_sized(&mut...
/* Multi-producer/single-consumer queue * Copyright (c) 2010-2011 Dmitry Vyukov. All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above co...
#[derive(Debug, Copy, Clone, Eq, PartialEq)] pub enum Direction { Up, Right, Down, Left, } impl Direction { pub fn opposite(&self) -> Self { match self { Self::Up => Self::Down, Self::Right => Self::Left, Self::Down => Self::Up, Self::Left => ...
//! Data types used in packets. use crate::adapters::*; // Define trivial types define_packet_data! { GroundTileData { x: i16, y: i16, tile_type: u16, }, MoveRecord { time: u32, x: f32, y: f32, }, ObjectData { object_type: u16, status...
//! Electrum Client use bitcoin::{Script, Txid}; use api::ElectrumApi; use batch::Batch; use raw_client::*; use types::*; /// Generalized Electrum client that supports multiple backends. This wraps /// [`RawClient`](client/struct.RawClient.html) and provides a more user-friendly /// constructor that can choose the r...
use std::io; use std::str; use thiserror::Error; use crate::{header, point, reader, vlr, writer, Transform, Version}; /// Crate-specific error enum. #[derive(Error, Debug)] pub enum Error { /// Feature is not supported by version. #[error("feature {feature} is not supported by version {version}")] #[allow(...
use specs::prelude::*; use super::{RunState, gamelog::GameLog, GameClock, SeedClock, Seed, IsSown}; pub struct SeedSystem {} impl<'a> System<'a> for SeedSystem { #[allow(clippy::type_complexity)] type SystemData = ( Entities<'a>, WriteStorage<'a, Seed>, ...
use super::types; use super::types::Type; use crate::core::parse::ast::TypeID; use std::fmt; use std::fmt::Debug; #[derive(Debug, Clone, PartialEq)] pub enum Value<'a> { Number(types::Number), Function(types::Function<'a>), String(types::String), Bool(types::Bool), Unit(types::Unit), Enum(types...
// This file is part of lock-free-multi-producer-single-consumer-ring-buffer. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/lock-free-multi-producer-single-consumer-ring-buffer/master/COPYRIGHT. No part o...
use libc::{c_void, c_int, size_t, ssize_t, off_t}; #[repr(C)] pub struct iovec { pub iov_base: *mut c_void, pub iov_len: size_t } #[cfg(target_os = "linux")] extern { pub fn pwritev(fd: c_int, iov: *const iovec, iovcnt: c_int, offset: off_t) -> ssize_t; } #[cfg(any(target_os = "macos", target_os="linux")...
use crate::query_testing; use anyhow::{Context, Result}; use std::{ fs, io::{self, Write}, ops::Range, path::Path, time::Instant, }; use tree_sitter::{Language, Parser, Point, Query, QueryCursor}; pub fn query_files_at_paths( language: Language, paths: Vec<String>, query_path: &Path, ...
mod schip8; use schip8::SChip8; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use web_sys::CanvasRenderingContext2d; use web_sys::HtmlCanvasElement; #[wasm_bindgen(start)] pub fn start() { let window = web_sys::window().unwrap(); let canvas = window .document() .unwrap() .get...
#[macro_use] extern crate diesel; use std::io::{Read, Write}; use std::net::TcpStream; use std::str::from_utf8; use byteorder::{ByteOrder, LittleEndian}; use diesel::prelude::*; use diesel::mysql::MysqlConnection; use dotenv::dotenv; use std::env; use std::time::Duration; use device_query::{DeviceQuery, DeviceState, K...
fn main() { let features: &[u16] = &[1, 2]; let families: &[u16] = &[0, 1]; let constraint_a: &[[u16; 3]] = &[[0, 1, 0], [1, 0, 1], [1, 2, 0]]; let constraint_b: &[[u16; 3]] = &[[0, 1, 1], [1, 0, 1], [1, 2, 0]]; let constraint_c: &[[u16; 3]] = &[[2, 3, 0], [2, 4, 1], [3, 5, 0], [1, 2, 0]]; let...
//! [ExtraData](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-shllink/c41e062d-f764-4f13-bd4f-ea812ab9a4d1) related structs mod tracker_data_block; use std::io::{Result, Seek, Read, Cursor}; use byteorder::{LittleEndian, ReadBytesExt}; use serde::Serialize; use tracker_data_block::TrackerDataBlock; ...
use std::mem; struct Fibonacci { curr: u32, next: u32, } impl Iterator for Fibonacci { type Item = u32; fn next(&mut self) -> Option<u32> { let new_next = self.curr + self.next; let new_curr = mem::replace(&mut self.next, new_next); Some(mem::replace(&mut self.curr, new_curr)) ...
//! How client and server communicate. Usually a client will send the server //! some action it wants to execute, and the server will send some other action, //! possibly the very one the the client sent, and possibly to other clients //! other than the sender. It should send the action to all clients affected by //! t...
#![warn(missing_docs)] #![feature(box_syntax, box_patterns)] //! A Rust implementation of chapter 4 of Benjamin C. Pierce's "Types and Programming Languages" //! `arith` language. //! //! c.f. https://www.cis.upenn.edu/~bcpierce/tapl/checkers/arith/core.ml for the sample OCaml //! implementation. //! //! # Example //!...
//! Deserializer implementation for ShopSite `.aa` files. //! //! # Parsing Is Not Strict //! //! Because there is no public specification for the format of `.aa` files, and all format details are inferred from the `.aa` files that ShopSite itself generates, this parser is not strict about what it will accept as vali...
#[doc = "Register `CDCFGR2` reader"] pub type R = crate::R<CDCFGR2_SPEC>; #[doc = "Register `CDCFGR2` writer"] pub type W = crate::W<CDCFGR2_SPEC>; #[doc = "Field `CDPPRE1` reader - CPU domain APB1 prescaler Set and reset by software to control the CPU domain APB1 clock division factor. The clock is divided by the new ...
extern crate build_probe_mpi; extern crate bindgen; use std::env; use std::path::PathBuf; fn main() { // Allow user to set PETSc paths from environment variables. let petsc_include_dir: PathBuf = [env::var("PETSC_DIR").unwrap(), String::from("include")].iter().collect(); let petsc_arch_include_di...
use super::hitable::HitRecord; use super::ray::Ray; use super::vec3::Vec3; fn random_in_unit_sphere() -> Vec3 { let mut p: Vec3; loop { p = 2.0 * Vec3::new( rand::random::<f32>(), rand::random::<f32>(), rand::random::<f32>(), ) - V...
use crate::errors::*; use crate::request::{FilterOptions, ModelRequest, RequestDetails, RequestParameters, ZohoRequest}; use reqwest::Method; use serde::{Deserialize, Serialize}; use std::collections::HashMap; pub mod comment; pub(crate) fn model_path( portal: impl std::fmt::Display, project: impl std::fmt::D...
#[doc = "Register `EXTI_HWCFGR5` reader"] pub type R = crate::R<EXTI_HWCFGR5_SPEC>; #[doc = "Field `CPUEVENT` reader - CPUEVENT"] pub type CPUEVENT_R = crate::FieldReader<u32>; impl R { #[doc = "Bits 0:31 - CPUEVENT"] #[inline(always)] pub fn cpuevent(&self) -> CPUEVENT_R { CPUEVENT_R::new(self.bits...
pub mod external_command;