text
stringlengths
8
4.13M
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Control register 1"] pub cr1: CR1, #[doc = "0x04 - Control register 2"] pub cr2: CR2, #[doc = "0x08 - Own address register 1"] pub oar1: OAR1, #[doc = "0x0c - Own address register 2"] pub oar2: OAR2, #[d...
#![cfg(any(feature = "hash_md5", feauture = "hash_sha1"))] use std::convert::TryInto; use md5; use sha1::Sha1; use crate::{Layout, Node, Variant, Version, UUID}; impl Layout { fn hash_fields(hash: [u8; 16], v: Version) -> Self { Self { field_low: ((hash[0] as u32) << 24) | (h...
use std::process::ExitStatus; use std::os::unix::process::ExitStatusExt; pub fn clear_screen() { print!( "\x1B[2J\x1B[H" ); } pub unsafe fn disable_ctrl_c() { // TODO } pub fn get_exit_code( status: ExitStatus ) -> Option<i32> { match status.code() { Some( x ) => Some( x ), None => status...
use std::env; use std::process; use std::fs::File; use std::io; use std::io::Read; fn get_file_string(filename: &str) -> Result<String, io::Error> { let mut file = try!(File::open(filename)); let mut s = String::new(); try!(file.read_to_string(&mut s)); Ok(s) } fn main() { let args = env::args()....
struct Solution; use std::collections::HashMap; impl Solution { pub fn find_itinerary(tickets: Vec<Vec<String>>) -> Vec<String> { // 转成 map,出发点是 key,终点列表是 value,并且 value 是排序了的。 let mut map = HashMap::new(); for mut ticket in tickets.into_iter() { let values = map.entry(ticket.r...
use crate::lib::canister_info::{CanisterInfo, CanisterInfoFactory}; use crate::lib::error::DfxResult; use std::path::{Path, PathBuf}; pub struct MotokoCanisterInfo { input_path: PathBuf, output_root: PathBuf, idl_path: PathBuf, output_wasm_path: PathBuf, output_idl_path: PathBuf, output_did_js...
use super::*; pub async fn analyze_one_inner( analysis_id: &String, sender: &Sender<RealTimeMessage>, temp_path: &PathBuf, ) -> Option<()> { send_stage(Stage::InitializeAnalysis, StageResult::Pending, sender).ok()?; let a = match get_analysis_package(analysis_id) { Some(v) => v, Non...
#[doc = "Register `PLLSAICFGR` reader"] pub type R = crate::R<PLLSAICFGR_SPEC>; #[doc = "Register `PLLSAICFGR` writer"] pub type W = crate::W<PLLSAICFGR_SPEC>; #[doc = "Field `PLLSAIN` reader - PLLSAI division factor for VCO"] pub type PLLSAIN_R = crate::FieldReader<u16>; #[doc = "Field `PLLSAIN` writer - PLLSAI divisi...
macro_rules! remove_overriden { (@remove $_self:ident, $v:ident, $a:ident.$ov:ident) => { if let Some(ref ora) = $a.$ov { vec_remove_all!($_self.$v, ora); } }; (@arg $_self:ident, $arg:ident) => { remove_overriden!(@remove $_self, required, $arg.requires); remove_...
/// NotificationSubject contains the notification subject (Issue/Pull/Commit) #[derive(Debug, Default, Clone, Serialize, Deserialize)] pub struct NotificationSubject { pub latest_comment_url: Option<String>, pub state: Option<String>, pub title: Option<String>, #[serde(rename = "type")] pub type_: ...
use byteorder::{ByteOrder, NativeEndian}; use crate::{ traits::{Emitable, Parseable}, DecodeError, Field, }; const FORWARDING: Field = 0..4; const MC_FORWARDING: Field = 4..8; const PROXY_ARP: Field = 8..12; const ACCEPT_REDIRECTS: Field = 12..16; const SECURE_REDIRECTS: Field = 16..20; const SEND_REDIRECTS: ...
#![recursion_limit="1024"] // limit the recursion depth of the html! macro mod helper; mod clock; mod form; use wasm_bindgen::prelude::*; use yew::prelude::*; use yew::services::{Task, IntervalService, ConsoleService}; use helper::{hours, minutes, seconds}; use clock::Clock; use form::Form; use wasm_bindgen::__rt::co...
extern crate opencv; use opencv::{calib3d::*, core::*, highgui::*, imgcodecs::*, prelude::*, types::*, videoio::*}; use std::{thread, time}; use crate::errors::Error; use crate::utils::*; const BOARD_VERTICES_W: u8 = 9; const BOARD_VERTICES_H: u8 = 5; const BOARD_SQUARE_LENGTH: f32 = 0.13; // in meters const REQUIRED...
//! # Tendermock Builder API //! //! This modules holds the builder API, which can be use to create and start a mocked chain easily. //! //! It is the public API for interacting with Tendermock. use std::net::SocketAddr; use std::path::Path; use futures::future::try_join_all; use futures::try_join; use crate::config...
pub mod quadric;
extern crate gl; use std::error::Error; use std::option::NoneError; use std::fmt; use std; #[derive(Debug)] pub struct GlError(String); pub type Result<T> = std::result::Result<T, GlError>; pub fn validate_gl() -> Result<()> { if let Some(err) = get_error() { Err(GlError::new(err)) } else { O...
#[doc = "Reader of register TX_EN_EXT_DELAY"] pub type R = crate::R<u32, super::TX_EN_EXT_DELAY>; #[doc = "Writer for register TX_EN_EXT_DELAY"] pub type W = crate::W<u32, super::TX_EN_EXT_DELAY>; #[doc = "Register TX_EN_EXT_DELAY `reset()`'s with value 0x1345"] impl crate::ResetValue for super::TX_EN_EXT_DELAY { t...
mod trig; #[cfg(test)] mod tests { use trig; #[test] fn test_sin() { assert!(trig::sin(0.0) == 0.0); } #[test] fn test_cos() { assert!(trig::cos(0.0) == 1.0); } #[test] fn test_tan() { assert!(trig::tan(0.0) == 0.0); } }
use crate::models::AccessionNumber; use crate::postgres::*; use crate::sec_entry::{FilingType, SECEntry}; use regex::Regex; use std::collections::HashSet; use xml::reader::{EventReader, XmlEvent}; use crate::errors::*; const NUM_ENTRY_ELEMENTS: usize = 4; pub fn read_rss(xml: &str, ignore: HashSet<FilingType>) -> Re...
use ferris_base; mod utils; #[test] // Baba is you: Space 6 fn blocked_by_stop() { let start = vec![ "......🦀..🦀..", "......🧱🧱🧱..", "Wa==St........", "Fe==Fa&&U ....", ]; let inputs = vec![ferris_base::core::direction::Direction::RIGHT]; let end = vec![ ".....
use crate::{callbacks, types::{self, adapter}, utils}; use super::auto::{HasInner, Abstract}; use super::container::{Container, ContainerInner, AContainer}; use super::control::{Control, AControl, ControlBase, ControlInner}; use super::member::{Member, AMember, MemberBase}; define_abstract! { Adapted: Con...
use std::path::Path; use tera::Tera; use crate::Site; use config::Config; use errors::{bail, Error, Result}; use templates::{filters, global_fns, PEPEL_TERA}; use utils::templates::rewrite_theme_paths; pub fn load_tera(path: &Path, config: &Config) -> Result<Tera> { let tpl_glob = format!("{}/{}", path.t...
use nix::unistd::{getegid, geteuid, getgid, getuid, setegid, seteuid, Gid, Uid}; use std::error::Error; #[derive(Debug, Clone)] pub struct ExecutionContext { pub is_suid: bool, pub is_sgid: bool, pub uid: Uid, pub euid: Uid, pub gid: Gid, pub egid: Gid, } impl Default for ExecutionContext { ...
use pretty_assertions::assert_eq; use super::*; use crate::ast::tests::Locator; #[test] fn regex_literal() { let mut p = Parser::new(r#"/.*/"#); let parsed = p.parse_file("".to_string()); let loc = Locator::new(&p.source[..]); assert_eq!( parsed, File { base: BaseNode { ...
#[doc = "Register `VOSCR` reader"] pub type R = crate::R<VOSCR_SPEC>; #[doc = "Register `VOSCR` writer"] pub type W = crate::W<VOSCR_SPEC>; #[doc = "Field `VOS` reader - voltage scaling selection according to performance These bits control the V&lt;sub>CORE&lt;/sub> voltage level and allow to obtain the best trade-off ...
#[doc = "Register `FDCAN_TXEFC` reader"] pub type R = crate::R<FDCAN_TXEFC_SPEC>; #[doc = "Register `FDCAN_TXEFC` writer"] pub type W = crate::W<FDCAN_TXEFC_SPEC>; #[doc = "Field `EFSA` reader - EFSA"] pub type EFSA_R = crate::FieldReader<u16>; #[doc = "Field `EFSA` writer - EFSA"] pub type EFSA_W<'a, REG, const O: u8>...
use super::super::{ program::MaskCheckProgram, webgl::{WebGlF32Vbo, WebGlI16Ibo, WebGlRenderingContext}, ModelMatrix, }; use crate::block::{self, BlockId}; use ndarray::Array2; pub struct AreaCollectionRenderer { vertexis_buffer: WebGlF32Vbo, texture_coord_buffer: WebGlF32Vbo, index_buffer: Web...
use base64ct::{Base64Unpadded, Encoding}; fn main() { for ex in &["Mi", "Mg"] { println!("--- {} ---", ex); let a = base64::decode(ex); let b = Base64Unpadded::decode_vec(ex); println!("base64: {:?}", a); println!("base64ct: {:?}", b); } }
// Copyright 2014-2018 The Rust 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>,...
use hyper::{Client, Response}; use tokio::runtime::Runtime; use hyper::Error; use std::convert::TryInto; use hyper::client::HttpConnector; use hyper::body::Body; use std::borrow::Borrow; use hyper::http::response::Parts; type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; pub fn new_eng...
use indoc::indoc; pub const DEFAULT_CONFIG_SETTINGS: &str = indoc!( " # The number of seconds in a break. break_duration_seconds = 600 # 10 minutes # The number of seconds in between breaks. seconds_between_breaks = 3000 # 50 minutes # Whether or not to use idle detection. # # If set ...
use std::collections::HashMap; use std::pin::Pin; use std::sync::Arc; use futures::{ future::{poll_fn, select}, pin_mut, FutureExt, Sink, }; use crate::{ client::{watch_for_client_state_change, Broadcast, Client, ClientTaskTracker}, error::WampError, proto::TxMessage, transport::Transport, ...
extern crate reqwest; extern crate scraper; extern crate select; use select::document::Document; use select::predicate::{Class, Name, Predicate}; use scraper::{Html, Selector}; fn main() { println!("\n{}\n", "*. Hacker news headlines"); // assert!(hacker_news("https://news.ycombinator.com").is_ok()); // ...
#![deny(warnings)] use embedded_hal::can::ExtendedId; use embedded_time::Clock; use uavcan::{ session::StdVecSessionManager, time::StdClock, transfer::Transfer, transport::can::{Can, CanFrame as UavcanFrame, CanMetadata}, types::TransferId, Node, Priority, StreamingIterator, Subscription, Trans...
use super::constants::*; use super::waves::*; #[derive(Clone, Copy)] pub struct SamplingContext { pub clock: f32, pub sample_rate: f32, } pub trait Node: Send { fn sample (&self, ctx: &SamplingContext) -> f32; } pub enum WaveType { Sine, Square, Sawtooth, Triangle } pub struct WaveGenera...
use reqwest::{header, Client}; use serde::Deserialize; use std::collections::HashMap; use thiserror::Error; #[derive(Error, Debug)] pub enum EmojiListError { #[error("invalid token was passed: {0}")] InvalidTokenPassed(header::InvalidHeaderValue), #[error("reqwest client couldn't be built: {0}")] Clien...
#![cfg(test)] use super::{super::EntityStorage, *}; #[test] fn test_insertion() { let mut entities = EntityStorage::with_key(); let mut storage = ComponentStorage::new(); let entity = entities.insert(()); let component = "foo"; assert_eq!(storage.insert(entity, component), None); assert!(sto...
#[macro_use] extern crate rocket; #[macro_use] extern crate lazy_static; #[macro_use] extern crate rbatis; use example::BizActivity; use rbatis::crud::{CRUD}; use rbatis::rbatis::Rbatis; //mysql driver url pub const MYSQL_URL: &'static str = "mysql://root:123456@localhost:3306/test"; // init global rbatis pool lazy_sta...
use super::*; use crate::{mock::*, Error}; use frame_support::{assert_noop, assert_ok}; #[test] fn test_create_kitty_success() { new_test_ext().execute_with(|| { System::set_block_number(10); assert_ok!(KittiesModule::create_kitty(Origin::signed(1))); }); } #[test] fn test_transfer_kitty_succes...
#![feature(fs, io, path)] use std::process::Command; use std::io::Write; use std::fs::{ rename, OpenOptions }; use std::path::PathBuf; use std::env; extern crate gcc; fn main() { let config = &[ format!("--target={}", env::var("TARGET").unwrap()), format!("--host={}", env::var("HOST").unwrap()), ]; let dir =...
/// /// 回文 /// pub fn palindrome_str_low() { println!("wow this palindrome test!"); let s = String::from("daaad"); let mut _index = 0; let mut _iner_index = 0; let mut _len = s.len(); println!("str len:{}", &_len); for _index in 0..s.len() { let mut _index_str = &s[_index.._index +...
fn main() { let s = "15cm"; println!("{}", s.split("cm").next().unwrap()); }
use arch::io; const CONFIG_ADDRESS: u16 = 0xCF8; const CONFIG_DATA: u16 = 0xCFC; /// Read from PCI config space pub unsafe fn pci_readcfg(bus: u32, dev: u32, func: u32, offset: u32) -> u32 { let address = 0x80000000u32 | (bus << 16) | (dev << 11) | (func << 8) | (offset & 0xfc); io::outl(CONFIG_ADDRESS, addre...
// Copyright 2018-2020 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate 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) a...
#[doc = "Register `CREL` reader"] pub type R = crate::R<CREL_SPEC>; #[doc = "Register `CREL` writer"] pub type W = crate::W<CREL_SPEC>; #[doc = "Field `DAY` reader - Time Stamp Day"] pub type DAY_R = crate::FieldReader; #[doc = "Field `DAY` writer - Time Stamp Day"] pub type DAY_W<'a, REG, const O: u8> = crate::FieldWr...
use protocol::serde_am::*; #[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Hash)] #[cfg_attr(features = "serde", derive(Serialize, Deserialize))] pub struct Upgrades { pub speed: u8, pub shield: bool, pub inferno: bool, } impl Serialize for Upgrades { fn serialize(&self, ser: &mut Serializer) -> Result<(), S...
pub type c_char = i8; pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; pub type c_ushort = u16; pub type c_int = i32; pub type c_uint = u32; pub type c_long = i32; pub type c_ulong = u32; pub type c_float = f32; pub type c_double = f64; pub type size_t = u32; pub type ptrdiff_t = i32; pub type cloc...
fn main() { let mut v = vec![1, 2, 3]; v.push(4); println!("{:?}", v); // let fourth = v[3]; // let fifth = & v.get(4); // println!("{:?}",fifth); for i in &mut v { println!("{}", i); *i *= 2; } println!("{:?}", v); for c in "नमस्ते".chars() { println!("{}",...
use std; use std::error::Error; use std::io::Read; use hyper; use hyper::Client; use hyper::client::RequestBuilder; use hyper::client::pool::{Config, Pool}; use hyper::client::response::Response; #[cfg(feature="ssl")] use hyper::net::HttpsConnector; #[cfg(feature="ssl")] use hyper::net::Openssl; #[cfg(feature="unix")...
extern crate bitcoinrs_bytes; mod sha2; mod rand; pub use self::sha2::sha256; pub use self::rand::xorshift32;
use rand::{thread_rng, RngCore}; #[repr(C)] struct Mouth {} impl Mouth { /* * Note: Currently just spouts random data * */ pub fn speak() -> Vec<u8> { let mut data = [u8; random_number(5,50) ]; // each time we don't speak same amount of things... hai na :D thread_rng().fill...
//! Overflow-safe utilities for tracking JSON document depth. use super::error::DepthError; use std::{ fmt::Display, ops::{Add, Deref, Sub}, }; /// Overflow-safe thin wrapper for a [`u8`] depth counter. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Depth(u8); impl Dep...
use crate::mac::Poly1305; use crate::mem::constant_time_eq; mod chacha20; use self::chacha20::Chacha20; /// ChaCha20 and Poly1305 for OpenSSH Protocols (chacha20-poly1305@openssh.com) /// /// <https://github.com/openbsd/src/blob/master/usr.bin/ssh/PROTOCOL.chacha20poly1305> #[derive(Clone)] pub struct Chacha20Poly130...
#[aoc_generator(day2, part1)] pub fn parse_program(input: &str) -> Vec<usize> { input .split(',') .map(|i| i.parse::<usize>().unwrap()) .collect() } fn run_tape(mut tape: Vec<usize>) -> Vec<usize> { let mut i = 0; loop { match tape[i] { 1 => { let...
#[doc = "Register `MACMDIOAR` reader"] pub type R = crate::R<MACMDIOAR_SPEC>; #[doc = "Register `MACMDIOAR` writer"] pub type W = crate::W<MACMDIOAR_SPEC>; #[doc = "Field `MB` reader - MII Busy"] pub type MB_R = crate::BitReader; #[doc = "Field `MB` writer - MII Busy"] pub type MB_W<'a, REG, const O: u8> = crate::BitWr...
fn main() { prost_build::compile_protos(&["src/worker/schema/dht.proto"], &["src/worker/schema"]).unwrap(); }
mod block_template; mod blockchain; mod bytes; mod cell; mod net; mod pool; mod proposal_short_id; mod trace; pub type BlockNumber = String; pub type Capacity = String; pub type Cycle = String; pub use self::block_template::{ BlockTemplate, CellbaseTemplate, TransactionTemplate, UncleTemplate, }; pub use self::bl...
//! Angles. use std::{f64::consts::PI, ops::*}; /// Wrapper type storing angle expressed in radians. /// /// ``` /// use veccentric::{Angle, Angular}; /// /// let half_pi: Angle = (3.14_f32 / 2.0).rad(); /// ``` #[derive(Copy, Clone, PartialEq, Default, Debug)] pub struct Angle(f64); impl Deref for Angle { type ...
mod cache; mod config; pub mod data_loader_wrapper; mod db; mod snapshot; mod store; mod transaction; pub use cache::StoreCache; pub use config::StoreConfig; pub use db::ChainDB; pub use snapshot::StoreSnapshot; pub use store::ChainStore; pub use transaction::StoreTransaction; use ckb_db::Col; pub const COLUMNS: u32...
#![feature(min_const_fn)] extern crate stringly_typed_rust_esosyntax; use stringly_typed_rust_esosyntax::stringly_typed; const fn to_string(n: i32) -> String { format!("{}", n) } stringly_typed!{"'N'id'String'ty'"to_string"id"69"int'call"const} fn main() { println!("N = {}!", N); }
//! The `Fuzzer` is the main struct for a fuzz campaign. use crate::{ bolts::current_time, corpus::{Corpus, CorpusScheduler, Testcase}, events::{Event, EventFirer, EventManager}, executors::{Executor, ExitKind, HasExecHooksTuple, HasObservers, HasObserversHooks}, feedbacks::Feedback, inputs::In...
#[allow(unused_imports)] use super::prelude::*; type Input = Vec<((i32, i32), u32)>; pub fn input_generator(input: &str) -> Input { let mut paths = Vec::new(); for line in input.lines() { let mut current = (0i32, 0i32); let mut points = HashMap::new(); let mut distance = 0u32; ...
// ANCHOR: struct #[derive(Serialize, Deserialize, Debug)] pub struct BlogPost { pub title: String, pub body: String, pub category: Option<String>, } // ANCHOR_END: struct // ANCHOR: view pub trait BlogPostsByCategory { type Collection = BlogPost; type Key = Option<String>; type Value = u32; ...
use std::{ fmt::{Display, Formatter}, io::{BufWriter, ErrorKind, Read}, io, net::{SocketAddr, TcpListener, TcpStream}, sync::mpsc::{channel, Receiver, Sender, SendError, TryRecvError}, thread::{JoinHandle, sleep}, time::Duration, }; use crate::{ Direction::{Inbound, Outbound}, Direc...
#[doc = "Register `APB3LPENR` reader"] pub type R = crate::R<APB3LPENR_SPEC>; #[doc = "Register `APB3LPENR` writer"] pub type W = crate::W<APB3LPENR_SPEC>; #[doc = "Field `SBSLPEN` reader - SBS clock enable during sleep mode Set and reset by software."] pub type SBSLPEN_R = crate::BitReader; #[doc = "Field `SBSLPEN` wr...
use crate::config::dfinity::Config; use crate::lib::builders::{ BuildConfig, BuildOutput, BuilderPool, CanisterBuilder, IdlBuildOutput, WasmBuildOutput, }; use crate::lib::canister_info::CanisterInfo; use crate::lib::environment::Environment; use crate::lib::error::{BuildError, DfxError, DfxResult}; use crate::lib:...
fn main() { let s1 = gives_ownership(); let s1_len = calculate_length(&s1); // does not take ownership of s1 println!("length of {} (s1): {}", s1, s1_len); // s1 can still be used! let s2 = String::from("hello"); let s3 = takes_and_gives_back(s2); takes_ownership(s3); // s3 was moved, owner...
use rand::Rng; #[cfg(feature = "parallel")] use rayon::prelude::*; use subspace_archiving::archiver::Archiver; use subspace_archiving::piece_reconstructor::{PiecesReconstructor, ReconstructorError}; use subspace_core_primitives::crypto::kzg::{embedded_kzg_settings, Kzg}; use subspace_core_primitives::objects::BlockObje...
//! Fearless [Concurrency] //! //! [concurrency]: https://doc.rust-lang.org/book/ch16-00-concurrency.html pub mod sec03;
use std::fs; use crate::poc::PocMap; use crate::prelude::*; use askama::Template; use structopt::StructOpt; #[derive(Debug, StructOpt, Template)] #[template(path = "new_poc.rs", escape = "none")] pub struct AddArgs { #[structopt(name = "crate", help = "target crate name")] krate: String, #[structopt( ...
pub mod instruction; pub mod opcode;
use std::io::{self}; fn transform_input(file_content: &Vec<String>) -> Vec<usize> { let helper: Vec<usize> = file_content[0] .split(",") .collect::<Vec<_>>() .iter() .map(|x| x.parse::<usize>().unwrap()) .collect(); let mut state = vec![0; 9]; for el in helper { ...
use std::fs; pub mod ast; pub mod text_tree; pub fn parse_file(filename: &str) -> Result<ast::Program, String> { let text = fs::read_to_string(filename).expect("failed to read file"); let parser = text_tree::ProgramParser::new(); dbg!(parser.parse(&text) .map_err(|e| e.to_string())) }
#[cfg(feature = "autoload")] pub mod autoload; pub mod sna;
#![allow(dead_code)] pub const ROUTE_RXPEN: u32 = 0x1 << 0; pub const ROUTE_TXPEN: u32 = 0x1 << 1; pub const ROUTE_CSPEN: u32 = 0x1 << 2; pub const ROUTE_CLKPEN: u32 = 0x1 << 3; pub const ROUTE_LOCATION_MASK: u32 = 0x700; pub const ROUTE_LOCATION_LOC0: u32 = 0x0 << 8; pub const ROUTE_LOCATION_LOC1: u32 = 0x1 << 8; pu...
mod inventory; #[macro_use] extern crate prettytable; use std::error::Error; use std::{io, fmt}; use std::process; use std::fs::File; use serde::Deserialize; use prettytable::{Table, Cell}; use prettytable::format; use prettytable::format::Alignment; use crate::inventory::Inventory; use prettytable::{color}; use chron...
//! Strategies for merging disk-resident sorted runs of data. mod leveled; mod size_tiered; pub use self::leveled::LeveledStrategy; pub use self::size_tiered::SizeTieredStrategy; use lsm_tree::{Result, SSTable, SSTableValue}; use std::path::Path; /// An iterator for the disk-resident data. pub type CompactionIter<T...
#[macro_use] extern crate cpython; use cpython::{Python, PyResult}; /// This will generate a method named PyInit_hello which will be called when /// Python loads the library. The actual name should be PyInit_<library> /// where <library> is the library name. For example if your library is named /// lab3 then you woul...
use bit_field::BitField; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] pub struct VirtAddr(usize); impl VirtAddr { #[cfg(riscv32)] pub fn new(addr: usize) -> VirtAddr { VirtAddr(addr) } #[cfg(riscv64)] pub fn new(addr: usize) -> VirtAddr { if addr.get_bit(47) { ...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Control"] pub ctl: CTL, _reserved1: [u8; 12usize], #[doc = "0x10 - Clock control"] pub clock_ctl: CLOCK_CTL, _reserved2: [u8; 12usize], #[doc = "0x20 - Command"] pub cmd: CMD, _reserved3: [u8; 28usize], ...
use markdown::mdast::{Node, Root}; pub(crate) trait IntoPlainText { fn plain_text(&self) -> String; } impl IntoPlainText for Node { fn plain_text(&self) -> String { fn blank() -> String { "".to_string() } fn surround_with(surround_token: &str, inner: String) -> String { ...
use std::{io, path::Path}; pub use directory::Directory; pub use directory::MmapDirectory; pub use directory::RamDirectory; use ownedbytes::OwnedBytes; use crate::util::{Ext, SetExt}; pub fn load_data_pair(directory: &Box<dyn Directory>, path: &Path) -> Result<(OwnedBytes, OwnedBytes), io::Error> { let data_path...
//! This module contains a Margin settings of a [`Table`]. //! //! # Example //! #![cfg_attr(feature = "std", doc = "```")] #![cfg_attr(not(feature = "std"), doc = "```ignore")] //! use tabled::{settings::{Margin, Style}, Table}; //! //! let data = vec!["Hello", "World", "!"]; //! //! let mut table = Table::new(data); ...
// -*- mode:rust;mode:rust-playground -*- // snippet of code @ 2017-04-18 12:24:11 // === Rust Playground === // Execute the snippet with Ctl-Return // Remove the snippet completely with its dir and all files M-x `rust-playground-rm` fn main() { let (tx, rx) = channel(); spawn(proc () { tx.send(2u+2);...
struct Rectangle { height: i32, length: i32, } impl Rectangle { fn is_square(&self) -> bool { return self.height == self.length; } }
// thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1' // prusti-viper/src/encoder/procedure_encoder.rs:5764:36 union Foo { a: [i32; 1], b: [i32; 1], } fn main() { let _ = Foo { a: [0] }; }
// 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::{ self, cmp::{ PartialEq, PartialOrd, Ordering }, fmt::{ self, Debug }, num::FpCategory, ops::{ Mul, Div, Rem, Neg, MulAssign, DivAssign, RemAssign }, }; #[cfg(not(feature = "double"))] use std::f32::consts; #[cfg(feature = "double")] use std::f64::consts; use cgmath::ApproxEq; use deriv...
extern crate itertools; extern crate rayon; extern crate hashbrown; use itertools::Itertools; use rayon::prelude::*; use hashbrown::HashMap; #[derive(Debug, Clone)] pub struct DistanceMatrix { pub size: usize, pub array: Vec<Option<u32>>, } impl DistanceMatrix { /// Creates new Distance Matrix pub f...
use crate::{ audio, interrupts, memory::io::{Interrupt, IoRegisters, Timer}, scheduler::{EventTag, Scheduler}, Gba, }; pub fn started(idx: usize, ioregs: &mut IoRegisters, scheduler: &Scheduler) { let timer = &mut ioregs.timers[idx]; timer.origin = ioregs.time; timer.counter = timer.reload;...
use std::path::Path; use std::{env, fmt, fs, io, panic, thread}; use backtrace::Backtrace; pub fn setup(logging_path: &Path) -> Result<(), fern::InitError> { let level_filter = match std::env::var("XI_LOG") { Ok(level) => match level.to_lowercase().as_ref() { "trace" => log::LevelFilter::Trace...
use util::*; fn main() -> Result<(), Box<dyn std::error::Error>> { let mut nums = input::lines::<usize>(&std::env::args().nth(1).unwrap()); nums.sort(); let mut hi = nums.len() - 1; let mut lo = 0; while nums[lo] + nums[hi] != 2020 { if nums[lo] + nums[hi] > 2020 { hi -= 1; ...
pub(crate) use self::{ stream::Stream, transport::ClickhouseTransport, }; mod read_to_end; pub(crate) mod transport; pub(crate) mod stream;
#![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(dead_code)] #![cfg_attr(feature = "cargo-clippy", allow(expl_impl_clone_on_copy))] include!("bindings.rs"); #[cfg(node8)] mod node8; #[cfg(node8)] pub use self::node8::Status; #[cfg(node9)] mod node9; #[cfg(node9)] p...
use std::fs::create_dir_all; use std::path::{Path, PathBuf}; use once_cell::sync::Lazy; pub static CALTRAIND_PATH: Lazy<PathBuf> = Lazy::new(|| { let p = PathBuf::from("/tmp/caltraind"); create_dir_all(&p).expect("error creating /tmp/caltraind"); p }); pub static PID_PATH: Lazy<PathBuf> = Lazy::new(|...
use core::sync::atomic::{AtomicBool, Ordering::SeqCst}; use embedded_graphics::{geometry::Size, pixelcolor::Rgb565, prelude::RgbColor}; pub const WIDTH: u16 = 240; pub const HEIGHT: u16 = 240; pub const VERT_LINES: u16 = 320; pub const SIZE: Size = Size::new(WIDTH as u32, HEIGHT as u32); pub type PixelFormat = Rgb565...
pub struct Register { val: u8, } pub struct Core { ix: Register, iy: Register, y: Register, a: Register, b: Register, c: Register, d: Register, e: Register, h: Register, l: Register, } impl Register { pub fn new() -> Register { Register { val: 0, } } pub fn set(&mut...
use crate::redis_wrapper::init::{self, read_hashmap_key, write_hashmap_key}; use redis::Connection; pub fn get_topics_list(con: &mut Connection) { let hm = read_hashmap_key(con, &("topics".to_string())); println!("hm = {:?}", hm); }
use thiserror::Error; use serde::Deserialize; use crate::{ web::scraping::Html, util::bytes, }; // The bitrate and size fields come from the same element. It's not practical to handle // them as separate results. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Deserialize)] pub struct Data { pub bitrate: u16, ...
// TODO: This file is utter mess, should be refactored #[macro_use] extern crate glium; #[macro_use] extern crate itertools; extern crate nalgebra as na; extern crate cam; extern crate vecmath; extern crate rand; extern crate time; mod marching_cubes_data; mod linspace; use glium::Surface; use glium::backend::glutin...