text
stringlengths
8
4.13M
//! Traits for operations. use crate::Layer; use crate::gates::{PauliGate, HGate, SGate, TGate, CXGate}; mod opsvec; pub use opsvec::OpsVec; mod opargs; pub use opargs::{opid, OpArgs}; /// Provides operations for initialize and measurement. pub trait Operation<L> where L: Layer + ?Sized { fn initialize() -> Sel...
#[macro_use] extern crate lazy_static; mod ca; mod handler; mod rule; use clap::Parser; use http_mitm::*; use log::*; use rustls_pemfile as pemfile; use std::fs; async fn shutdown_signal() { tokio::signal::ctrl_c() .await .expect("failed to install CTRL+C signal handler"); } #[derive(Parser)] #[...
#[doc = r"Register block"] #[repr(C)] pub struct RXD { #[doc = "0x00 - Configuration of incoming frames"] pub frameconfig: FRAMECONFIG, #[doc = "0x04 - Size of last incoming frame"] pub amount: AMOUNT, } #[doc = "FRAMECONFIG (rw) register accessor: an alias for `Reg<FRAMECONFIG_SPEC>`"] pub type FRAMECO...
use super::{n16, Checksum}; use std::{mem, slice, u8}; use ip::Ipv4Addr; /// UDP header as defined in RFC 768 #[derive(Copy, Clone, Debug)] #[repr(packed)] pub struct UdpHeader { /// Source port pub src: n16, /// Destination port pub dst: n16, /// Length pub len: n16, /// Checksum pub ...
uucore_procs::main!(uu_nl); // spell-checker:ignore procs uucore
use std::collections::HashMap; use async_std::stream; use async_trait::async_trait; use serde_derive::{Deserialize, Serialize}; use svc_agent::{ mqtt::{IncomingRequestProperties, ResponseStatus}, Addressable, AgentId, }; use uuid::Uuid; use crate::app::context::Context; use crate::app::endpoint::prelude::*; u...
use changers::logic; use std::collections::HashMap; #[test] fn test_change_possible() { let result = logic::make_change(10.0, vec![1.0, 2.0, 5.0, 10.0]).unwrap(); let target: HashMap<String, i32> = [ (String::from("1"), 0), (String::from("2"), 0), (String::from("5"), 0), (String...
#[derive(Default, Debug)] pub struct NlpResponse { pub intent: ::sami::Intent, pub device: Option<Vec<String>>, pub value: Option<String>, pub field: Option<String>, pub meta: Option<Vec<String>>, }
// Copyright 2020 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 ...
#![deny(warnings)] mod al; mod alc; pub use al::*; pub use alc::*; #[cfg(test)] mod tests { use super::*; use std::ptr; #[test] fn test_alc_open_device() { let device = unsafe { alc_open_device(ptr::null()) }; assert_eq!(device.is_null(), false); unsafe ...
use lib_error::*; use std::convert::From; mod config; mod encrypted_repo; pub use self::encrypted_repo::EncryptedRepo; /// Represents a collection in the repo. #[derive(Debug)] pub struct Collection(pub String); impl Collection { fn name(&self) -> &str { &self.0 } } impl From<String> for Collection ...
use my_algo::fib; use structopt::StructOpt; #[derive(StructOpt, Debug)] struct Opt { input: usize, } fn main() { let opt = Opt::from_args(); let result = fib(opt.input); println!("{}", result); }
pub mod atlas;
// Advent of Code Day 4 part 2 // Based on part 1, with only slight modifications -read that for more info! // I peeped at a solution that a more experienced Rust programmer wrote and I was // amazed at how simple it was and all of the different language functions // it used. I'm embarrassed by my silly method here, ...
//! Simple & extensible type-checked matrixes //! //! This was made as a learning project and thrives to provide matrices generic over any type. //! Some basic matrix manipulation operations are implemented for the matrix assuming the concrete type implements the required traits. //! The main selling point is that most...
// Copyright 2015-2018 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
mod sdf; mod serialization; mod spatial_hash; mod world; #[allow(unused_imports)] use sdf::*; #[cfg(feature = "serde_support")] use serialization::*; use spatial_hash::*; pub use world::*; #[cfg(feature = "fixed_point")] mod fixed_math; #[cfg(feature = "fixed_point")] use fixed_math::*; #[cfg(feature = "fixed_point")]...
use { crate::makepad_editor_core::{ delta::{Delta, OperationRange}, text::Text, }, std::{ ops::{Deref, Index}, slice::Iter, }, }; pub struct IndentCache { lines: Vec<Line>, } impl IndentCache { pub fn new(text: &Text) -> IndentCache { let mut cache = Ind...
#[cfg(test)] pub fn data_from_str(s: &'static str) -> String { String::from_str(s) } pub fn char_width(c: char, is_cjk: bool, tab_width: uint, position: uint) -> Option<uint> { if c == '\t' { Some(tab_width - position%tab_width) } else { c.width(is_cjk) } } pub fn str_width(s: &str, is...
use std::ops::{Index, IndexMut}; pub type Pos = (i32, i32); #[derive(Clone)] pub struct Map<T> { pub size: (u32, u32), pub tiles: Vec<T> } impl<T: Clone> Map<T> { pub fn new(size: (u32, u32), initial: T) -> Map<T> { let mut tiles = Vec::with_capacity((size.0 * size.1) as usize); tiles.res...
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::move_resource::MoveResource; use anyhow::Result; use move_core_types::account_address::AccountAddress; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct BlockRewardEvent { pub block...
/* https://adventofcode.com/2018/day/3 --- Day 3: No Matter How You Slice It --- The Elves managed to locate the chimney-squeeze prototype fabric for Santa's suit (thanks to someone who helpfully wrote its box IDs on the wall of the warehouse in the middle of the night). Unfortunately, anomalies are still affecting ...
use crate::{Object, Result, Args, Literal}; use std::sync::Arc; use crate::types::{RustClosure, List}; use std::fmt::{self, Debug, Formatter}; use tracing::instrument; #[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Function; #[derive(Clone)] pub struct BoundRustFn(Arc<dyn Fn(...
// 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 ...
mod map_loading; mod music; pub mod prefabs; pub use self::map_loading::*; pub use self::music::Music; pub use self::prefabs::*;
// vim: tw=80 //! The Database layer owns all of the Datasets //! //! Clients use the Database to obtain references to the Datasets. The Database //! also owns the Forest and manages Transactions. use cfg_if::cfg_if; use crate::common::{ *, tree::MinValue }; mod database; cfg_if! { if #[cfg(test)]{ ...
use crate::domains::Collection; use serde_json::error; // Parse the supplied CSP JSON config to a collection of domains and directives. pub fn json(json: &str) -> Result<Collection, error::Error> { let result = serde_json::from_str(json); match result { Ok(result) => { let parsed: Collecti...
// 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 super::{JSConte...
use std::fmt; pub use arp_frame::*; pub use ethernet_frame::*; pub use hwaddr::*; pub use ieee_llc_frame::*; use crate::clone_into_array; use super::internet::*; mod ethernet_frame; mod ieee_llc_frame; mod arp_frame; mod hwaddr;
use ili9225::{Lcd, Font, BLACK}; use std::io::{Result, Read}; const XMAX: u16 = 176; const YMAX: u16 = 220; const XMAX2: u16 = 175; const YMAX2: u16 = 219; fn main() -> Result<()> { let lcd = Lcd::new(0x9225, XMAX, YMAX); let fxg16 = Font::new( "ili9225spi_rpi/fontx/ILGH16XB.FNT", "ili9225spi...
extern crate maplit; extern crate sorted_iter; use maplit::*; use sorted_iter::SortedPairIterator; fn main() { let city = btreemap! { 1 => "New York", 2 => "Tokyo", }; let country = btreemap! { 1 => "USA", 2 => "Japan", }; let res: Vec<_> = city.iter().join(country....
use crate::tape::Tape; use crate::token::{Token, TokenTree}; mod tape; mod token; fn process_token(tape: &mut Tape, token: &Token) { match token { Token::MoveRight => tape.move_pointer_right(), Token::MoveLeft => tape.move_pointer_left(), Token::Increment => tape.increment_cell(), ...
use super::tree::{AvlNode, AvlTree}; use core::iter::Peekable; use std::cmp::Ordering; use std::iter::FromIterator; use std::mem::replace; #[cfg(test)] use quickcheck::{Arbitrary, Gen}; #[derive(Debug, PartialEq, Clone)] pub struct AvlTreeSet<T: Ord> { root: AvlTree<T>, } impl<'a, T: 'a + Ord> Default for AvlTre...
use crate::{graph::*, hash}; use std::collections::{HashSet, VecDeque}; use std::hash::Hash; pub enum Mode { Bredth, Depth, } impl<T: Hash> Graph<T> { pub fn bfs<'a>(&'a self, start: &'a T) -> WalkIter<'a, T> { self.walk(start, Mode::Bredth) } pub fn dfs<'a>(&'a self, start: &'a T) -> Wal...
use serde_json::Deserializer; use std::{ env, fmt, io::{self, BufRead, BufReader, Read}, }; #[derive(Debug)] enum Error { CapnProto(capnp::Error), NotInSchema(capnp::NotInSchema), Serde(serde_json::Error), Io(io::Error), } impl From<io::Error> for Error { fn from(cause: io::Error) -> Self ...
use core::fmt::{self, Write}; use core::mem; use spin::Mutex; use volatile::Volatile; use x86_64::instructions::port::Port; #[allow(dead_code)] #[derive(Debug, Clone, Copy)] #[repr(u8)] pub enum Color { Black = 0, Blue = 1, Green = 2, Cyan = 3, Red = 4, Magenta = 5, Brown = 6, LightGray...
use crate::instructions::base::bytecode_reader::BytecodeReader; use crate::instructions::base::instruction::Instruction; use crate::instructions::base::method_invoke_logic::invoke_method; use crate::runtime::frame::Frame; use crate::oops::constant_pool::Constant::InterfaceMethodReference; use crate::oops::method_ref::M...
fn separated() {}
// Copyright 2020 The Jujutsu 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed t...
struct Solution; impl Solution { fn find_length(a: Vec<i32>, b: Vec<i32>) -> i32 { let n = a.len(); let m = b.len(); let mut dp: Vec<Vec<i32>> = vec![vec![0; m + 1]; n + 1]; let mut res = 0; for i in 0..n { for j in 0..m { if a[i] == b[j] { ...
use serde_derive::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize, Clone)] pub struct Activation { pub probability: f64, pub foreshadowing: i32, pub upramp: i32, pub time: i32, pub fade: i32, }
use std::collections::BTreeMap; #[derive(Default)] struct MyCalendarTwo { double_booked: Vec<Interval>, } impl MyCalendarTwo { fn new() -> Self { let double_booked = vec![]; MyCalendarTwo { double_booked } } fn book(&mut self, start: i32, end: i32) -> bool { let mut triple_boo...
impl Solution { pub fn trap(height: Vec<i32>) -> i32 { let N = height.len(); if N == 0 { return 0 } let mut water = vec![0; N]; let mut l_idx = 0; let mut st = 0; let mut l_height = 0; for i in 0..N { ...
#[doc = "Register `REQSTATUS` reader"] pub struct R(crate::R<REQSTATUS_SPEC>); impl core::ops::Deref for R { type Target = crate::R<REQSTATUS_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<REQSTATUS_SPEC>> for R { #[inline(always)] fn from(read...
use amethyst::{ core::Time, ecs::{Entities, Entity, Join, ReadExpect, ReadStorage, System, WriteStorage}, }; use std::time::Duration; use crate::models::mob_actions::MobAttackType; use crate::{ components::{DamageHistory, Monster, Player, WorldPosition}, data_resources::{GameScene, MonsterDefinitions}...
//! Contains utilities for parsing a WASM module to retrieve the information needed by [`super::WasmObject`] use super::WasmError; use crate::base::{ObjectKind, Symbol}; use wasmparser::{ FuncValidatorAllocations, NameSectionReader, Payload, TypeRef, Validator, WasmFeatures, }; #[derive(Default)] struct BitVec { ...
use ::*; pub fn run(port: u16) { let mut jar = std::process::Command::new("java"); jar.arg("-jar").arg(std::path::Path::new("..").join("target").join("troll-invasion.jar")); jar.stdin(std::process::Stdio::piped()); jar.stdout(std::process::Stdio::piped()); let jar = jar.spawn().expect("Failed to st...
//! Implement SMTStore trait use crate::traits::KVStore; use gw_common::{ sparse_merkle_tree::{ error::Error as SMTError, traits::Store, tree::{BranchKey, BranchNode}, }, H256, }; use gw_db::schema::Col; use gw_types::{packed, prelude::*}; pub struct SMTStore<'a, DB: KVStore> { ...
use crate::vec::FloatType; pub fn random_float() -> FloatType { use rand::{thread_rng, Rng}; let mut rng = thread_rng(); rng.gen() } pub fn random_float_range(min: FloatType, max: FloatType) -> FloatType { use rand::{thread_rng, Rng}; let mut rng = thread_rng(); rng.gen_range(min..max) }
struct Solution; use util::*; trait Preorder { fn preorder(&self, cur: &mut Vec<char>, min: &mut String); } impl Preorder for TreeLink { fn preorder(&self, cur: &mut Vec<char>, min: &mut String) { if let Some(node) = self { let node = node.borrow(); let val = (node.val as u8 + ...
extern crate tiff; use std::io::{Cursor, Seek, Write}; use tiff::{ decoder::{Decoder, DecodingResult}, encoder::{ colortype::{self, ColorType}, compression::*, TiffEncoder, TiffValue, }, }; trait TestImage<const NUM_CHANNELS: usize>: From<Vec<<Self::Color as ColorType>::Inner>> { ...
use super::pbrt::{Float, Spectrum, consts::SHADOW_EPSILON}; use super::geometry::{Vector3f, Normal3f, Point2f, Point3f, Ray, offset_ray_origin, dot_normal_vec}; use super::medium::{Medium, MediumInterface, PhaseFunction}; use super::shape::Shape; use super::primitive::Primitive; use super::reflection::BSDF; use super::...
use super::*; use crate::score::Spatium; #[derive(Clone, Debug)] pub struct Style { values: Vec<ValueVariant>, precomputed_values: Vec<f32>, } impl Style { pub fn new() -> Self { let mut values = Vec::new(); values.resize_with(STYLE_COUNT, || ValueVariant::default()); for (id, value) in style_default_values(...
// This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.a...
//! Probabilistic binary search tree where each node also maintains the heap invariant. mod implicit_tree; mod list; mod map; mod node; mod set; mod tree; pub use self::list::TreapList; pub use self::map::TreapMap; pub use self::set::TreapSet;
use crate::rt::compute_raw_varint64_size; use crate::rt::singular::bytes_size_no_tag; use crate::rt::tag_size; use crate::wire_format::Tag; use crate::wire_format::WireType; use crate::CodedInputStream; use crate::UnknownFields; use crate::UnknownValueRef; fn skip_group(is: &mut CodedInputStream) -> crate::Result<()> ...
use anyhow::{ensure, Context, Result}; use generic_array::typenum::U0; use itertools::Itertools; use log::debug; use merkletree::store::{StoreConfig, StoreConfigDataVersion}; use rayon::prelude::*; use sha2raw::Sha256; use storage_proofs_core::{ hasher::{Domain, Hasher}, merkle::{DiskTree, LCTree, MerkleTreeTra...
// Copyright 2020 Yevhenii Reizner // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use core::convert::TryFrom; use crate::{FiniteF32, IntSize, LengthU32, PathBuilder, Point, SaturateRound, Size, Transform}; #[cfg(all(not(feature = "std"), feature = "no-std-f...
use std::ascii::StrAsciiExt; use std::io::{Reader, Buffer}; use std::char::from_u32; use std::str::from_char; use std::num::from_str_radix; use util::{is_whitespace, is_name_start, is_name_char}; use util::{ErrKind, Config}; use util::{is_restricted, clean_restricted, is_char}; use util::{RestrictedCharError,MinMinInC...
// Copyright 2023 The Jujutsu 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed t...
struct Solution; use std::fmt; #[derive(Debug, PartialEq, Eq, Clone)] struct Time { hour: i32, minute: i32, } impl Time { fn new(hour: i32, minute: i32) -> Self { Time { hour, minute } } fn is_valid(&self) -> bool { self.hour < 24 && self.minute < 60 } fn from_digits(a: &[...
// --- Use --- // use rand::{random, Open01}; use specs::{Component, VecStorage}; use ggez::{Context, GameResult}; use ggez::graphics; use world; use util::math::{Scalar, PI, map}; // --- ==== --- // // --- Constants --- // const ASTEROID_RESOLUTION: usize = 16; // --- ==== --- // // TODO: Split asteroid into t...
//! A module that contains all the actions related to the terminal. //! Like clearing and scrolling in the terminal or getting the window size from the terminal. use super::{AnsiTerminal, ClearType, ITerminal}; use crossterm_utils::{write, Result, TerminalOutput}; #[cfg(windows)] use super::WinApiTerminal; #[cfg(wind...
#![feature(try_blocks)] #![feature(box_syntax)] #![feature(box_patterns)] #![warn(clippy::all)] #![warn(rust_2018_idioms)] // SystemData is often complex :( #![cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] #[macro_use] extern crate specs_derive; #[macro_use] extern crate failure; #[macro_use] ext...
// Copyright (c) 2016 The vulkano developers // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT // license <LICENSE-MIT or https://opensource.org/licenses/MIT>, // at your option. All files in the project carrying such // notice may not be ...
mod aes; mod keybag; mod keybag_block; mod keybag_type; mod keytype; mod protectionclass; pub use self::aes::*; pub use keybag::*; pub use keybag_block::*; pub use keybag_type::*; pub use keytype::*; pub use protectionclass::*;
extern crate rand; use super::{ int_sqrt, modmul, modpow, modpow_s }; /// Deterministic primality test. pub fn is_prime(n : u64) -> bool { if n <= 1 { return false; } if n == 2 { return true; } if n & 1 == 0 { return false; } let mut x : u64 = 3; while x * x <= n { if n % x == 0 { return false; } ...
extern crate regex; use regex::Regex; use std::io; fn main() { let mut arr = String::new(); println!("Enter your email id :"); let mut b1:String=io::stdin().read_line(&mut arr).unwrap().to_string(); let n: Regex = Regex::new(r"^[A-Za-z0-9!#$%&'*+=?^_`{|}~.]+@[a-zA-z0-9]+\.[a-z]*").unwrap(); ...
#[derive(Debug, PartialEq)] pub struct RibonucleicAcid { seq: String } impl RibonucleicAcid { pub fn new(sequence: &str) -> RibonucleicAcid { RibonucleicAcid { seq: sequence.to_owned() } } } #[derive(Debug, PartialEq)] pub struct DeoxyribonucleicAcid { seq: String } impl D...
use byteorder::{BigEndian, ByteOrder}; use crate::decode::Decode; use crate::encode::{Encode, IsNull}; use crate::error::BoxDynError; use crate::types::Type; use crate::{PgArgumentBuffer, PgHasArrayType, PgTypeInfo, PgValueFormat, PgValueRef, Postgres}; impl Type<Postgres> for f32 { fn type_info() -> PgTypeInfo {...
pub use std::time::Duration; pub use std::num::ParseFloatError; pub trait DurationExt { /// Constructs Duration from &str parsed as f64 representing seconds. /// /// This is useful with `structopt` to get `Duration`: `parse(try_from_str = Duration::from_secs_str)` fn from_secs_str(val: &str) -> Result<...
//! World resource that handles all user input. use std::borrow::Borrow; use std::hash::Hash; use amethyst_core::shrev::EventChannel; use smallvec::SmallVec; use winit::{ DeviceEvent, ElementState, Event, KeyboardInput, MouseButton, VirtualKeyCode, WindowEvent, }; use super::controller::{ControllerButton, Contro...
use crate::{Cell, Instruction}; use std::str::Chars; use crate::parser::Token; use std::marker::PhantomData; const OP_INC_INDEX: char = '>'; const OP_DEC_INDEX: char = '<'; const OP_INC_VALUE: char = '+'; const OP_DEC_VALUE: char = '-'; const OP_IO_READ: char = ','; const OP_IO_WRITE: char = '.'; const OP_LOOP_START: ...
use std::collections::HashMap; fn speak_number(number: usize, turn: usize, spoken_numbers: &mut HashMap<usize, (i32, i32)>) { match spoken_numbers.get(&number) { Some((_prev, last)) => { spoken_numbers.insert(number, (*last, turn as i32)); } None => { spoken_numbers....
// Copyright 2020 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 ...
//! Resource Objects defined in the OneDrive API. //! //! # Field descriptors //! //! Resource object `struct`s have field descriper `enum`s representing //! all controlable fields of it, which may be used //! in [`onedrive_api::option`][option] to [`select`][select] or [`expand`][expand] it using //! `with_option` ver...
use std::fs::File; use std::io::prelude::*; fn process(a: i32) -> Result<String, String> { println!("process={}", a); let mut f = File::open("test.txt").map_err(|_e| "Error".to_string())?; let mut m = String::new(); f.read_to_string(&mut m).map_err(|_e| "Error".to_string())?; Ok(m) } fn main() { ...
use maat_graphics::DrawCall; use maat_graphics::imgui::*; use crate::modules::Logs; use std::io::{Write, BufWriter}; use std::fs::File; use std::fs; use std::fs::copy; use std::path::Path; use hlua; use hlua::Lua; use open; use crate::cgmath::{Vector2, Vector3}; const LOCATION: &str = "./Scenes/"; const OBJECTS: ...
use std::collections::HashSet; use crate::token::Token; use crate::rule::{ Rule, Symbol }; use crate::partech::Partech; use crate::tree::Tree; use crate::error::ErrorDuringParsing; #[derive(Hash)] #[derive(Clone)] #[derive(Debug)] #[derive(PartialEq, Eq)] pub struct Item <'a> { rule: Rule<'a>, choice_name: &'...
use classfile::raw::*; use classfile::attribute::*; use classfile::constant::Constant; use util::*; use classfile_preprocessor::rawprocessor::*; pub fn refine_attribute(constants: &Vec<Constant>, raw_attribute: &RawAttributeInfo) -> Attribute { let bytes = &raw_attribute.info; let name_index = raw_attribute.at...
fn main() { let mut test = NumberTestSpec::new(); test.start(); }
// This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.a...
use super::*; pub use self::chdir::do_chdir; pub use self::getcwd::do_getcwd; pub use self::mount::{ do_mount, do_mount_rootfs, do_umount, MountFlags, MountOptions, UmountFlags, }; pub use self::statfs::{do_fstatfs, do_statfs, fetch_host_statfs, Statfs}; pub use self::sync::do_sync; mod chdir; mod getcwd; mod mou...
use morphorm::{Cache, GeometryChanged}; use crate::{CachedData, Display, Entity, Visibility}; impl Cache for CachedData { type Item = Entity; fn visible(&self, node: Self::Item) -> bool { //self.visibility.get(node).cloned().map_or(true, |vis| vis == Visibility::Visible) self.display.get(no...
use crate::error::{Error, ErrorKind}; use crate::traits::db::DatabaseTrait; use crate::traits::kvs::{Batch, KeyValueStore, KvsIterator}; use kvdb::{DBTransaction, KeyValueDB}; use kvdb_memorydb::InMemory; pub struct CoreDb { db: InMemory, } impl DatabaseTrait for CoreDb { fn open(_dbname: &str) -> Self { ...
// for iterator .join() method extern crate itertools; use itertools::Itertools; pub fn abbreviate(phrase: &str) -> String { phrase.trim() .split(|c: char| !c.is_alphabetic()) .filter(|&word| word.len() > 0) .map(|word| { if word.chars().all(|ch| ch.is_uppercase()) { ...
extern crate bytes; extern crate byteorder; extern crate sodiumoxide; extern crate tokio_core; extern crate tokio_io; use std; use self::bytes::{BufMut, BytesMut}; use self::byteorder::{BigEndian, ByteOrder}; use self::sodiumoxide::crypto::secretbox; use self::tokio_io::codec::{Decoder, Encoder}; pub struct SecretBox...
// Copyright 2021 Conflux Foundation. All rights reserved. // Conflux is free software and distributed under GNU General Public License. // See http://www.gnu.org/licenses/ // // Modification based on https://github.com/hlb8122/rust-bitcoincash-addr in MIT License. // A copy of the original license is included in LICEN...
/// allocate an `i32[]` of length `len`, returning /// the `ptr` in wasm memory /// /// fills the array with zero by default. #[no_mangle] pub fn alloc_arr_i32(len: i32) -> i32 { // leak the allocation Box::into_raw(vec![0i32; len as usize].into_boxed_slice()) as *mut () as i32 } /// allocate an `f32[]` of len...
use std::collections::{HashMap, HashSet}; use std::hash::Hash; use std::fmt::Debug; use math::graph::Graph; /// Graph implemented using vectors of adjacent vertices and incidence lists #[derive(Debug, Clone)] pub struct DirectedAdjacencyList<L, T> where T: Debug, L: Eq + Hash + Debug + Clone { vertices: HashMap<L,...
//! A wrapper for a variable that hold additional flag that tells that initial value was changed in runtime. //! //! For more info see [`InheritableVariable`] use crate::{ reflect::{prelude::*, ReflectArray, ReflectInheritableVariable, ReflectList}, visitor::prelude::*, }; use bitflags::bitflags; use std::{ ...
//! A library and CLI utility for querying word etymologies //! from the inimitable [EtymOnline.com](https://etymonline.com). use anyhow::Result; use regex::Regex; use scraper::{Html, Selector}; /// An etymology as retrieved from EtymOnline.com. pub struct Etymology { /// The search term used for looking up an en...
use crate::{handle::Handle, ColumnFamily, Error}; use libc::c_void; use std::ffi::{CStr, CString}; pub trait GetProperty { /// Retrieves a RocksDB property by name. /// /// For a full list of properties, see /// https://github.com/facebook/rocksdb/blob/08809f5e6cd9cc4bc3958dd4d59457ae78c76660/include/r...
// Copyright (c) 2018-present, Facebook, Inc. // All rights reserved. // // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. use std::collections::HashMap; use std::fs; use std::fs::File; use std::io::BufRead; use std::io::BufReader; use s...
mod entity; mod graph; mod schedule; mod entity_state; mod behaviour; mod entity_cluster; extern crate rand; use entity_state::EntityState::Stationary; use entity::Entity; use entity_cluster::ConnectedEdges; use entity_cluster::EntityCluster; use schedule::MarkovChain; use schedule::Schedule; use graph::Graph; use st...
use std::sync::{ atomic::{AtomicBool, Ordering}, Arc, }; use arc_swap::ArcSwap; use once_cell::sync::Lazy; #[derive(Debug)] pub enum Notification { Info(String), Warn(String), Error(String), } impl From<anyhow::Error> for Notification { fn from(err: anyhow::Error) -> Notification { No...
//! External Language Ast. The language ast for nana. pub use crate::base::*; #[derive(Clone, Debug)] pub struct Nana { pub body: GatedBlock, } #[derive(Clone, Debug)] pub struct GatedBlock { pub traces: Vec<Binder>, pub block: Block } #[derive(Clone, Debug)] pub enum Block { Tuple(Vec<Abstraction>,...
mod solver; use serde::Deserialize; use solver::{Device, Solver}; use std::error::Error; #[derive(Deserialize, Debug, Default)] struct ChallengeReponse { session: String, question: String, } #[derive(Deserialize, Debug, Default)] struct TokenResponse { token: String, expires_in: usize, debug_inform...
//! XYZ color type use super::chromaticity::XYY; use std::convert::From; use std::fmt; use std::ops::{AddAssign, Index, IndexMut, Add, Sub, Mul, Div, Neg}; use num_traits::{Bounded, One, Zero}; use float_cmp::{F32Margin, F64Margin, ApproxEq}; use crate::math::Real; pub type XYZf32 = XYZ<f32>; pub type XYZf64 = XYZ<f...
//! Validates that users have correct authorization to download packages. use crate::frontend::rest::services::authentication; use crate::installer::InstallerFramework; use crate::logging::LoggingErrors; use crate::tasks::resolver::ResolvePackageTask; use crate::tasks::{Task, TaskDependency, TaskMessage, TaskOrderi...