text
stringlengths
8
4.13M
pub mod scripts { use colored::*; use crate::helpers::funcs; pub fn install_neovim() { use std::process::Stdio; let mut scoop_path = funcs::get_home_dir(); scoop_path.push("scoop"); scoop_path.push("shims"); let nvim_installer = std::process::Command::new("powershe...
#[doc = "Reader of register INTR_HOST_EP_MASKED"] pub type R = crate::R<u32, super::INTR_HOST_EP_MASKED>; #[doc = "Reader of field `EP1DRQED`"] pub type EP1DRQED_R = crate::R<bool, bool>; #[doc = "Reader of field `EP1SPKED`"] pub type EP1SPKED_R = crate::R<bool, bool>; #[doc = "Reader of field `EP2DRQED`"] pub type EP2...
#![doc = "generated by AutoRust 0.1.0"] #![allow(non_camel_case_types)] #![allow(unused_imports)] use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct ErrorResponseBody { #[serde(default, skip_serializing_if = "Option::is_none")] pub code: Option<String>, ...
use super::super::messages::WriteGTP; use super::*; use std::convert::TryFrom; use std::io; #[derive(Clone, Debug, PartialEq, Eq)] pub struct Value { data: u32, } #[derive(Debug)] pub struct TryFromIntError(()); impl TryFrom<u32> for Value { type Error = TryFromIntError; fn try_from(data: u32) -> Result<Self, Se...
#![cfg_attr(feature = "unstable", feature(test))] // Launch program : cargo run --release < input/input.txt // Launch benchmark : cargo +nightly bench --features "unstable" /* Benchmark results: running 5 tests test tests::test_part_1 ... ignored test tests::test_part_2 ... ignored test bench::bench_...
// 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 friendly::bytes; use indicatif::ProgressBar; use log::*; use std::fs; use std::io::{BufRead, BufReader, Result as IOResult}; use std::path::{Path, PathBuf}; pub mod background; pub mod compress; pub mod ext; pub mod lines; pub mod object; pub use compress::open_gzin_progress; pub use lines::LineProcessor; pub use...
#[macro_use] mod common; make_test!(var: r"let x = 0; x" => "0"); make_test!(func: r"let f(x) = x + 1; f(2)" => "3"); make_test!(func2: r"let f(x)(y) = x * y + x + y; f(3)(4)" => "19"); make_test!(pipe: r"let f(x)(y) = x + y; 1 | f(2)" => "3"); make_test!(pipe_twice: r"let f(x) = x + 1; let g(x) = x * 2; 1 | f | g" =>...
#[allow(dead_code)] pub fn binary_exponentiation(base: usize, power: usize) -> usize { if power == 0 { return 1; } if power == 1 { return base; } let val = binary_exponentiation(base * base, power / 2); if power % 2 == 1 { return base * val; } else { return va...
use std::panic; use std::collections::HashMap; #[test] fn vec_access() { let v = vec![1, 2, 3, 4, 5]; let first = v.get(0); assert_eq!(first.expect("Expected 1"), &1); let third: &i32 = &v[2]; assert_eq!(third, &3); let v_index = 2; let v_index_value = match v.get(v_index) { Some...
use ::objc::runtime::*; use objc_foundation::NSString; use std::os::raw::{c_char, c_void}; use std::ptr::NonNull; extern "C" { pub fn OBJC_NSString(str: *const c_char) -> *mut c_void; pub fn OBJC_NSLog(str: *const c_char); pub fn NSLogv(nsFormat: *const NSString); // format from inside rust or it dies pub fn MSHoo...
/*! Wasm modules */ use anyhow::{anyhow, Result}; use async_std::channel::unbounded; use async_std::task::JoinHandle; use log::trace; use uuid::Uuid; use wasmtime::{Store, Val}; use std::sync::Arc; use crate::{ environment::UNIT_OF_COMPUTE_IN_INSTRUCTIONS, mailbox::MessageMailbox, process::{self, Process...
use std::thread; fn main(){ let handle = thread::spawn(move || { panic!("!!!"); }); let result = handle.join(); assert!(result.is_err()); }
#![allow(non_camel_case_types)] use super::*; use crate::structural_trait::{FieldInfo,StructuralDyn}; #[allow(unused_imports)] use crate::GetFieldExt; use core::{ ops::{Range,RangeFrom,RangeTo,RangeInclusive,RangeToInclusive}, //marker::Unpin, mem::ManuallyDrop, ops::Deref, pin::Pin, }; type St...
pub mod bkdr; pub mod crc32; pub use bkdr::Bkdr; pub use crc32::Crc32; pub const DISTRIBUTION_CONSISTENT: &str = "ketama"; pub const DISTRIBUTION_MODULA: &str = "modula"; pub const HASH_BKDR: &str = "bkdr"; pub const HASH_CRC32: &str = "crc32"; use enum_dispatch::enum_dispatch; #[enum_dispatch] pub trait Hash { ...
#![feature(const_fn, const_fn_fn_ptr_basics)] mod data_types; mod errors; mod init; mod utils; use data_types::*; use init::*; use std::collections::HashMap; use std::env::args; use std::time::{SystemTime, UNIX_EPOCH}; use utils::*; fn main() { let mut sym_map: HashMap<String, String> = HashMap::new(); let comman...
pub(crate) mod class; pub(crate) mod core; pub(crate) mod kernel; pub(crate) mod predict; pub(crate) mod problem; use crate::vectors::Triangular; #[derive(Clone, Debug, Default)] pub(crate) struct Probabilities { pub(crate) a: Triangular<f64>, pub(crate) b: Triangular<f64>, } /// Classifier type. #[doc(hidd...
use crate::io::*; use crate::model::rnn::*; use crate::model::seq2seq::*; use crate::optimizer::{NewAdam, NewSGD}; use crate::trainer::{RnnlmTrainer, Seq2SeqTrainer}; use crate::types::*; use crate::util::*; use ndarray::{array, s, Array2, Axis, Ix2}; use std::collections::HashMap; use itertools::concat; fn train_seq...
#[doc = "Register `LUT876H` reader"] pub type R = crate::R<LUT876H_SPEC>; #[doc = "Register `LUT876H` writer"] pub type W = crate::W<LUT876H_SPEC>; #[doc = "Field `LO` reader - Line offset"] pub type LO_R = crate::FieldReader<u32>; #[doc = "Field `LO` writer - Line offset"] pub type LO_W<'a, REG, const O: u8> = crate::...
use bytes::BytesMut; use super::header::{Header, MessageType}; use crate::error::ConvertBytesToBgpMessageError; #[derive(PartialEq, Eq, Debug, Clone, Hash)] pub struct KeepaliveMessage { header: Header, } impl KeepaliveMessage { pub fn new() -> Self { let header = Header::new(19, MessageType::Keepali...
/* Copyright 2018 Intel Corporation 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 in writing, ...
//! Generate rooms //! mod params; pub use params::*; use crate::geometry::{Axial, Hexagon}; use crate::indices::WorldPosition; use crate::storage::views::{UnsafeView, View}; use crate::tables::morton_hierarchy::SpacialStorage; use crate::tables::{hex_grid::HexGrid, morton_table::msb_de_bruijn}; use crate::terrain::T...
use crate::errors::Error; use crate::errors::ParsingError; use crate::headers::*; use crate::resource_quota::resource_quotas_from_str; use crate::resources::document::IndexingDirective; use crate::ResourceQuota; use azure_core::headers; use azure_core::headers::parse_date_from_str; use azure_core::headers::parse_int; u...
use super::collector::Collector; use super::underlying::Underlying; use super::Arc; /// [`Barrier`] allows the user to read [`AtomicArc`](super::AtomicArc) and keeps the /// underlying instance pinned to the thread. /// /// [`Barrier`] internally prevents the global epoch value from passing through the value /// annou...
mod library; mod parser; use std::{fs, io}; use crate::parser::*; use crate::library::*; fn main() -> io::Result<()> { let test_cases_name = "a_example"; let input = fs::read_to_string(format!("input/{}.txt", test_cases_name)); match input { Ok(input) => { let (metadata, mut libraries...
// 图 #[derive(Debug)] pub struct Node { node_id: usize, node_name: String, } #[derive(Clone, Debug)] pub struct Edge { edge: bool, } #[derive(Debug)] pub struct Graph { node_num: usize, graph: Vec<Vec<Edge>>, } impl Node { pub fn new(node_id: usize, node_name: String) -> Self { Node ...
#[doc = "Register `CHSELR0` reader"] pub type R = crate::R<CHSELR0_SPEC>; #[doc = "Register `CHSELR0` writer"] pub type W = crate::W<CHSELR0_SPEC>; #[doc = "Field `CHSEL` reader - Channel-x selection"] pub type CHSEL_R = crate::FieldReader<CHSEL_A>; #[doc = "Channel-x selection\n\nValue on reset: 458752"] #[derive(Clon...
extern crate diesel; extern crate UserManagerCrud; use self::diesel::prelude::*; use self::UserManagerCrud::models::*; use self::UserManagerCrud::*; fn main() { use UserManagerCrud::schema::users::dsl::*; let connection = establish_connection(); let results = users .limit(10) .load::<User...
#[derive(DbEnum, Debug, Clone, PartialEq, Serialize, Deserialize, juniper::GraphQLEnum)] pub enum SaleState { Draft, Approved, PartiallyPayed, Payed, Cancelled, } #[derive(Debug)] pub enum Event { Approve, Cancel, PartiallyPay, Pay, } impl SaleState { pub fn next(self, event: E...
fn main() { let value = 32; let mut things = vec![]; things.push("thing"); }
#[doc = "Register `UR12` reader"] pub type R = crate::R<UR12_SPEC>; #[doc = "Field `SECURE` reader - Secure mode"] pub type SECURE_R = crate::BitReader; impl R { #[doc = "Bit 16 - Secure mode"] #[inline(always)] pub fn secure(&self) -> SECURE_R { SECURE_R::new(((self.bits >> 16) & 1) != 0) } } #...
// Copyright 2019 Google LLC // // 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 to in ...
//! Traits, structs, and functions relating to disk images. //! //! This crate supports the following disk image types: //! //! 1. **D64**. Images of this type represent a 5¼-inch single-sided 170KB disk //! as used in Commodore 1541 disk drives. //! 2. **D71**. Images of this type represent a 5¼-inch double-sided 3...
//! `jsl` is a Rust implementation of [JSON Schema Language][jsl] ("JSL"), a //! portable way to describe and validate the structure of JSON data. //! //! The documentation for this crate focuses on making JSON Schema Language work //! with Rust. For information on JSON Schema Language in general, refer to the //! [doc...
/* Copyright 2019-2023 Didier Plaindoux 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...
use crate::asset::property::meta::*; use crate::asset::property::prop_type::*; use crate::asset::*; /// Represents a value that can be turned into the parts of a property pub trait AsProperty { fn prop_type(&self) -> PropType; fn as_tag(&self, header: &AssetHeader) -> Tag; fn as_value(&self, header: &AssetHeader...
#![feature(proc_macro)] extern crate glib_sys; extern crate gobject_gen; #[macro_use] extern crate glib; use gobject_gen::gobject_gen; extern crate gobject_sys; // glib_wrapper! wants these bindings use glib_sys as glib_ffi; use gobject_sys as gobject_ffi; use std::mem; use std::ptr; use glib::translate::*; use gl...
use kite::segment::Segment; use kite::schema::FieldRef; use kite::term::TermRef; use kite::doc_id_set::DocIdSet; use byteorder::{ByteOrder, BigEndian}; use RocksDBIndexReader; use key_builder::KeyBuilder; pub struct RocksDBSegment<'a> { reader: &'a RocksDBIndexReader<'a>, id: u32, } impl<'a> RocksDBSegment...
mod common; use std::path::PathBuf; use assert_fs::prelude::*; use common::{ testenv, TestEnv, EXAMPLE_SUN, EXAMPLE_TIME, IMAGE_DAY, IMAGE_NIGHT, PROPERTIES_SUN, PROPERTIES_TIME, }; use predicates::prelude::*; use rstest::rstest; #[rstest] #[case(EXAMPLE_SUN.to_path_buf(), PROPERTIES_SUN.to_path_buf())] #[cas...
use specs::*; use types::*; use super::*; use OwnedMessage; use SystemInfo; use component::channel::*; use component::counter::*; use protocol::server::ScoreUpdate; use protocol::{to_bytes, ServerPacket}; pub struct SendScoreUpdate { reader: Option<OnPlayerJoinReader>, } #[derive(SystemData)] pub struct SendScor...
//! Security advisories in the RustSec database pub mod affected; mod category; mod date; mod id; mod informational; mod keyword; mod license; pub mod linter; mod metadata; mod parts; pub(crate) mod versions; pub use self::{ affected::Affected, category::Category, date::Date, id::{Id, IdKind}, inf...
use futures::future; use gotham::handler::{Handler, HandlerFuture, NewHandler}; use gotham::http::response::create_response; use gotham::state::{request_id, FromState, State}; use hyper::header::Location; use hyper::{Headers, Response, StatusCode}; use serde::Deserialize; use std::io; use std::marker::PhantomData; use ...
use arkecosystem_crypto::configuration::network; use arkecosystem_crypto::enums::{Network, TransactionType}; use arkecosystem_crypto::transactions::deserializer; use *; #[test] fn test_signed_with_a_second_passphrase() { let fixture = json_transaction("second_signature_registration", "second-passphrase"); let ...
mod key; mod service; mod user; use actix_web::http::header; use serde::ser::Serialize; use url::Url; // TODO(feature): Client methods. /// Client errors. #[derive(Debug, Fail)] pub enum ClientError { /// TODO(refactor): Error type improvements. #[fail(display = "ClientError::Unwrap")] Unwrap, } /// Cli...
use std::fs::{self}; use std::path::{PathBuf, Path}; use std::process::Command; use std::sync::atomic::{Ordering,AtomicBool, AtomicUsize}; use std::sync::Arc; use std::cell::UnsafeCell; #[derive(Clone)] pub struct MultiSliceReadWriteLock<T> { data: Arc<UnsafeCell<T>> } unsafe impl<T> Send for MultiSliceReadWrite...
use super::schema::lists; /* * Structures paralleling the lists table used by diesel * for querying and insertion of lists. */ /** * Model struct for querying the lists table. * * Cannot specify table name for this struct. * Diesel assumes the table name is the plural of the queryable model name, */ #[derive(...
pub fn task000() -> u32 { 10 } pub fn task001(ceiling : u32) -> String { let result : u32 = (1..ceiling).filter(|value| value % 3 == 0 || value % 5 == 0) .sum(); format!("{}", result) } pub fn task002(ceiling : u64) -> u64 { let mut sum = 0; let mut first = 1; let mut second = 1;...
#[doc = "Register `RCC_MPCKSELR` reader"] pub type R = crate::R<RCC_MPCKSELR_SPEC>; #[doc = "Register `RCC_MPCKSELR` writer"] pub type W = crate::W<RCC_MPCKSELR_SPEC>; #[doc = "Field `MPUSRC` reader - MPUSRC"] pub type MPUSRC_R = crate::FieldReader; #[doc = "Field `MPUSRC` writer - MPUSRC"] pub type MPUSRC_W<'a, REG, c...
use std::{collections::HashSet, io::Write}; use framework::CursorIcon; use nonblock::NonBlockingReader; use notify::RecursiveMode; use serde_json::json; use crate::{ editor::{self, Editor, PerFrame}, event::Event, keyboard::{KeyCode, KeyboardInput}, native::open_file_dialog, widget::{Position, Siz...
static x: i32 = 5; struct Foo; fn main() { let foo2 = Foo; foo2.bar(); foo2.bar(); foo(&x); } impl Foo {} impl Foo { fn bar(self) {} } fn foo(_n: &'static i32) { _n; }
use crate::Error; use std::fmt; const N_ITER: u32 = 1_000; #[derive(Serialize, Deserialize, Clone)] #[serde(transparent)] pub struct Cred { cred: String, } impl fmt::Debug for Cred { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { write!(f, "Cred {{ ... }}") } } impl Cred { ...
pub mod app; pub mod gpu72_work; mod lists; pub mod p95_work; pub mod validators;
use rand::Rng; use std::ops::{Add, Sub, Mul, Neg}; use std::fmt; use std::marker::PhantomData; use super::FieldElement; use rustc_serialize::{Encodable, Encoder, Decodable, Decoder}; use arith::U256; pub trait FpParams { fn name() -> &'static str; fn modulus() -> U256; fn inv() -> u64; fn rsquared() ...
use anyhow::{anyhow, Result}; use std::path::PathBuf; use structopt::StructOpt; use taskpaper::{Database, TaskpaperFile}; #[derive(StructOpt, Debug)] pub struct CommandLineArguments { /// File to modify. #[structopt(parse(from_os_str), long = "--input", short = "-i")] input: PathBuf, /// Style to form...
pub mod world_map; pub mod main_old; pub mod learning;
#[derive(Debug, PartialEq, Clone)] pub enum Token { Error, EndOfFile, LeftParen, RightParen, Symbol(String), Number(String), StringLiteral(String), Caret, SingleQuote, Character { val: String, raw: String }, } impl Token { pub fn display(&self) -> String { match self...
#[derive(Debug, PartialEq, Eq, Hash)] pub struct Method(String); impl From<&str> for Method { fn from(value: &str) -> Self { return Method(value.replace("\"", "")); } } impl Method { pub fn is_empty(&self) -> bool { return self.0.is_empty(); } pub fn is_valid(&self) -> bool { ...
// El discurso de Zoe // // Copyright (C) 2016 GUL UC3M // // This program 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 later version. // // Th...
#[doc = "Counter control register\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modi...
//! Top-level lib.rs for `cretonne_faerie`. //! //! Users of this module should not have to depend on faerie directly. #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] #![warn(unused_import_braces, unstable_features)] #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] ...
//! A scope is something that contains variable values. use crate::css::{self, Value}; use crate::functions::{get_builtin_function, Module, SassFunction}; use crate::output::Format; use crate::sass::{self, Item}; use crate::selectors::Selectors; use crate::Error; use std::collections::BTreeMap; use std::sync::Mutex; ...
extern crate phashmap; use phashmap::*; fn main() { let mut h8: PHashMap<u8, u8> = PHashMap::new(); h8.insert(8, 0); h8.insert(9, 2); h8.insert(9, 3); h8.insert(10, 4); println!("{:?}", h8.get(8)); println!("{:?}", h8.get(11)); println!("{:?}", h8.get(9)); h8.update(9, 5); prin...
use ::Provider; use ::ProviderLoader; pub mod fake; pub mod rpi; pub fn backend_loader() -> Vec<Box<Provider>> { let mut vector: Vec<Box<Provider>> = vec![Box::new(fake::FakeProvider {})]; if let Some(provider) = rpi::RpiProvider::new() { vector.push(provider); }; vector }
use std::ffi::CStr; use std::fmt; use std::os::raw::{c_int, c_void}; use crate::error::{Error, Result}; use crate::hostent::{HasHostent, HostAddressResultsIter, HostAliasResultsIter, HostentBorrowed}; use crate::panic; /// The result of a successful host lookup. #[derive(Clone, Copy)] pub struct HostResults<'a> { ...
/// An enum to represent all characters in the SoraSompeng block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum SoraSompeng { /// \u{110d0}: '𑃐' LetterSah, /// \u{110d1}: '𑃑' LetterTah, /// \u{110d2}: '𑃒' LetterBah, /// \u{110d3}: '𑃓' LetterCah, /// \u{110d4}: '𑃔'...
use alloc::vec::Vec; use keccak::KeccakF1600; use util::Hash; pub struct Shake256(KeccakF1600); impl Shake256 { pub fn new(n: usize) -> Self { Self(KeccakF1600::new(1088, 512, n)) } } impl Default for Shake256 { fn default() -> Self { Self::new(256 / 8) } } impl Hash for Shake256 { ...
use crate::country::Country; const R: f64 = 6371.0; fn string_to_radians(val: &str) -> f64 { let f: f64 = val.parse().unwrap(); f.to_radians() } pub fn calculate_distance(country1: &Country, country2: &Country) -> f64 { let lat1 = string_to_radians(&country1.latitude); let lat2 = string_to_radians(&c...
use crate::errors::PcapError; use byteorder::{BigEndian, ByteOrder, LittleEndian, ReadBytesExt}; use crate::Endianness; use crate::pcapng::blocks::common::opts_from_slice; use crate::pcapng::{CustomBinaryOption, CustomUtf8Option, UnknownOption}; use std::borrow::Cow; use derive_into_owned::IntoOwned; ///Section Header...
use float_eq::assert_float_eq; use totsu::prelude::*; use totsu::*; type La = FloatGeneric<f64>; type AMatBuild = MatBuild<La>; type AProbSDP = ProbSDP<La>; type ASolver = Solver<La>; // #[test] fn test_sdp1() { let _ = env_logger::builder().is_test(true).try_init(); let n = 2; let p ...
use serde_derive::{Deserialize, Serialize}; #[derive(Debug, Clone)] #[derive(Deserialize, Serialize)] pub struct Entry { pub ts: i64, pub value: f64, } impl PartialEq for Entry { fn eq(&self, other: &Self) -> bool { self.ts == other.ts && (other.value - self.value).abs() <= 1e-6 } } #[test] f...
fn main() { Print::print(&123456); Print::print(&'💕'); } trait Print { fn print(&self); } impl Print for u64 { fn print(&self) { println!("Print for u64: {}", self); } } impl Print for char { fn print(&self) { println!("Print for char: {}", self); } }
use unicode_segmentation::UnicodeSegmentation; use std::collections::{HashMap, HashSet}; fn duplicate_address(address: u64, offset: u64) -> (u64, u64) { let mask = 1 << offset; return (address | mask, address & !mask); } fn create_addresses(mask: &Vec<(usize, char)>, address: u64) -> HashSet<u64> { let ...
//! Tests for the `cargo yank` command. use std::fs; use cargo_test_support::paths::CargoPathExt; use cargo_test_support::project; use cargo_test_support::registry; fn setup(name: &str, version: &str) { let dir = registry::api_path().join(format!("api/v1/crates/{}/{}", name, version)); dir.mkdir_p(); fs:...
const MIN: u32 = 1; const MAX: u32 = 64; pub fn square(num: u32) -> u64 { match num { MIN..=MAX => 2u64.pow(num - 1), _ => panic!("Square must be between {} and {}", MIN, MAX), } } pub fn total() -> u64 { u64::max_value() }
use crate::{ models::{Coordinates, Ship}, views::utils::translate_game_coords_to_board_coords, }; use std::io::{Stdout, Write}; use termion::cursor::Goto; use termion::raw::RawTerminal; use termion::{color, style}; pub struct ShipView { origin: Coordinates, model: Ship, } impl ShipView { pub fn ne...
mod atomic; mod terrain; pub mod timer; pub use self::atomic::SHUTDOWN; pub use self::terrain::TERRAIN;
use std::u32; fn main() { proconio::input! { n: usize, mut d: [u32; n], } d.sort(); d.reverse(); let mut count = 0; let mut min = u32::MAX; for x in d { if x < min { count += 1; min = x; } } println!("{}", count);...
fn main() { let elem = 5u8; let mut vec = Vec::new(); vec.push(elem);// commenting out -> error: cannot infer type for `T` vec.push(elem); println!("{:?}", vec);// [5, 5] }
#[repr(u8)] #[derive(Copy, Clone, Debug, FromPrimitive, PartialEq)] pub enum DaemonStatus { Inactive = 0, FetchingPackages = 1, RecoveryUpgrade = 2, ReleaseUpgrade = 3, PackageUpgrade = 4, } impl From<DaemonStatus> for &'static str { fn from(status: DaemonStatus) -> Self { match status ...
#[doc = "Reader of register DDRPHYC_DCUSR0"] pub type R = crate::R<u8, super::DDRPHYC_DCUSR0>; #[doc = "Reader of field `RDONE`"] pub type RDONE_R = crate::R<bool, bool>; #[doc = "Reader of field `CFAIL`"] pub type CFAIL_R = crate::R<bool, bool>; #[doc = "Reader of field `CFULL`"] pub type CFULL_R = crate::R<bool, bool...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - RNG control register"] pub rng_cr: RNG_CR, #[doc = "0x04 - RNG status register"] pub rng_sr: RNG_SR, #[doc = "0x08 - The RNG_DR register is a read-only register."] pub rng_dr: RNG_DR, _reserved3: [u8; 0x03e4], ...
#![no_std] use zoon::*; use shared::{UpMsg, DownMsg, Message}; use std::mem; blocks!{ #[s_var] fn username() -> String { "John".to_owned() } #[update] fn set_username(username: String) { username().set(username); } #[s_var] fn messages() -> Vec<VarC<Message>> { ...
// size_of type_id #![allow(unused_variables)] fn main() { let a = 100_usize; //let s = std::mem::size_of::<usize>(); //let ty = std::any::TypeId::of::<usize>(); //println!("{} {} {:?}", a, s, ty); let a = 100.0f32; // override, but can't apply to other env, like function parameters // http://blogs.msdn.c...
use super::{HyperLTL, Op, QuantKind}; use pest::error::Error; use pest::iterators::{Pair, Pairs}; use pest::prec_climber::{Assoc, Operator, PrecClimber}; use pest::Parser; #[derive(Parser)] #[grammar = "ltl.pest"] struct LTLParser; lazy_static! { // precedence taken from https://spot.lrde.epita.fr/tl.pdf // P...
fn main() { let outer = 42; { let inner = 3.14; println!("Block variable: {}", inner); let outer = 99; println!("Block variable outer: {}", outer); } println!("outer variable: {}", outer); }
//! RS485 support for serial devices //! //! RS485 is a low-level specification for data transfer. While the spec only //! defines electrical parameter and very little else, in reality it is most //! often used for serial data transfers. //! //! To realize an RS485 connection, a machine's UARTs are usually used. These ...
#![recursion_limit = "256"] extern crate carrier_build_core; fn main() { carrier_build_core::compile_protos(&["proto/certificate.proto"], &["proto"]).unwrap(); }
//! --------------------------------------------------- //! | | //! | WARNING! - proxy demo | //! | Not for production! Only for frontend debugging | //! | Allows payments without authentication! | //! | TODO: Remove proxy mod and re...
mod spritesheet_loading; pub use self::spritesheet_loading::{ load_image_png, load_spritesheet, load_image_png_tracked, load_spritesheet_tracked, };
#[doc = "Reader of register DDRCTRL_ADDRMAP5"] pub type R = crate::R<u32, super::DDRCTRL_ADDRMAP5>; #[doc = "Writer for register DDRCTRL_ADDRMAP5"] pub type W = crate::W<u32, super::DDRCTRL_ADDRMAP5>; #[doc = "Register DDRCTRL_ADDRMAP5 `reset()`'s with value 0"] impl crate::ResetValue for super::DDRCTRL_ADDRMAP5 { ...
pub enum Part { Part1, Part2, }
use xstate::{Machine, XState, EventSender, EventHandlerResponse}; use super::types::{Id, Context, Event}; use super::states; use super::keyboard_events; fn empty_event_handler(context: &mut Context, event: &Event, task_event_sender: &Option<&mut EventSender<Event>>) -> EventHandlerResponse<Id> { println!("Empty e...
pub mod jwt; pub mod res; pub mod role; pub mod sign_in; pub mod user; pub use jwt::*; pub use res::*; pub use role::*; pub use sign_in::*; use crate::error::Error; use crate::service::CONTEXT; use actix_http::Response; use actix_web::HttpResponse; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize};...
use std::collections::HashMap; use std::fmt::Debug; #[derive(Clone, Debug, PartialEq)] pub enum Unresolved<T> { Any, Literal(T), Generic(T, Vec<TypeVar>), } #[derive(Clone, Debug, PartialEq)] pub enum Resolved<T> { Literal(T), Generic(T, Vec<Resolved<T>>), } #[derive(Clone, PartialEq)] pub enum C...
#![feature(proc_macro_hygiene)] #![feature(decl_macro)] #![feature(maybe_uninit_extra)] #![feature(maybe_uninit_ref)] #![feature(new_uninit)] mod stoppable_thread; mod shmem_poller; mod string_collection; mod memdb; mod common; use temporal_lens::shmem::{SharedMemory, FrameData}; use string_collection::{StringCollect...
use serde::{Deserialize, Serialize}; #[derive(PartialEq, Eq, Clone, Serialize, Deserialize, Debug)] pub enum KVSMessage { Put { key: String, value: String }, Get { key: String }, Response { key: String, value: String }, }
pub mod ray; pub mod utils;
use std::{path::{Path, PathBuf}, env}; use example as _; fn main() { let current_dir = env::current_dir().unwrap(); let current_parent = current_dir.parent().unwrap(); assert_eq!(env::var("CRATE_BUILD_COMMAND").unwrap(), "cargo build --package dependency"); assert_eq!(PathBuf::from(env::var("CRATE_MAN...
//https://ptrace.fefe.de/wp/wpopt.rs // gcc -o lines lines.c // tar xzf llvm-8.0.0.src.tar.xz // find llvm-8.0.0.src -type f | xargs cat | tr -sc 'a-zA-Z0-9_' '\n' | perl -ne 'print unless length($_) > 1000;' | ./lines > words.txt //#![feature(impl_trait_in_bindings)] use std::fmt::Write; use std::io; use std::iter::...
use anyhow::{Context, Result}; use mongodb::{ bson::{doc, Document}, Client, Database, }; use crate::bench::{drop_database, Benchmark, DATABASE_NAME}; pub struct RunCommandBenchmark { db: Database, num_iter: usize, cmd: Document, uri: String, } pub struct Options { pub num_iter: usize...