text
stringlengths
8
4.13M
#![feature(test)] extern crate test; use morgan_runtime::message_processor::*; use test::Bencher; #[bench] fn bench_has_duplicates(bencher: &mut Bencher) { bencher.iter(|| { let data = test::black_box([1, 2, 3]); assert!(!has_duplicates(&data)); }) }
use abi_stable::StableAbi; #[repr(u8)] #[derive(StableAbi)] #[sabi(kind(WithNonExhaustive( size = 2, )))] #[sabi(with_constructor)] pub enum OkSize { Foo, Bar, Baz(u8), } // The size of the storage is actually `align_of::<usize>()`, // because the alignment defaults to that of a usize #[repr(u8)] #[de...
// Based on https://github.com/Bombfuse/emerald/blob/master/src/core/engine.rs use crate::mq; use multiqueue2::{broadcast_queue, BroadcastReceiver, BroadcastSender}; use ringbuffer::{AllocRingBuffer, RingBuffer, RingBufferExt, RingBufferWrite}; pub mod events; mod frame_timer; pub mod input; mod logger; mod miniquad; ...
extern crate regex; extern crate time; use std::env; use std::io; use std::io::prelude::*; use std::io::BufReader; use std::fs::File; use regex::Regex; use std::collections::HashSet; use time::PreciseTime; #[derive(Copy, Clone, Debug)] enum Tile { Island(i32, i32), Water, Bridge, } #[derive(Clone)] struc...
use crate::logic::models::ground::Ground; use actix_web::{Error, HttpRequest, HttpResponse, Responder}; use futures::future::{ready, Ready}; use serde::Serialize; #[derive(Serialize)] pub struct Data { pub items: Vec<Ground>, } impl Responder for Data { type Error = Error; type Future = Ready<Result<HttpR...
#[doc = "Reader of register PC"] pub type R = crate::R<u32, super::PC>; #[doc = "Writer for register PC"] pub type W = crate::W<u32, super::PC>; #[doc = "Register PC `reset()`'s with value 0"] impl crate::ResetValue for super::PC { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { ...
use std::process::{Command, Output}; use std::fs; use std::io::Error; use std::path::Path; pub fn decompress(archive_path: &String, destination_folder: &String, version_str: &String) -> Result<Output, Error> { Command::new("tar") .arg("-zxf") .arg(archive_path) .arg("-C") .arg(versi...
use std::fmt; #[derive(Clone, Debug, PartialEq)] pub enum Token { Identifier(String), IntegerConstant(String), StringValue(String), Plus, Minus, Multiplication, Division, Equals, LessThan, GreaterThan, Assign, Var, Print, Colon, True, False, Read, ...
use std::path::Path; use crate::casc::CascStorage; use crate::sprite_config::{SpriteGroup, SpriteFormat}; use std::error::Error; use crate::anim::Anim; use std::fs::{create_dir_all, File, read_dir}; use crate::sprite_maker::{makeSprites, Preset, makeSpritesSd, FactorioSprites}; use crate::lua; use crate::lua::LuaSynt...
//! Request all local ip addresses via `hostname`, useful to find out which IP address can be used //! in a server use std::io; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use std::process::Command; /// Execute `hostname` and parses the output as either Ipv4 or Ipv6 address /// /// ## Example /// ```rust /// use hex_...
use escapi; use super::CameraProvider; use image; use std::option::Option; use image::ImageFormat; use std::sync::Arc; pub struct WindowsCamera { width: usize, height: usize, frame_rate: usize, device : escapi::Device, last_frame : Option<Vec<u8>>, counter: usize } unsafe impl ...
#[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::BIT { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w ...
// This file is part of ICU4X. For terms of use, please see the file // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). mod calendar; mod date; mod duration; mod error; pub mod iso; pub use calendar::Calendar; pub use date::{AsCalendar,...
// Copyright 2019, The Tari Project // // 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 copyright notice, this list of conditions and the following // disclai...
//! WPPR // Copyright 2018 Otto Rask // // 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 agree...
extern crate fixedbitset; extern crate slab; extern crate smallvec; extern crate vec_drain_where; #[macro_use] extern crate log; use std::fmt::Debug; pub trait ActionConfiguration: 'static { type Target: Clone + PartialEq + Debug; type KeyKind: Clone + PartialEq + Ord + Debug; type CursorPos: Clone + Part...
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { bitflags::bitflags, byteorder::NativeEndian, fuchsia_async as fasync, fuchsia_syslog::fx_log_info, fuchsia_zircon::{self as zx, s...
use std::char; use std::collections::BTreeMap; use std::fs::{create_dir_all, File}; use std::io::{BufRead, BufWriter, Cursor, Write}; use std::path::Path; #[cfg(test)] use std::collections::BTreeSet; #[cfg(test)] use std::iter::FromIterator; use crate::fst_generator; use anyhow::{anyhow, bail, Context, Result}; use f...
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors. // // 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 ...
#[doc = "Reader of register MISR"] pub type R = crate::R<u32, super::MISR>; #[doc = "Reader of field `ALRAMF`"] pub type ALRAMF_R = crate::R<bool, bool>; #[doc = "Reader of field `ALRBMF`"] pub type ALRBMF_R = crate::R<bool, bool>; #[doc = "Reader of field `WUTMF`"] pub type WUTMF_R = crate::R<bool, bool>; #[doc = "Rea...
// Copyright (c) Calibra Research // SPDX-License-Identifier: Apache-2.0 use super::*; use simulated_context::SimulatedContext; use smr_context::*; struct SharedRecordStore { store: RecordStoreState, contexts: HashMap<Author, SimulatedContext>, } impl SharedRecordStore { fn new(num_nodes: usize, epoch_tt...
// 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 ...
use cow::Move; pub trait Mover { fn new(loc: usize, id: usize) -> Self; fn compute_move(&mut self, neighborhood: ([bool; 8], [bool; 8])); fn get_move(&self) -> Move; fn loc(&self) -> usize; fn set_loc(&mut self, loc: usize); fn score(&self) -> usize; fn inc_score(&mut self); fn reset_s...
#[macro_use] extern crate conrod; extern crate glutin; #[macro_use] extern crate gfx; extern crate gfx_core; extern crate gfx_window_glutin; extern crate genmesh; extern crate noise; extern crate rand; extern crate obj; #[macro_use] extern crate lazy_static; extern crate find_folder; #[macro_use] extern crate log; ...
//! Imports from `std` that would be polyfilled for `no_std` builds (see `src/polyfill/no_std`). //! //! This implementation is used when `std` is available and just imports the necessary items from //! `std`. For `no_std` builds, the file `src/polyfill/no_std` is used instead, which doesn't //! depend on the standard ...
use std::collections::HashMap; use std::io; use std::io::BufRead; use std::path::{Path, PathBuf}; struct HeaderExtractor<R: BufRead> { reader: std::iter::Filter<std::iter::Map<io::Split<R>, fn(io::Result<Vec<u8>>) -> io::Result<Vec<u8>>>, fn(&io::Result<Vec<u8>>) -> bool>, } fn drop_lf(item: io::Result<Vec<u8>>) ...
use crate::common::writer_properties::{Compression, Encoding, WriterVersion}; use parquet::basic::{BrotliLevel, GzipLevel, ZstdLevel}; use wasm_bindgen::prelude::*; impl From<Encoding> for parquet::basic::Encoding { fn from(x: Encoding) -> parquet::basic::Encoding { match x { Encoding::PLAIN =>...
use std::fmt::{Display, Formatter, Result as FmtResult}; use std::path::{Path, PathBuf}; use std::str::FromStr; use serde::de::{self, Deserialize, Deserializer}; use serde::ser::{Serialize, Serializer}; use super::{FilesystemId, ManifestId}; use crate::hash::Hash; use crate::name::Name; #[derive(Clone, Debug, Eq, Ha...
use hello_world::customer_service::CustomerService; use hello_world::event_publishing::DomainEventPublisher; use hello_world::mysql_util::new_connection_pool; use std::sync::Arc; use std::time::SystemTime; #[actix_rt::test] async fn customer_service_saves_and_finds_customers() { let pool = new_connection_pool()...
//! Contains types related to defining shared resources which can be accessed inside systems. //! //! Use resources to share persistent data between systems or to provide a system with state //! external to entities. use std::{ any::TypeId, collections::{hash_map::Entry, HashMap}, fmt::{Display, Formatter}...
//! A logical persistence queue abstraction. use std::{fmt::Debug, sync::Arc}; use async_trait::async_trait; use parking_lot::Mutex; use tokio::sync::oneshot; use crate::buffer_tree::partition::{persisting::PersistingData, PartitionData}; /// An abstract logical queue into which [`PersistingData`] (and their matchi...
use reqwest::{StatusCode, header::{COOKIE, LOCATION, SET_COOKIE, HeaderMap, HeaderValue}}; pub struct Session { client: reqwest::Client, cookies: cookie::CookieJar, } impl Session { // reqwest 0.9.6 doesn't handle `set-cookie` header in case of a redirect, // so i have to do it myself. // see this...
#[test] fn cycle_test() { let names = ["Batman", "Superman", "Spiderman"]; let mut cycle = names.iter().cycle(); assert_eq!(cycle.next(), Some(&"Batman")); assert_eq!(cycle.next(), Some(&"Superman")); assert_eq!(cycle.next(), Some(&"Spiderman")); assert_eq!(cycle.next(), Some(&"Batman")); a...
fn main() { let a = [1, 2, 3, 4, 5]; let _first = a[0]; let _second = a[1]; }
mod part; mod part_attributes; mod partkind; pub mod parts; mod reply; mod reply_type; mod request; mod request_type; mod server_usage; pub(crate) mod util; #[cfg(feature = "async")] pub(crate) mod util_async; pub(crate) mod util_sync; pub use self::{ part::Part, part_attributes::PartAttributes, partkind::PartKi...
// the lifetime annotations in the fn signature // mean that any values that do not adhere to // this contract should be rejected by the // borrow checker // lifetime annotations always go in fn sig // and not in the fn body!!! fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { if x.len() > y.len() { x ...
extern crate json; use algo_tools::load_json_tests; use algo_tools::treenode::{TreeNode,vector2tree}; use std::rc::Rc; use std::cell::RefCell; use std::iter; type Tree = Option<Rc<RefCell<TreeNode>>>; struct Solution; impl Solution { fn dfs(root: &Tree, branch_sum: i32, tree_sum: i32) -> i32 { let mut ts = tree_...
mod element; mod style; mod update; use crate::{ addon::{Addon, AddonState}, config::{load_config, Config, Flavor}, curse_api, error::ClientError, tukui_api, wowinterface_api, Result, }; use iced::{ button, pick_list, scrollable, Application, Column, Command, Container, Element, Length, Set...
use std::convert::Infallible; use crate::algorithms::DiffHook; use crate::{group_diff_ops, DiffOp}; /// A [`DiffHook`] that captures all diff operations. #[derive(Default, Clone)] pub struct Capture(Vec<DiffOp>); impl Capture { /// Creates a new capture hook. pub fn new() -> Capture { Capture::defaul...
use crate::vec3::{Point3, Vec3, random_in_uint_disk}; use crate::ray::Ray; pub struct Camera { origin: Point3, lower_left_corner: Point3, horizontal: Vec3, vertical: Vec3, u: Vec3, v: Vec3, w: Vec3, lens_radius: f32, } impl Camera { pub fn camera(lookfrom: Point3, lookat: Point3, vu...
mod sound { fn guitar() { } pub mod instrument { pub mod woodwind { pub fn clarinet() {} } pub fn clarinet() {} } mod voice { } } fn main() { crate::sound::instrument::clarinet(); sound::instrument::clarinet(); sound::instrument::woodwind::cl...
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[cfg(feature = "Devices_Pwm_Provider")] pub mod Provider; #[link(name = "windows")] extern "system" {} pub type PwmController = *mut ::core::ffi::c_void; pub type PwmPin = *mut ::core::ffi::c_void; #[repr...
use environment::{LocalEnv, GraphChain}; use io::{Io, open_read}; use document::{NodeP, Ptr}; use std::boxed::FnBox; use futures::Future; use futures::future::{ok, join_all}; use super::{LoomError}; use istring::IString; pub fn register(env: &mut LocalEnv) { // env.add_command("fontsize", cmd_fontsize); env.a...
pub mod binary; pub mod current_symbol_table; mod subfield; mod typed_value;
// SPDX-License-Identifier: (MIT OR Apache-2.0) pub use self::isodirectory::{ISODirectory, ISODirectoryIterator}; pub use self::isofile::{ISOFile, ISOFileReader}; use crate::parse::{DirectoryEntryHeader, FileFlags}; use crate::{FileRef, ISO9660Reader, Result}; mod isodirectory; mod isofile; #[derive(Clone, Debug)] ...
use super::{Lab, EPSILON, KAPPA}; use std::arch::x86_64::*; use std::{iter, mem}; static BLANK_RGB: [u8; 3] = [0u8; 3]; /// Converts a slice of `[u8; 3]` RGB triples to `Lab`s using 256-bit SIMD operations. /// /// # Panics /// This function will panic if executed on a non-x86_64 CPU or one without AVX /// and SSE 4....
#[doc = "Reader of register SR"] pub type R = crate::R<u32, super::SR>; #[doc = "Writer for register SR"] pub type W = crate::W<u32, super::SR>; #[doc = "Register SR `reset()`'s with value 0"] impl crate::ResetValue for super::SR { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { ...
#[macro_use] extern crate log; extern crate env_logger; extern crate clap; extern crate csv; extern crate sli2dli; extern crate time; use clap::{App, Arg}; use sli2dli::*; use std::env; use std::fs; use std::os::unix::fs::MetadataExt; use time::PreciseTime; use self::manifest::manifest::Manifest; use self::options::...
pub use VkBufferUsageFlags::*; #[repr(u32)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum VkBufferUsageFlags { VK_BUFFER_USAGE_TRANSFER_SRC_BIT = 0x0000_0001, VK_BUFFER_USAGE_TRANSFER_DST_BIT = 0x0000_0002, VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT = 0x0000_0004, VK_BUFFER_USAGE_STORAGE_TEXEL_BU...
use crate::{util::HashableHashSet, Rewrite, RewritePlan}; use std::hash::Hash; use super::Id; /// A collection of timers that have been set for a given actor. #[derive(Clone, Debug, Hash, PartialEq, Eq, serde::Serialize)] pub struct Timers<T: Hash + Eq>(HashableHashSet<T>); impl<T: Hash + Eq> Default for Timers<T> {...
use futures::{try_ready, Future, Poll}; use http; use linkerd2_error::Error; /// Determines how a request's response should be classified. pub trait Classify { type Class; type ClassifyEos: ClassifyEos<Class = Self::Class>; /// Classifies responses. /// /// Instances are intended to be used as an ...
//! Contains objects representing image parameters use crate::utils::*; /// The region parameter defines the rectangular portion of the /// full image to be returned. Region can be specified by pixel coordinates, /// percentage or by the value “full”, which specifies that the entire image /// should be returned. //...
use std::env; use std::error::Error; use std::fs; pub fn genome_from_path(text: &[&str]) -> String { let mut seq: String = text[0].into(); for kmer in &text[1..] { seq.push(kmer.chars().last().unwrap()); } seq } fn main() -> Result<(), Box<dyn Error>> { let input: String = env::args() ...
use std::env; fn main() { let args: Vec<_> = env::args().collect(); if args.len() > 2{ let a = &args[1]; let b = &args[2]; hex_xor(a,b); } } fn hex_xor(a: &str, b: &str){ if a.len() != b.len() { println!("Lenght error"); }else{ //using for to handle arbitr...
extern crate rand; pub mod core; mod tests;
#[doc = "Reader of register MPCBB1_VCTR38"] pub type R = crate::R<u32, super::MPCBB1_VCTR38>; #[doc = "Writer for register MPCBB1_VCTR38"] pub type W = crate::W<u32, super::MPCBB1_VCTR38>; #[doc = "Register MPCBB1_VCTR38 `reset()`'s with value 0"] impl crate::ResetValue for super::MPCBB1_VCTR38 { type Type = u32; ...
use juniper::ID; use serde_json::{json, Value}; use crate::app_env::get_env; pub struct MailTemplate { pub id: String, pub data: Value, } impl MailTemplate { pub fn register_confirmation(activation_id: &ID, email: &String) -> MailTemplate { MailTemplate { id: get_env::sendgrid_template...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Device Identification 0"] pub did0: DID0, #[doc = "0x04 - Device Identification 1"] pub did1: DID1, #[doc = "0x08 - Device Capabilities 0"] pub dc0: DC0, _reserved3: [u8; 4usize], #[doc = "0x10 - Device Capa...
use { std::{ path::Path, collections::HashMap, } } enum Asset<T>{ Loading(T), Loaded(T), } struct Assetmanager{ cache:Vec<Asset<Font>>, } impl Assetmanager { fn load<T>(&mut self, future:T) { self.cache.insert(P, future); } }
use serde::Deserialize; use std::fmt; const API_URL: &'static str = "https://www.swr3.de/ext/cf=42/actions/feed/onair.json"; #[derive(Debug, Deserialize)] pub struct Swr3ApiResponse { pub playlist: Vec<Swr3Song>, } #[derive(Debug, Deserialize, Clone, PartialEq)] pub struct Swr3Song { pub title: String, p...
use generic_array::{ArrayLength, GenericArray}; use itertools::{IntoChunks, Itertools}; use crate::raw; use std::marker::PhantomData; use crate::FlannError; use crate::Indexable; use crate::Neighbor; use crate::Parameters; pub struct Index<T: Indexable, N: ArrayLength<T>> { index: raw::flann_index_t, storage: ...
extern crate regex; fn get_base(s: &str) -> (u128, u32) { use regex::Regex; if Regex::new(r"\.").unwrap().is_match(format!("{}", s).trim()) { ( Regex::new(r"(?P<a>\d*)\.(?P<b>\d*)") .unwrap() .replace_all(format!("{}", s).trim(), "$a$b") .pars...
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // 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 ...
use std::{thread, time}; use reqwest::{Client as HttpClient, Url}; use super::API_BASE_URL; use serde::{de, Deserialize, Deserializer, Serialize}; use websocket::{ ClientBuilder, client::sync::Client as WsClientSync, stream::sync::{ TlsStream as WsTlsStreamSync, TcpStream as WsTcpStreamSync...
#![warn(unused_imports)] #![warn(unused_variables)] use arrayvec::ArrayVec; use crate::sprite; use std::cmp::max; use std::fmt; use std::fs::File; use std::io::Read; use std::path::PathBuf; const RAM_SIZE: usize = 0x1000; const PROGRAM_START: usize = 0x200; const PROGRAM_MAX_SIZE: usize = RAM_SIZE - PROGRAM_START; p...
mod _2_keys_keyboard; mod _3sum; mod coin_change; mod dungeon_game; mod maximal_square; mod min_path_sum; mod missing_number; mod ones_and_zeroes; mod perfect_number; mod perfect_squares; mod range_sum_query_immutable; mod summary_ranges; mod the_employee_that_worked_on_the_longest_task; mod triangle; mod two_sum;
{{~#*inline "args_decl"~}} {{#each arguments~}}, mut {{this.[0]}}: {{this.[1].def.keys.IdType}}{{/each}} {{~/inline~}} {{~#*inline "args"}}({{#each arguments}}{{this.[0]}},{{/each}}){{/inline~}} {{~#*inline "restrict_op"~}} {{~#with choice_def.Counter~}} {{~#ifeq kind "Add"}}apply_diff_add{{/ifeq~}} ...
#[doc = "Reader of register ODISR"] pub type R = crate::R<u32, super::ODISR>; #[doc = "Writer for register ODISR"] pub type W = crate::W<u32, super::ODISR>; #[doc = "Register ODISR `reset()`'s with value 0"] impl crate::ResetValue for super::ODISR { type Type = u32; #[inline(always)] fn reset_value() -> Sel...
#![no_main] use libfuzzer_sys::fuzz_target; use std::pin::Pin; use std::sync::{Arc, Mutex}; use std::task::{Context, Poll}; use async_std::io::Cursor; use futures_io::{AsyncRead, AsyncWrite}; #[derive(Clone, Debug)] struct RwWrapper(Arc<Mutex<Cursor<Vec<u8>>>>); impl RwWrapper { fn new(input: Vec<u8>) -> Self {...
use std::sync::Arc; use super::{QoS, LastWill, PacketIdentifier, Protocol, ConnectReturnCode}; #[derive(Debug, Clone, PartialEq)] pub enum Packet { Connect(Box<Connect>), Connack(Connack), Publish(Box<Publish>), Puback(PacketIdentifier), Pubrec(PacketIdentifier), Pubrel(PacketIdentifier), Pubcomp(PacketIdentifi...
extern crate cgmath; extern crate objekt; use cgmath::{Vector3, InnerSpace}; use rand::{Rng, thread_rng}; use crate::ray::Ray; use crate::objects::{HitRecord}; type Vec3 = Vector3<f64>; fn rand_f64() -> f64 { thread_rng().gen::<f64>() } fn unit_vector(vector: &Vec3) -> Vec3 { vector / vector.magnitude() } ...
// Copyright (c) 2014 Michael Woerister // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publis...
use futures::{StreamExt, TryStreamExt}; use object_store::{DynObjectStore, ObjectMeta}; use observability_deps::tracing::info; use snafu::prelude::*; use std::sync::Arc; use tokio::sync::mpsc; use tokio_util::sync::CancellationToken; pub(crate) async fn perform( shutdown: CancellationToken, object_store: Arc<D...
use itertools::Itertools; #[derive(Debug)] struct SignalNote<'a> { output: Vec<&'a str>, } impl<'a> SignalNote<'a> { fn from_str(input: &'a str) -> Self { let (_patterns, output) = input.split_once(" | ").unwrap(); Self { output: output.split(' ').collect(), } } } fn n...
use crate::io::BufMut; use crate::mysql::protocol::{Capabilities, Encode}; // https://dev.mysql.com/doc/dev/mysql-server/8.0.12/page_protocol_com_query.html #[derive(Debug)] pub struct ComQuery<'a> { pub query: &'a str, } impl Encode for ComQuery<'_> { fn encode(&self, buf: &mut Vec<u8>, _: Capabilities) { ...
use std::collections::VecDeque; pub struct FIFOBuffer<T> where T: Sync, T: Send { items: VecDeque<T>, desired_buffering: usize, } impl<T> FIFOBuffer<T> where T: Sync, T: Send { pub fn new(desired_buffering: usize) -> FIFOBuffer<T> { FIFOBuffer::<T> { items: ...
// Copyright 2019. The Tari Project // // 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 copyright notice, this list of conditions and the following // disclai...
use std::vec::Vec; use std::iter::range_step; use std::num::{pow, one}; use std::num::FromPrimitive; use std::mem::swap; use std::default::Default; use cgmath::{Point, Point2, Point3}; use cgmath::{Vector, Vector2, Vector3}; use cgmath::BaseNum; use {Max, Min, Merge, Center, Intersects}; pub struct BvhBuilder<T, C,...
extern crate rainwater; use rainwater::scan_rayon; fn main() { let heights = vec![1; 1_000_000]; for _ in 0..100_000 { scan_rayon::capacity(&heights, 32); } }
use chrono::prelude::{NaiveDateTime}; use std::borrow::Cow; use usiem::components::common::LogParsingError; use usiem::events::field::{SiemField, SiemIp}; use usiem::events::{SiemLog, SiemEvent}; use usiem::events::auth::{AuthEvent,AuthLoginType, LoginOutcome, RemoteLogin}; use std::collections::BTreeMap; pub fn parse...
use std::{ io::ErrorKind, net::{TcpListener, UdpSocket}, }; use crate::{ common::{ListenerId, NetProtocol}, socket::{Socket, SocketTcp, SocketUdp}, IpAddress, Port, SocketAddress, SocketId, }; /// 1 MB buffer for UDP "connections" const DEFAULT_UDP_BUFFER: usize = 1_000_000; pub trait Listener: S...
use anyhow::{anyhow, Result}; use async_channel::{Receiver, Sender}; use bitvec::{order::Msb0, prelude::BitVec}; use std::{collections::HashMap, net::SocketAddr, sync::Arc}; use tokio::{ io::{AsyncReadExt, AsyncWriteExt}, net::TcpStream, task::JoinHandle, }; use crate::torrent::TorrentContext; #[derive(De...
#[cfg(test)] mod tests { use super::*; #[test] fn it_works() { assert_eq!(2 + 2, 4); } #[test] fn system() { let s = System::new(); } } mod numa; mod node; mod set; mod mask; extern crate errno; use numa::*; pub use set::{CpuSet, NodeSet}; pub use mask::{CpuMask, NodeMas...
extern crate num; use num::clamp; use std::collections::{HashMap, VecDeque}; use std::io::{self, Write}; use std::sync::mpsc::channel; use std::thread; use std::time::Instant; use termion::cursor::Goto; use termion::event::Key; use termion::raw::IntoRawMode; use tui::backend::TermionBackend; use tui::layout::{Constrai...
// RGB standard library // Written in 2020 by // Dr. Maxim Orlovsky <orlovsky@pandoracore.com> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warr...
use super::*; use super::{Crypto,Sr25519}; use sp_core::{ed25519, Pair, crypto::{Ss58Codec,Ss58AddressFormat}, blake2_256}; pub struct Ed25519; impl Crypto for Ed25519 { type Seed = [u8; 32]; type Pair = ed25519::Pair; type Public = ed25519::Public; fn seed_from_phrase(phrase: &str, password: Option<...
extern crate git2; use std::error; use std::fmt; use std::io; #[derive(Debug)] pub enum HookError { NoRemoteHost, Io(io::Error), Git(git2::Error), } impl fmt::Display for HookError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { HookError::Io(ref e) => write...
// Copyright 2023 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 proconio::input; fn main() { input! { _n: u16, m: u16, x: u16, t: u16, d: u16, }; if x <= m { println!("{}", t); } else { println!("{}", t - d * (x - m)); } }
use crate::render::*; use crate::alloc::*; use std::f32::consts::PI; const TOLERANCE: f32 = 0.1; pub struct Graphics { dpi_factor: f32, renderer: Renderer, fonts: Slab<font_rs::font::Font<'static>>, atlas: Atlas, atlas_tex: TexId, layers: Vec<(usize, usize)>, stack: Vec<usize>, items...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[cfg(feature = "ApplicationModel_Calls_Background")] pub mod Background; #[cfg(feature = "ApplicationModel_Calls_Provider")] pub mod Provider; #[repr(transparent)] #[derive(:: core :: cmp ::...
mod helpers; // Don't forget to add all the modules, so that the UTs are run. // pub mod d2_1_bubble_sort; pub mod d2_2_merge_sort; pub mod d2_2_merge_sort_source; pub mod d2_3_quicksort; pub mod d2_4_dynamic_programming; pub mod d3_1_linked_list; pub mod d3_2_doubly_linked_list; pub mod d3_3_binary_tree; pub mod d3_4...
use needletail::{parse_fastx_stdin, Sequence}; fn main() -> Result<(), Box<dyn std::error::Error>> { let mut n_bases = 0; let mut n_valid_kmers = 0; let mut reader = parse_fastx_stdin().expect("valid path/file"); while let Some(record) = reader.next() { let seqrec = record.expect("invalid recor...
use git_version::{git_hash, git_hash_short, run_command}; #[test] fn git_hash() { assert!(git_hash!().len() == 40); } #[test] fn git_hash_short_default() { assert!(git_hash_short!().len() == 7); } #[test] fn git_hash_short_custom() { assert!(git_hash_short!(0).len() == 4); // minimum output length is 4 ...
//! Linux `mount`. use crate::backend::mount::types::{ InternalMountFlags, MountFlags, MountFlagsArg, MountPropagationFlags, UnmountFlags, }; use crate::{backend, io, path}; /// `mount(source, target, filesystemtype, mountflags, data)` /// /// # References /// - [Linux] /// /// [Linux]: https://man7.org/linux/ma...
use super::skill_description::SkillDescription; use crate::models::skill::Skill; use yew::prelude::*; use yew::{html, Html}; #[derive(Clone, Debug, Eq, PartialEq, Properties)] pub struct Props { pub skills: Vec<Skill>, } pub struct SkillsPanel { skills: Vec<Skill>, } impl Component for SkillsPanel { type...
use core::marker::PhantomData; pub use crate::make_anon_typeid_owner as new_anon; pub use crate::make_typeid as make; #[macro_export] macro_rules! make_anon_typeid_owner { () => { unsafe { $crate::Owner::new($crate::typeid::Type::new_unchecked(|| ())) } }; } #[macro_export] macro_rules! make_typeid {...
// 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 ...
pub mod status; use super::Apply; use super::QueryActor; use crate::sim::{SimState, SimTime}; use bevy_ecs::prelude::Entity; use delegate::delegate; use status::{Status, StatusFlag}; // TODO: Maybe a time ordered heap would be faster. Benchmark when we have more functionality. #[derive(Default)] pub struct S...
#[doc = "Reader of register FDCAN_TTOCN"] pub type R = crate::R<u32, super::FDCAN_TTOCN>; #[doc = "Writer for register FDCAN_TTOCN"] pub type W = crate::W<u32, super::FDCAN_TTOCN>; #[doc = "Register FDCAN_TTOCN `reset()`'s with value 0"] impl crate::ResetValue for super::FDCAN_TTOCN { type Type = u32; #[inline(...