text
stringlengths
8
4.13M
use std::any::Any; use std::marker::PhantomData; use specs::*; use dispatch::sysinfo::*; use dispatch::syswrapper::*; pub trait AbstractBuilder<'a> { fn build<'b>(self, disp: DispatcherBuilder<'a, 'b>) -> DispatcherBuilder<'a, 'b>; } pub trait AbstractThreadLocalBuilder<'b> { fn build_thread_local<'a>(self, disp:...
extern crate clap; mod intcode_machine; mod util; use intcode_machine::{run_all, Machine, State}; use std::collections::HashMap; use std::io::{stdin, BufRead}; use util::{PartID, part_id_from_cli}; struct Frame { map: HashMap<(i64, i64), i64>, max_x: i64, max_y: i64, score: i64, ball_x : i64, ...
#[doc = "Register `CFGR1` reader"] pub type R = crate::R<CFGR1_SPEC>; #[doc = "Register `CFGR1` writer"] pub type W = crate::W<CFGR1_SPEC>; #[doc = "Field `DMAEN` reader - Direct memory access enable"] pub type DMAEN_R = crate::BitReader<DMAEN_A>; #[doc = "Direct memory access enable\n\nValue on reset: 0"] #[derive(Clo...
use super::types; use std::collections::HashMap; pub fn compile_declaration( module_builder: &fmm::build::ModuleBuilder, declaration: &pir::ir::Declaration, types: &HashMap<String, pir::types::RecordBody>, ) { module_builder.declare_variable( declaration.name(), types::compile_unsized_c...
use actix_web::{middleware, web, App, error, Error, HttpRequest, HttpServer, HttpResponse}; use std::thread; use bytes::Bytes; use futures::{future::ok, Future, Stream}; use futures::unsync::mpsc; fn index(req: HttpRequest) -> &'static str { println!("REQ: {:?}", req); no_loop(); "Index Hello world!" }...
extern crate april; extern crate image; use april::*; use std::env::args; fn main() { println!("STARTING"); let mut detector = Detector::create(); detector.add_family(TagFamilyType::Tag16h5); detector.add_family(TagFamilyType::Tag25h7); detector.add_family(TagFamilyType::Tag25h9); detector.a...
use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian}; use csv::StringRecord; use std::io::Cursor; use std::ops::Index; // TODO change Schema to ColumnTypes? // TODO remove indexes, all info can be inferred from schema // once Text is allocated as fixed length use {DataType, Schema}; use error::*; #[derive(Debug,...
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under both the MIT license found in the * LICENSE-MIT file in the root directory of this source tree and the Apache * License, Version 2.0 found in the LICENSE-APACHE file in the root directory * of this source tree. */ #![cf...
use serde::Deserialize; use common::result::Result; use crate::domain::role::{RoleId, RoleRepository}; use crate::domain::user::{UserId, UserRepository}; #[derive(Deserialize)] pub struct ChangeRoleCommand { pub role_id: String, } pub struct ChangeRole<'a> { role_repo: &'a dyn RoleRepository, user_repo:...
use sha2::{Digest, Sha512Trunc256}; pub const SIZE256: usize = 32; pub type SHA512_256 = Sha512Trunc256; impl super::Hash for SHA512_256 { fn size() -> usize { SHA512_256::output_size() } fn block_size() -> usize { super::BLOCK_SIZE } fn reset(&mut self) { Digest::reset(...
fn main() { let n = 4; if n > 0 { println!("positive"); } }
use self::Filter::*; use bindgen::Builder; use make_cmd::make; use std::env::var; use std::fs::copy; use std::path::{Path, PathBuf}; use std::process::{Command, ExitStatus}; enum Filter { Function, Type, Var, } const WHITELIST: &[(Filter, &str)] = &[ // // cache (Var, "startup_info"), (Fun...
use std::collections::HashMap; use std::path::Path; use std::fs::File; use std::io::Read; use toml; #[derive(Serialize, Deserialize, Debug)] pub struct Factoids { pub factoids: HashMap<String, String> } impl Factoids { pub fn load(src: &Path) -> Factoids { let mut file = File::open(src).unwrap(); ...
#[doc = "Register `MACMIIAR` reader"] pub type R = crate::R<MACMIIAR_SPEC>; #[doc = "Register `MACMIIAR` writer"] pub type W = crate::W<MACMIIAR_SPEC>; #[doc = "Field `MB` reader - MII busy"] pub type MB_R = crate::BitReader<MB_A>; #[doc = "MII busy\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pu...
// Copyright 2017-2018 Parity Technologies // // 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 ...
use std::io; use std::io::prelude::*; use std::fs::File; fn main() { let x = frequency(0,readfile()); println!("{}", x); } fn readfile() -> Vec<String>{ let file = File::open("input.txt").unwrap();; let reader = io::BufReader::new(file); reader.lines().map(|l| l.expect("Could not parse line")).collect() } ...
use std::collections::HashMap; fn get_bottles(n: i32) -> HashMap<&'static str, String> { let mut h = HashMap::new(); // https://stackoverflow.com/a/38908324 for current in (0..100).rev() { let mut next: i32 = current - 1; if current == 0 { next = 99; println...
#[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; mod helpers; use crate::helpers::configuration::*; use crate::helpers::request_handling::*; use crate::helpers::virustotal::*; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>>{ let load_config = get_conf(...
mod misc; mod normal; mod setup; pub use normal::{Payload, PayloadBuilder}; pub use setup::{SetupPayload, SetupPayloadBuilder};
/** * Authors: Jorge Martins && Diogo Lopes * This example is from Vasconcelos, V.T. (and several others): * "Behavioral Types in Programming Languages" (figures 2.4, 2.5 and 2.6) */ use crate::agency; use crate::message::Decision; use crate::message::Message; use chan::Receiver; use chan::Sender; use chrono::prelude::...
use crate::cars::data::CarComponent; use crate::interaction::{FollowEntity, Movable, MovedEvent}; use crate::map_model::IntersectionComponent; use crate::physics::{Kinematics, Transform}; use crate::rendering::meshrender_component::MeshRender; use cgmath::Vector2; use imgui::im_str; use imgui::Ui; use imgui_inspect::{I...
pure fn is_whitespace(c: char) -> bool { const ch_space: char = '\u0020'; const ch_ogham_space_mark: char = '\u1680'; const ch_mongolian_vowel_sep: char = '\u180e'; const ch_en_quad: char = '\u2000'; const ch_em_quad: char = '\u2001'; const ch_en_space: char = '\u2002'; const ch_em_space: ch...
//! A series of re-exports to simplify usage of the framework. //! //! Some exports are renamed to avoid name conflicts as they are generic. //! These include: //! //! - `Context` -> `FrameworkContext` //! - `Error` -> `FrameworkError` #[cfg(feature = "macros")] pub use command_attr::{check, command, hook}; pub use c...
#![allow(unknown_lints)] #![deny(unused_variables)] #![deny(unused_mut)] #![deny(clippy)] #![deny(clippy_pedantic)] #![allow(stutter)] #![recursion_limit = "128"] //! //! Neon-serde //! ========== //! //! This crate is a utility to easily convert values between //! //! A `Handle<JsValue>` from the `neon` crate //! and...
// Run-time: // status: success // stdin: abc // stdout: Hello abc use std::io::{Read, stdin}; fn main() { let mut buf = String::new(); stdin().read_to_string(&mut buf).unwrap(); println!("Hello {}", buf); }
/* * 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 */ /// SloResponse : A service level objective response containing a single service level objective. #[d...
#![allow(clippy::missing_safety_doc)] #[cfg(test)] mod tests; use curve25519_dalek::constants::ED25519_BASEPOINT_TABLE; use curve25519_dalek::edwards::{CompressedEdwardsY, EdwardsPoint}; use curve25519_dalek::scalar::Scalar; use rand::rngs::OsRng; use std::collections::HashSet; use std::convert::TryInto; use std::sli...
use super::token::literal::{PrimitiveType, TerminalSymbol}; #[derive(Debug, Clone, PartialEq)] pub struct CustomType { name: String, } #[derive(Debug, Clone)] pub enum Type { Primitive(PrimitiveType), Custom(CustomType), // InvalidTypeError, IgnoreType, NoneType, } impl Type { pub fn int(...
use super::expression::Expression; use super::variable::{FreeVariable, GlobalVariable, LocalVariable}; use crate::ast_transform::Transformer; use crate::scm::Scm; use crate::source::SourceLocation; use crate::symbol::Symbol; use crate::syntax::{Reify, Variable}; use crate::utils::{Named, Sourced}; sum_type! { #[de...
#[doc = "Reader of register CTRL"] pub type R = crate::R<u32, super::CTRL>; #[doc = "Writer for register CTRL"] pub type W = crate::W<u32, super::CTRL>; #[doc = "Register CTRL `reset()`'s with value 0"] impl crate::ResetValue for super::CTRL { type Type = u32; #[inline(always)] fn reset_value() -> Self::Typ...
#![cfg(not(target_arch = "wasm32"))] //! Surface syntax tests of asynchrony and networking. use std::collections::{BTreeSet, HashSet}; use std::error::Error; use std::net::{Ipv4Addr, SocketAddr}; use std::time::Duration; use bytes::Bytes; use hydroflow::scheduled::graph::Hydroflow; use hydroflow::util::{collect_read...
use glium; use glium::{Display, Surface}; use glium::texture::{Texture2d, ClientFormat, RawImage2d}; use std::borrow::Cow; use tile_net::TileNet; use std; // Re-export for configuration pub use glium::uniforms::MinifySamplerFilter; pub use glium::uniforms::MagnifySamplerFilter; pub struct Renderer { net_width: us...
#[doc = "Register `MAPR` reader"] pub type R = crate::R<MAPR_SPEC>; #[doc = "Register `MAPR` writer"] pub type W = crate::W<MAPR_SPEC>; #[doc = "Field `SPI1_REMAP` reader - SPI1 remapping"] pub type SPI1_REMAP_R = crate::BitReader; #[doc = "Field `SPI1_REMAP` writer - SPI1 remapping"] pub type SPI1_REMAP_W<'a, REG, con...
pub mod constants; pub mod handlers; pub mod report; pub mod room;
// Copyright (c) 2019 - 2020 ESRLabs // // 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 ...
use crate::mbr::MasterBootRecord; use crate::prelude::*; // #[repr(C, packed)] // #[derive(Copy, Clone)] // struct RawUuid(u32, u16, u16, [u8; 8]); // impl From<&RawUuid> for Uuid { // fn from(raw: &RawUuid) -> Self { // Uuid::from_fields(raw.0, raw.1, raw.2, &raw.3).unwrap() // } // } #[repr(C, pack...
#[doc = r"Register block"] #[repr(C)] pub struct LAYER { #[doc = "0x00 - Layerx Control Register"] pub cr: CR, #[doc = "0x04 - Layerx Window Horizontal Position Configuration Register"] pub whpcr: WHPCR, #[doc = "0x08 - Layerx Window Vertical Position Configuration Register"] pub wvpcr: WVPCR, ...
#[doc = "Reader of register CONFIG"] pub type R = crate::R<u32, super::CONFIG>; #[doc = "Writer for register CONFIG"] pub type W = crate::W<u32, super::CONFIG>; #[doc = "Register CONFIG `reset()`'s with value 0x0400_0000"] impl crate::ResetValue for super::CONFIG { type Type = u32; #[inline(always)] fn rese...
use std::collections::HashMap; impl Solution { pub fn find_max_length(nums: Vec<i32>) -> i32 { let (mut ans,n,mut cur) = (0,nums.len(),0); let mut mp = HashMap::new(); let mut cnt = 0; mp.insert(0, -1); for (idx,num) in nums.into_iter().enumerate(){ match num { ...
//! Virtual machine flags. bitflags::bitflags! { #[derive(Default)] pub struct VmKey: u16 { const KEY_0 = 0b0000000000000001; const KEY_1 = 0b0000000000000010; const KEY_2 = 0b0000000000000100; const KEY_3 = 0b0000000000001000; const KEY_4 = 0b0000000000010000; const KEY_5 = 0b0000000000100...
#[doc = "Reader of register INTERP0_POP_FULL"] pub type R = crate::R<u32, super::INTERP0_POP_FULL>; impl R {}
use std::collections; use std::convert::TryFrom; use std::sync::{Arc, RwLock}; use anyhow::{anyhow, Error}; use rustls::server; use rustls::server::ClientHello; use rustls::sign; /// Something that resolves do different cert chains/keys based /// on client-supplied server name (via SNI). /// Support add certificate d...
// Problem 29 - Distinct powers // // Consider all integer combinations of a^b for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5: // // 2^2=4, 2^3=8, 2^4=16, 2^5=32 // 3^2=9, 3^3=27, 3^4=81, 3^5=243 // 4^2=16, 4^3=64, 4^4=256, 4^5=1024 // 5^2=25, 5^3=125, 5^4=625, 5^5=3125 // // If they are then placed in numerical order, wi...
use crate::ci::GenerateCI; use crate::BridgeModel; use anyhow::{bail, Context, Result}; use console::style; use dialoguer::{theme::ColorfulTheme, Select}; use fs_err as fs; use minijinja::{context, Environment}; use std::path::Path; /// Mixed Rust/Python project layout #[derive(Debug, Clone, Copy)] enum ProjectLayout ...
use nom::{branch::alt, bytes::complete::tag, multi::fold_many1, IResult}; use std::collections::HashMap; use std::fs::File; use std::io::prelude::*; #[derive(Clone, PartialEq)] enum Direction { East, SouthEast, SouthWest, West, NorthWest, NorthEast, } // represents co-ordinates on a hex grid. ...
#![cfg_attr(all(feature = "nightly", test), feature(test))] #[macro_use] extern crate log; #[macro_use] extern crate lazy_static; extern crate chrono; extern crate core; extern crate libc; extern crate pbr; extern crate unix_daemonize; extern crate byteorder; extern crate udt; extern crate ring; extern crate colored; e...
use std::convert::TryInto; use std::future::Future; use std::io::IoSlice; use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; use std::time::Duration; use anyhow::Result; use async_std::io::{ReadExt, WriteExt}; use async_std::net::{TcpListener, TcpStream}; use wasmtime::{Caller, FuncType, Linke...
// Copyright 2020 IOTA Stiftung // // 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 w...
fn main() { println!("Hello, world!"); } #[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } #[test] fn summing_up() { // let numbers = vec![1.0, 5.0, 2.0, 0.5, 1.5]; let mut numbers: Vec<f64> = Vec::new(); numbers.push(1.0); numbers...
use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Queryable)] pub struct Task { pub id: i32, pub description: String, pub completed: bool, pub created_at: chrono::NaiveDateTime, }
use crate::{IntegerMachineType, RealMachineType}; use std::fmt::{Display, Formatter}; use std::ops::{Add, Mul, Neg, Sub}; #[derive(Clone, Copy, Debug, PartialEq)] pub enum NumericType { Integer(IntegerMachineType), Real(RealMachineType), } impl NumericType { pub(super) fn as_real(&self) -> RealMachineType...
use notify::{Watcher, watcher, DebouncedEvent, RecursiveMode, RecommendedWatcher}; use std::sync::mpsc::channel; use std::time::Duration; use crate::Error; use std::thread; use std::path::PathBuf; pub struct WatcherHandle { watcher: RecommendedWatcher, } pub fn create_watcher(path: &PathBuf, debounce: u64) -> Res...
#[doc = "Reader of register DONE"] pub type R = crate::R<u32, super::DONE>; #[doc = "Reader of field `proc1`"] pub type PROC1_R = crate::R<bool, bool>; #[doc = "Reader of field `proc0`"] pub type PROC0_R = crate::R<bool, bool>; #[doc = "Reader of field `sio`"] pub type SIO_R = crate::R<bool, bool>; #[doc = "Reader of f...
// Copyright 2021 The MWC Develope; // // 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 std::io; fn main() { println!("Insert a number to be converted into Euro currency!"); let mut number_input = String::new(); io::stdin() .read_line(&mut number_input) .expect("Insert floating number!"); let number_to_convert: f64 = number_input.trim().parse().unwrap_or(0.0); i...
extern crate csv; #[macro_use] extern crate serde_derive; use std::env; use std::error::Error; use std::ffi::OsString; use std::fs::File; use std::process; #[derive(Deserialize, Debug)] struct Row<'a> { address_code: &'a str, pref_code: &'a str, city_code: &'a str, area_code: &'a str, zip_code: &'...
// Copyright 2015 The GeoRust 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 agreed...
use super::*; mod deserialize; mod serialize; mod structure; mod value_deserializer; mod value_serializer;
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // https://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT o...
use std::net::TcpListener; use khang_first_project::run; #[actix_web::main] async fn main() -> std::io::Result<()> { let listener = TcpListener::bind("127.0.0.1:8080").expect("Failed to bind to address"); run(listener)?.await } // #[cfg(test)] // mod tests { // use crate::health_check; // #[actix_r...
extern crate dotenv; //use diesel::prelude::*; use crate::models::character::Character; use crate::models::movie::Movie; use crate::schema::movie_characters; #[derive(Identifiable, Queryable, Associations, Debug)] #[table_name = "movie_characters"] #[belongs_to(Movie)] #[belongs_to(Character)] pub struct MovieCharact...
//! Implementation for simple format strings using curly braces. //! //! See [`SimpleCurlyFormat`] for more information. //! //! [`SimpleCurlyFormat`]: struct.SimpleCurlyFormat.html use regex::{CaptureMatches, Captures, Regex}; use crate::{ArgumentResult, ArgumentSpec, Error, Format, Position}; lazy_static::lazy_sta...
use crate::internal::messaging::Msg; use crate::types::Endpoint; use futures::future; use futures::prelude::{ Future, Stream, Sink }; use futures::sync::mpsc; use tokio::spawn; pub(crate) fn discover(consumer: mpsc::Receiver<Option<Endpoint>>, sender: mpsc::Sender<Msg>, endpoint: Endpoint) -> impl Future<Item=(), ...
use core::cell::{Cell, RefCell}; use stm32f4::stm32f411 as stm32; use stm32::{interrupt}; use cortex_m::interrupt::{free, Mutex}; use heapless::String; use heapless::spsc::{Queue}; use heapless::consts::{U256, U16}; use core::borrow::{BorrowMut, Borrow}; use core::ops::DerefMut; use crate::command_parser::{CommandPa...
mod config; mod error; mod http_server; mod grpc_server; mod misc; use std::process; use ace::App; fn main() { let c = get_proc_info(); match c { Some(info) => { println!("{:?}", info); match &info.server_type { config::ServerType::HTTP => { http_server::run(inf...
#[derive(Debug, PartialEq, Clone, Copy, Eq, PartialOrd, Ord)] pub struct Position { pub line: usize, pub pos: usize, }
mod bundler; mod processor; use crate::bundler::Bundler; use crate::processor::{ ConfigProcessor, CopyProcessor, EitherProcessor, SvgProcessor, TiledMapProcessor, }; use clap::{App, Arg}; use env_logger::Env; use std::path::PathBuf; fn main() -> anyhow::Result<()> { env_logger::Builder::from_env(Env::default(...
use crate::error_system::OsuKeyboardError; use crate::processor::Processor; use arduino_uno::Peripherals; pub struct KeyboardProcessor { peripherals: Peripherals, } impl KeyboardProcessor { pub fn new(peripherals: Peripherals) -> Self { Self { peripherals } } } impl Processor for KeyboardProcesso...
fn foobar() -> Result<i32, failure::Error> { let lib = libloading::Library::new("libmath/libmath.so")?; unsafe { let f: libloading::Symbol<unsafe extern "C" fn(i32, i32)->i32> = lib.get(b"add")?; Ok(f(2, 2)) } } #[cfg(test)] mod test { use super::*; #[test] fn test_foobar() { ...
#![deny(warnings)] use std::fs::File; use std::io::{self, Write}; use std::time::Instant; fn main() { let uptime = Instant::now().inner().as_secs(); let mut width = 0; let mut height = 0; if let Ok(display) = File::open("display:") { let path = display.path().map(|path| path.into_os_string()....
use super::*; use serde::{Serialize, Deserialize}; use mysql::params; /// Id type for guild pub type GuildId = EntityId; /// Any organisation involved in book renting #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct Guild { /// Unique id pub id: Option<GuildId>, /// Name of Guild pub...
use libc::{c_int}; use std::kinds::marker::ContravariantLifetime; use result::{NanoResult, last_nano_error}; use libnanomsg; /// An endpoint created for a specific socket. Each endpoint is identified /// by a unique return value that can be further passed to a shutdown /// function. The shutdown is done through the e...
// SPDX-License-Identifier: Apache-2.0 mod builder; mod vm; pub use vm::{ measure::{self, Measurement}, personality::Personality, Builder, Hook, Vm, }; use crate::backend::{self, Datum, Keep}; use crate::binary::Component; use anyhow::Result; use kvm_ioctls::Kvm; use std::sync::{Arc, RwLock}; pub cons...
use ContextRef; cpp! { #include "llvm/IR/LLVMContext.h" pub fn LLVMRustCreateContext() -> ContextRef as "llvm::LLVMContext*" { return new llvm::LLVMContext(); } pub fn LLVMRustDestroyContext(ctx: ContextRef as "llvm::LLVMContext*") { delete ctx; } } #[cfg(test)] mod test { us...
use chip8_emulator; fn main() { chip8_emulator::start_emulator(String::from("example.chip")); }
use executable_path::executable_path; use std::{process, str}; use test_utilities::tmptree; #[test] fn dotenv() { let tmp = tmptree! { ".env": "KEY=ROOT", sub: { ".env": "KEY=SUB", justfile: "default:\n\techo KEY=$KEY", }, }; let binary = executable_path("just"); let output = process...
#[allow(unused_imports)] use super::util::prelude::*; use super::super::resource::ImageData; use super::util::{Pack, PackDepth}; use super::BlockRef; block! { [pub Player(constructor, pack)] icon: Option<BlockRef<ImageData>> = None; name: String = String::from("プレイヤー"); } impl Player { pub fn icon(&s...
pub use crate::{alpha::*, coordinates::*, multi_result::*, names::*}; pub trait Pair<T> { type Output; fn pair(self, other: T) -> Self::Output; } impl<T, U, E> Pair<Result<U, E>> for Result<T, E> where E: Semigroup, { type Output = Result<(T, U), E>; fn pair(self, other: Result<U, E>) -> Self::O...
pub mod error; use serde::Deserialize; use error::{ProxyError, ProxyTomlConfigError}; use std::path::Path; #[derive(Deserialize, PartialEq, Eq)] enum ServerSideAuth { None, ServerPublicKey, ServerPrivateKey, CommonPublicKey, ClientToken, } #[derive(Deserialize, PartialEq, Eq)] enum ...
// found elsewhere. adapted and fixed pub fn reply(msg: &str) -> &str { let msg = msg.trim(); // filter only alphabetic stuff let mut msg_2 = String::new(); for c in msg.chars() { if c.is_alphabetic() { msg_2.push(c); } } // .all() returns true if you ch...
use proconio::{fastout, input}; #[fastout] fn main() { input! { n: usize, s: String, }; let s: Vec<char> = s.chars().collect(); let mut dp: Vec<i64> = vec![0; n + 1]; dp[1] = match (s[0], s[1]) { ('A', 'T') | ('T', 'A') | ('C', 'G') | ('G', 'C') => 1, _ => 0, }...
use std::io::{self}; fn part_1(file_content: &Vec<String>) -> i32 { 0 } fn part_2(file_content: &Vec<String>) -> i32 { 0 } fn main() -> io::Result<()> { let files_results = vec![("test.txt", 0, 0), ("input.txt", 0, 0)]; for (f, result_1, result_2) in files_results.into_iter() { println!("{}",...
#[doc = "Register `CIFR` reader"] pub type R = crate::R<CIFR_SPEC>; #[doc = "Field `LSIRDYF` reader - LSI ready interrupt flag Reset by software by writing LSIRDYC bit. Set by hardware when the LSI clock becomes stable and LSIRDYIE is set."] pub type LSIRDYF_R = crate::BitReader; #[doc = "Field `LSERDYF` reader - LSE r...
// use self::organizer; pub mod models; pub mod organizer; pub mod shared;
use std::fs::{File, metadata, OpenOptions}; use std::path::Path; use std::error::Error; use update_type::UpdateType; #[derive(Serialize, Deserialize)] pub struct Revision { pub id: u64, pub byte_offset: u64, pub rows: u64 } #[derive(Clone)] pub struct CsvLog { pub basename: String, pub filename: ...
//! Embedded SPI helper package //! This defines a higher level `Transactional` SPI interface, as well as an SPI `Transaction` enumeration //! that more closely map to the common uses of SPI peripherals, as well as some other common driver helpers. //! //! An `embedded_spi::wrapper::Wrapper` type is provided to wrap ex...
use std::sync::Arc; use crate::*; pub struct Sphere { center: Vector3, radius: f32, material: Arc<Material>, } impl Sphere { pub fn new<T: Material + 'static, U: Into<Arc<T>>>( center: &Vector3, radius: f32, material: U, ) -> Sphere { Sphere { center: *...
use ethereum_types::{Address, U256}; use rustc_hex::FromHex; use solana_client::rpc_client::RpcClient; use solana_sdk::{program_pack::Pack, pubkey::Pubkey}; use uniswap_program::state::UniswapOracle; pub struct MoebiusApi { client: RpcClient, } impl MoebiusApi { pub fn new() -> Self { Self { ...
use super::super::HasTable; use super::{Component, FromWorld, View, World}; use crate::tables::unique_table::UniqueTable; use crate::tables::TableId; use std::ops::Deref; /// Fetch read-only tables from a Storage /// pub struct UnwrapView<'a, Id: TableId, C: Component<Id>>(&'a UniqueTable<Id, C>); impl<'a, Id: TableI...
//! # The Chain Specification //! //! By default, when simply running CKB, CKB will connect to the official public Nervos network. //! //! In order to run a chain different to the official public one, //! with a config file specifying chain = "path" under [ckb]. //! //! Because the limitation of toml library, //! we mu...
/* File_config_functionalities_pmz */ // conditions: /* exec trait: [alias:(file/any)] [operations] [path/name] [parameters/--options] Read:Content _ none Write:Content _ String : if use multi line content -> check len()::Enum -> i32|&str Update:Content _ String ...
use std::collections::HashSet; use std::str::FromStr; use anyhow::{anyhow, Result}; use crate::Challenge; use itertools::Itertools; pub struct Day08; impl Challenge for Day08 { const DAY_NUMBER: u32 = 8; type InputType = AssemblyEmulator; type OutputType = i32; fn part1(input: &Self::InputType) ->...
use super::Control; use error::UIError; use std::ffi::{CStr, CString}; use std::mem; use std::os::raw::c_int; use ui::UI; use ui_sys::{self, uiAlign, uiAt, uiBox, uiControl, uiGrid, uiGroup, uiSeparator, uiTab}; /// Defines the ways in which the children of boxes can be layed out. pub enum LayoutStrategy { /// Mak...
use vec_map::VecMap; use std::mem; use std::fs::File; use std::io::Read; use std::path::Path; use piston::input::Button; use graphics::Context; use opengl_graphics::{GlGraphics, Texture}; use super::{Unit, Grid, Controller}; use controller::{LocalController, DummyController, AiController}; pub struct Game { pub g...
v1_imports!(); use rocket::{Route, State}; use authn::{AuthnBackend, AuthnHolder}; use config::Config; pub fn get_routes() -> Vec<Route> { routes![get_meta] } #[allow(needless_pass_by_value)] #[get("/meta")] pub fn get_meta(auth: State<AuthnHolder>, conf: State<Config>) -> Result<String, ErrorResponse> { le...
use wasm_bindgen::prelude::*; use wasm_bindgen::convert::{OptionIntoWasmAbi, IntoWasmAbi, FromWasmAbi}; use crate::bigint_256::{self, WasmBigInteger256}; use algebra::biginteger::BigInteger256; use algebra::{ToBytes, FromBytes}; use mina_curves::pasta::fq::{Fq, FqParameters as Fq_params}; use algebra::{ fields::{Fi...
// TODO: think about ownership, examine when passing ownership // TODO: rustfmt setting to not make structs so verbose.. use pretty_env_logger; use std::io::{BufRead, BufReader}; use std::path::PathBuf; use std::time::Duration; use std::{fmt::Display, fs::File}; use anyhow::{Context, Result}; use lazy_static::lazy_sta...
use alloc::vec::Vec; #[cfg(feature = "std")] use std::io::{self, Write}; #[inline] pub(crate) fn is_alphanumeric(e: u8) -> bool { (b'0'..=b'9').contains(&e) || (b'a'..=b'z').contains(&e) || (b'A'..=b'Z').contains(&e) } #[inline] pub(crate) fn write_hex_to_vec(e: u8, output: &mut Vec<u8>) { output.reserve(6);...
mod error; use std::io::{self, Read}; use env_logger::Builder; use log::LevelFilter; use nmstate::NetworkState; use serde::Serialize; use serde_yaml::{self, Value}; use crate::error::CliError; const SUB_CMD_GEN_CONF: &str = "gc"; const SUB_CMD_SHOW: &str = "show"; const SUB_CMD_APPLY: &str = "apply"; fn main() { ...
use super::rocket; use rocket::local::Client; use rocket::http::Status; use std::fs::File; use std::io::Read; fn test_query_file<T> (path: &str, file: T, status: Status) where T: Into<Option<&'static str>> { let client = Client::new(rocket()).unwrap(); let mut response = client.get(path).dispatch(); a...