text
stringlengths
8
4.13M
pub mod request; pub mod response; pub mod session; pub mod user;
use std::collections::HashMap; use anyhow::{anyhow, Result}; use itertools::Itertools as _; use petgraph::graph::{DiGraph, NodeIndex}; use crate::Challenge; pub struct Day07; type Rules = DiGraph<(), usize>; impl Challenge for Day07 { const DAY_NUMBER: u32 = 7; type InputType = (Rules, HashMap<String, Nod...
//! # PubNub Core //! //! Provides the common high-level logic for PubNub clients. //! //! - Fully `async`/`await` ready. //! - Modular, bring your own [`Transport`] and [`Runtime`]. //! - Multiplexes subscription polling for multiple logical streams over a //! single transport invocation to optimize kernel network s...
use actix_web::get; use actix_web::web::HttpResponse; use serde::Serialize; #[derive(Serialize)] struct VersionResponseBody<'a> { version: &'a str, } // The current Matrix version of the server. const MATRIX_VERSION: &str = "1.0"; // The response body returned by versions endpoint. const VERSION_RESPONSE: Version...
mod board; mod color; mod direction; mod file; pub mod game; mod name; mod piece; mod rank; mod square;
use std::iter::FromIterator; use crate::{ grid::dimension::CompleteDimensionVecRecords, grid::records::{ExactRecords, Records}, settings::TableOption, }; /// A structure used to set [`Table`] height via a list of rows heights. /// /// [`Table`]: crate::Table #[derive(Debug)] pub struct HeightList { li...
use std::env; use std::fs::File; use std::io::Write; use std::path::Path; fn implement_type_conversion_for_trait() { let out_dir = env::var("OUT_DIR").unwrap(); let dest_path = Path::new(&out_dir).join("conv.rs"); let mut f = File::create(&dest_path).unwrap(); let supported_types = [ ("ByteTens...
use crate::utils::translators; use std::char; pub fn decode_str(val: &str) -> String { let mut decoded: String = String::new(); let mut byte_buf: u32 = 0; let mut buf_size: usize = 0; let padding = val.len() - val.trim_end_matches('=').len(); let val = val.trim_end_matches('='); //cw== fo...
extern crate cc; use std::env; use std::fs::{self, File}; use std::io::{self, Read, Write}; use std::path::{Path, PathBuf}; const ENV_NAME: &str = "NATIVE_VERSIONING_VERSION"; /// Error enum. #[derive(Debug)] pub enum Error { Io(::std::io::Error), EnvVar(::std::env::VarError), Fmt(::std::fmt::Error) } i...
use std::thread; use std::sync::mpsc::{Receiver, sync_channel}; use websocket::{ClientBuilder, Message}; use websocket::result::WebSocketResult; use websocket::stream::Stream; use websocket::client::sync::Client; use websocket::message::OwnedMessage; use serde_json; #[derive(Serialize, Deserialize)] pub struct GDAXMes...
fn main() { use std::io::{self, BufRead}; use std::collections::HashMap; let stdin = io::stdin(); let mut two = 0; let mut three = 0; for id in stdin.lock().lines(){ let mut letter_count = HashMap::new(); for c in id.unwrap().chars(){ let count = letter_count.ent...
#[doc = r"Register block"] #[repr(C)] pub struct CH { #[doc = "0x00 - MDMA channel x interrupt/status register"] pub isr: ISR, #[doc = "0x04 - MDMA channel x interrupt flag clear register"] pub ifcr: IFCR, #[doc = "0x08 - MDMA Channel x error status register"] pub esr: ESR, #[doc = "0x0c - T...
// 所有权和移动语义 // C++ 对 C 中的手动内存管理进行了一个改进,即通过“智能指针”来描述“所有权”(Ownership)概念。 // 这在一定程度上减少了内存使用 bug,实现了“半自动化”的内存管理。 // Rust 在此基础上更进一步,将“所有权”的理念直接融入到了语言之中。 // “所有权”代表着以下意义: // 1. 每个值在 Rust 中都有一个变量来管理它,这个变量就是这个值、这块内存的所有者; // 2. 每个值在一个时间点上只有一个管理者; // 3. 当变量所在的作用域结束的时候,变量以及它代表的值将会被销毁。 pub fn first() { fn test1() { /...
pub mod websocket;
use crate::renderer::{App, AppControl, EventChannel, EventLoop, UserEvent}; use crate::wry::menu::MenuIds; use anyhow::Error; use wry::application::event::{Event, StartCause, WindowEvent}; use wry::application::event_loop::{ControlFlow, EventLoopProxy}; pub type WryEventLoop = wry::application::event_loop::EventLoop<U...
/// Include generated proto server and client items. /// /// You must specify the gRPC package name. /// /// ```rust,ignore /// mod pb { /// tonic::include_proto("helloworld"); /// } /// ``` #[macro_export] macro_rules! include_proto { ($package: tt) => { include!(concat!(env!("OUT_DIR"), concat!("/", $...
mod node; mod problem; mod solver; mod cover; mod iter; pub mod instances; pub use problem::Problem; pub use solver::Solver;
use std::convert::TryFrom; use std::error::Error; use std::ffi::{CStr, CString}; use std::path::PathBuf; use std::sync::{Arc, Mutex, RwLock}; use cffi::{FromForeign, InputType, ReturnType, ToForeign}; use once_cell::sync::Lazy; use pahkat_types::payload::{ macos::InstallTarget as MacOSInstallTarget, windows::Insta...
use crate::msbuild; use nom::{ branch::alt, bytes::complete::{is_not, tag, take_until}, character::complete::{self, char}, combinator::{self, recognize}, error::{ParseError, VerboseError}, sequence::{self, pair}, IResult, }; use petgraph::prelude::*; #[derive(Debug)] pub enum Expr<'input> {...
fn main() -> () { let list: Vec<u32> = vec![1, 2, 3, 4, 5]; fn f(v: &u32) -> bool { 3.eq(v) } let func: fn(&u32) -> bool = f let result = find::<u32>(&list, func).unwrap(); assert!(3.eq(result)); } fn find<T>(xs: &Vec<T>, f: fn(&T) -> bool) -> Option<&T> { // for x in xs { // if f(x) { ...
use log::*; use sphinx::SphinxPacket; use std::net::SocketAddr; use tokio::prelude::*; pub struct MixClient {} impl MixClient { pub fn new() -> MixClient { MixClient {} } // Sends a Sphinx packet to a mixnode. pub async fn send( &self, packet: SphinxPacket, mix_addr: S...
use cgmath::{self, InnerSpace, Vector2, Zero}; use midgar::{Button, KeyCode, MouseButton}; use midgar::Input; #[derive(Debug, Clone)] pub enum FireInput { Idle, Fire(Vector2<f32>), } #[derive(Clone, Debug)] pub struct PlayerInput { pub move_dir: Vector2<f32>, pub fire: FireInput, pub bomb: bool, }...
use arkecosystem_client::connection::Connection; const MOCK_HOST: &str = "http://127.0.0.1:1234/api/"; #[test] fn test_connection() { let connection = Connection::new(MOCK_HOST); assert_eq!(connection.client.host, MOCK_HOST); }
//! *col* is an esoteric programming language inspired by classical architectural columns and the //! syntax of other esolangs like [Befunge](https://esolangs.org/wiki/Befunge) and //! [Brainfuck](https://esolangs.org/wiki/Brainfuck). //! //! Learn more in the [project repository](https://github.com/cassaundra/col). //...
pub mod date_format { use chrono::{DateTime, Local, TimeZone}; use serde::{self, Deserialize, Deserializer, Serializer}; const FORMAT: &str = "%Y-%m-%d %H:%M:%S"; pub fn serialize<S>(date: &DateTime<Local>, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { let s ...
use std::{collections::HashMap, fs::{self, File}, io::{prelude::*, BufReader}, net::TcpStream, sync::mpsc::{self, Sender}, thread}; use serde::{Serialize}; use chrono::{Utc}; use mysql::{Opts, Pool, prelude::Queryable}; use crate::settings::Settings; mod settings; // So we are interested in connecting to the AMI ser...
use iron::prelude::*; use common::http::*; pub fn render_resource(req: &mut Request) -> IronResult<Response> { respond_view("resource", &ViewData::new(req)) } pub fn render_about_site(req: &mut Request) -> IronResult<Response> { respond_view("about-site", &ViewData::new(req)) }
pub const DEFAULT_SPEC: &str = "mainnet"; pub const AVAILABLE_SPECS: &[&str] = &["mainnet", "testnet", "staging", "dev"]; pub const DEFAULT_RPC_PORT: &str = "8114"; pub const DEFAULT_P2P_PORT: &str = "8115"; const START_MARKER: &str = " # {{"; const END_MAKER: &str = "# }}"; const WILDCARD_BRANCH: &str = "# _ => "; u...
pub mod base64; pub mod command; pub mod command_runtime; pub mod error; pub mod message; pub mod project; use std::rc::Rc; use std::sync::{Arc, Mutex}; #[derive(Clone)] pub struct WxWorkProjectSet { pub projs: project::WxWorkProjectMap, pub cmds: Rc<command::WxWorkCommandList>, pub events: Rc<command::Wx...
// Copyright 2020 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. /// Implements the `synthesizer::InputDevice` trait, and the server side of the /// `fuchsia.input.report.InputDevice` FIDL protocol. Used by /// `modern_b...
//! Shader settings. use arctk::{access, clone, img::Gradient, math::Pos3}; /// Colouring settings. pub struct Shader<'a> { /// Sun position used for lighting calculations [m]. sun_pos: Pos3, /// Ambient, diffuse, and occlusion lighting fractions. light: [f64; 3], /// Ambient, diffuse, and occlusi...
/* * Datadog API V1 Collection * * Collection of all Datadog Public endpoints. * * The version of the OpenAPI document: 1.0 * Contact: support@datadoghq.com * Generated by: https://openapi-generator.tech */ /// TimeseriesWidgetRequest : Updated timeseries widget. #[derive(Clone, Debug, PartialEq, Serialize,...
#[doc = "Register `FIR0` writer"] pub type W = crate::W<FIR0_SPEC>; #[doc = "Field `FAE0` writer - FAE0"] pub type FAE0_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>; #[doc = "Field `FAE1` writer - FAE1"] pub type FAE1_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>; #[doc = "Field `FAE2` writer - FAE2"...
fn print_point(pnt: &Point) { println!("{:#?}",pnt); } fn inc_x(pnt: &mut Point) { pnt.x += 1; } fn inc_y(pnt: &mut Point) { pnt.y += 1; } #[derive(Clone,Debug)] struct Point { x: i32, y: i32 } fn max(a: i32, b:i32)->i32{ if a > b { a } else { b } } fn main() { ...
#![feature(generic_associated_types)] use crystalorb::{ client::stage::{Stage, StageMut}, timestamp::Timestamp, world::Tweened, Config, TweeningMethod, }; use pretty_assertions::assert_eq; use test_env_log::test; mod common; use common::{MockClientServer, MockCommand, MockWorld}; #[test] fn while_al...
use std::fs; use std::io::prelude::*; use std::io::Cursor; use std::net::{TcpListener, TcpStream}; fn handle_header(buffer: &[u8]) -> Result<(String, String), ()> { let mut cursor = Cursor::new(buffer); let mut buf = String::new(); let _ = cursor.read_line(&mut buf); let mut header = buf.split_whitespa...
use criterion::{black_box, criterion_group, criterion_main, Criterion}; use subspace_core_primitives::crypto::kzg::{embedded_kzg_settings, Kzg}; use subspace_core_primitives::crypto::Scalar; use subspace_core_primitives::RawRecord; fn criterion_benchmark(c: &mut Criterion) { let values = (0..RawRecord::SIZE / Scal...
pub mod school_member{ pub mod student{ pub fn get_age(){ println!("Age"); } } }
fn main() { let aa = [1, 2, 3, 4, 5]; // same type // aa 不能改变长度了 println!("The value of aa[0] is: {}", aa[0]); }
#[cfg(test)] mod tests { use super::super::nock::*; #[test] fn it_works() { assert!(1 == 1) } #[test] fn op_0() { let input = "[57 [0 1]]"; let product = parse_and_nock(input.to_string()); assert_eq!(format!("{}", product), "57"); let input = "[[132 19] [0 3]]"; let product = par...
pub mod matrix; pub mod neuralnetwork; pub mod xorshift; use crate::matrix::Matrix; use crate::neuralnetwork::NeuralNetwork; use std::fs; use std::time::{SystemTime, UNIX_EPOCH}; pub fn current_millis() -> u128 { SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_millis() } pub ...
use super::PubNub; use crate::data::channel; use crate::data::object::Object; use crate::data::request; use crate::data::timetoken::Timetoken; use crate::runtime::Runtime; use crate::transport::Transport; impl<TTransport, TRuntime> PubNub<TTransport, TRuntime> where TTransport: Transport + 'static, TRuntime: R...
use std::sync::Arc; use rosu_v2::prelude::{Beatmap, GameMode, OsuError, Score, Username}; use twilight_model::application::interaction::{ application_command::{CommandDataOption, CommandOptionValue}, ApplicationCommand, }; use crate::{ commands::{ osu::{get_user_and_scores, unchoke_pp, ScoreArgs, ...
pub fn test() { println!("Hello, world!"); demo_ip_addr_kind(); demo_ip_addr(); demo_message(); demo_option(); demo_match(); demo_if_let(); } fn demo_ip_addr_kind() { #[derive(Debug)] enum IpAddrKind { V4, V6, } #[derive(Debug)] struct IpAddr { ...
use std::str::FromStr; use chrono::{Duration, Utc}; use futures::future::join_all; use lazy_static::lazy_static; use reqwest; use tokio::sync::{Mutex, MutexGuard}; use url::Url; use thetvdb::{ error::{Error, Result}, params::*, Client, }; mod data; use data::*; const ENV_APIKEY: &str = "THETVDB_APIKEY"...
use std::fs::File; use std::io::{BufRead, BufReader}; fn main() { // let filename = "src/input0"; let filename = "../part1/src/input"; // Open the file in read-only mode (ignoring errors). let file = File::open(filename).unwrap(); let reader = BufReader::new(file); let mut digits = Vec::new();...
#[doc = "Register `ISR_output` reader"] pub type R = crate::R<ISR_OUTPUT_SPEC>; #[doc = "Field `CC1IF` reader - Compare 1 interrupt flag The CC1IF flag is set by hardware to inform application that LPTIM_CNT register value matches the compare register's value. The CC1IF flag can be cleared by writing 1 to the CC1CF bit...
use std::collections::HashSet; /// Determine whether a sentence is a pangram. pub fn is_pangram(sentence: &str) -> bool { let lowercase: HashSet<char> = "abcdefghijklmnopqrstuvwxyz".chars().collect(); let sentence_letters: HashSet<char> = sentence .chars() .map(|c| c.to_ascii_lowercase()) .filter(|c| c...
use std::{ fmt::{self, Debug, Formatter}, path::Path, }; /// A file with its contents stored in a `&'static [u8]`. #[derive(Clone, PartialEq, Eq)] pub struct File<'a> { path: &'a str, contents: &'a [u8], #[cfg(feature = "metadata")] metadata: Option<crate::Metadata>, } impl<'a> File<'a> { ...
#[doc = "Register `ODSR` reader"] pub type R = crate::R<ODSR_SPEC>; #[doc = "Field `TA1ODS` reader - Timer A Output 1 disable status"] pub type TA1ODS_R = crate::BitReader; #[doc = "Field `TA2ODS` reader - Timer A Output 2 disable status"] pub type TA2ODS_R = crate::BitReader; #[doc = "Field `TB1ODS` reader - Timer B O...
mod leaf; mod operator; pub use leaf::UserFilter; pub use operator::Operator; use std::{collections::HashSet, convert::From, fmt}; #[derive(Clone, PartialEq, Eq)] pub enum UserAST { Attributed(String, Box<UserAST>), BinaryClause(Box<UserAST>, Operator, Box<UserAST>), Leaf(Box<UserFilter>), } // conversi...
/* * Copyright 2017-2018 Ben Ashford * * 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 accor...
use hacspec_dev::prelude::*; use hacspec_lib::prelude::*; use hacspec_chacha20::*; #[test] fn test_quarter_round() { let mut state = State::from_public_slice(&[ 0x879531e0, 0xc5ecf37d, 0x516461b1, 0xc9a62f8a, 0x44c20ef3, 0x3390af7f, 0xd9fc690b, 0x2a5f714c, 0x53372767, 0xb00a5631, 0x974c541a, 0x359...
use drawille::Canvas; use image::{ imageops::{resize, FilterType::Lanczos3}, open, DynamicImage, }; use terminal_size::{terminal_size, Height, Width}; fn main() { let im = open("logo.jpg").unwrap().to_rgba8(); let gray = DynamicImage::ImageRgba8(im).into_luma8(); let (Width(_tw), Height(_th)) = te...
use crate::*; use std::fs::File; use std::io::prelude::*; use std::path::PathBuf; use std::sync::Arc; use tracing; pub struct PingResultProcessorTextLogger { common_config: Arc<PingResultProcessorCommonConfig>, log_path: PathBuf, log_file: File, } impl PingResultProcessorTextLogger { #[tracing::instru...
// // Static Field Access // An example that demonstrates setting and retrieving values from public // static fields on objects. // extern crate rjni; use std::path::PathBuf; use std::env; use rjni::{JavaVM, Version, Classpath, Options, Value, Type}; fn main() { // Find the path to the manifest folder, then ap...
use server::*; use specs::*; use server::component::channel::{OnCommand, OnCommandReader}; use server::component::time::ThisFrame; use server::protocol::server::{GameFlag, ServerPacket}; use server::protocol::{to_bytes, FlagUpdateType}; use component::*; pub struct DropSystem { reader: Option<OnCommandReader>, } #...
use std::process::{exit, Command}; const RAGEL_SOURCE: &'static str = "src/lex/scan.rl"; fn main() { println!("cargo:rerun-if-changed={}", RAGEL_SOURCE); let code = Command::new("/Users/charlie/code/ragel-rust/ragel/ragel") .args(&["--host-lang=Rust", "-o", "src/lex/scan.rs", RAGEL_SOURCE]) ....
//! A simple horizontal or vertical layout with padding and child spacing. use std::collections::HashMap; use crate::{scalar, Scalar, Dimensions, Context, LayoutChildrenArgs, MinimumSizeArgs}; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Axis { Horizontal, Vertical, } #[derive(Debug, Clone)] pub st...
use pam_sys::{ acct_mgmt, authenticate, close_session, end, getenv, open_session, putenv, setcred, start, }; use pam_sys::{PamFlag, PamHandle, PamReturnCode}; use users; use std::{env, ptr}; use crate::{env::get_pam_env, ffi, Converse, PamError, PamResult, PasswordConv}; /// Main struct to authenticate a user //...
// Copyright (C) 2020 Sebastian Dröge <sebastian@centricular.com> // // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use super::*; use crate::Method; /// `Public` header ([RFC 7826 section 18.39](https://tools.ietf.org/html/rfc7826#section-18.39)). #[derive(Debug, Clone...
use iced::{Align, button, Button, Element, Length, Row, scrollable, Scrollable, Text, text_input, TextInput}; use crate::central_ui; use crate::puzzle_backend; use std::rc::Rc; use std::cell::RefCell; pub struct CluesBrowser { pub backend: Rc<RefCell<puzzle_backend::Puzzle>>, pub a_clues: Vec<ClueEntry>, ...
#[doc = "Reader of register ADC_CTL"] pub type R = crate::R<u32, super::ADC_CTL>; #[doc = "Writer for register ADC_CTL"] pub type W = crate::W<u32, super::ADC_CTL>; #[doc = "Register ADC_CTL `reset()`'s with value 0"] impl crate::ResetValue for super::ADC_CTL { type Type = u32; #[inline(always)] fn reset_va...
use std::io; use thiserror::Error; use crate::store::ID; pub type ReviseResult<T> = Result<T, ReviseError>; #[derive(Error, Debug)] pub enum ReviseError { #[error("Rusqlite error: {0}")] RusqliteError(#[from] rusqlite::Error), #[error("Not found: {0}")] NotFoundError(ID), #[error("data store disc...
// q0041_first_missing_positive struct Solution; impl Solution { pub fn first_missing_positive(nums: Vec<i32>) -> i32 { let mut nums = nums; let nlen = nums.len(); if nlen == 0 { return 1; } let mut i = 0; while i < nlen { let cur_v = nums[i]...
use quote::quote_spanned; use syn::parse_quote_spanned; use super::{ FlowProperties, FlowPropertyVal, OperatorCategory, OperatorConstraints, OperatorWriteOutput, WriteContextArgs, RANGE_0, RANGE_1, }; use crate::graph::OperatorInstance; /// > 0 input streams, 1 output stream /// /// > Arguments: A [`Duration`...
use super::super::common; use anyhow::Result; use std::process::{Command, Stdio}; #[test] fn cli_print_help_long() -> Result<()> { let status = Command::new(common::get_rcterm_exec_path()?) .arg("--help") .stdout(Stdio::null()) .status()?; assert!(status.success()); Ok(()) } #[te...
//! Query language AST and parsing utilities //! mod ast; mod format; mod grammar; pub(crate) mod minified; pub mod refs; pub use self::ast::*; mod visit; pub use self::visit::*; mod name; pub use self::grammar::{fragment_definition, operation_definition, parse_query}; pub use self::name::*;
pub mod camera; pub mod model; pub mod texture;
use sqlx::sqlite::{SqliteConnectOptions, SqlitePool}; use std::str::FromStr; use crate::libs::config::CONFIG; use sqlx::ConnectOptions; #[derive(Clone)] pub struct Context { pub db: SqlitePool, } impl Context { pub(crate) async fn new() -> Self { let db_uri = CONFIG.db_uri.as_str(); debug!("C...
use std::thread; use std::rc::Rc; use std::sync::{Arc, Mutex, Condvar}; use std::cell::{Cell, RefCell }; use std::marker::PhantomData; use std::time::Duration; use std::collections::VecDeque; fn main() { // o_call(); // t_call(); // t_call2(); // f_call(); // f_call2(); // f3(&5, &mut 2); ...
pub struct Tokenizer { current: Option<String>, } impl Tokenizer { fn new(line: &str) -> Self { Tokenizer { current: Some(line.to_string()), } } } impl Iterator for Tokenizer { type Item = String; fn next(&mut self) -> Option<Self::Item> { if let Some(s) = &mu...
// Copyright 2019 The vault713 Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or a...
#[doc = "Register `RCC_PLL1CFGR1` reader"] pub type R = crate::R<RCC_PLL1CFGR1_SPEC>; #[doc = "Register `RCC_PLL1CFGR1` writer"] pub type W = crate::W<RCC_PLL1CFGR1_SPEC>; #[doc = "Field `DIVN` reader - DIVN"] pub type DIVN_R = crate::FieldReader<u16>; #[doc = "Field `DIVN` writer - DIVN"] pub type DIVN_W<'a, REG, cons...
use std::fmt::Display; use std::io::{stdout, Stdout, Write}; use crossterm::{ cursor, execute, queue, style::{self, style, Attribute, Color, StyledContent}, terminal::{self, size}, }; use crate::display::{Board, Entity, GameDisplay}; use crate::game::{Block, EntityBlock, CHUNK_SIZE}; pub struct CTDisplay...
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under both the MIT license found in the * LICENSE-MIT file in the root directory of this source tree and the Apache * License, Version 2.0 found in the LICENSE-APACHE file in the root directory * of this source tree. */ use p...
use itertools::Itertools; mod common; struct PatternIterator { repeat: usize, repeat_pos: usize, pos: usize, } impl Iterator for PatternIterator { type Item = i32; fn next(&mut self) -> Option<Self::Item> { self.repeat_pos += 1; if self.repeat_pos == self.repeat { self....
use rand::rngs::StdRng; use rand::{RngCore, SeedableRng}; use sealpir::PirReply; use hybridpir::client::HybridPirClient; use hybridpir::server::HybridPirServer; #[test] fn test_pir() { let mut prng = StdRng::from_entropy(); let size = 1 << 20; let raidpir_servers = 2; let raidpir_redundancy = 2; ...
use rusoto_core::Region; use rusoto_logs::{ CloudWatchLogs, CloudWatchLogsClient, CreateLogGroupRequest, CreateLogStreamRequest, DescribeLogGroupsRequest, DescribeLogStreamsRequest, GetLogEventsRequest, InputLogEvent, LogGroup, PutLogEventsRequest, }; use std::default::Default; #[test] fn describe_group() ...
#[doc = "Reader of register CHAN_RESULT_NEWVALUE"] pub type R = crate::R<u32, super::CHAN_RESULT_NEWVALUE>; #[doc = "Reader of field `CHAN_RESULT_NEWVALUE`"] pub type CHAN_RESULT_NEWVALUE_R = crate::R<u16, u16>; impl R { #[doc = "Bits 0:15 - If set the corresponding RESULT data received a new value, i.e. was sample...
pub trait BlockingDelay { fn blocking_delay_ms(&self, amount: u32); fn blocking_delay_us(&self, amount: u32); }
//! Parse various text markup formats. //! //! Each module is optional and relies on a feature. #[cfg(feature = "markdown")] pub mod markdown; #[cfg(feature = "markdown")] pub use self::markdown::MarkdownText; use owning_ref::OwningHandle; use owning_ref::StringRef; use std::borrow::Cow; use std::ops::Deref; use them...
//! Auxiliary Proof of Work Pallet //! //! This pallet allows blockchain users to submit proofs of work on the parent block (or maybe a //! few recent parents). //! //! Why? //! It's cool //! To avoid long range attacks //! To not waste orphaned work (like GHOST) //! To help forks resolve in a more continuous manner. ...
use crate::robust_arduino::*; use crate::logger::*; use serial::prelude::*; use serial::SystemPort; use std::time::Duration; use std::thread; const SETTINGS: serial::PortSettings = serial::PortSettings { baud_rate: serial::Baud115200, char_size: serial::Bits8, parity: serial::ParityNone, st...
use ark_bls12_381::{Bls12_381, Fr}; use ark_ff::{to_bytes, UniformRand}; use ark_poly_commit::kzg10::Commitment; use ark_std::test_rng; use merlin::Transcript; pub trait TranscriptProtocol { /// Append a `commitment` with the given `label`. fn append_commitment(&mut self, label: &'static [u8], comm: &Commitmen...
pub use authorized_users::{ get_random_key, get_secrets, token::Token, AuthorizedUser, AUTHORIZED_USERS, JWT_SECRET, KEY_LENGTH, SECRET_KEY, TRIGGER_DB_UPDATE, }; use futures::TryStreamExt; use log::debug; use maplit::hashset; use reqwest::Client; use rweb::{filters::cookie::cookie, Filter, Rejection, Schema}; ...
use bitcoin::{BlockHash, Transaction, Txid}; use parking_lot::RwLock; use std::collections::HashMap; use std::sync::Arc; use crate::{ merkle::Proof, metrics::{self, Histogram, Metrics}, }; pub(crate) struct Cache { txs: Arc<RwLock<HashMap<Txid, Transaction>>>, proofs: Arc<RwLock<HashMap<(BlockHash, T...
use crate::types::*; use regmach::dsp::types as rdt; use regmach::dsp::types::Display; use regmach::schem::types::Schematic; use std::cell::RefCell; use std::rc::Rc; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use web_sys::WebGl2RenderingContext as GL; use rusttype::{point, FontCollection, PositionedGlyph,...
// #![deny(missing_docs)] //! A key-value store system #![allow(dead_code)] // #![allow(unused)] #[macro_use] extern crate log; mod backend; mod client; mod config; mod error; mod percolator; mod raft; mod rpc; mod server; /// Thread Pool pub mod thread_pool; pub use backend::{EngineKind, KvSled, KvStore, KvsEngin...
pub use blake2b_rs::{Blake2b, Blake2bBuilder}; pub const BLAKE2B_KEY: &[u8] = &[]; pub const BLAKE2B_LEN: usize = 32; pub const CKB_HASH_PERSONALIZATION: &[u8] = b"ckb-default-hash"; pub fn new_blake2b() -> Blake2b { Blake2bBuilder::new(32) .personal(CKB_HASH_PERSONALIZATION) .build() } pub fn bl...
use crate::grammar::ast::FuncCall; use crate::grammar::testing::TestingContext; #[test] fn test_empty() { TestingContext::with(&["", " ", "\n"]).test_all_fail(FuncCall::parse) } #[test] fn test_underscore() { TestingContext::with(&["_()"]).test_all_fail(FuncCall::parse) } #[test] fn test_reserved() { Tes...
pub struct PrimeFactors { n: usize, last_prime: usize, primes: primal::Primes, } impl Iterator for PrimeFactors { type Item = usize; fn next(&mut self) -> Option<usize> { if self.n == 0 || self.n == 1 { return None; } loop { if self.n % self.last_pri...
#[derive(Debug, Clone, PartialEq, Eq)] pub enum PaymentSwapResult { Native, Swapped, Transferred, } pub trait CurrencySwap<AccountId, Balance> { fn swap(who: &AccountId, fee: Balance) -> Result<PaymentSwapResult, frame_support::sp_runtime::DispatchError>; }
use std::f64::consts::PI; use std::f64; use rand::{thread_rng, Rng}; use piston_window::types::Color; use piston_window::{RenderArgs, UpdateArgs}; pub enum Speed { Go { scala: f64 }, None, } pub enum Side { None, Center, Up, Down, Right, Left, } pub struct Arrow { theta: f64, sin...
extern crate glutin_window; extern crate graphics; extern crate opengl_graphics; use crate::{BODY_PIXEL_SIZE, GRID_SIDE, WINDOW_SIDE, LAST_UNTAGGED_DISPLAY_LENGTH}; use crate::grid::Position; use glutin_window::GlutinWindow as Window; use graphics::*; use opengl_graphics::{GlGraphics, OpenGL}; use piston::event_loop...
include!(concat!(env!("OUT_DIR"), "/BUILDSCRIPT_GENERATED_use.rs")); include!(concat!(env!("OUT_DIR"), "/BUILDSCRIPT_GENERATED_only_adapters.rs")); include!(concat!(env!("OUT_DIR"), "/BUILDSCRIPT_GENERATED_fmt_adapters.rs"));
use vector::Vector3; #[derive(Debug, Clone, Copy)] pub struct Ray { pub origin: Vector3<f64>, pub direction: Vector3<f64>, } #[derive(Debug, Clone, Copy)] pub struct HitInfo<'a> { pub distance: f64, pub point: Vector3<f64>, pub normal: Vector3<f64>, pub material: &'a str, }
pub(crate) mod numeric_constant; pub(crate) mod string_constant; use apllodb_shared_components::{ApllodbResult, SqlValue}; use apllodb_sql_parser::apllodb_ast; use crate::ast_translator::AstTranslator; impl AstTranslator { pub(crate) fn constant(ast_constant: apllodb_ast::Constant) -> ApllodbResult<SqlValue> { ...
#[doc = "Register `RCC_PLL3CSGR` reader"] pub type R = crate::R<RCC_PLL3CSGR_SPEC>; #[doc = "Register `RCC_PLL3CSGR` writer"] pub type W = crate::W<RCC_PLL3CSGR_SPEC>; #[doc = "Field `MOD_PER` reader - MOD_PER"] pub type MOD_PER_R = crate::FieldReader<u16>; #[doc = "Field `MOD_PER` writer - MOD_PER"] pub type MOD_PER_W...
use anyhow::Result; use regex::Regex; use std::collections::HashMap; pub fn day4() -> Result<()> { /* let passports = r#"ecl:gry pid:860033327 eyr:2020 hcl:#fffffd byr:1937 iyr:2017 cid:147 hgt:183cm iyr:2013 ecl:amb cid:350 eyr:2023 pid:028048884 hcl:#cfa07d byr:1929 hcl:#ae17e1 iyr:2013...