text
stringlengths
8
4.13M
use std::io; use memchr::memchr; use crate::errors::ParseError; use crate::parser::record::SequenceRecord; pub(crate) const BUFSIZE: usize = 64 * 1024; /// Remove a final '\r' from a byte slice #[inline] pub(crate) fn trim_cr(line: &[u8]) -> &[u8] { if let Some((&b'\r', remaining)) = line.split_last() { ...
pub mod app; pub use self::app::*; pub mod easings; pub use self::easings::*; pub mod f32; pub use self::f32::*; pub mod hsl; pub use self::hsl::*; pub mod iterator; pub use self::iterator::*; pub mod point2; pub use self::point2::*; pub mod vector2; pub use self::vector2::*; pub mod path2; pub use self::path2::...
//! The Signal type. //! //! Signals are values that change over time. They represent shared mutable state, but exposed //! in a functional way. The value can be read using the `Signal::sample` method. Signals do all //! their work on the receiver side, so they're "lazy". Operations applied on a signal are applied //! ...
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[link(name = "windows")] extern "system" {} pub type ContactDataProviderConnection = *mut ::core::ffi::c_void; pub type ContactDataProviderTriggerDetails = *mut ::core::ffi::c_void; pub type ContactListCr...
use bigdecimal::BigDecimal; pub struct Point { // [-90;+90] pub latitude: BigDecimal, // [-180;+180) pub longitude: BigDecimal, }
fn double[T](a: &T) -> T[] { ret ~[a] + ~[a]; } fn double_int(a: int) -> int[] { ret ~[a] + ~[a]; } fn main() { let d = double(1); assert (d.(0) == 1); assert (d.(1) == 1); d = double_int(1); assert (d.(0) == 1); assert (d.(1) == 1); }
// Copyright 2020-2021, The Tremor Team // // 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 agr...
use crate::{ app::{ config::{self, Rgba}, sample::{create_sample_plume, Sample}, AppContext, AppContextPointer, ZoomableDrawingAreas, }, coords::{DeviceCoords, DtHCoords, ScreenCoords, ScreenRect, XYCoords}, errors::SondeError, gui::{ plot_context::{GenericContext, Ha...
/// pretyy print menggunakan format `{:#?}` /// #[derive(Debug)] struct Person { name: &'static str, age: u8, } fn main() { let name = "Agus"; let age = 35; let agus = Person { name, age }; println!("{:#?}", agus); }
use std::time::Duration; use assert_matches::assert_matches; use data_types::NamespaceId; use generated_types::influxdata::{ iox::{ ingester::v1::WriteRequest, namespace::v1::{namespace_service_server::NamespaceService, *}, partition_template::v1::*, table::v1::{table_service_server...
use chamomile_types::message::DeliveryType as P2pDeliveryType; use lazy_static::lazy_static; use std::path::PathBuf; /// P2P default binding addr. pub const P2P_ADDR: &str = "0.0.0.0:7364"; /// P2P default transport. pub const P2P_TRANSPORT: &str = "tcp"; /// RPC default binding addr. pub const RPC_ADDR: &str = "127...
use crate::driver::pca::PCA9685; use embedded_hal::blocking::i2c::{Write, WriteRead}; use motor_direction::*; pub struct Motors<TI2C> { pca: PCA9685<TI2C>, } impl<TI2C: Write + WriteRead> Motors<TI2C> { pub fn init(pca: PCA9685<TI2C>, i2c: &mut TI2C) -> Result<Self, <TI2C as Write>::Error> { let mut m...
// 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. // lazy_static is required for re_find_static. use lazy_static::lazy_static; use nom::{ branch::alt, bytes::complete::{escaped, is_not, tag}, c...
use std::fs::File; use std::io::prelude::*; use std::time::Instant; use super::regex; struct BenchmarkCase { name: &'static str, comment: &'static str, filename: &'static str, regex: &'static str, } pub fn run_all_tests<T>(stream: &mut T) -> Result<(), std::io::Error> where T: std::io::Wr...
//! ParquetFile cache use backoff::{Backoff, BackoffConfig}; use cache_system::{ backend::policy::{ lru::{LruPolicy, ResourcePool}, remove_if::{RemoveIfHandle, RemoveIfPolicy}, ttl::{ConstantValueTtlProvider, TtlPolicy}, PolicyBackend, }, cache::{driver::CacheDriver, metrics...
use actix::prelude::*; #[derive(Debug, Message)] #[rtype(result = "Data")] struct CreateData { value: u32, } #[derive(Debug, MessageResponse)] struct Data { id: String, value: u32, } struct SampleActor; impl Actor for SampleActor { type Context = SyncContext<Self>; fn started(&mut self, _ctx: ...
use crate::{event::Event, stream::VecStreamExt, transforms::Transform}; use futures::{ compat::Stream01CompatExt, future, stream::{self, BoxStream}, FutureExt, StreamExt, TryStreamExt, }; use futures01::Stream; use std::time::Duration; /// A structure representing user-defined timer. #[derive(Clone, Co...
pub mod timeutil; pub use timeutil::*; pub mod strings; pub use strings::*;
use crate::{ sabi_types::MaybeCmp, std_types::utypeid::{no_utypeid, some_utypeid, UTypeId}, }; /// Passed to trait object constructors to make the /// trait object downcast capable, /// as opposed to [`TD_Opaque`](./struct.TD_Opaque.html). /// /// [The `from_value`/`from_ptr`/`from_const` methods here /// ](.....
pub mod common; pub mod gql_schema; pub mod schema; pub mod state;
pub struct Solution; impl Solution { pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 { let n = nums.len(); if n == 0 { return 0; } let mut cnt = 1; for i in 1..n { if nums[i] != nums[cnt - 1] { nums[cnt] = nums[i]; ...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct DeviceServicingDetails(pub ::windows::core::II...
pub mod server; pub mod client; use std::net::SocketAddr; use std::sync::Arc; use std::time::{ Duration, Instant }; use std::io::{ Error, ErrorKind }; use std::collections::HashMap; use std::pin::Pin; use std::rc::Rc; use std::cell::RefCell; use std::sync::Mutex; use std::fmt::Debug; use std::any::Any; use async_std:...
pub mod raft; mod tonic;
/// Note: most of these tests are duplicated doc tests, but they're here so that /// we can run them through miri and get a good idea of the soundness of our /// implementations. #[test] fn test_channels_then_resize() { let mut buffer = crate::Sequential::<f32>::new(); buffer.resize_channels(4); buffer.re...
use std::{convert::TryInto, num::TryFromIntError}; use crate::{Tile, TileRegionCoordinate, TileRegionPosition, TileRegionRect, TileWorldPosition}; use game_lib::{ bevy::{math::Vec2, prelude::*}, derive_more::{Display, Error}, }; use game_morton::Morton; // TODO: implement Serialize/Deserialize, doesn't suppor...
use composer::*; #[test] fn token_test() { use tokenize::TokenKind; assert!(TokenKind::Character('c').is_character()); assert!(TokenKind::Number(42).is_number()); assert!(TokenKind::BraceString("string".to_string()).is_brace_string()); } #[test] fn tokenize_test() { use tokenize::*; use TokenK...
extern crate iron; extern crate router; extern crate serde; extern crate serde_json; extern crate docker; #[macro_use] mod macros; pub mod registry_v2; pub mod errors; pub mod middleware; pub mod d2dregistry; pub use registry_v2::*; pub use d2dregistry::DockerToDockerRegistry; pub use errors::*;
use game::*; use std; fn collide_rects(x1: i64, y1: i64, w1: i64, h1: i64, x2: i64, y2: i64, w2: i64, h2: i64)->bool{ if x1>x2+w2||x1+w1<x2 {return false}; if y1>y2+h2||y1+h1<y2 {return false}; true } const MOVER_DEFAULT_WIDTH: i64=40-3; impl Mover{ pub fn default(x: f64, y: f64)->Self{ Mover{x: x, y: y, xspeed...
use rltk::{Point, VirtualKeyCode}; use specs::prelude::*; use crate::{console_log, Context, GameLog, Item, Map, RunState, WaitCause, WantsToMelee, WantsToMove, WantsToPickUp, WantsToWait}; use super::{CombatStats, Player, Position, State}; pub fn player_input(state: &mut State, context: &mut Context) -> RunState { ...
#![allow(clippy::comparison_chain)] #![allow(clippy::collapsible_if)] use std::cmp::Reverse; use std::cmp::{max, min}; use std::collections::{BTreeSet, HashMap, HashSet, VecDeque}; use std::fmt::Debug; use itertools::Itertools; use whiteread::parse_line; const ten97: usize = 1000_000_007; /// 2の逆元 mod ten97.割りたいときに使...
use ds::relations; use examples_shared::{self as es, anyhow, ds, tokio, tracing}; #[tokio::main] async fn main() -> Result<(), anyhow::Error> { let client = es::make_client(ds::Subscriptions::RELATIONSHIPS).await; let mut rel_events = client.wheel.relationships().0; let relationships = client.discord.get...
use seed::{prelude::*, *}; use std::borrow::Cow; use std::fmt; use std::rc::Rc; pub struct FormGroup<'a, Ms: 'static> { id: Cow<'a, str>, label: Option<Cow<'a, str>>, value: Option<Cow<'a, str>>, input_event: Option<Rc<dyn Fn(String) -> Ms>>, input_type: InputType, is_invalid: bool, invalid...
use domain_patterns::command::Command; use domain_patterns::message::Message; #[derive(Clone, Command)] pub struct RemoveSurveyCommand { pub id: String, pub requesting_author: String, }
// Copyright 2020 - 2021 Alex Dukhno // // 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...
// Copyright © 2016-2017 VMware, Inc. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 use std::convert::{From, Into}; use rand::{thread_rng, Rng}; use rabble::{self, Pid, CorrelationId, Envelope}; use time::SteadyTime; use msg::Msg; use vr::vr_fsm::{Transition, VrState, State}; use vr::vr_msg::{VrMsg, GetS...
#![allow(unused_imports)] use std::os::unix::net::UnixStream; use sodiumoxide::crypto::box_; use std::io::{self, BufRead, BufReader, Write}; use std::str::from_utf8; use common::SOCKET_PATH; pub mod common; fn main() { let mut stream = UnixStream::connect(SOCKET_PATH).expect("Couldn't connect to the socket"); ...
/* * Author: Dave Eddy <dave@daveeddy.com> * Date: February 20, 2022 * License: MIT */ use anyhow::Result; use assert_cmd::Command; pub fn vsv() -> Result<Command> { let mut cmd = Command::cargo_bin("vsv")?; cmd.env_clear(); Ok(cmd) }
pub mod energy; /** * Extractors index */ pub mod rms; pub mod zcr; pub mod amp_spectrum; pub mod power_spectrum; pub mod spectral_centroid; pub mod spectral_flatness; pub mod spectral_kurtosis; pub mod spectral_rolloff; pub mod bark_loudness;
use std::default::Default; use std::time::Duration; use aspect::Aspect; use context::{Context, InternalContext}; use entity::Entity; pub trait System { type Aspect: Aspect; fn process(&mut self, context: &mut impl Context, duration: Duration, entities: Vec<Entity>); } trait Executor { fn execute(&mut se...
#[doc = "Reader of register DMAISR"] pub type R = crate::R<u32, super::DMAISR>; #[doc = "Reader of field `DC0IS`"] pub type DC0IS_R = crate::R<bool, bool>; #[doc = "Reader of field `MTLIS`"] pub type MTLIS_R = crate::R<bool, bool>; #[doc = "Reader of field `MACIS`"] pub type MACIS_R = crate::R<bool, bool>; impl R { ...
use colored::*; use std::fmt; use std::io; use std::string::{FromUtf8Error, String}; use utf8::BufReadDecoderError; #[derive(Debug)] pub enum Error { IO(io::Error), UTF8(), PATH(Vec<u8>), MANY(Vec<Error>), CUSTOM(String), PARSEFORMAT(String), } impl fmt::Display for Error { fn fmt(&self, f...
#[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::SSMUX2 { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &...
use std::fs::File; use std::io::{self, prelude::*, BufReader}; use std::path::Path; use reqwest; // fn load_example_magnet_link() -> String { // let file_path = Path::new("./src/data/example-magnet-link.txt"); // let file = File::open(file_path).expect("File not found"); // let mut reader = BufReader::new...
extern crate serde; extern crate serde_xml_rs; use serde::{Deserialize, Serialize}; #[derive(Debug, Deserialize, Serialize)] #[serde(rename = "designspace")] pub struct Designspace { pub format: i32, pub axes: Axes, pub sources: Sources, pub instances: Option<Instances>, // pub rules: Rules, } #[d...
use super::{Item, Value}; impl Item { pub fn get_tagged<'a>(&'a self, tag: &str) -> Option<&'a Value> { for arg in &self.args { if let Some(ref inner_tag) = arg.tag { if inner_tag == tag { return Some(&arg.value); } } } ...
#[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::SYSCONFIG { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R...
// 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 std::{collections::HashMap, convert::Infallible, env, net::SocketAddr}; use axum::{handler::head, response::IntoResponse, Json, Router}; use dotenv::dotenv; use futures::TryStreamExt; use hyper::{ service::{make_service_fn, service_fn}, Body, Method, Request, Response, Server, StatusCode, }; use serde_json...
#[doc = "Reader of register MTLTxQDR"] pub type R = crate::R<u32, super::MTLTXQDR>; #[doc = "Writer for register MTLTxQDR"] pub type W = crate::W<u32, super::MTLTXQDR>; #[doc = "Register MTLTxQDR `reset()`'s with value 0"] impl crate::ResetValue for super::MTLTXQDR { type Type = u32; #[inline(always)] fn re...
pub type IFeed = *mut ::core::ffi::c_void; pub type IFeed2 = *mut ::core::ffi::c_void; pub type IFeedEnclosure = *mut ::core::ffi::c_void; pub type IFeedEvents = *mut ::core::ffi::c_void; pub type IFeedFolder = *mut ::core::ffi::c_void; pub type IFeedFolderEvents = *mut ::core::ffi::c_void; pub type IFeedItem = *mut ::...
// Copyright 2013 Google Inc. All Rights Reserved. // Copyright 2017 The Ninja-rs Project Developers. All Rights Reserved. // // 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:/...
use crate::structures::*; pub fn create(l : usize) -> Assignation { (0..l).map(|_| false).collect() } pub fn grow(ass : Assignation) -> Option<Assignation> { if ass.iter().all(|x| *x) { return None }; Some(add_one(ass)) } fn add_one(ass : Assignation) -> Assignation { let (f, t) : (&bool, &[bool]) = ...
mod handler; mod upgrade; pub use upgrade::Context;
use regex::Regex; use std::collections::HashMap; use std::fs; use std::str::Lines; fn part_1(lines: Lines) { let mut memory = HashMap::new(); let reg = Regex::new(r"^mem\[(\d+)\] = (\d+)").unwrap(); let mut or_mask = 0; let mut and_mask: u64 = 2u64.pow(36) - 1; for line in lines { if line...
use crate::core::{Oracle, ShellCmd}; pub struct Price {} impl Price { pub fn new() -> Price { Price {} } } impl Oracle for Price { type T = f32; fn as_cmd(&self) -> ShellCmd { ShellCmd::new("curl", &["https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD"]) } fn fr...
// use failure::Error; // use std::error::Error; use crate::error::KvsError; use std::result; /// Using failure::Error as error type pub type Result<T> = result::Result<T, KvsError>; /// Define the storage interface pub trait KvsEngine: Clone + Send + 'static { /// Set the value of a string key to a string fn...
#![cfg_attr(feature = "bench", feature(test))] #![allow(non_snake_case)] #![allow(unused)] #[macro_use] extern crate jsontests_derive; use bigint::{Address, Gas}; use evm::{EmbeddedAccountPatch, Patch, Precompiled, EMBEDDED_PRECOMPILEDS}; // Shifting opcodes tests #[derive(JsonTests)] #[directory = "jsontests/res/fi...
pub(crate) mod dev; pub(crate) mod local; pub(crate) mod testnet; use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_core::{crypto::Ss58Codec, Pair, Public}; use sp_finality_grandpa::AuthorityId as GrandpaId; use sp_runtime::traits::{IdentifyAccount, Verify}; use vln_commons::runtime::{AccountId, Signature}...
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),...
use std::hash::{Hash, Hasher}; use protobuf_iter::*; use delta::DeltaEncodedIter; use super::primitive_block::PrimitiveBlock; use super::info::Info; use super::tags::TagsIter; #[derive(Debug, Clone)] pub struct Way<'a> { pub id: u64, pub info: Option<Info<'a>>, tags_iter: TagsIter<'a>, refs_iter: Delt...
use legion::systems::{ Builder, CommandBuffer, }; use legion::{ component, maybe_changed, Entity, }; use nalgebra::Matrix3; use sourcerenderer_core::{ Matrix4, Quaternion, Vec3, }; use super::GlobalTransform; use crate::game::{ TickDelta, TickDuration, }; pub struct PreviousGlo...
pub use morgan_runtime::genesis_utils::{ create_genesis_block_with_leader, GenesisBlockInfo, BOOTSTRAP_LEADER_DIFS, }; use morgan_interface::pubkey::Pubkey; // same as genesis_block::create_genesis_block, but with bootstrap_leader staking logic // for the core crate tests pub fn create_genesis_block(mint_difs: u6...
// https://docs.microsoft.com/en-us/windows/desktop/power/power-management-portal mod device; mod ffi; mod iterator; mod manager; pub use self::device::PowerDevice; pub use self::iterator::PowerIterator; pub use self::manager::PowerManager;
use ws::{connect, CloseCode}; use std::rc::Rc; use std::cell::Cell; use serde_json::{Value}; use crate::base::misc::util::downcast_to_string; use crate::api::config::Config; use crate::api::fee_info::data::{ RequestBrokerageCommand, RequestBrokerageResponse, BrokerageSideKick }; pub fn request<F>(config:...
use clap::Arg; pub fn account_arg<'a>() -> Arg<'a, 'a> { Arg::with_name("account") .long("account") .short("a") .help("Selects a specific account") .value_name("STRING") }
//! Test integration between different policies. use std::{collections::HashMap, sync::Arc, time::Duration}; use iox_time::{MockProvider, Time}; use parking_lot::Mutex; use rand::rngs::mock::StepRng; use test_helpers::maybe_start_logging; use tokio::{runtime::Handle, sync::Notify}; use crate::{ backend::{ ...
use crate::client::Client; use crate::config::Config; use crate::market::Market; #[allow(clippy::all)] pub enum API { SerumRest(Rest), SerumWebSocket(WebSocket), } pub enum Rest { Pairs, Trades(String), AddressTrade(String), AllRecentTrades, Volumes(String), OrderBooks(String), } pub ...
use std::fmt; use std::num; use std::io; use std::str::Utf8Error; use std::string::FromUtf8Error; use rmp::decode::{DecodeStringError, ValueReadError, MarkerReadError}; use rmp::encode::ValueWriteError; #[derive(Debug)] pub enum BsonErr { ParseError(String), ParseIntError(Box<num::ParseIntError>), DecodeIn...
use core::fmt; use crate::device::{ Device, UsingDevice }; use crate::command::{ FlushTx, ReadRxPayload, ReadRxPayloadWidth, WriteTxPayload }; use crate::rxtx::{ Received, SendReceiveResult }; use crate::registers::{ FifoStatus, Status }; use crate::config::Configuration; /// In PTX mode, the device transmits packet...
//! Command line options for running compactor use super::main; use crate::process_info::setup_metric_registry; use clap_blocks::{ catalog_dsn::CatalogDsnConfig, compactor::CompactorConfig, object_store::make_object_store, run_config::RunConfig, }; use compactor::object_store::metrics::MetricsStore; use iox_qu...
use std::iter::FromIterator; use itertools::zip; pub trait Metric<T> { fn score(lhs: &T, rhs: &T) -> f32; fn score_map(lhs: &T, rhs: &[T]) -> f32 { let mut res = 0_f32; for i in 0..rhs.len() { let delta = Self::score(lhs, &rhs[i]); res += delta * delta; } ...
use crate::Transformer; use lowlang_syntax::*; use lowlang_syntax::visit::VisitorMut; use std::collections::BTreeMap; pub struct Inliner<'t> { to_inline: BTreeMap<ItemId, Body<'t>>, current_body: Option<*mut Body<'t>>, current_block: Option<*mut Block<'t>>, changed: bool, } impl<'t> Inliner<'t> { ...
extern crate sdl2; extern crate rustfft; extern crate num; extern crate rand; use num::complex::Complex; use std::f64::consts::PI; use std::f64; use rand::Rng; const DIMS: (usize, usize) = (400, 400); struct Point { pos: (i32, i32), } fn radians_to_rgb(rad: f64) -> (f64, f64, f64) { //outputs values bounded f...
use std::ops; use super::Vector3; use super::Matrix4; pub struct Quaternion { pub x: f32, pub y: f32, pub z: f32, pub w: f32, } impl Quaternion { pub fn with_angle_axis(angle: f32, axis: &Vector3) -> Quaternion { let half_angle = angle / 2.; let s = half_angle.sin(); Quat...
// auto generated, do not modify. // created: Mon Feb 22 23:57:02 2016 // src-file: /QtWidgets/qgraphicsscene.h // dst-file: /src/widgets/qgraphicsscene.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main bl...
extern crate crypto; // 外部库引入 use crypto::digest::Digest; use crypto::sha3::Sha3; fn main() { let mut h = Sha3::sha3_256(); h::input_str("hello world"); let result = h.result_str(); println!("hash = {}", result); println!("Hello, world!"); }
use std::{collections::HashSet, sync::Arc}; use datafusion::{ common::{DataFusionError, Result as DataFusionResult}, execution::FunctionRegistry, logical_expr::{AggregateUDF, ScalarUDF, WindowUDF}, }; use once_cell::sync::Lazy; use crate::{gapfill, regex, window}; static REGISTRY: Lazy<IOxFunctionRegistr...
// 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 intern; use grammar::{parse_tree, repr}; use std::collections::{HashMap, HashSet}; pub struct FirstSet { pub set: HashSet<parse_tree::TerminalString>, pub epsilon: bool } pub fn firsts(grammar: &repr::Grammar) -> HashMap<parse_tree::NonterminalString, Firs...
use std::collections::VecDeque; pub const INPUT: &str = include_str!("../input.txt"); pub struct HeightMap { width: usize, height: usize, heights: Vec<u8>, initial_position: usize, target_position: usize, } impl HeightMap { fn from_input(input: &str) -> Self { let lines = input.lines(...
// pathfinder/path-utils/src/curve.rs // // Copyright © 2017 The Pathfinder Project 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. This file m...
use super::InternalEvent; use metrics::counter; #[derive(Debug)] pub struct FileEventReceived<'a> { pub file: &'a str, pub byte_size: usize, } impl InternalEvent for FileEventReceived<'_> { fn emit_logs(&self) { trace!( message = "received one event.", %self.file, ...
pub type TyRef = usize; pub type TmRef = usize; pub type DBI = usize; #[derive(Eq, Clone, Copy, PartialEq, Debug)] pub enum Ty { Var(DBI), ForAll(TyRef), Arr(TyRef, TyRef), } #[derive(Eq, Clone, Copy, PartialEq, Debug)] pub enum Tm { Var(DBI), Abs(TyRef, TmRef), App(TmRef, TmRef), Gen(TmR...
fn main() { println!("Repeated={}", m1::test1(4)); test_res(42); test_res(230); } mod m1 { use std::iter; pub fn test1(len: usize) -> String { iter::repeat("x").take(len).collect() } } fn test_res(x: usize) { match fallible1(x) { Ok(s) => println!("worked 1={}", s), ...
//! Boolean satisfiability solver. use std::io; use partial_ref::{IntoPartialRef, IntoPartialRefMut, PartialRef}; use anyhow::Error; use thiserror::Error; use varisat_checker::ProofProcessor; use varisat_dimacs::DimacsParser; use varisat_formula::{CnfFormula, ExtendFormula, Lit, Var}; use crate::{ assumptions::...
pub mod codegen; pub mod context; pub mod stored_value; pub mod constexpr;
#[doc = "Reader of register MOSCCTL"] pub type R = crate::R<u32, super::MOSCCTL>; #[doc = "Writer for register MOSCCTL"] pub type W = crate::W<u32, super::MOSCCTL>; #[doc = "Register MOSCCTL `reset()`'s with value 0"] impl crate::ResetValue for super::MOSCCTL { type Type = u32; #[inline(always)] fn reset_va...
use std::cmp::Ordering; use std::convert::From; use std::fmt; use std::net::{AddrParseError, Ipv4Addr, Ipv6Addr}; use std::str::FromStr; use std::u128; #[derive(Debug, Clone, Copy)] struct Ipv4Range { ip: u32, cidr: u8, } #[derive(Debug, Clone, Copy)] struct Ipv6Range { ip: u128, cidr: u8, } impl Par...
use crate::assembler::program_parsers::program; use crate::vm::VM; use std; use std::fs::File; use std::io; use std::io::prelude::*; use std::io::Write; use std::path::Path; use crate::assembler::Assembler; pub struct REPL { command_buffer: Vec<String>, vm: VM, asm: Assembler, } impl REPL { pub fn ne...
use jsonrpc_http_server::{jsonrpc_core::{Compatibility, IoHandler, Params, Value}, ServerBuilder, jsonrpc_core}; use futures::channel::{mpsc}; use futures::executor::block_on; use futures::{StreamExt, TryFutureExt}; use futures::future::FutureExt; // Massbit dependencies use tokio02_spawn::core::abort_on_panic; use to...
extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; mod parser; mod generator; use std::fs::File; use std::path::Path; use std::io::Read; use std::error::Error; // TODO: Use error_chain! pub fn translate(input_filename: &str, output_filename: &Path) -> Result<(), Box<Error>> { ...
//! Quite complex implementation for possibly timed out operation. Needed to be this complex so //! that any Unpin traits and such the inner future might have are properly reimplemented (by //! leveraging futures combinators). use futures::future::{Either, Map}; use std::future::Future; use std::time::Duration; use to...
//! Log and trace initialization and setup use std::cmp::max; pub use trogging::config::*; pub use trogging::{self, TroggingGuard}; use trogging::{ cli::LoggingConfigBuilderExt, tracing_subscriber::{prelude::*, Registry}, }; /// Start simple logger. Panics on error. pub fn init_simple_logs(log_verbose_count: ...
use input_i_scanner::{scan_with, InputIScanner}; fn main() { let stdin = std::io::stdin(); let mut _i_i = InputIScanner::from(stdin.lock()); let t = scan_with!(_i_i, usize); for _ in 0..t { let n = scan_with!(_i_i, usize); let a = scan_with!(_i_i, u64; n); solve(n, a); } } ...
use std::collections::VecDeque; use super::ArcDynFact; #[derive(Clone)] pub struct FactsRow<In> { pub(super) cells: VecDeque<ArcDynFact<In>>, pub(super) value: usize, } #[derive(Clone)] pub struct FactsTable<In> { pub(super) rows: VecDeque<FactsRow<In>>, } impl<In> FactsRow<In> { pub fn new<I: IntoI...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Master Timer Control Register"] pub mcr: MCR, #[doc = "0x04 - Master Timer Interrupt Status Register"] pub misr: MISR, #[doc = "0x08 - Master Timer Interrupt Clear Register"] pub micr: MICR, #[doc = "0x0c - MDIE...
use std::io; fn main() { let mut buffer = String::new(); io::stdin().read_line(&mut buffer).unwrap(); let input_num_vec: Vec<i64> = buffer .trim() .split_whitespace() .map(|c| c.parse().unwrap()) .collect(); let first_num = input_num_vec[0]; let second_num = input_n...
use proconio::input; #[allow(unused_imports)] use proconio::marker::*; #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; #[allow(unused_imports)] use std::f64::consts::*; #[allow(unused)] const INF: usize = std::usize::MAX / 4; #[allow(unused)] const M: usize = 1000000007; fn...
#![feature(macro_rules)] use runge_kutta::{step_rk2, step_rk4}; mod runge_kutta; #[deriving(Show)] struct State { p: f64, v: f64 } impl Add<State, State> for State { fn add(&self, rhs: &State) -> State { State { p: self.p + rhs.p, v: self.v + rhs.v } } } impl Mul<f64, State> for State { ...