text
stringlengths
8
4.13M
fn main() { let points = 10i32; let mut saved_points: u32 = 0; saved_points = points; }
use gssapi_sys; use std::ptr; use super::buffer::BufferRef; use super::error::{Error, Result}; use super::oid::OID; #[derive(Debug)] pub struct Name { name: gssapi_sys::gss_name_t, name_type: OID, } impl Name { pub fn new<'a, T: Into<BufferRef<'a>>>(name: T, name_type: OID) -> Result<Self> { let m...
//! Abstracts over content providers for the songs. mod youtube; use self::youtube::Youtube; /// A content provider that uses URLs to provide content. pub trait UrlContentProvider { /// Returns a list of usable URLs. fn urls(&self) -> Vec<&str>; } /// Returns the fitting content provider for the given path....
// Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. use failure_ext::Result; use nix::unistd; use serde::de::DeserializeOwned; use serde::Serialize; use std::io::{BufRead, BufReader, Write}...
use rand::seq::SliceRandom; use rand::thread_rng; use rand::Rng; use crate::ship::*; #[derive(Debug)] pub struct Ocean { pub ships: Vec<Vec<Ship>>, pub shots: [[bool; 10]; 10], pub shots_fired_count: u32, pub shots_hit_count: u32, pub ship_sunk_count: u32, } impl Ocean { /// Creates an empty ...
use std::os::raw::c_uint; use std::path::PathBuf; use std::fs::File; use std::io::Write; use serde::{Serialize, Deserialize}; pub struct Config { encoding: Encoding, } #[derive(Debug)] pub enum CamError { RasCam(rascam::CameraError), Io(std::io::Error) } impl From<rascam::CameraError> for CamError { ...
//use std::fmt; /* #[derive(Debug)] struct Structure(i32); impl fmt::Display for Structure { fn fmt(&self,f: &mut fmt::Formatter) -> fmt::Result { println!("{}",self); } } */ fn main(){ println!("{} days",2); println!("{0},{1},{2}","Rits","Unv","sity"); println!("My name is {0},{0} {1}","James",...
use amethyst::{ assets::PrefabData, derive::PrefabData, ecs::{Component, DenseVecStorage, Entity, WriteStorage}, Error, }; use serde::{Deserialize, Serialize}; #[derive(Clone, Copy, Debug, Serialize, Deserialize, PrefabData)] #[prefab(Component)] pub struct Ball; impl Component for Ball { type Sto...
/* 配列型 [i64;256] 64bit(2**6)×256(2**8)=16kbit スライス型 &[u8] 配列への参照を表す */ fn main(){ let a: [isize;3] = [1, 2, 3]; // "&配列"でスライスが作れる。 let b: &[isize] = &a; // スライスをフォーマットするにはプレースホルダが"{:?}"になる。 println!("{:?}", b); for elm in b { println!("{}", elm); } }
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::mock::{KeyPairWallet, MemWalletStore}; use crate::{ServiceResult, Wallet, WalletAccount, WalletAsyncService}; use anyhow::Result; use starcoin_types::account_address::AccountAddress; use starcoin_types::transaction::{RawU...
use std::fs::File; use std::error::{Error}; use std::io::{self, Write, Read}; use std::process; use serde::Deserialize; use rand::{thread_rng, Rng}; use std::str; // DISCLAIMER: Chemical processes replicated in the program are simplified and not extremely accurate #[derive(Debug)] struct Atom<'a> { element: Element...
use std::io::{Result, Error, ErrorKind}; use std::path::Path; use std::fs::File; use serde_json; use types::Struct; use random::{Rng, seeded_rng, thread_rng}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Corpus { pub seed: u64, pub serializations: usize, pub mutations: usize, pub structs...
use aoc::read_data; use std::collections::HashMap; use std::error::Error; #[allow(dead_code)] fn trans(s: &str) -> Vec<usize> { s.split(',').map(|x| x.parse().unwrap()).collect() } fn turrn(data: &mut Vec<usize>, videno: &mut HashMap<usize, (usize, usize)>, turn: usize) -> usize { if turn - 1 < data.len() { ...
use crate::actions::Action; use crate::error::Result; use crate::shared::install_log::PackageLog; use crate::shared::FileSystemResource; use prettytable::Table; // ------------------------------------------------------------------------------------------------ // Public Types // ---------------------------------------...
#[cfg(test)] mod tests { use super::super::instruction::*; use super::super::parser::*; fn ins(size: u16, instruction: Instruction) -> SizedInstruction { SizedInstruction { size: size, instruction: instruction } } #[test] fn test() { let test_cases = vec! [ (vec![0xB8, 0x2A, 0x00], ins(...
use friday_error::FridayError; use friday_logging; use crate::core::{Signal, Device}; pub struct MockDevice; impl MockDevice { pub fn new() -> MockDevice { MockDevice{} } } impl Device for MockDevice { fn name(&self) -> String { "mock".to_owned() } fn send(&mut self, signal: &Signal) -> Resul...
#![feature(test)] extern crate test; extern crate little; extern crate byteorder; use std::collections::HashMap; use std::io::{ self, Read, Write, Seek }; use std::fmt; use std::mem; use little::*; use little::interpreter::Interpreter; /// Simple value implementation. /// You can provide your own value implementati...
#![allow(dead_code)] fn func(n: i32) -> bool { if n < 0 { print!("{} is negative", n); false } else if n > 0 { print!("{} is positive", n); true } else { print!("{} is zero", n); true } // 如果 else 分支省略掉了,那么编译器会认为 else 分支的类型默认为 () } // if-else 表达式 pub...
/*! ```rudra-poc [target] crate = "multiqueue" version = "0.3.2" [[target.peer]] crate = "futures" version = "0.1.27" [report] issue_url = "https://github.com/schets/multiqueue/issues/31" issue_date = 2020-12-25 rustsec_url = "https://github.com/RustSec/advisory-db/pull/744" rustsec_id = "RUSTSEC-2020-0143" [[bugs]]...
#![warn(missing_docs)] #![feature(doc_cfg, auto_traits, negative_impls)] //! Tiny 2D vector library. Inspired by [p5.js](https://p5js.org/)'s //! [`p5.Vector`](https://p5js.org/reference/#/p5.Vector). //! //! The main type, [`Vecc<T>`](crate::vecc::Vecc), is a generic struct //! implementing many useful traits and ope...
use std::io::{Write, BufRead, BufReader,BufWriter}; use crate::turn::Turn; use crate::board::Board; use crate::game::Play; #[derive(Debug)] pub struct Player; impl Play for Player{ fn play(&self, turn:&Turn, board:&Board) -> u64 { let legalboard = board.LegalBoard(turn); let mut pos: u6...
#[doc = "Register `EXTI_RTSR3` reader"] pub type R = crate::R<EXTI_RTSR3_SPEC>; #[doc = "Register `EXTI_RTSR3` writer"] pub type W = crate::W<EXTI_RTSR3_SPEC>; #[doc = "Field `RT65` reader - RT65"] pub type RT65_R = crate::BitReader; #[doc = "Field `RT65` writer - RT65"] pub type RT65_W<'a, REG, const O: u8> = crate::B...
use crate::device::Device; use crate::error::Error; use crate::error::Result; use crate::object::Object; use crate::object::ObjectType; use crate::rawdevice::drm_mode_get_property; #[derive(Debug)] pub struct Property<'a> { dev: &'a Device, id: u32, name: String, } impl<'a> Object for Property<'a> { ...
#[macro_use] mod version_deps; mod accessor; mod apply_log; mod as_ref_async; mod as_ref_opt; mod async_try_from; mod ctx; mod ctx_type_info; mod entity; mod entity_fields; mod entity_of; mod error; pub mod gc; mod get; mod get_mut; mod hash_table; mod init; mod insert; mod instrumented_err; mod is_defined; mod iterat...
use super::window::Window; pub struct StatusBar { window: Box<dyn Window>, } impl StatusBar { pub fn new(window: Box<dyn Window>) -> Self { Self { window } } pub fn update_mode(&mut self, mode: &str) { self.window.save_cursor_pos(); self.window.move_cursor_and_clear_line(0); ...
// Readonly middleware use interface::*; use errors::*; /// Read-only wrapper for MemoryBlocks. /// Raises an error if you try to write to it. /// Reading simply gets passed through. /// Useful in cases where you dynamically dispatch between different blocks. pub struct ReadOnly<M: MemoryBlock> { mem: Box<M>, } i...
#![allow(unused_imports)] #![allow(non_snake_case)] #![allow(non_camel_case_types)] #![allow(dead_code)] #![allow(unused_must_use)] use std::str; use std::sync::*; use std::thread; use std::env; use zmq; use server::*; use server::param::*; use server::worker::*; fn main() { let args: Vec<String> = env::args()....
use crate::{errors::Error, Datum}; pub trait Filter: FilterClone { fn exec(&mut self, datum: Datum) -> Result<Option<Datum>, Error>; } // This is a hack to allow us to clone Filters that are passed around as trait objects. // https://stackoverflow.com/questions/30353462/how-to-clone-a-struct-storing-a-boxed-trait...
use std::fs::File; use std::io::{self, BufRead}; use substring::Substring; use std::cmp::max; pub fn part1() -> usize { return partn(); } pub fn part2() -> usize { return partn(); } fn partn() -> usize { let file = File::open("data/d05.txt").unwrap(); let buf = io::BufReader::new(file); let mut ...
#[doc = "Register `CSGCMCCM4R` reader"] pub type R = crate::R<CSGCMCCM4R_SPEC>; #[doc = "Register `CSGCMCCM4R` writer"] pub type W = crate::W<CSGCMCCM4R_SPEC>; #[doc = "Field `CSGCMCCM4` reader - CSGCMCCM4"] pub type CSGCMCCM4_R = crate::FieldReader<u32>; #[doc = "Field `CSGCMCCM4` writer - CSGCMCCM4"] pub type CSGCMCC...
// Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. use air::Air; use math::{fft, log2, StarkField}; use utils::collections::Vec; // TYPES AND INTERFACES // ================================...
use { std::{ fmt, cmp::{PartialEq, Eq}, hash::{Hash, Hasher} }, serde::{Serialize, Deserialize}, crate::io::* }; pub type AxisScale = f32; pub type AxisValue = f32; #[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Serialize, Deserialize)] pub enum AxisId { Key(VirtualKey),...
use std::{path::Path, process::Command, env}; fn add_indention(text: &str, indention: usize) -> String { let mut new_text = String::new(); for line in text.lines() { new_text.push_str(&" ".repeat(indention)); new_text.push_str(line); new_text.push_str("\n"); } new_text } fn pre...
use enum_primitive::*; use fal::parsing::{read_u16, read_u32}; #[derive(Clone, Debug)] pub struct CryptoFlags; enum_from_primitive! { #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub enum ProtectionClass { DirNone = 0, A = 1, B = 2, C = 3, D = 4, F = 6, ...
use shrev::*; use specs::*; use types::*; use consts::timer::SCORE_BOARD; use dispatch::SystemInfo; use systems; use component::channel::*; use component::event::TimerEvent; use component::time::ThisFrame; use protocol::server::PlayerKill; use protocol::{to_bytes, ServerPacket}; use websocket::OwnedMessage; pub st...
use proconio::{input, marker::{Bytes, Chars}}; fn main() { input! { n: usize, s: Bytes, x: Chars, } let s: Vec<u8> = s.iter().map(|c| c - b'0').collect(); let mut dp = 1; for i in (0..n).rev() { let mut r = 0; for j in 0..7 { let m = ((j * 10 % 7...
#![allow(non_snake_case)] use crate::{ math::{FromCSV, Matrix, Vector}, regressor::{ config::Config, regressor::Regressor, utils::{assess_alpha as assess, Penalty}, }, }; pub mod regressor; pub mod math; #[no_mangle] pub extern "C" fn fit(buffer: *mut f64, n: usize, method: u64, i...
use std::fs; use std::fs::File; use std::path::Path; use std::io; use std::io::{Error, ErrorKind}; use std::io::{BufRead, BufReader}; use std::io::{Seek, SeekFrom}; use crate::window::*; use crate::util::*; pub struct RFile { pub name: String, pub main: Option<File>, // opening an empty instance will create a sw...
use clap::{App, Arg}; use polyseme::{PolysemeBuilder, PolysemeParser, RecordFetcher}; use std::io::Stdout; use std::io::{stdout, Write}; use std::net::IpAddr; use std::str::FromStr; use trust_dns_resolver::config::{NameServerConfigGroup, ResolverConfig, ResolverOpts}; use trust_dns_resolver::Resolver; fn main() { ...
pub mod schema; #[cfg(feature = "schema-language")] pub mod schema_language; use crate::db::Extension; use crate::db::PoolPg; //= sqlx::Pool<sqlx::postgres::Postgres>; use axum::extract::{FromRequest, RequestParts}; use futures::TryFutureExt; use std::{convert::Infallible, sync::Arc}; use http::request::Request; use ...
use crate::prelude::*; pub trait ReadAt { fn read_at(&self, offset: u64, buffer: &mut [u8]) -> Result<usize>; fn read_exact_at(&self, offset: u64, buffer: &mut [u8]) -> Result<()> { let mut buffer = buffer; while !buffer.is_empty() { match self.read_at(offset, buffer) { ...
use std::borrow::Cow; use std::fmt; use proc_macro2::{Span, TokenStream}; use syn::spanned::Spanned; use syn::{Lit, Meta}; use crate::utils::ErrorExt; /// Creates `"`a`, `b` or `c`"` from `&["a", "b", "c"]` and `"or"` fn format_items<I, T: fmt::Display, L: fmt::Display>(iterator: &I, last: L) -> String where for...
pub mod header; extern crate bytes; extern crate mio;
// Copyright 2018 Dmitry Tantsur <divius.inside@gmail.com> // // 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 ap...
use std::process; const XX_BIT : u64 = 64; const CODE_START : usize = 0x8000; const KEYBOARD_ADDR : usize = 0x6000; const SCREEN_START : i64 = 0x4000; const SCREEN_END : i64 = 0x5fff; /* const DATA_START : u64 = 0; const DATA_END : u64 = 0x3fff; const DATA_SIZE : u64 = DATA_END - DATA_START ...
// we need check url is http or https ? // it's easy fn check_is_url(url: String) -> bool { if (url.find("http://") != None) || (url.find("https://") != None) { return true; } else { return false; } } fn main() { // some test case println!("{:#?}", check_is_url("https://google.com/"...
#[doc = "Register `AXIMC_PERIPH_ID_0` reader"] pub type R = crate::R<AXIMC_PERIPH_ID_0_SPEC>; #[doc = "Field `PERIPH_ID_0` reader - PERIPH_ID_0"] pub type PERIPH_ID_0_R = crate::FieldReader; impl R { #[doc = "Bits 0:7 - PERIPH_ID_0"] #[inline(always)] pub fn periph_id_0(&self) -> PERIPH_ID_0_R { PER...
#![allow(dead_code)] mod lexer; mod parser; fn main() { println!("Hello, world!"); let _v = parser::parse(r#"{"key":"value"}"#); }
#![doc = "generated by AutoRust 0.1.0"] #![allow(unused_mut)] #![allow(unused_variables)] #![allow(unused_imports)] use super::{models, API_VERSION}; #[non_exhaustive] #[derive(Debug, thiserror :: Error)] #[allow(non_camel_case_types)] pub enum Error { #[error(transparent)] Certificates_List(#[from] certificate...
fn main() { let str = include_str!("input.txt"); let mut lines = str.lines(); let mut s = SnailNumbers::new(); s.parse(lines.next().unwrap()); s.explode_and_split(); let mut res = s.to_string(); let mut mag = 0; for line in lines { let mut s = SnailNumbers::by_adding(res.as_str(...
//! examples/timing_exam.rs // #![deny(unsafe_code)] // #![deny(warnings)] #![no_main] #![no_std] use cortex_m::{asm, peripheral::DWT}; use panic_halt as _; use rtic::cyccnt::{Duration, Instant, U32Ext}; use stm32f4::stm32f411; #[no_mangle] static mut T1_MAX_RP: u32 = 0; #[no_mangle] static mut T2_MAX_RP: u32 = 0; #...
// 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...
#![feature(extern_prelude)] #[macro_use] extern crate lazy_static; extern crate reqwest; extern crate image; extern crate resize; pub mod gsi; pub mod cities_skylines; pub mod lib_error; pub mod gsj; pub mod wgs84; pub mod web_mercator; use std::mem; use std::io::Write; use lib_error::{ Error }; pub fn empty_test() ...
use ::{ ActoxResult, ActoxError, ActorPool }; use ::etrace::Error; use ::std::{ thread, collections::VecDeque, time::Duration, sync::mpsc::{ self, SyncSender, Receiver, TryRecvError } }; /// A blocking event source pub trait BlockingEventSource<E: Send + 'static, R: Send + 'static> where Self: Send + 'static { ///...
pub trait CurrencyApi { fn transfer(receiver: &String, amount: u64); }
//! Crate **ruma_identifiers** contains types for [Matrix](https://matrix.org/) identifiers //! for events, rooms, room aliases, and users. #![deny(missing_debug_implementations)] #![deny(missing_docs)] #![deny(warnings)] #[cfg(feature = "diesel")] #[cfg_attr(feature = "diesel", macro_use)] extern crate diesel; use ...
use regex::Regex; use common::error::Error; use common::result::Result; #[derive(Debug, Clone)] pub struct Email { email: String, } impl Email { pub fn new<S: Into<String>>(email: S) -> Result<Self> { let email = email.into(); if email.len() < 5 { return Err(Error::new("email", "...
#![allow(unused)] extern crate serde; extern crate serde_json; #[macro_use] extern crate serde_derive; extern crate rand; #[macro_use] mod common; mod lib; mod ai; global!(STIME: std::time::SystemTime = std::time::SystemTime::now()); const DEFAULT_AI: &'static str = "lightning"; #[derive(Serialize, Deserialize, D...
use crate::{ attribute::attribute_name::AttributeName, correlation::{ aliased_correlation_name::AliasedCorrelationName, correlation_alias::CorrelationAlias, correlation_name::CorrelationName, }, field::{aliased_field_name::AliasedFieldName, field_alias::FieldAlias, field_name::FieldName}...
use crate::analyzer::dex::dex_field_node::DexFieldNode; use crate::analyzer::dex::dex_method_node::DexMethodNode; use crate::analyzer::dex::DexElementNode; #[derive(Clone)] pub struct DexClassNode { pub(crate) name: String, pub(crate) child: Vec<DexElementNode>, } impl DexClassNode { pub fn new(name: Stri...
use proc_macro::TokenStream; use quote::quote; use syn::{parse_macro_input, AttributeArgs, Ident, ItemFn, Lit, NestedMeta}; #[proc_macro_attribute] pub fn main(args: TokenStream, input: TokenStream) -> TokenStream { let input_path = match &parse_macro_input!(args as AttributeArgs)[..] { [NestedMeta::Lit(Li...
// Copyright (c) 2020 Ant Financial // // SPDX-License-Identifier: Apache-2.0 // mod protocols; mod utils; #[macro_use] extern crate log; use std::sync::Arc; use log::LevelFilter; #[cfg(unix)] use protocols::r#async::{agent, agent_ttrpc, health, health_ttrpc, types}; #[cfg(unix)] use ttrpc::asynchronous::Server; u...
#[doc = "Reader of register ETH_DMAMR"] pub type R = crate::R<u32, super::ETH_DMAMR>; #[doc = "Writer for register ETH_DMAMR"] pub type W = crate::W<u32, super::ETH_DMAMR>; #[doc = "Register ETH_DMAMR `reset()`'s with value 0x8000"] impl crate::ResetValue for super::ETH_DMAMR { type Type = u32; #[inline(always)...
use super::*; #[test] fn fn_def_is_well_formed() { test! { program { fn foo(); } goal { WellFormed(foo) } yields { "Unique" } } } #[test] fn fn_def_is_sized() { test! { program { #[lang(sized)] trai...
use std::fs::File; use std::error::Error; use std::net::TcpStream; use std::io::{Write, Read}; use serde_derive::Serialize; fn main() -> Result<(), Box<dyn Error>> { let time = std::time::Instant::now(); let emoji_test_data = fetch("unicode.org", "/Public/emoji/13.0/emoji-test.txt")?; // let emoji_test_data = fe...
use std::io; use std::mem; use tracker::errors::{Result, ErrorKind}; pub(super) struct Reader { data: Vec<u8>, idx: usize, state: ReadState, } enum ReadState { ParsingHeaderR1, ParsingHeaderN1, ParsingHeaderR2, ParsingHeaderN2, ParsingResponse, } enum ReadRes { Done, Again, ...
use image; use num::complex::Complex; fn get_color(i: u32, max_iters: u32) -> image::Rgb<u8> { if i > max_iters{ return image::Rgb([255,255,255]); } if max_iters == 255 { let idx = i as u8; return image::Rgb([idx, idx, idx]); } let idx = (((i as f32)/(max_iters as f32))*255...
use crate::library::Library; #[derive(Debug)] pub struct Metadata { books_count: usize, library_count: usize, pub days: usize, } impl Metadata { fn new(values: Vec<usize>) -> Self { Self { books_count: values[0], library_count: values[1], days: values[2], ...
use utils; use std::collections::HashSet; use std::iter::FromIterator; pub fn problem_046() -> usize { let n = 100; let squares: Vec<usize> = (0..n).map(|i| i * i).collect(); let primes: Vec<usize> = utils::prime_sieve(n * n); let prime_set: HashSet<&usize> = HashSet::from_iter(primes.iter()); le...
#[macro_use] extern crate lazy_static; use rand::distributions::Uniform; use rand::prelude::*; use std::collections::HashMap; lazy_static! { pub static ref TEST_DATA: HashMap<String, ProgramData> = get_all_programs(); } pub struct ProgramData { pub text: &'static str, pub valid_io: Vec<(Vec<i64>, Vec<i64...
use crate::display::DisplayWith; use serde::Deserialize; use serde::Serialize; use std::collections::btree_map::Entry; use std::collections::BTreeMap; use std::fmt; use std::iter; use std::ops; use std::ops::Deref; use std::ops::DerefMut; use std::slice; #[derive(Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord,...
//! Module describing user-configurable aspecs of GSync use crate::env::Env; use rusqlite::named_params; use crate::{Result, unwrap_db_err, Error}; /// Struct describing a configuration for GSync #[derive(Debug)] pub struct Configuration { /// Google Client ID pub client_id: Option<String>, ...
use super::components::*; use super::GameLog; use specs::prelude::*; pub struct DamageSyst {} impl DamageSyst { pub fn delete_the_dead(ecs: &mut World) { let mut dead_vec: Vec<Entity> = Vec::new(); let mut log = ecs.write_resource::<GameLog>(); let combat_stats = ecs.read_storage::<Combat...
use jsonrpc_core::{Result, Error}; use jsonrpc_derive::rpc; use sp_core::blake2_256; type Hash = [u8; 32]; #[rpc] pub trait PuzzleRpc { #[rpc(name = "puzzle")] fn create_puzzle(&self, recipient: String, password: String) -> Result<String>; } pub struct Puzzle; impl PuzzleRpc for Puzzle { fn create_puzzl...
use hangul::HangulExt; use rand::seq::SliceRandom; use strsim::normalized_levenshtein; pub fn manufacture_file(content: &String) -> Vec<String> { let content: Vec<&str> = content.split("\n").collect(); let mut result: Vec<String> = Vec::new(); for i in content { &mut result.push(String::from(i));...
pub use self::arch::*; #[cfg(target_arch = "x86")] #[path="x86/idt.rs"] mod arch; #[cfg(target_arch = "x86_64")] #[path="x86_64/idt.rs"] mod arch;
// cargo test -- --nocapture use std::collections::HashMap; fn main() { println!("Hello, world!"); } fn mod1(elements: Vec<i32>) -> Result<Vec<i32>, String> { let mut m = vec![]; let mut n: i32 = 0; for e in elements.iter() { n += e; m.push(n); } Ok(m) } fn birthday_cake_candle...
use crate::ctx::ClientContext; use crate::session_ctx::SessionContext; use anyhow::Result; use maud::html; use rustimate_core::profile::UserProfile; use rustimate_core::session::EstimateSession; use rustimate_core::ResponseMessage; use std::sync::RwLock; use uuid::Uuid; pub(crate) struct MessageHandler {} impl Messa...
use std::io; use std::sync::mpsc::{Receiver, RecvError, Sender, TryRecvError}; use std::thread::JoinHandle; use std::time::{SystemTime, UNIX_EPOCH}; use crate::{block, spawn_with_name}; use crate::block::Block; use crate::node::Incoming; #[derive(Debug, Copy, Clone)] pub enum ToMiner { Start(u8, Block), Reset...
pub mod point; pub mod triangle; pub mod mesh;
#[doc = "Register `GCCFG` reader"] pub type R = crate::R<GCCFG_SPEC>; #[doc = "Register `GCCFG` writer"] pub type W = crate::W<GCCFG_SPEC>; #[doc = "Field `PWRDWN` reader - Power down"] pub type PWRDWN_R = crate::BitReader; #[doc = "Field `PWRDWN` writer - Power down"] pub type PWRDWN_W<'a, REG, const O: u8> = crate::B...
#[doc = "Register `FS1R` reader"] pub type R = crate::R<FS1R_SPEC>; #[doc = "Register `FS1R` writer"] pub type W = crate::W<FS1R_SPEC>; #[doc = "Field `FSC0` reader - Filter scale configuration"] pub type FSC0_R = crate::BitReader; #[doc = "Field `FSC0` writer - Filter scale configuration"] pub type FSC0_W<'a, REG, con...
#[macro_use] // extern crate lazy_static; extern crate sdl2; extern crate xmplayer; mod leak; #[cfg(feature="sdl2-feature")] mod sdl2_audio; #[cfg(feature="sdl2-feature")] use sdl2_audio::AudioOutput; #[cfg(feature="portaudio-feature")] mod portaudio_audio; #[cfg(feature="portaudio-feature")] use portaudio_audio::A...
pub mod article; pub mod user; pub mod comment;
use super::{Hertz, RCC}; const VCO_MIN: u32 = 150_000_000; const VCO_MAX: u32 = 420_000_000; #[derive(Default)] pub struct PllConfig { pub p_ck: Option<Hertz>, pub q_ck: Option<Hertz>, pub r_ck: Option<Hertz>, } pub(super) struct PllConfigResults { pub ref_x_ck: u32, pub pll_x_m: u32, pub pll...
#![no_std] #![no_main] #![feature(custom_test_frameworks)] #![test_runner(blog_os::test_runner)] #![reexport_test_harness_main = "test_main"] use core::panic::PanicInfo; extern crate alloc; use alloc::{boxed::Box, vec, vec::Vec}; #[cfg(not(test))] use blog_os::{println, serial_print, serial_println}; use blog_os::...
use std::cell::Cell; use std::ffi::*; use std::fmt; use std::mem; use std::ops::Drop; use std::ptr; use super::*; use exprtk_sys::*; use libc::{c_char, c_double, c_void, size_t}; // Sending pointers to CExpression and CSymbolTable // around should be safe. Calls to methods with non-mutable // access to self should ha...
use actix_web::{ App, HttpServer }; use actix_files as fs; mod paths; static PATH_FE: &'static str = "./_FE/DemoApp/dist/"; pub async fn main() -> std::result::Result<(), std::io::Error> { actix_web::rt::System::new("web").block_on(async move { HttpServer::new(move || { App::new() ...
extern crate proc_macro; extern crate syn; #[macro_use] extern crate quote; use proc_macro::TokenStream; mod message; macro_rules! create_derive( ($mod_: ident, $trait_: ident, $fn_name: ident) => { #[proc_macro_derive($trait_)] #[doc(hidden)] pub fn $fn_name(input: TokenStream) -> TokenS...
use crate::atomicfile; use display_as::{display, with_template, DisplayAs, HTML, UTF8}; use futures::{FutureExt, StreamExt}; use serde::{Deserialize, Serialize}; use tokio::sync::{mpsc, RwLock}; use warp::reply::Reply; use warp::{path, Filter}; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] struct Char...
use regex::{Regex, Captures}; use std::fs::read_to_string; use std::collections::HashMap; const INPUT_FILE: &str = "data/day_7.txt"; lazy_static! { static ref ASSIGN_REGEX: Regex = Regex::new(r"^(\w+) -> (\w+)$").unwrap(); static ref AND_REGEX: Regex = Regex::new(r"^(\w+) AND (\w+) -> (\w+)$").unwrap(); s...
use std::rc::Rc; use theme::ColorStyle; use Cursive; use vec::Vec2; use view::View; use event::*; use printer::Printer; use unicode_width::UnicodeWidthStr; /// Simple text label with a callback when ENTER is pressed. /// A button shows its content in a single line and has a fixed size. pub struct Button { label: ...
#![feature(test)] extern crate test; extern crate delight_book; use delight_book::chapter9::*; use std::borrow::BorrowMut; #[bench] #[allow(overflowing_literals)] fn bench_multiply_mulmns(b: &mut test::Bencher) { let test = [ // m, n, u..., v..., cq..., cr.... 1, 1, 3, 0, 1, 1, ...
use rmu::raw::Vec4f; use titanium::base::Size; use titanium::gui::{ layout::CoordinateArea, widget::*, }; use titanium::renderer::canvas::{ Layer, text::Text, graphics::*, }; use titanium::graphics::Rectangle; use titanium::event::Event; #[derive(Clone)] pub struct InfoBar { pub information:...
// Project Euler #5. Accidentally Quadratic for the win! // This might benefit from some memoization. use std::collections::HashMap; type Int = i64; struct Memocate { memo: HashMap<(Int, Int), bool> } impl Memocate { fn new() -> Memocate { Memocate { memo: HashMap::new() } } fn predicate(...
pub mod math; pub mod learning;
//! Parser for a "matcher string". The tokens produced by this parser are used to construct a matcher. #![deny( missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, trivial_numeric_casts, unsafe_code, unstable_features, unused_qualifications )] pub ...
//! The client module exposes the `PTClient` struct which is the main interface to use, and //! contains all methods necessary to make calls to the API. //! //! Please see the [`passivetotal::client::PTClient`][1] documentation //! //! [1]: ./struct.PTClient.html use std::io::Error as IoError; use std::io::Read; use h...
#![cfg(all(test, feature = "test_e2e"))] use azure_core::prelude::*; use azure_cosmos::prelude::*; use futures::stream::StreamExt; mod setup; const TRIGGER_BODY: &str = r#" function updateMetadata() { var context = getContext(); var collection = context.getCollection(); var response = context.getResponse(...
#[allow(dead_code, unused_variables, unused_imports)] mod instr_block_data_transfer; #[allow(dead_code, unused_variables, unused_imports)] mod instr_coprocessor; #[allow(dead_code, unused_variables, unused_imports)] mod instr_dataproc; #[allow(dead_code, unused_variables, unused_imports)] mod instr_hws_data_transfer; #...