text
stringlengths
8
4.13M
// Copyright 2021 Datafuse Labs. // // 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 agre...
/* A boxed version of binary search tree */ #[derive(Debug)] pub struct Node { val: i32, left: Option<NodeRef>, right: Option<NodeRef> } type NodeRef = Box<Node>; impl Node { pub fn new(val: i32) -> Self { Node { val: val, left: None, right: None }...
#[doc = "Reader of register ACR"] pub type R = crate::R<u32, super::ACR>; #[doc = "Writer for register ACR"] pub type W = crate::W<u32, super::ACR>; #[doc = "Register ACR `reset()`'s with value 0x30"] impl crate::ResetValue for super::ACR { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type {...
/*! Type definitions for identifier types. A [`StateID`] represents the possible set of identifiers used in regex engine implementations in this crate. For example, they are used to identify both NFA and DFA states. A [`PatternID`] represents the possible set of identifiers for patterns. All regex engine implementati...
use anyhow::Context; use rusqlite::Transaction; /// This migration replaces block hash with block number for class_definitions. /// /// This enables range querying when the class was declared. pub(crate) fn migrate(tx: &Transaction<'_>) -> anyhow::Result<()> { tx.execute( "ALTER TABLE class_definitions ADD...
// -*- mode: rust; -*- // // This file is part of ed25519-dalek. // Copyright (c) 2017-2019 isis lovecruft // See LICENSE for licensing information. // // Authors: // - isis agora lovecruft <isis@patternsinthevoid.net> //! Integration tests for ed25519-dalek. #[cfg(all(test, feature = "serde"))] extern crate bincode;...
use procon_reader::ProconReader; fn main() { let stdin = std::io::stdin(); let mut rd = ProconReader::new(stdin.lock()); let n: usize = rd.get(); let m: usize = rd.get(); let t: u32 = rd.get(); let p1: usize = rd.get(); let p2: usize = rd.get(); let p3: usize = rd.get(); let mut g ...
//! Download shard probabilities. #![warn( missing_docs, trivial_casts, trivial_numeric_casts, unused_import_braces, unused_qualifications )] #![warn(clippy::all, clippy::pedantic)] #![allow(clippy::module_name_repetitions, clippy::default_trait_access)] use setup::Collection; use anyhow::anyhow;...
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. #![recursion_limit = "200"] #[macro_use( kv, slog_kv, slog_error, slog_warn, slog_record, slog_b, slog_log, slog_record_static )] extern crate slog; #[macro_use] extern crate slog_global; #[macro_use] extern crate prome...
// Copyright 2021 Datafuse Labs. // // 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 agreed to ...
// Copyright (c) 2016 The Rouille developers // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT // license <LICENSE-MIT or http://opensource.org/licenses/MIT>, // at your option. All files in the project carrying such // notice may not be co...
mod static_kv; use static_kv::mod_test; fn main() { mod_test(); println!("Hello, world!"); }
#[macro_use] extern crate log; extern crate fern; extern crate chrono; use std::io::BufRead; use clap::{App, Arg}; use log::LevelFilter; use jsonl::input::Input; use jsonl::errors::CustomError; use jsonl::jsonl::JsonlHandler; use jsonl::text::TextHandler; static VERSION: &'static str = "0.1.1"; fn make_app<'a, 'b>()...
use std::fs::File; use std::io::prelude::*; use std::io::BufReader; use beerxml::recipe::Recipe; /// DISASTATIC_POWER -> DIASTATIC_POWER #[test] fn beerxml_recipe() { let file = File::open("tests/data/beerxml/recipe.xml").unwrap(); let mut buf_reader = BufReader::new(file); let mut contents = String::new(...
use graphics::types::Color; use graphics::{Context, Graphics}; use crate::simulation::environment::Environment; // use crate::simulation::colony::Colony; pub struct WorldViewSettings { pub ant_color: Color, pub pixel_size: usize } pub struct WorldView { pub settings: WorldViewSettings, } impl WorldVi...
use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; fn main() { for i in 0..100{ for j in 0..100{ if let Ok(lines) = read_lines("./rust_input.txt") { for line in lines { if let Ok(intcode_line) = line { let mut intcod...
// See LICENSE file for copyright and license details. use std::cmp; use std::collections::hashmap::HashMap; use stb_tt; use cgmath::{Vector3, Vector2}; use core::types::{Size2, MInt}; use core::misc::add_quad_to_vec; use visualizer::texture::Texture; use visualizer::types::{VertexCoord, TextureCoord, MFloat, ScreenPo...
use crate::dynamics::MassProperties; use crate::geometry::{Collider, ColliderHandle, InteractionGraph, RigidBodyGraphIndex}; use crate::math::{AngVector, AngularInertia, Isometry, Point, Rotation, Translation, Vector}; use crate::utils::{WCross, WDot}; use num::Zero; #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[cfg_...
use std::time::Duration; use ggez::{ event::KeyCode, graphics::{Color, DrawMode, DrawParam, Drawable, FillOptions, Rect}, Context, }; use crate::math::Vector2; const PADDLE_WIDTH: f32 = 100.0; const PADDLE_HEIGHT: f32 = 10.0; const PADDLE_SPEED: f32 = 350.0; pub struct Paddle { pub position: Vector2...
// 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 according to those terms. use std::cmp; /// ...
#![allow(clippy::type_complexity)] #[allow(unused_imports)] use core_extensions::{matches, SelfOps}; #[allow(unused_imports)] use abi_stable::std_types::{Tuple1, Tuple2, Tuple3, Tuple4}; use abi_stable::{ std_types::{RSlice, RStr}, type_layout::{ LifetimeArrayOrSlice, LifetimeIndex, LifetimeIndexPair...
//! Private module for selective re-export. use crate::{Rewrite, RewritePlan}; use std::iter::FromIterator; use std::marker::PhantomData; use std::ops::{Index, IndexMut}; /// A map optimized for cases where each key corresponds with a unique entry in the range /// `[0..self.len()]` and vice versa (each number in that...
use crate::ghwf::Step; use crate::yaml::Yaml; use std::fmt; pub fn checkout_sources() -> Step { Step::uses("Checkout sources", "actions/checkout@v2") } #[derive(Eq, PartialEq, Copy, Clone)] pub enum RustToolchain { Stable, Beta, Nightly, } impl fmt::Display for RustToolchain { fn fmt(&self, f: &m...
use std::env; use std::fs::File; use std::io::Write; use std::io::BufRead; use std::io::BufReader; use std::collections::hash_set::HashSet; #[derive(Copy, Debug, Eq)] pub struct Coord { pub x: i64, pub y: i64, pub vx: i64, pub vy: i64, } impl Clone for Coord { fn clone(&self) -> Coord { *self } } ...
use std::collections::HashSet; fn part1(num_list: &Vec<i32>) { let mut nums = HashSet::new(); for n in num_list { let diff = 2020 - n; if nums.contains(&diff) { let product = n * diff; println!("Product: {}", product); break; } nums.insert(n)...
use crate::{Mutator, SubValueProvider}; // maybe the mutator should be a generic type parameter of the MutateOperation trait, maybe the T and C should be too // but the step and revert should not pub trait Mutation<Value, M>: Sized where Value: Clone + 'static, M: Mutator<Value>, { type RandomStep: Clone; ...
use super::Part; use crate::codec::{Decode, Encode}; use crate::{remote_type, RemoteObject}; remote_type!( /// A fairing. Obtained by calling `Part::fairing().` object SpaceCenter.Fairing { properties: { { Part { /// Returns the part object for this fairing. /// ...
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. mod utf8mb4; pub use self::utf8mb4::*; use std::cmp::Ordering; use std::hash::Hasher; use codec::prelude::*; use crate::codec::Result; pub macro match_template_collator($t:tt, $($tail:tt)*) { match_template::match_template! { $t = [ ...
#![allow(dead_code)] extern crate cgmath; extern crate embree; extern crate support; use cgmath::{Vector3, Vector4}; use embree::{Device, Geometry, IntersectContext, RayHitN, RayN, Scene, TriangleMesh}; fn main() { let mut display = support::Display::new(512, 512, "triangle"); let device = Device::new(); ...
use core::fmt; use sp_core::H256; // BankDetailsCid should hold a sha256 cid from ipfs pub type BankDetailsCid = H256; /// Identifier for different destinations on VLN #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[derive( Clone, Copy, Debug, Eq, Ord, PartialEq,...
extern crate cc; fn main(){ cc::Build::new() .file("./c/protocol.c") .compile("lib"); println!("cargo:rustc-link-lib=static=lib"); }
mod gemini; mod http; mod https; mod log; mod null; mod random; mod zero; pub use self::{gemini::*, http::*, https::*, log::*, null::*, random::*, zero::*};
pub(crate) mod command; pub(crate) mod event; pub(crate) use command::{Command, CommandKind}; pub(crate) use event::{Event, EventKind}; #[derive(serde::Serialize)] pub(crate) struct Rpc<T: serde::Serialize> { /// The RPC type pub(crate) cmd: CommandKind, /// Every RPC we send to Discord needs a [`nonce`](...
// Copyright 2012-2014 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-MI...
use clippy_utils::diagnostics::span_lint_and_help; use rustc_hir::intravisit::{walk_expr, walk_fn, FnKind, NestedVisitorMap, Visitor}; use rustc_hir::{Body, Expr, ExprKind, FnDecl, FnHeader, HirId, IsAsync, YieldSource}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::map::Map; use rustc_session::{d...
#![allow(non_camel_case_types)] #![allow(unused_unsafe)] use super::fs_helpers::*; use crate::ctx::WasiCtx; use crate::fdentry::FdEntry; use crate::sys::errno_from_host; use crate::sys::fdentry_impl::determine_type_rights; use crate::sys::host_impl; use crate::{host, wasm32}; use nix::libc::{self, c_long, c_void, off_t...
// iterators4.rs pub fn factorial(num: u64) -> u64 { match num { 0 => 0, 1 => 1, x => { match (1..(x + 1)).reduce(|i, j| i * j) { Some(result) => result, None => 0 } } } } #[cfg(test)] mod tests { use super::*; #[...
create_enum_with_aux_fns!( /// An asset that backs or can be used as a security for other assets #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[derive( Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, parity_s...
// Currently this program just writes all Unicode codepoints to stdout. use std::io::{self, Write}; use anyhow::Context; fn main() -> anyhow::Result<()> { let stdout = io::stdout(); let mut bufwtr = io::BufWriter::new(stdout.lock()); let _ = Args::parse()?; for cp in 0..=0x10FFFF { let ch = ...
tag option[T] { some(@T); none; } fn main() { let a: option[int] = some[int](@10); a = none[int]; }
use std::borrow::Cow; use std::fmt; use std::path::{Path, PathBuf}; use firefly_util::diagnostics::FileName; #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub enum InputType { Erlang, AbstractErlang, SSA, MLIR, Unknown(Option<String>), } impl InputType { const TYPES: &'static [InputType] = &[ ...
pub static ALPHABET: &[u8; 58] = b"jpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65rkm8oFqi1tuvAxyz"; pub const PASSWORD_LEN: usize = 16; /// The order of the secp256k1 curve // pub const CURVE_ORDER: [u8; 32] = [ pub const CURVE_ORDER: &[u8] = &[ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf...
use std::borrow::Cow; use std::fmt; use std::ffi::{CStr, CString, OsStr, OsString}; use std::ops::{Index, Range, RangeFull}; use std::os::unix::ffi::OsStrExt; use std::path::{Path, PathBuf}; #[derive(Clone, Debug)] pub enum Content { String(String), OsString(OsString), CString(CString), PathBuf(PathBuf...
use std::io::prelude::*; use std::fs::File; use std::f64::consts::PI; mod font; struct Buffer{ width: usize, height: usize, data: Box<[u32]> } pub struct Canvas{ buffer: Buffer, pub px: isize, pub py: isize, pub mx: f64, pub my: f64, pub x: f64, pub y: f64, pub wx: f64, ...
use crate::{Config, InputType, OutputType}; use bytesize::ByteSize; use chrono::{DateTime, Duration, Utc}; use std::fs::OpenOptions; use std::io::{self, Write}; use std::path::{Path, PathBuf}; pub struct Report { config: Config, sum_bytes: usize, min_bytes: usize, max_bytes: usize, avg_bytes: f64, ...
// Copyright 2014 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 crate::message::Message; use crate::widgets::UserInterface; use crate::{Backend, Frontend, GlobalState}; use anyhow::{anyhow, Context, Result}; use slog::{info, debug}; use spin_sleep; use std::path::PathBuf; use iced_winit::{ conversion, winit::{ event::{Event, WindowEvent}, event_loop::{...
use crate::compiling::v1::assemble::prelude::*; /// Compile a return. impl Assemble for ast::ExprReturn { fn assemble(&self, c: &mut Compiler<'_>, _: Needs) -> CompileResult<Asm> { let span = self.span(); log::trace!("ExprReturn => {:?}", c.source.source(span)); // NB: drop any loop tempor...
extern crate clap; pub mod lib; use lib::{calculate_simple, calculate_variable}; use clap::{Arg, App}; fn main() { let matches = App::new("set_in_range") .version("1.0.0") .author("Igor Sowinski <igor@sowinski.blue>") .about("constrain a numerical value between a minimum and maximum") ...
use midir; use std::collections::HashMap; use std::string::*; use std::sync::{Arc, Mutex}; pub struct Input { input_port: midir::MidiInputPort, device_name: String, // optional because it needs to be consumed and sent to the connection thread midi_input: Option<midir::MidiInput>, connection: Option...
pub mod block; pub mod input; pub mod output; pub mod type_channel; pub mod types;
use std::sync::Arc; use super::HEqTable; use super::Property; use super::Trie; use super::TrieBuildFailure; pub trait ForkTable<In> { fn lookup<'a>(&'a self, input: &In) -> Option<&'a Trie<In>>; } pub struct TypedForkTable<In, K, P: Property<In, K>> { property: Arc<P>, table: HEqTable<K, Trie<In>>, } i...
use std::error; use std::fmt; use std::io; use std::ops::Deref; #[derive(Debug)] pub enum ErrorBox { ParseOrLex(ParseOrLexError), Io(io::Error), } impl From<ParseOrLexError> for ErrorBox { fn from(error: LexError) -> Self { ErrorBox::ParseOrLex(error) } } impl From<io::Error> for ErrorBox { ...
fn main() { let x = get_prime(60); println!("{:?}", x); } fn get_prime(x: i32) -> Vec<i32> { let mut res = Vec::new(); let mut divisor = 2; loop { let y = x/divisor; if y == 0 && { break; } else { divisor += 1; } } res }
use crate::components::Position; use hecs::World; pub use hecs_rapier::*; pub struct PhysicsEngine { pub(crate) gravity: Vector<Real>, pub(crate) integration_parameters: IntegrationParameters, pub(crate) physics_pipeline: PhysicsPipeline, pub(crate) modification_tracker: ModificationTracker, pub(cr...
// Copyright (c) 2016 The Rouille developers // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT // license <LICENSE-MIT or http://opensource.org/licenses/MIT>, // at your option. All files in the project carrying such // notice may not be co...
#[macro_use]extern crate serde_derive; use device_query::keymap::Keycode; #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum CrossKey { Key0, Key1, Key2, Key3, Key4, Key5, Key6, Key7, Key8, Key9, LControl, RControl, RShift, LShift, C...
use std::cell::UnsafeCell; use std::intrinsics; use std::mem; use super::map::TableInfo; use super::mutex::{MUTEX_INIT, StaticMutex}; //#[derive(Clone,Copy)] pub struct HazardPointer(pub UnsafeCell<Option<&'static UnsafeCell<usize>>>); unsafe impl Sync for HazardPointer {} /// This is a hazard pointer, used to indic...
use crate::errors; use crate::interop; use crate::io_github_kawamuray_wasmtime_Config::JniConfig; use crate::utils; use jni::objects::{JClass, JObject, JString}; use jni::sys::{jboolean, jlong, jobject}; use jni::{self, JNIEnv}; use std::path::Path; use std::result::Result; use wasmtime::{Config, OptLevel, ProfilingStr...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[cfg(feature = "Win32_Foundation")] #[inline] pub unsafe fn AddLogContainer<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param2: ::windows::core::IntoParam<'...
use super::raycast::Raycaster; use super::spatial_index::SpatialIndex; use crate::{GridMapView, Pose}; use nalgebra::{Scalar, SimdRealField, SimdValue}; use std::ops::{Add, Mul}; pub use vecsi::VecSpatialIndexForCDDT; type DefaultSpatialIndexForCDDT<N> = VecSpatialIndexForCDDT<N, DDTSlice<N>>; pub struct CDDT<N, SI: S...
#[macro_use] extern crate lazy_static; #[macro_use] extern crate serde_derive; #[macro_use] extern crate validator_derive; use crate::server::server; mod config; mod errors; pub mod handlers; mod helpers; mod models; mod routes; mod server; mod tests; mod validate; fn main() -> std::io::Result<()> { server() }
use crate::context::RpcContext; use crate::v02::types::ContractClass; use anyhow::Context; use pathfinder_common::{BlockId, ClassHash}; use starknet_gateway_types::pending::PendingData; crate::error::generate_rpc_error_subset!(GetClassError: BlockNotFound, ClassHashNotFound); #[derive(serde::Deserialize, Debug, Parti...
use rand::Rng; fn get_random_values() -> (usize, usize){ //returneaza doua valori random intre 1 si 6 let mut rng = rand::thread_rng(); let n1 = (rng.gen::<usize>() % 6) + 1; let n2 = (rng.gen::<usize>() % 6) + 1; let pair = (n1, n2); return pair; } pub fn start_player() -> char{ let pair1 = get_random_value...
fn main(){ let x; // cant use it before initialization. // println!("{x}"); x = 10; println!("{x}"); }
use serde::{Deserialize, Serialize}; use std::collections::HashMap; #[derive(Debug, Serialize, Deserialize)] pub struct Profile { #[serde(rename = "profileIconId")] pub profile_icon_id: i64, pub name: String, pub puuid: String, #[serde(rename = "summonerLevel")] pub summoner_level: i6...
extern crate futures; use futures::*; use futures::stream::Stream; struct CounterStream { index: i32, limit: i32, ready: bool, } fn counter(limit: i32) -> CounterStream { CounterStream{index: 0, limit: limit, ready: false} } impl Stream for CounterStream { type Item = i32; type Error = (); ...
//! Utilities for game state management. pub struct StateData<'a, T> where T: 'a, { /// User defined game data pub data: &'a mut T, } impl<'a, T> StateData<'a, T> where T: 'a, { /// Create a new state data pub fn new(data: &'a mut T) -> Self { StateData { data } } } /// Types of st...
//! Parser combinators for lexing Ruby's syntax pub(crate) mod comment; pub(crate) mod expression; pub(crate) mod program; pub(crate) mod statement; pub(crate) mod token;
// Copyright 2016 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 ...
// Copyright 2022 Datafuse Labs. // // 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 agreed to ...
use crate::compiling::v1::assemble::prelude::*; /// Compile a for loop. impl Assemble for ast::ExprFor { fn assemble(&self, c: &mut Compiler<'_>, needs: Needs) -> CompileResult<Asm> { let span = self.span(); log::trace!("ExprFor => {:?}", c.source.source(span)); let continue_label = c.asm....
use super::content_encoding::ContentEncoding; use super::tracks::kAv1CodecId; use super::util; use super::writer::Writer; use crate::MkvId; pub struct Track { // Track element names. codec_id_: String, codec_private_: Vec<u8>, language_: String, max_block_additional_id_: u64, name_: String, ...
use super::Project; use crate::datastore::prelude::*; use juniper::ID; use utils::PathToRef; pub fn get_project_path<'a>(id: &'a ID) -> PathToRef<'a> { vec![(KeyKind("Projects"), KeyId::Cuid(id.clone()))] } pub async fn get_project(client: &Client, id: &ID) -> Response<Entity> { let entity = operations::run_q...
pub mod coll; pub mod db; mod client_utils;
use std::collections::BTreeMap; use std::error::Error; use std::fs::File; use std::io::{BufReader, BufWriter, Read}; use std::string::{FromUtf8Error, ParseError}; use bencode::{Bencode, Decoder, FromBencode, NumFromBencodeError, StringFromBencodeError, ToBencode, VecFromBencodeError}; use bencode::Bencode::ByteString;...
pub use gilrs::GamepadId; use crate::Context; pub fn connected(ctx: &Context, gamepad: GamepadId) -> bool { #[cfg(not(target_arch = "wasm32"))] { ctx.input.gamepad.connected_gamepad(gamepad).is_some() } #[cfg(target_arch = "wasm32")] { false } } pub fn gamepads<'c>(ctx: &'c Co...
use thiserror::Error; /// Custom `Error` #[derive(Error, Debug)] pub enum KvsError { #[error("Invalid Data -> Empty Key")] EmptyKey, #[error("Invalid Data: {0}")] InvalidData(String), #[error("Internal Error -> IO Error: {0}")] IOError(#[from] std::io::Error), #[error("Internal Error: {0}")...
extern crate juju; extern crate nix; use std::path::Path; use self::nix::sys::statvfs::vfs::Statvfs; pub fn collect_metrics() -> Result<(), String> { let p = Path::new("/mnt/glusterfs"); let mount_stats = Statvfs::for_path(p).map_err(|e| e.to_string())?; // block size * total blocks let total_space = ...
extern crate ply_rs; use ply_rs as ply; /// Demonstrates simplest use case for reading from a file. fn main() { // set up a reader, in this a file. let path = "example_plys/greg_turk_example1_ok_ascii.ply"; let mut f = std::fs::File::open(path).unwrap(); // create a parser let p = ply::parser::Par...
// SPDX-License-Identifier: Apache-2.0 #![deny(clippy::all)] use koine::{Backend, Contract}; use warp::http::header::{HeaderValue, CONTENT_TYPE}; use warp::http::StatusCode; async fn spawn_server(timeout: &str) -> tokio::io::Result<(String, tokio::process::Child)> { const BIN: &str = env!("CARGO_BIN_EXE_keepmgr...
task4.SimpleCompount task4.Intrst
use hathor::FileGenerator; use static_files::sets::{generate_resources_sets, SplitByCount}; use std::path::Path; use std::{env, ffi::OsStr}; const TARGET: &str = "generated"; fn main() { let flag = Path::new(&TARGET).join("flag"); if !flag.exists() { std::fs::remove_dir_all(TARGET).unwrap_or_default(...
// Copyright © 2016-2017 VMware, Inc. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 use std::collections::HashMap; use std::collections::hash_map::Drain; use time::{SteadyTime, Duration}; use rabble::Pid; #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] pub struct QuorumTracker<T> { qu...
use serde_json::{Map, Value}; use std::collections::HashMap; use std::fs::write; use std::vec::Vec; pub struct Database { config: DatabaseConfig, documents: Vec<Value>, } pub struct DatabaseConfig { pub path: String, } impl Database { pub fn new(config: DatabaseConfig) -> Database { Database ...
#[doc = "Reader of register CPT2ACR"] pub type R = crate::R<u32, super::CPT2ACR>; #[doc = "Writer for register CPT2ACR"] pub type W = crate::W<u32, super::CPT2ACR>; #[doc = "Register CPT2ACR `reset()`'s with value 0"] impl crate::ResetValue for super::CPT2ACR { type Type = u32; #[inline(always)] fn reset_va...
use std::process; use onfido_caller::*; fn main() { let api_token = env::get_env_var("API_TOKEN").unwrap_or_else(|e| { eprintln!("couldn't find the API token: {}", e); process::exit(1); }); if let Err(_) = run(&api_token) { process::exit(1); } }
use input_i_scanner::InputIScanner; fn main() { let stdin = std::io::stdin(); let mut _i_i = InputIScanner::from(stdin.lock()); macro_rules! scan { (($($t: ty),+)) => { ($(scan!($t)),+) }; ($t: ty) => { _i_i.scan::<$t>() as $t }; (($($t: ty),...
// Copyright 2022 Datafuse Labs. // // 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 agreed to ...
#![cfg_attr(not(feature = "std"), no_std)] #[cfg(not(feature = "std"))] use core::panic::PanicInfo; /// Create aliases for FFI types for esp32c3, which doesn't have std. #[cfg(not(feature = "std"))] mod ffi { #![allow(dead_code)] #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![all...
pub const SYS_EXIT: u64 = 93; pub const SYS_LOAD_TRANSACTION: u64 = 2051; pub const SYS_LOAD_SCRIPT: u64 = 2052; pub const SYS_LOAD_TX_HASH: u64 = 2061; pub const SYS_LOAD_SCRIPT_HASH: u64 = 2062; pub const SYS_LOAD_CELL: u64 = 2071; pub const SYS_LOAD_HEADER: u64 = 2072; pub const SYS_LOAD_INPUT: u64 = 2073; pub const...
//https://leetcode.com/problems/sum-of-all-subset-xor-totals/submissions/ impl Solution { pub fn subset_xor_sum(nums: Vec<i32>) -> i32 { let mut xor_sum = 0; for mask in 0..(1<<nums.len()) { let mut tmp_xor = 0; for i in 0..nums.len() { if (mask & (1 << i)) !...
// Copyright 2022 Datafuse Labs. // // 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 agreed to ...
extern crate rss; extern crate request; use rss::Rss; use std::collections::HashMap; fn main() { let url = "http://www.andjosh.com/rss.xml"; let mut headers: HashMap<String, String> = HashMap::new(); headers.insert( "Connection".to_string(), "close".to_string() ); let resp = matc...
//! The linux_raw backend. //! //! This makes Linux syscalls directly, without going through libc. //! //! # Safety //! //! These files performs raw system calls, and sometimes passes them //! uninitialized memory buffers. The signatures in this file are currently //! manually maintained and must correspond with the si...
use crate::dfa::automaton::{Automaton, State}; use crate::MatchError; /// This is marked as `inline(always)` specifically because it supports /// multiple modes of searching. Namely, the 'earliest' boolean getting inlined /// permits eliminating a few crucial branches. #[inline(always)] pub fn find_fwd<A: Automaton + ...
#[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::ENUPD { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'...
//! Memory twiddling utilities, so far just for reinterpreting between //! [u8] and Block. use super::Block; use std::mem; /// Interprets an 8-byte `[u8]` array as a `Block`. pub fn read_block<'a>(chunk: &'a [u8]) -> &'a Block { debug_assert_eq!(chunk.len(), 8); unsafe { mem::transmute(chunk.as_ptr() as *cons...
// auto generated, do not modify. // created: Mon Feb 22 23:57:02 2016 // src-file: /QtCore/qdatastream.h // dst-file: /src/core/qdatastream.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main block begin =>...
use std::fmt::Display; use async_trait::async_trait; use observability_deps::tracing::{debug, error, info}; use crate::{error::DynError, file_classification::FilesForProgress, PartitionInfo}; use super::PostClassificationPartitionFilter; #[derive(Debug)] pub struct LoggingPostClassificationFilterWrapper<T> where ...