text
stringlengths
8
4.13M
#[doc = "Register `CFGR2` reader"] pub type R = crate::R<CFGR2_SPEC>; #[doc = "Register `CFGR2` writer"] pub type W = crate::W<CFGR2_SPEC>; #[doc = "Field `ROVSE` reader - ADC oversampler enable on scope ADC group regular"] pub type ROVSE_R = crate::BitReader<ROVSE_A>; #[doc = "ADC oversampler enable on scope ADC group...
// Copyright 2021. The Tari Project // SPDX-License-Identifier: BSD-3-Clause use alloc::vec::Vec; use core::{ cmp::Ordering, hash::{Hash, Hasher}, ops::{Add, Mul}, }; use snafu::prelude::*; use tari_utilities::{ByteArray, ByteArrayError}; use crate::{ commitment::{HomomorphicCommitment, HomomorphicCo...
use std::cmp::Ordering::{self, *}; use cc_traits::Iter; use crate::{IsBot, IsTop, LatticeFrom, LatticeOrd, Merge}; /// Vec-union compound lattice. /// /// Contains any number of `Lat` sub-lattices. Sub-lattices are indexed starting at zero, merging /// combines corresponding sub-lattices and keeps any excess. /// //...
extern crate time; extern crate rustlsystem; mod app; use app::Application; fn main() { Application::run(); }
use x86_64::structures::paging::FrameAllocator; use x86_64::structures::paging::Size4KiB; use x86_64::structures::paging::PhysFrame; use x86_64::structures::paging::Page; use x86_64::VirtAddr; pub fn init_frame_allocator<T: Iterator<Item = PhysFrame>>(frames: T) -> BumpFrameAllocator<impl Iterator<Item = PhysFrame>> ...
pub mod game; mod ui; extern crate rand; extern crate rustc_serialize; use std::env::args; use std::fs::File; use game::board::Board; use game::player::Player; fn main() { let mut args = args(); if let Some(filename) = args.nth(1) { let mut file_handle = File::open(&filename).expect(&format!("Unable...
extern crate conch_parser; use conch_parser::ast::builder::*; use conch_parser::parse::ParseError::*; use conch_parser::token::Token; mod parse_support; use parse_support::*; #[test] fn test_subshell_valid() { let mut p = make_parser("( foo\nbar; baz\n#comment\n )"); let correct = CommandGroup { comm...
use crate::switch::ToCKBCellDataTuple; use crate::utils::verifier::verify_btc_witness; use crate::utils::{ config::{PLEDGE, SIGNER_FEE_RATE, SUDT_CODE_HASH, XT_CELL_CAPACITY}, transaction::{is_XT_typescript, XChainKind}, types::{mint_xt_witness::MintXTWitnessReader, Error, ToCKBCellDataView, XExtraView}, };...
#[doc = "Register `SAI_ACLRFR` writer"] pub type W = crate::W<SAI_ACLRFR_SPEC>; #[doc = "Field `COVRUDR` writer - COVRUDR"] pub type COVRUDR_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>; #[doc = "Field `CMUTEDET` writer - CMUTEDET"] pub type CMUTEDET_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>; #[d...
#[macro_use] extern crate derive_more; pub mod dmu_stream; pub mod fletcher4; pub mod lsm; pub mod split_tree;
use super::error::Result; use super::{error, Walker}; use rio_api::parser::TriplesParser; use rio_turtle::TurtleParser; use skorm_store::RdfStore; use std::fs::OpenOptions; use std::io::BufReader; use tracing::{debug, span, Level}; pub fn build_rdf_store(walker: &Walker) -> Result<RdfStore> { let curie = walker.buil...
use std::sync::atomic::Ordering; use counter::{Counter, AtomicCounter}; use sequence::{Sequence, Limit, MultiCache, CacheError, CommitError}; #[derive(Debug, Default)] pub struct Shared { claimed: AtomicCounter, count: AtomicCounter, } #[derive(Debug)] pub struct Cache { limit: Counter, } impl MultiCac...
use anyhow::Error; use reqwest::Client; use serde::de::DeserializeOwned; use telegram_types::bot::{methods::*, types::*}; #[derive(Debug)] pub struct Bot { token: String, client: Client, } impl Bot { pub fn new(token: &str) -> Self { Self { token: token.to_owned(), client: ...
use lazy_static::lazy_static; use syntect::highlighting::ThemeSet; use syntect::parsing::SyntaxSet; #[derive(Debug)] pub struct Highlighter { ps: syntect::parsing::SyntaxSet, ts: syntect::highlighting::ThemeSet, } pub fn highlight_lines(code: &String, ext: &String) -> Option<String> { lazy_static...
mod avatar; mod badge; mod bws; mod common; mod compare; mod country_snipe_list; mod country_snipe_stats; mod fix_score; mod graph; mod leaderboard; mod map; mod map_search; mod match_compare; mod match_costs; mod match_live; mod medal; mod medal_stats; mod medals_common; mod medals_list; mod medals_missing; mod most_p...
use crate::{ grid::records::{Records, RecordsMut}, settings::TableOption, }; /// Set a tab size. /// /// The size is used in order to calculate width correctly. /// /// Default value is 4 (basically 1 '\t' equals 4 spaces). /// /// IMPORTANT: The tab character might be not present in output, /// it might be re...
use std::ffi::CStr; use std::fmt; use std::marker::PhantomData; use std::os::raw::{c_int, c_uchar, c_void}; use std::ptr; use std::slice; use crate::error::{Error, Result}; use crate::panic; /// The result of a successful SOA lookup. #[derive(Debug)] pub struct SOAResult { soa_reply: *mut c_ares_sys::ares_soa_rep...
mod migrations; mod store; mod types; pub use store::{DefaultIndexerStore, IndexerStore}; pub use types::{CellTransaction, IndexerConfig, LiveCell, TransactionPoint};
use super::{deployment_process::DeploymentProcess, plan::Plan, recipe::DeploymentRecipe}; use crate::config::Deployment; use crate::util::ask_for_confirm; use crate::wallet::{cli_types::LiveCell, Wallet}; use anyhow::{anyhow, Result}; use chrono::prelude::*; use ckb_tool::ckb_types::core::{Capacity, TransactionView}; u...
pub use feelui_core::*; #[cfg(feature = "baseview")] pub use feelui_baseview::*;
extern crate stringly_typed_rust_esosyntax; use stringly_typed_rust_esosyntax::stringly_typed; stringly_typed!{"'ANSWER'id'i32'ty'42'int"const} fn main() { println!("The answer is {}!", ANSWER); }
use vec3::Vec3; use rand::{thread_rng, Rng}; pub fn random() -> f32 { thread_rng().gen_range(0.0, 1.0) } pub fn random_in_unit_sphere() -> Vec3 { let mut p: Vec3; loop { p = 2.0 * Vec3::new(random(), random(), random()) - Vec3::new(1.0, 1.0, 1.0); if p.squared_length() ...
use super::disk::*; static MAX_DATA_SIZE: u32 = 50; pub fn lift<'a, A: 'a, B: 'a>(f: Box<dyn Fn(A) -> B>) -> Box<dyn Fn(Option<A>) -> Option<B> + 'a> { Box::new(move |x| match x { Some(a) => Some(f(a)), _ => None, }) } pub fn lift_disk_action<'a, A: 'a, B: 'a>( f: Box<dyn Fn(A) -> DiskAct...
pub mod producer; pub mod producer_structs; pub mod producer_to_game;
use crate::traverse::{traverse, VisitedNode}; use log::debug; use std::fmt; use yaml_rust::Yaml; pub const SPLAT: &'static str = "**"; pub const CHILD_FILTER_DELIM: &'static str = "=="; #[derive(Debug, PartialEq)] pub enum ArrayIndices { Star, Indices(Vec<usize>), } #[derive(Debug, Clone, PartialEq)] pub str...
extern crate libc; #[link(name = "sodium",style="static")] extern "C" { fn sodium_init() -> i32; fn randombytes_buf(buf: *mut u8, size: libc::size_t); fn crypto_secretbox_xsalsa20poly1305_keybytes() -> libc::size_t; fn crypto_secretbox_xsalsa20poly1305_noncebytes() -> libc::size_t; fn crypto_secret...
use crate::error::{NiaServerError, NiaServerResult}; use crate::protocol::Serializable; use nia_protocol_rust::StopListeningRequest; #[derive(Debug, Clone, PartialEq, Eq)] pub struct NiaStopListeningRequest {} impl NiaStopListeningRequest { pub fn new() -> NiaStopListeningRequest { NiaStopListeningReques...
use crate::error::Result; use crate::{ compression::{create_codec, Codec}, read::{CompressedDataPage, Page, PageHeader}, }; fn compress_(buffer: &[u8], decompressor: &mut dyn Codec) -> Result<Vec<u8>> { let mut compressed_buffer = Vec::new(); decompressor.compress(buffer, &mut compressed_buffer)?; ...
#[doc = "Reader of register PIDR5"] pub type R = crate::R<u32, super::PIDR5>; #[doc = "Reader of field `PIDR5`"] pub type PIDR5_R = crate::R<u32, u32>; impl R { #[doc = "Bits 0:31 - peripheral ID5"] #[inline(always)] pub fn pidr5(&self) -> PIDR5_R { PIDR5_R::new((self.bits & 0xffff_ffff) as u32) ...
//! The world to be rendered. use crate::aabb::AABB; use crate::hittable::{HitRecord, Hittable}; use crate::ray::Ray; use crate::vec3; use crate::vec3::Vec3; use rand::prelude::*; /// The world that needs to be rendered, with all of its objects. Every object /// needs to implement `Hittable`. Coincidentally, this str...
//#![feature(plugin)] //#![plugin(bindgen_plugin)] //#[allow(dead_code, uppercase_variables, non_camel_case_types)] //#[plugin(bindgen_plugin)] //mod mysql_bindings { // bindgen!("/usr/include/mysql/mysql.h", match="mysql.h", link="mysql"); //} //use std::env; //use std::fs; //use std::path::Path; //use std:...
#[derive(PartialEq, PartialOrd, Clone, Copy)] pub struct Hertz(pub u32); #[derive(PartialEq, PartialOrd, Clone, Copy)] pub struct KiloHertz(pub u32); #[derive(PartialEq, PartialOrd, Clone, Copy)] pub struct MegaHertz(pub u32); // impl From<MegaHertz> for u32 { // fn from(value: MegaHertz) -> u32 { // value.0 // } //...
pub type c_char = i8; pub type size_t = usize; #[repr(u8)] pub enum c_void { // Two dummy variants so the #[repr] attribute can be used. #[doc(hidden)] __variant1, #[doc(hidden)] __variant2, }
use super::MarkSweep; use crate::plan::barriers::NoBarrier; use crate::plan::mutator_context::Mutator; use crate::plan::mutator_context::MutatorConfig; use crate::plan::AllocationSemantics as AllocationType; use crate::util::alloc::allocators::AllocatorSelector; use crate::util::alloc::allocators::Allocators; use crate...
use num_traits::{Float}; use rand::Rng; use rand_distr::Distribution; use crate::*; use super::*; pub use rand_distr::StandardNormal; /// Distribution that produces normalized Moebius transformation, i.e. `det() == 1`. pub struct Normalized; impl<U> Distribution<Moebius<U>> for StandardNormal where StandardNormal:...
#![allow(dead_code, unused_variables)] /* There are three main types of smart pointers: Box<T> for allocating values on the heap Rc<T> is a reference counting type that enables multiple ownership Ref<T> and RefMut<T>, accessed through RefCell<T> is a type that enforces borrowing rules at runtime. Many libraries h...
use crate::errors::SortOrderError; use anyhow::Result; use regex::Regex; use std::collections::HashMap; use std::fs; use std::path::MAIN_SEPARATOR; #[derive(PartialEq)] pub enum SortOrder { Asc, Desc, } pub enum Source { Regex(Regex, usize, Option<usize>), Map(Vec<(String, String)>), Sort(SortOrde...
extern crate rustc_serialize; use std::str::FromStr; #[derive(Clone, RustcEncodable, RustcDecodable)] pub struct Pet { pub id: u32, category: Category, name: String, photo_urls: Vec<String>, tags: Vec<Tag>, pub status: Status } #[derive(Clone, RustcEncodable, RustcDecodable)] pub struct Categ...
use crate::TableSchema; use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; /// Table implementation. #[derive(Serialize, Deserialize, Clone)] pub struct Table { /// Table name. pub name: String, /// Table id. pub id: u64, /// Table schema. pub schema: TableSchema, } ...
use super::*; pub fn expression() -> Expression { Expression { boostrap_compiler, typecheck, codegen, } } fn boostrap_compiler(_compiler: &mut Compiler) {} fn typecheck( resolver: &mut TypeResolver<TypecheckType>, _: &TypevarFunction, args: &Vec<TypeVar>, ) -> GenericResul...
use libc::c_char; use utils::logger::{EnabledCB, FlushCB, LibvcxLogger, LibvcxDefaultLogger, LogCB, LOGGER_STATE, CVoid}; use utils::cstring::CStringUtils; use utils::error::SUCCESS; use log::LevelFilter; use error::prelude::*; /// Set default logger implementation. /// /// Allows library user use `env_logger` logger ...
mod test; use std::collections::HashMap; use std::fmt; pub type Neighbour = Option<Box<Cell>>; // Cell #[derive(Eq, PartialEq, Clone, Debug)] pub struct Cell { pub row: i32, pub column: i32, pub north: Neighbour, pub south: Neighbour, pub east: Neighbour, pub west: Neighbour, pub connect...
//! Defines multihash codes for Subspace DSN. use std::error::Error; use subspace_core_primitives::PieceIndex; /// Type alias for libp2p Multihash. Constant 64 was copied from libp2p protocols. pub type Multihash = libp2p::multihash::Multihash<64>; /// Start of Subspace Network multicodec namespace /// https://githu...
use crate::{BoxFuture, CtxTransaction, Result}; use std::fmt::Debug; pub trait Entity: Send + Sync + 'static { type Key: Send + Sync; type TrackCtx: Debug + Sync; fn track_insert<'a>( &'a self, _key: &'a Self::Key, _old: Option<&'a Self>, _ctx: &'a mut CtxTransaction, ...
#[cfg(feature = "python")] pub mod py; mod test; use crate::math::inverse_newton_raphson; /// The Lennard-Jones link potential freely-jointed chain (Lennard-Jones-FJC) model thermodynamics in the isometric ensemble. pub mod isometric; /// The Lennard-Jones link potential freely-jointed chain (Lennard-Jone...
use nix::poll::*; use nix::unistd::{write, pipe}; #[test] fn test_poll() { let (r, w) = pipe().unwrap(); let mut fds = [PollFd::new(r, POLLIN, EventFlags::empty())]; let nfds = poll(&mut fds, 100).unwrap(); assert_eq!(nfds, 0); assert!(!fds[0].revents().unwrap().contains(POLLIN)); write(w, b"...
//! This modules contains both the `static_loader` and `ArcLoader` //! implementations, as well as the `Loader` trait. Which provides a loader //! agnostic interface. #[cfg(feature = "handlebars")] mod handlebars; #[cfg(feature = "tera")] mod tera; mod shared; use std::collections::HashMap; use fluent_bundle::conc...
use crate::bond::deposit_farm_share; use crate::contract::{handle, init, query}; use crate::mock_querier::{mock_dependencies, WasmMockQuerier}; use crate::state::read_config; use cosmwasm_std::testing::{mock_env, MockApi, MockStorage, MOCK_CONTRACT_ADDR}; use cosmwasm_std::{ from_binary, to_binary, CosmosMsg, Decim...
use crate::errors::*; use crate::types::*; use uuid::Uuid; use serde::de::{Deserialize, Deserializer}; use std::fmt::Debug; /// TRAIT | Describes the type of a URL linking to an internal Telegram entity pub trait TDTMeUrlType: Debug + RObject {} /// Describes the type of a URL linking to an internal Telegram entity ...
// This file is part of rdma-core. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/rdma-core/master/COPYRIGHT. No part of rdma-core, including this file, may be copied, modified, propagated, or distributed ...
use std::iter::{Enumerate, ExactSizeIterator}; use std::fmt::Display; use std::io::Write; use std::io; pub fn list<I, T>(iterator: Enumerate<I>) -> Option<usize> where I: ExactSizeIterator + Iterator<Item = T>, T: Display { for (index, display) in iterator { println!("{}: {}", index, display); }...
use pyo3::prelude::*; use pyo3::exceptions; use std::fs::File; use std::io::{BufReader, BufRead}; use std::collections::HashMap; use regex::Regex; use crate::alignment::{SeqMatrix, new_seqmatrix}; lazy_static! { static ref WHITESPACE_REGEX: Regex = Regex::new(r"\s+").unwrap(); } // FASTA file readers pub fn fa...
extern crate bodyparser; extern crate exonum; extern crate iron; extern crate router; extern crate serde; extern crate serde_json; use exonum::api::Api; use exonum::blockchain::Transaction; use exonum::messages::Message; use hyper::header::ContentType; use iron::headers::AccessControlAllowOrigin; use iron::prelude::*;...
use errors::TextDiagnostic; use rowan::TreeRoot; use crate::language::LanguageId; use crate::syntax_kind_set::IterableSyntaxKindSet; use crate::syntax_kind::SyntaxKind; use smol_str::SmolStr; use rowan::WalkEvent; pub mod algo; pub mod syntax; pub mod syntax_text;
use chrono::{Timelike, Utc}; pub fn youtube_api_key() -> &'static str { if Utc::now().hour() % 2 == 0 { env!("YOUTUBE_API_KEY0") } else { env!("YOUTUBE_API_KEY1") } }
fn main() { fn consume_with_relish<F:FnOnce()->String>(func: F) where F: FnOnce() -> String { println!("Consumed: {}", func()); println!("Super Happy I did it!"); } // fn once function always consume values whether it is in println form or in its variabl...
use crate::query::{parse, Query, OrderOperator}; use err_derive::Error; use std::any::type_name; use std::collections::HashMap; use std::str::FromStr; use nom::Err; type UtcDateTime = chrono::DateTime<chrono::Utc>; #[derive(Debug, Error, PartialEq)] pub enum Error { #[error(display = "invalid value for field \"{}...
use proc_macro2::Span; #[derive(Debug)] pub enum Error { UnsupportedExpr(Span), // UnsupportedMethod(Span), // UnsupportedStatement(Span), // UnsuportedClosureArgument(Span), // BlockMustHaveOneStatement(Span), // BadAttribute(Span), NotFound(Span), CouldNotConvertToExpression(Span), ...
use std::io::{BufRead, BufReader, BufWriter, Read, Seek, SeekFrom, Write}; use std::fmt; use crate::kv::Result; #[derive(Debug)] pub struct LogReader<T: Read> { pub reader: BufReader<T>, pub pos: u64, // the position of the log } impl<T: Read + Seek> LogReader<T> { pub fn new(mut reader: T) -> Result<Self> { ...
#[cfg(feature = "sputnik")] /// Abstraction over [Sputnik EVM](https://github.com/rust-blockchain/evm) pub mod sputnik; /// Abstraction over [evmodin](https://github.com/rust-blockchain/evm) #[cfg(feature = "evmodin")] pub mod evmodin; mod blocking_provider; pub use blocking_provider::BlockingProvider; use ethers::{...
use clap::{crate_authors, crate_description, crate_name, crate_version, App, AppSettings, Arg}; use std::error::Error; pub mod config; pub mod logging; pub mod subcommands; pub async fn execute() -> Result<(), Box<dyn Error>> { let app = subcommands::setup(app()); let app_m = app.get_matches(); let config...
use std::mem; use std::ptr::null_mut; use bincode; use flate2; use libc::c_void; use bw; use dat; use entity_serialize::{self, deserialize_entity, entity_serializable, EntitySerializable}; use save::{fread, fwrite, fread_num, fwrite_num, SaveError, LoadError, print_text}; use sprites::{ sprite_to_id_current_mappi...
// // https://www.snoyman.com/blog/2018/10/introducing-rust-crash-course // // https://doc.rust-lang.org/rust-by-example/scope/raii.html // https://doc.rust-lang.org/book // https://learnxinyminutes.com/docs/rust/ // https://science.raphael.poss.name/rust-for-functional-programmers.html // fn main() { let v: Vec<i...
// 给定一个由整数组成的非空数组所表示的非负整数,在该数的基础上加一。 // 最高位数字存放在数组的首位, 数组中每个元素只存储一个数字。 // 你可以假设除了整数 0 之外,这个整数不会以零开头。 // 示例 1: // 输入: [1,2,3] // 输出: [1,2,4] // 解释: 输入数组表示数字 123。 // 示例 2: // 输入: [4,3,2,1] // 输出: [4,3,2,2] // 解释: 输入数组表示数字 4321。 // struct Solution{} impl Solution { pub fn plus_one(digits: Vec<i32>) -> Vec<i32>...
use std::fmt; /// Standard datatype for saving position of object in space pub struct Coordinates { pub x: i32, pub y: i32, pub z: i32, } impl fmt::Display for Coordinates { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "[{},{},{}]", self.x, self.y, self.z) } } impl Coo...
use anyhow::{Context, Result}; use clap::ArgMatches; use crate::cfg::Cfg; use crate::cli::cfg::get_cfg; use crate::cli::settings::{Settings}; use crate::cli::terminal::message::success; pub fn r#use(app: &ArgMatches) -> Result<()> { let mut cfg = get_cfg()?; cfg.sync_local_to_global()?; let cfg = cfg; ...
// Copyright 2019 The vault713 Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or a...
#[cfg(test)] mod tests { use super::* ; #[test] fn it_works() { assert_eq!(2 + 2, 4); } #[test] fn test_add() { assert_eq!( 3, add(1,2)); } #[test] fn test_add_zero() { assert_eq!( 0, add(0,0)); } #[test] fn test_add_under_zero() { ...
use SmolCommon::component::*; use super::Entity; use bit_vec::BitVec; use std::iter::FilterMap; /// Stores components as a normal vector pub struct VecStorage<T>{ storage: Vec<Option<T>>, valid: BitVec, } impl<T> VecStorage<T>{ pub fn new() -> Self{ VecStorage{ storage: Vec::new(), ...
use std::{fmt, cmp}; use std::cmp::{PartialOrd, Ord, Ordering}; use std::hash::{Hash, Hasher}; use std::convert::TryFrom; use pct_str::PctStr; use crate::parsing; use super::Error; #[derive(Clone, Copy)] pub struct Fragment<'a> { /// The fragment slice. pub(crate) data: &'a [u8] } impl<'a> Fragment<'a> { #[inline]...
use crate::conversions::{GpuBuffer}; use cgmath::{Decomposed, Deg, Matrix4, Quaternion, Rotation3, Vector3, Vector4}; use std::mem::size_of; use wgpu::BufferUsageFlags; pub struct ModelGroup { pub name: String, pub index_buf: GpuBuffer, pub vertex_buf: GpuBuffer, pub bind_group: wgpu::BindGroup, pu...
#![feature(proc_macro_diagnostic, proc_macro_span)] #![feature(core_intrinsics, decl_macro)] #![recursion_limit="256"] extern crate syn; extern crate proc_macro; extern crate proc_macro2; #[macro_use] extern crate quote; extern crate rocket; mod parser; mod spanned; mod ext; use parser::Result as PResult; use proc_m...
//! Fast, but limited allocator. use std::mem; use std::ops::{Index, IndexMut}; use std::vec::Vec; /// A struct representing an entry to `TypedArena<T>` #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub struct Entry { chunk_index: usize, block_index: usize, } enum Block<T> { Occupied(T), Vacant(Option...
//! # GSync //! GSync is a tool to help you stay backed up. It does this by synchronizing the folders you want to Google Drive, while respecting .gitignore files //! //! ## Installation //! You've got two options to install GSync //! //! 1. Preferred method: Via crates.io: `cargo install gsync` //! 2. Via GitHub: [Rele...
// q0125_valid_palindrome struct Solution; impl Solution { pub fn is_palindrome(s: String) -> bool { let s: Vec<char> = s .chars() .filter(char::is_ascii_alphanumeric) .map(|c| { if c.is_uppercase() { c.to_ascii_lowercase() ...
use nom::{be_u8,be_u32,IResult,Needed,Err,ErrorKind}; use std::str::from_utf8; /// Recognizes big endian unsigned 4 bytes integer #[inline] pub fn be_u24(i: &[u8]) -> IResult<&[u8], u32> { if i.len() < 3 { IResult::Incomplete(Needed::Size(3)) } else { let res = ((i[0] as u32) << 16) + ((i[1] as u32) << 8) ...
extern crate yada; use yada::builder::DoubleArrayBuilder; use yada::DoubleArray; fn main() { // make a keyset which have key-value pairs let keyset = &[ ("a".as_bytes(), 0), ("ab".as_bytes(), 1), ("abc".as_bytes(), 2), ("b".as_bytes(), 3), ("bc".as_bytes(), 4), ...
use ansi_term::Colour::Red; use std::io; use std::io::Write; fn print_before_read(text: &Option<String>) { match text { Some(text) => { print!("{}", text); io::stdout().flush().unwrap(); } None => {} }; } pub fn read_number(text: Option<String>) -> i32 { loo...
//! An implementation of the [BLAKE2][1] hash functions. //! //! Based on the [work][2] of Cesar Barros. //! //! # Usage //! //! An example of using `Blake2b` is: //! //! ```rust //! use blake2::{Blake2b, Digest}; //! //! // create a Blake2b object //! let mut hasher = Blake2b::default(); //! //! // write input message...
use project::Project; #[derive(Serialize, Deserialize, Debug, Default, Clone, Eq, PartialEq)] pub struct IndexProject { pub id: String, pub project_folder: String, pub image_name: String, pub title: String, pub b_w: bool, } impl IndexProject { pub fn from(proj: &Project) -> IndexProject { ...
use assembly_xml::universe_config::Environment; fn main() { let mut args = std::env::args(); let _self = args.next().unwrap(); let file = args.next().unwrap(); println!("{}", file); let xml = std::fs::read_to_string(&file).unwrap(); let data: Environment = quick_xml::de::from_str(&xml).unwrap()...
use comet::immix::Immix; use comet::immix::ImmixOptions; use comet::mutator::MutatorRef; use kompact::prelude::*; pub struct Runtime { pub system: KompactSystem, } impl Runtime { pub fn new() -> Self { let system = KompactConfig::default().build().unwrap(); Self { system } } } impl Defaul...
use env_logger::Builder; use log::LevelFilter; use stainless_ffmpeg::probe::*; use std::env; fn main() { let mut builder = Builder::from_default_env(); builder.init(); if let Some(path) = env::args().last() { let mut probe = Probe::new(&path); probe.process(LevelFilter::Off).unwrap(); let result = s...
// ------ RCC Clock Frequency related ------------------------- // // For the `HSI` (High-Speed Internal clock signal), it's an // internal 16 MHz RC oscillator. // // For the `HSE` (High-Speed External clock signal), usually, // it's external onboard oscillator hardware with the fixed // working frequency. Make sure y...
use crate::ffmpeg::{ TransitionFunc, Size }; pub struct AlphaBlend; pub struct Vertical; impl TransitionFunc for AlphaBlend { fn calc(&self, alpha: f32, img1: &Vec<u8>, img2: &Vec<u8>, _size: &Size) -> Vec<u8> { // create output vector with image size let mut r = vec![0; img1.len()]; // it...
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * 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. */ //! Serialization support for timespec structs. use serde::Deserialize; use serde::Serialize; ///...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - CEC control register"] pub cec_cr: CEC_CR, #[doc = "0x04 - This register is used to configure the HDMI-CEC controller. It is mandatory to write CEC_CFGR only when CECEN=0."] pub cec_cfgr: CEC_CFGR, #[doc = "0x08 - CEC T...
use syn::Attribute; use syn::Lit; use syn::Meta; pub fn get_docs(attrs: &Vec<Attribute>) -> String { let mut doc: Vec<String> = vec![]; for attr in attrs { if let Ok(Meta::NameValue(meta)) = attr.parse_meta() { if !meta.path.is_ident("doc") { continue; } if let Lit::Str(lit) = meta.li...
use serde::Serialize; use super::schema::{events, hands, cards}; #[derive(Debug, Serialize, Queryable)] pub struct Event { pub id: i32, pub year: i32, pub circa: bool, pub description: String, } #[derive(Debug, Clone, Copy, Queryable)] pub struct Hand { pub id: i32, pub session_hash: i32, ...
#[doc = "Register `ECCR` reader"] pub type R = crate::R<ECCR_SPEC>; #[doc = "Register `ECCR` writer"] pub type W = crate::W<ECCR_SPEC>; #[doc = "Field `ADDR_ECC` reader - ECC fail address"] pub type ADDR_ECC_R = crate::FieldReader<u32>; #[doc = "Field `BK_ECC` reader - BK_ECC"] pub type BK_ECC_R = crate::BitReader; #[d...
use super::{StreamReader, StreamBuilder}; /// provides types with serialization functions pub trait Serializeable { /// deserializes a byte array into a type fn deserialize(&mut self, reader: &StreamReader); /// serializes a type into a byte array fn serialize(&self, builder: &mut StreamBuilder); }
pub mod acceptxmr; pub mod amplifier_optimizer; pub mod archviz; pub mod mnist_tutorial; pub mod quadcopter; pub mod this_website; // Remember, all bindgen functions must be unique and in base scope. pub use acceptxmr::*; pub use amplifier_optimizer::*; pub use archviz::*; pub use mnist_tutorial::*; pub use quadcopter...
mod game; mod input; fn main() { let mut board = input::init(); let _board = &mut board; _board.print(); input::get_command(_board); }
fn main() { println!("Hello, world!"); let a = 1; println!("原变量值:{}",a); let a = a+1; println!("声明同名变量隐藏a原来的值,去原来的值加1,最后值:{}",a); let mut m="hello"; let mut n=m.clone(); println!("m original value:{}",m); println!("n original value:{}",n); n="ok"; println!("m original...
#![allow(incomplete_features)] #![feature(generic_associated_types)] #![feature(const_generics)] pub mod opencv;
use { std::{env, path::PathBuf, process}, structopt::StructOpt, util::Result, }; const SUPPORTED_ARCHES: [&str; 2] = ["x86_64", "aarch64"]; #[derive(StructOpt)] struct Opt { #[structopt(subcommand)] subcommand: Subcommand, } #[derive(StructOpt)] enum Subcommand { /// create a single-file exec...
pub mod push_down_automaton; pub mod tree_stack_automaton;
use std::convert::TryInto; use std::io::{self, BufRead}; fn modinv(a: isize, module: isize) -> isize { let mut mn = (module, a); let mut xy = (0, 1); while mn.1 != 0 { xy = (xy.1, xy.0 - (mn.0 / mn.1) * xy.1); mn = (mn.1, mn.0 % mn.1); } while xy.0 < 0 { xy.0 += module; ...
fn main() { // 一般的な四則演算子 let a = 20 + 10 ; println!("a is {}", a ); let a = 20 - 10 ; println!("a is {}", a ); let a = 20 * 10 ; println!("a is {}", a ); let a = 20 / 10 ; println!("a is {}", a ); let a = 20 % 3 ; println!("a is {}", a ); // 割り算で整数と実数の違い let a = 10 ;...
use crate::constants::{CURVE_ORDER, GROUP_G1_SIZE, FIELD_ORDER_ELEMENT_SIZE}; use crate::errors::{SerzDeserzError, ValueError}; use crate::curve_order_elem::{CurveOrderElement, CurveOrderElementVector}; use crate::group_elem::{GroupElement, GroupElementVector}; use crate::types::{GroupG1, FP, BigNum}; use crate::utils:...