text
stringlengths
8
4.13M
fn main() { let reference_to_nothing = dangle(); } fn dangle () -> &String { let s = String::from ("hello"); &s } //here s goes out of scope so does the refernce to that memory too, hence the returning address "&String" is not pointing to string "s";
fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn main() { let s: String = read(); let cv: Vec<char> = s.chars().collect(); if cv[0] != cv[1] { if (cv[0] == cv[2] && cv[1] == cv[3]) || (cv[0] =...
#[doc = "Register `ETH_MACISR` reader"] pub type R = crate::R<ETH_MACISR_SPEC>; #[doc = "Field `RGSMIIIS` reader - RGSMIIIS"] pub type RGSMIIIS_R = crate::BitReader; #[doc = "Field `PHYIS` reader - PHYIS"] pub type PHYIS_R = crate::BitReader; #[doc = "Field `PMTIS` reader - PMTIS"] pub type PMTIS_R = crate::BitReader; ...
use std::collections::{HashMap, HashSet}; use std::ops::{Add, AddAssign}; use crate::{BreakingInfo, Change, ChangeType, SemverScope}; #[derive(Debug, Clone, Eq, PartialEq, Default)] pub struct ChangeLog { breaking_changes: Section, features: Section, fixes: Section, scopes: HashSet<Option<Scope>>, } ...
use std::collections::HashMap; use timely::dataflow::channels::pact::Exchange; use timely::dataflow::operators::{Inspect, Map, Operator, Probe}; use timely::dataflow::{InputHandle, ProbeHandle}; use std::io::{self, Read}; use std::fs::File; use std::hash::Hash; use word_count::util::*; fn hash_str(text: &str) -> u...
// adapted from https://www.softax.pl/blog/rust-lang-in-a-nutshell-3-traits-and-generics/ use benchmarking; use std::env; use std::process; struct Fibonacci(u32, u128, u128); impl Fibonacci { fn new() -> Fibonacci { Fibonacci(0, 0, 1) } } trait Limit { // u128 can't hold Fibonacci sequence numbe...
use std::borrow::Cow; use std::cmp::{max, min}; use std::env; use std::process::{Command, Stdio}; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::mpsc::{channel, Receiver, Sender}; use std::sync::Arc; use std::thread; use std::thread::JoinHandle; use derive_builder::Builder; use nix::libc; u...
fn main() { let heart_eyed_cat = '😻'; let tup = (500, 6.4, true); let (x, y, z) = tup; println!("The value of y is: {}", y); println!("The first value is {}", tup.0); another_fn(x, z); let y = { let x = 3; x + 1 }; println!("The value of y is: {}", y); let numb...
/// NO. 97: Interleaving String pub struct Solution; // ----- submission codes start here ----- use std::collections::HashSet; impl Solution { pub fn is_interleave(s1: String, s2: String, s3: String) -> bool { if s1.len() + s2.len() != s3.len() { false } else { let s1 = s...
extern crate libc; extern crate rand; use libc::{c_char, c_float}; use std::cmp; use std::f32; use std::ffi::CStr; use std::fmt; use std::fs::File; use std::io::prelude::*; use std::mem; use std::ops::*; use std::ptr; use std::slice; use std::str::FromStr; use rand::Rng; // For serializing. TODO: Deprecate and rep...
/// An enum to represent all characters in the EnclosedIdeographicSupplement block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum EnclosedIdeographicSupplement { /// \u{1f200}: '🈀' SquareHiraganaHoka, /// \u{1f201}: '🈁' SquaredKatakanaKoko, /// \u{1f202}: '🈂' SquaredKatakanaSa,...
// Copyright 2020 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT use super::CONSENSUS_MINER_MIN_POWER; use crate::{BalanceTable, BytesKey, Multimap, Set, StoragePower, HAMT_BIT_WIDTH}; use address::Address; use cid::Cid; use clock::ChainEpoch; use encoding::Cbor; use ipld_blockstore::BlockStore; use ipl...
use std::error::Error; use std::fmt::{Display, Formatter}; use std::pin::Pin; use std::task::{Context, Poll}; use futures::{FutureExt, Stream}; use pin_project_lite::pin_project; use tokio_stream::{self as stream, StreamExt}; use tokio::io::{AsyncRead, AsyncWrite}; use tokio_util::codec::{Decoder, Framed}; mod frame; ...
use pest::Parser; use super::*; #[derive(Parser)] #[grammar = "conventional_commit.pest"] struct ConventionalCommitParser; pub(crate) fn parse(commit_msg: &str) -> Option<Change> { let commit = ConventionalCommitParser::parse(Rule::conventional_commit, commit_msg) .ok()? .next()?; let mut re...
use super::{ CInputKind, COutputKind, CompilerKind, DCompilerKind, DepKind, DetectOpts, FileKind, FormatArgs, LdScript, PlatformKind, SizeInfo, ToolchainOpts, }; use crate::{ qjs, system::{check_access, exec_out, which_any, write_file, AccessMode, Path, PathBuf}, Actual, Artifact, ArtifactStore, Box...
#[doc = "Register `PDCRI` reader"] pub type R = crate::R<PDCRI_SPEC>; #[doc = "Register `PDCRI` writer"] pub type W = crate::W<PDCRI_SPEC>; #[doc = "Field `PD0` reader - Port I pull-down bit 0"] pub type PD0_R = crate::BitReader; #[doc = "Field `PD0` writer - Port I pull-down bit 0"] pub type PD0_W<'a, REG, const O: u8...
use regex::Regex; use std::collections::{HashMap, HashSet}; use std::{ char::ParseCharError, cmp::{max, min}, convert::From, str::FromStr, }; const WATER_SPRING: Coord = Coord { x: 500, y: 0 }; #[aoc(day17, part1)] fn solve_part1(input: &str) -> usize { let mut r: Reservoir = input.parse().unwrap(...
use code_generator::CodeGenerator; use syntax_analyzer::ast_node::*; use std::env; use std::fs::File; use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Write}; fn main() { let mut reader: Box<dyn BufRead> = match env::args().nth(1) { None => Box::new(BufReader::new(stdin())), Some(filena...
#[macro_use] extern crate log; #[macro_use(doc, bson)] extern crate bson; extern crate mongo_driver; extern crate mongo_oplog; use bson::Bson; use bson::oid; use mongo_oplog::op::Op; mod utils; use utils::log_init; #[test] fn check_op_insert() { log_init(); let insert = doc! { "op" => "i", ...
use std::thread; use std::sync::{Arc, Mutex}; struct Numero{ value: i32 } impl Numero{ fn new(x: i32) -> Numero{ Numero{value: x} } fn add(& mut self, x: i32){ self.value += x; } fn lessthan(& self, x:i32) -> bool{ return self.value < x; } fn show(& self){ ...
use super::Cursor; use crate::libs::models::{Credits, Show, ShowDetails, Review}; use crate::{client, get, opt_param}; /// Show search cursor #[derive(Clone)] pub struct ShowSearch<'a> { /// The url to use url: String, /// The handler being used to perform this search handler: &'a Tv, /// The curre...
mod cd; mod cd_query; mod cp; mod glob; mod ls; mod mkdir; mod mv; mod open; mod rm; mod save; mod touch; mod util; mod watch; pub use cd::Cd; pub use cd_query::query; pub use cp::Cp; pub use glob::Glob; pub use ls::Ls; pub use mkdir::Mkdir; pub use mv::Mv; pub use open::Open; pub use rm::Rm; pub use save::Save; pub u...
use crate::Result; use clap::{App, Arg, ArgMatches}; use ronor::{Capability, HouseholdId, Player, PlayerId, Sonos}; pub const NAME: &str = "inventory"; pub fn build() -> App<'static, 'static> { App::new(NAME) .about("Describes available households, groups and logical players") .arg( Arg::with_name("AU...
/********************************************** > File Name : most_booked.rs > Author : lunar > Email : lunar_ubuntu@qq.com > Created Time : Sun Sep 4 17:16:40 2022 > Location : Shanghai > Copyright@ https://github.com/xiaoqixian **********************************************/ trait Comp<T...
use radmin::uuid::Uuid; use serde::{Deserialize, Serialize}; use super::ContactInfo as Contact; use crate::models::AddressBookTag as Tag; use crate::schema::contact_tags; #[derive( Debug, PartialEq, Clone, Serialize, Deserialize, Queryable, Identifiable, AsChangeset, Associations, ...
//! A matrix with two rows and columns. macro_rules! impl_op { ($op_trait:ident, $op_func:ident, $op:tt) => { impl<I> $op_trait<I> for Mat2<I> where I: $op_trait<I> + Copy, <I as $op_trait<I>>::Output: Into<I> { type Output = Mat2<I>; fn $op_f...
// lib/option::rs tag t<@T> { none; some(T); } fn get<@T>(opt: t<T>) -> &T { alt opt { some(x) { ret x; } none. { fail "option none"; } } } fn map<@T, @U>(f: block(T) -> U, opt: t<T>) -> t<U> { alt opt { some(x) { some(f(x)) } none. { none } } } fn is_none<@T>(opt: t<T>) -> bool { alt opt { none. { true...
use crate::result::{ProgramError, ProgramResult}; use prediction_poll_data::TallyData; use solana_sdk_bpf_utils::entrypoint::SolKeyedAccount; use solana_sdk_bpf_utils::info; use solana_sdk_types::SolPubkey; pub fn record_wager( tally: &mut TallyData, user_pubkey: &SolPubkey, wager: u64, ) -> ProgramResult<...
pub mod modules { //MODULE_JSON pub const UNITY_2021_2_2_F_1:&str = include_str!("2021.2.2f1_modules.json"); pub const UNITY_2021_1_28_F_1:&str = include_str!("2021.1.28f1_modules.json"); } pub mod manifests { //MANIFEST_INI pub const UNITY_2021_2_2_F_1:&str = include_str!("2021.2.2f1_manifest.ini"...
use crate::data_lake::clients::FileSystemClient; use crate::data_lake::responses::*; use azure_core::prelude::*; use azure_core::{headers::add_optional_header, AppendToUrlQuery}; use http::method::Method; use http::status::StatusCode; use std::convert::TryInto; #[derive(Debug, Clone)] pub struct DeleteFileSystemBuilde...
// --- paritytech --- use cumulus_pallet_dmp_queue::Config; use frame_system::EnsureRoot; use xcm_executor::XcmExecutor; // --- darwinia-network --- use crate::*; impl Config for Runtime { type Event = Event; type XcmExecutor = XcmExecutor<XcmConfig>; type ExecuteOverweightOrigin = EnsureRoot<AccountId>; }
use std::iter::FromIterator; use im::Vector; #[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)] pub struct EqMap<Key: PartialEq + std::fmt::Debug + Clone, Val: std::fmt::Debug + Clone> { storage: Vector<(Key, Val)>, } impl<Key: PartialEq + std::fmt::Debug + Clone, Val: std::fmt::Debug + Cl...
extern crate futures; extern crate hyper; extern crate hyper_tls; extern crate tokio_core; extern crate url; mod pushover_client; use pushover_client::PushoverClient; fn main() { let mut args = std::env::args().skip(1); let key = args .next() .expect("pass pushover key as first positional arg"...
use bip39::{Mnemonic, Language}; use sodiumoxide::crypto::hash::sha256; use sodiumoxide::crypto::sign::ed25519; use sodiumoxide::crypto::sign::ed25519::Seed; #[macro_use] extern crate clap; fn kp(phrase: &str) { // recover seed let mnemonic = Mnemonic::from_phrase(phrase, Language::English).unwrap(); let...
use crate::exchange::trades::history::OrderBookDiff; use crate::message::{ExchangeReply, TraderRequest}; use crate::trader::{subscriptions::{HandleSubscriptionUpdates, OrderBookSnapshot}, Trader}; use crate::types::{DateTime, StdRng}; pub struct VoidTrader; impl HandleSubscriptionUpdates for VoidTrader { fn handl...
use amethyst::input::{InputBundle, StringBindings}; pub fn create_input_bundle() -> InputBundle<StringBindings> { InputBundle::<StringBindings>::new() }
use std::{cmp::Ordering, collections::BTreeMap}; use chrono::{DateTime, Utc}; use futures::stream::StreamExt; use hashbrown::HashMap; use rosu_v2::prelude::{GameMode, User, Username}; use sqlx::Row; use crate::{ commands::osu::UserValue, database::{Database, UserStatsColumn, UserValueRaw}, embeds::Ranking...
extern "C" { pub fn foo() -> i32; pub fn bar1() -> i32; pub fn bar2() -> i32; pub fn asm() -> i32; pub fn baz() -> i32; #[cfg(windows)] pub fn windows(); #[cfg(target_env = "msvc")] pub fn msvc(); }
// Do not pop up cmd.exe window when clicking .exe on Windows. This also disables any console outputs // so logger output will not work. // https://learn.microsoft.com/en-us/cpp/build/reference/subsystem-specify-subsystem #![cfg_attr(all(windows, not(debug_assertions), not(__bench)), windows_subsystem = "windows")] us...
#[allow(unused_imports)] use super::prelude::*; type Input = Layout; #[derive(PartialEq, Eq, Hash, Clone, Copy)] pub struct Layout { layout: u32 } impl Layout { fn new() -> Self { Self { layout: 0 } } fn get(&self, x: usize, y: usize) -> Tile { if self.layout & (1 << (x + 5 * y)) != 0 { Tile::Bug } el...
struct Metrolpolis{ }
use pdb::{FallibleIterator, PdbInternalRva, PdbInternalSectionOffset, Rva}; // This test is intended to cover OMAP address translation: // https://github.com/willglynn/pdb/issues/17 fn open_file() -> std::fs::File { let path = "fixtures/symbol_server/3844dbb920174967be7aa4a2c20430fa2-ntkrnlmp.pdb"; std::fs:...
#![no_main] #![no_std] extern crate cortex_m_rt as rt; use rt::entry; use rt::exception; use rt::ExceptionFrame; extern crate cortex_m as cm; extern crate cortex_m_semihosting; use cortex_m_semihosting::hprintln; extern crate panic_semihosting; extern crate stm32f0; use stm32f0::stm32f0x0; #[entry] fn main() -> !...
pub mod functions; pub mod garbage; pub mod primitives; pub mod strings; pub mod vectors; #[cfg(feature = "dataframes")] pub mod dataframe; pub mod series; pub mod channels; pub mod cells; use crate::data::garbage::Garbage; use comet::gc_base::GcBase; use dyn_clone::DynClone; use std::fmt::Debug; use std::hash::Hash...
#![allow(non_snake_case)] mod cli; mod task; use structopt::StructOpt; use cli::{Action::*, CommandLineArgs}; use task::Task; fn main() -> std::io::Result<()> { let CommandLineArgs { action, file } = CommandLineArgs::from_args(); let file = file.expect("Failed to find To-Do List "); match action { ...
use std::fmt; #[allow(dead_code)] #[derive(Clone, Copy, PartialEq)] pub struct Position { pub lin: usize, pub col: usize, } #[derive(Clone, Copy)] pub struct Cell { pub value: Option< u8 >, } impl fmt::Debug for Cell { fn fmt( &self , formatter: &mut fmt::Formatter ) -> fmt::Result { //write!( formatter...
const INPUT: &str = include_str!("../inputs/day_5_input"); pub fn solve() { let mut polymer = INPUT.to_owned(); println!("Final polymer length: {}", react_polymer(&mut polymer)); } pub fn solve_extra() { let min_polymer = (b'a'..b'z') .map(|x| { let mut polymer = remove_all(x, INPUT.to...
//! Tools to make a given actor able to receive delayed and recurring messages. //! //! To apply this to a given (receiving) actor: //! * Use [`TimedContext<Self::Message>`] as [`Actor::Context`] associated type. //! * Such actors cannot be spawned unless wrapped, making it impossible to forget wrapping it. //! * Wra...
use components::Link; use prelude::*; pub fn view<T: Component>(routes: Vec<(Route, String)>, current: &str) -> Html<T> { html! { <nav class="breadcrumbs", > <span class="breadcrumb_links", > { for routes.iter().map(|(route, label)| { html! { ...
pub mod p1; pub mod p2; pub mod p3; pub struct Solution {}
use super::IRustError; use crate::irust::IRust; use crate::utils::{read_until_bytes, StringTools}; use crossterm::ClearType; use std::env::temp_dir; use std::io::{self, Write}; use std::process::{Child, Command, Stdio}; pub enum Cycle { Up, Down, } pub struct Racer { process: Child, main_file: String,...
pub mod shapes { #[derive(Debug)]//basically toString functionality pub struct Rectangle<'a, 'b> { width: &'a i32, height: &'b i32, } impl<'a, 'b> Rectangle<'a, 'b> { pub fn area(&self) -> i32 { self.width * self.height } pub fn from(width: &'a i32, ...
#[macro_export] macro_rules! or { ( $( $predicate:expr ),* ) => { Box::new(move |chr| { $( $predicate(chr) || )* false }) }; } #[macro_export] macro_rules! and { ( $( $predicate:expr ),* ) => { Box::new(move |chr| { $( $predicate(chr) && )* true }) ...
use swf_tree as ast; use nom::{IResult, Needed}; use nom::{le_u8 as parse_u8, le_u16 as parse_le_u16}; use parsers::basic_data_types::{ parse_bool_bits, parse_i32_bits, parse_u16_bits, parse_u32_bits, parse_le_fixed8_p8, parse_matrix, parse_s_rgb8, parse_straight_s_rgba8 }; use parsers::gradient::parse_...
mod test_block_chain; mod test_opened_block;
//! General Purpose Input / Output //! //! This module makes heavy use of types to try and ensure you can't have a //! pin in a mode you didn't expect. //! //! Most pins start in the `Tristate` state. You can call methods to convert //! them to inputs, outputs or put them into Alternate Function mode (e.g. to //! use w...
use serde::de::DeserializeOwned; use crate::error::Result; use crate::service::CONTEXT; use crate::service::cache_service::CacheProxyType::Mem; use std::time::Duration; use async_trait::async_trait; use serde::{Serialize}; pub enum CacheProxyType { Mem, Redis, } #[async_trait] pub trait ICacheService { a...
/* chapter 4 syntax and semantics */ #[derive(Debug)] struct Foo; fn main() { println!("{:?}", Foo); } // deriving is limited to a certain set of traits: /* Clone Copy Debug Default Eq Hash Ord PartialEq PartialOrd */ // output should be: /* */
// Rust's std::result type enum Result<T, E> { Ok(T), Err(E), } // Rust's std::option type enum Option<T> { Some(T), None, } fn divide(a: i32, b: i32) -> Result<i32, &'static str> { match b { 0 => Result::Err("divide by zero"), _ => Result::Ok(a / b), } } fn find_item(nr: i32)...
#![feature(plugin)] #![plugin(rocket_codegen)] extern crate rocket; extern crate wuligege; extern crate json; use wuligege::user::User; use rocket::response::content; #[get("/")] fn index() -> content::JSON<String> { let user = User::new("simon".to_string(),"123666".to_string()); content::JSON(user.to_json...
use super::node::FileNode; use super::node::NODE_TYPE_DIR; use std::iter::repeat; static SPACE_ONE: &'static str = " "; static SPACE_THREE: &'static str = " "; static SPACE_FOUR: &'static str = " "; static HORIZONTAL_LINE: &'static str = "─"; static VERTICAL_LINE: &'static str = "│"; static T_PREFIX: &'static str...
use std::{fs, collections::BTreeSet}; fn main() { let input = fs::read_to_string("./input.txt").unwrap_or_default(); let mut unique_houses: BTreeSet<(i32, i32)> = BTreeSet::new(); unique_houses.insert((0,0)); let mut x_santa = 0; let mut y_santa = 0; let mut x_robot = 0; let mut y_robot = ...
use mongodb::Database; use serde::Deserialize; use std::sync::Arc; use warp::http::StatusCode; use crate::user::{User, UserError}; #[derive(Deserialize)] pub struct UserParams { username: String, password: String, } pub async fn register( params: UserParams, db: Arc<Database>, ) -> Result<impl warp::...
use crate::*; static PACKAGE_NAME_VERSION_DELIMETER: &str = "@"; pub type PackageNameVersion = String; #[derive(BorshDeserialize, BorshSerialize)] pub struct Package { pub src_hash: String, pub urls: Vec<String>, } #[derive(Serialize, Deserialize)] #[serde(crate = "near_sdk::serde")] pub struct PackageJson {...
#[doc = "Register `GPIOB_OTYPER` reader"] pub type R = crate::R<GPIOB_OTYPER_SPEC>; #[doc = "Register `GPIOB_OTYPER` writer"] pub type W = crate::W<GPIOB_OTYPER_SPEC>; #[doc = "Field `OT0` reader - OT0"] pub type OT0_R = crate::BitReader; #[doc = "Field `OT0` writer - OT0"] pub type OT0_W<'a, REG, const O: u8> = crate:...
use std::collections::HashMap; /// A parser to parse JSON from string written with top-down parsing method. use crate::lexer::{generate_tokens, Token, TokenType}; #[derive(Debug, PartialEq)] pub enum Value { Null, Bool(bool), Number(f64), String(String), Array(Vec<Value>), Object(HashMap<String...
#![feature(inclusive_range_syntax)] #![feature(step_by)] #![crate_type = "cdylib"] #[no_mangle] pub extern "C" fn is_prime(n: u32) -> bool { match n { 0 | 1 => false, 2 | 3 => true, n if n & 1 == 0 => false, // even numbers n => { let limit = (n as f32).sqrt() as u32 +...
use super::codegen::ContextKind; use crate::*; #[cfg(feature = "perf")] use super::perf::*; use std::collections::HashMap; use std::path::PathBuf; use std::sync::mpsc::{Receiver, SyncSender}; use vm_inst::*; pub type ValueTable = HashMap<IdentId, Value>; pub type VMResult = Result<Value, RubyError>; #[derive(Debug)]...
use gssapi_sys; use std::ptr; use super::buffer::Buffer; use super::credentials::Credentials; use super::error::{Error, Result}; use super::name::Name; use super::oid::OID; #[derive(Debug)] pub struct Context { context_handle: gssapi_sys::gss_ctx_id_t, mech_type: OID, time_rec: u32, flags: u32, } imp...
use super::{category::CategorySchema, comment::CommentSchema, embed::EmbedSchema}; use crate::{ graphql::{schema::Context, user::UserSchema}, models::{ comment::Comment, embed::{Embed, Rating}, handler::Handler, node::CategoryNode, post::{Post, StatusPost}, user::...
//! A simple, thread-safe IRC server library. #![unstable = "This has yet to be written."]
#![allow(unused_imports)] use simplelog::Level::{Error, Info, Trace}; use tfdeploy::Tensor; use errors::*; use format::*; use utils::*; use {OutputParameters, Parameters}; /// Handles the `compare` subcommand. #[cfg(not(feature = "tensorflow"))] pub fn handle(_params: Parameters, _: OutputParameters) -> Result<()> { ...
// This file is part of css-purify. 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/css-purify/master/COPYRIGHT. No part of css-purify, including this file, may be copied, modified, propagated, or distribut...
#[macro_use] extern crate serde_derive; extern crate toml; extern crate regex; extern crate pcre2; pub mod config; pub mod rule; pub mod highlighter;
use std::net::TcpStream; use std::io::Write; use std::io::BufRead; use std::io::{BufReader, BufWriter}; fn main() { let host = "whois.radb.net"; let port = 43; match TcpStream::connect(format!("{}:{}", host, port)) { Ok(stream) => { println!("connected to {}:{}", host, port); ...
use crate::format::problem::*; use crate::format::solution::*; use crate::helpers::*; fn create_vehicle_type_with_shift_time_limit(shift_time: f64) -> VehicleType { VehicleType { limits: Some(VehicleLimits { max_distance: None, shift_time: Some(shift_time), tour_size: No...
// Copyright 2019, 2020 Wingchain // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to...
use proc_macro::TokenStream; use proc_macro2::TokenTree; use std::collections::HashSet; use syn; #[derive(Debug)] pub struct Pattern { pub struct_name: String, pub size: String, pub trimmed_pattern: String, pub original_pattern: String, pub tokens: HashSet<char>, } #[derive(Default)] struct Parsed...
use std::process::Command; use web3::types::{Address, U256}; use crypto::sha3::Sha3; use crypto::digest::Digest; use secp256k1::{Secp256k1, SecretKey}; use crate::primitive::block::Block; use bincode::{deserialize}; use serde::{Serialize, Deserialize}; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct BLSKe...
use self::query_plan_node::node_id::QueryPlanNodeId; pub(crate) mod query_plan_node; /// Query plan tree. /// This tree is a binary tree because every SELECT operation can break down into unary or binary operations. #[derive(Clone, PartialEq, Debug, new)] pub(crate) struct QueryPlanTree { pub(crate) root: QueryPl...
// Shields clippy errors in generated bundled.rs #![allow(clippy::unreadable_literal)] mod template; pub use self::template::{ TemplateContext, AVAILABLE_SPECS, DEFAULT_P2P_PORT, DEFAULT_RPC_PORT, DEFAULT_SPEC, }; pub use std::io::{Error, Result}; use self::template::Template; use numext_fixed_hash::H256; use st...
use hydroflow::{hydroflow_syntax, var_args}; #[hydroflow::main] async fn main() { let mut df = hydroflow_syntax! { // Should be a `Duration`. source_interval(5) -> for_each(std::mem::drop); }; df.run_async().await; }
use super::super::characters::Character; use super::super::boosters::Booster; use super::super::moves::Move; /// A request to the user for an `Answer`. /// /// This is how input is obtained. /// Every question is associated with a context (information that helps the user in answering the question). /// The context is ...
#![no_std] #![no_main] #![feature(trait_alias)] #![feature(min_type_alias_impl_trait)] #![feature(impl_trait_in_bindings)] #![feature(type_alias_impl_trait)] #![allow(incomplete_features)] #[path = "../example_common.rs"] mod example_common; use embassy_stm32::gpio::{Level, Output, Speed}; use embedded_hal::digital::...
#[doc = "Register `SECBOOTADD0R` reader"] pub type R = crate::R<SECBOOTADD0R_SPEC>; #[doc = "Register `SECBOOTADD0R` writer"] pub type W = crate::W<SECBOOTADD0R_SPEC>; #[doc = "Field `BOOT_LOCK` reader - BOOT_LOCK"] pub type BOOT_LOCK_R = crate::BitReader; #[doc = "Field `BOOT_LOCK` writer - BOOT_LOCK"] pub type BOOT_L...
use crate::er::{self, Result}; use crate::git; use crate::server; use crate::utils::{self, CliEnv}; use failure::{format_err, Error}; use futures::{ future::{self, Either}, Future, }; use serde::{Deserialize, Serialize}; use server::SshConn; use std::io; use std::path::PathBuf; #[derive(Serialize, Deserialize,...
use crate::enums::{ Align, CallbackTrigger, Color, ColorDepth, Cursor, Damage, Event, Font, FrameType, LabelType, Shortcut, }; use std::convert::From; use std::{fmt, io}; /// Error types returned by fltk-rs + wrappers of std errors #[derive(Debug)] pub enum FltkError { /// i/o error IoError(io::Error),...
/* * Datadog API V1 Collection * * Collection of all Datadog Public endpoints. * * The version of the OpenAPI document: 1.0 * Contact: support@datadoghq.com * Generated by: https://openapi-generator.tech */ use reqwest; use crate::apis::ResponseContent; use super::{Error, configuration}; /// struct for typ...
fn main(){ enum Temp{ hot, normal, cold, } fn calc_temp(t: Temp) -> i32{ match t { Temp::hot => 39, Temp::normal => 36, _ => 34, } } let temp = Temp::cold; println!("{}", calc_temp(temp)); }
/* * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT license. */ use std::env; use diskann::{ common::{ANNError, ANNResult}, index::ann_disk_index::create_disk_index, model::{ default_param_vals::ALPHA, vertex::{DIM_104, DIM_128, DIM_256}, DiskI...
use std::{borrow::Cow, collections::HashMap}; use serde::Serialize; use crate::{context::Context, shared_strings::SharedStringIndex}; #[derive(Default, Serialize)] pub(crate) struct Cells { pub(crate) next_col_index: ColIndex, pub(crate) cells: HashMap<ColIndex, Cell>, } #[derive(Default, Copy, Clone, Eq, P...
use crate::{ app::{ settings::Settings, sound::{SoundDevice, ZXSample, CHANNEL_COUNT, DEFAULT_LATENCY, DEFAULT_SAMPLE_RATE}, }, backends::SDL_CONTEXT, }; use sdl2::audio::{AudioCallback, AudioDevice, AudioSpecDesired}; use std::sync::mpsc; /// Struct which used in SDL audio callback struct ...
// Copyright © 2017, ACM@UIUC // // This file is part of the Groot Project. // // The Groot Project is open source software, released under the // University of Illinois/NCSA Open Source License. You should have // received a copy of this license in a file with the distribution. extern crate hyper; use hyper::*;...
use std::fs::{File, OpenOptions}; use std::io::prelude::*; use std::path::PathBuf; use toml; use gpg::{GPG}; use std::os::unix::fs::OpenOptionsExt; use PROTECTED_MODE; use std::error::Error; use secstr::SecStr; #[derive(Serialize, Deserialize, Debug)] pub struct EncryptedPassword { username: Option<String>, ...
#![feature(marker_trait_attr, termination_trait_lib)] #[macro_use] extern crate log; mod ingame; pub mod state_machine; pub use rsc2_pb::protocol; use std::io; use rsc2_pb::codec::Codec; use tokio::net::TcpStream; use tokio_util::codec::Framed; pub type Connection = Framed<TcpStream, Codec>; pub async fn connect...
/* * 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. */ use std::ffi::CStr; /// Path to the sabre executable. Needed for intercepting syscalls after execv...
#[doc = "Register `GICD_ICACTIVER1` reader"] pub type R = crate::R<GICD_ICACTIVER1_SPEC>; #[doc = "Register `GICD_ICACTIVER1` writer"] pub type W = crate::W<GICD_ICACTIVER1_SPEC>; #[doc = "Field `ICACTIVER1` reader - ICACTIVER1"] pub type ICACTIVER1_R = crate::FieldReader<u32>; #[doc = "Field `ICACTIVER1` writer - ICAC...
use crate::data::{Entry, Item, Status}; use crate::handler::Only; use crate::path::try_strip_prefix; use crate::{files, path_str}; use anyhow::Result; use glob::Pattern as GlobPattern; use std::path::{Path, PathBuf}; #[cfg(test)] mod tests; pub struct Indexer { // The path to the users home directory. home: P...
use crate::runtime_api::StateRootExtractor; use sp_api::ProvideRuntimeApi; use sp_blockchain::{Error, HeaderBackend}; use sp_domains::DomainsApi; use sp_runtime::traits::{Block as BlockT, Header, NumberFor}; use std::sync::Arc; /// Verifies if the xdm has the correct proof generated from known parent block. /// This i...
use messagebus::{ derive::{Error as MbError, Message}, error, Bus, Handler, Message, Module, }; use thiserror::Error; #[derive(Debug, Error, MbError)] enum Error { #[error("Error({0})")] Error(anyhow::Error), } impl<M: Message> From<error::Error<M>> for Error { fn from(err: error::Error<M>) -> Sel...