text
stringlengths
8
4.13M
use bls12_381::Scalar; use ff::{Field, PrimeField}; use group::{Curve, Group, GroupEncoding}; mod mint2_contract; mod vm; use mint2_contract::{load_params, load_zkvm}; fn unpack<F: PrimeField>(value: F) -> Vec<Scalar> { let mut bits = Vec::new(); print!("Unpack: "); for (i, bit) in value.to_le_bits().into...
#[doc = "Reader of register POC_REG__TIM_CONTROL"] pub type R = crate::R<u32, super::POC_REG__TIM_CONTROL>; #[doc = "Writer for register POC_REG__TIM_CONTROL"] pub type W = crate::W<u32, super::POC_REG__TIM_CONTROL>; #[doc = "Register POC_REG__TIM_CONTROL `reset()`'s with value 0"] impl crate::ResetValue for super::POC...
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. use crate::string::{CStr, NoNullStr, ByteStr}; use core::{mem}; // &[u8] -> &ByteStr // &[u8] -> Result<&NoNullStr> ...
extern crate blorb; extern crate glulx; use std::env::args; use std::error::Error; use std::fs::File; use std::io::Read; use std::path::Path; use blorb::{ BlorbCursor, Chunk, Usage, }; mod machine; type Result<T> = std::result::Result<T, Box<Error + Send + Sync>>; fn run_blorb(exec: Chunk, blorb: Blo...
/// An enum to represent all characters in the HangulJamoExtendedA block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum HangulJamoExtendedA { /// \u{a960}: 'ꥠ' HangulChoseongTikeutDashMieum, /// \u{a961}: 'ꥡ' HangulChoseongTikeutDashPieup, /// \u{a962}: 'ꥢ' HangulChoseongTikeutDas...
use std::collections::{HashMap,HashSet}; #[derive(PartialEq,Eq,Clone,Hash,Debug)] pub enum VarType { Unknown, Float, Int, Number, String, Bool, Unify(Vec<String>) } pub type TypeMap = HashMap<String,VarType>; #[derive(Debug,PartialEq,Eq)] pub enum TypeOrd{ Sub,Super,Same,Unrelated,Cross} ...
use super::fraction_normal::Fraction; #[derive(Clone)] pub struct ContinuedFraction { root: u128, list: Vec<u128>, } impl ContinuedFraction { pub fn from_square_root(n: u128) -> Self { let root = (n as f64).sqrt().floor() as u128; if n == root * root { return Self { ...
use super::schema::*; use diesel::*; use diesel::pg::Pg; use diesel::deserialize::{self, FromSql}; use diesel::serialize::{self, IsNull, Output, ToSql}; use std::io::Write; use juniper::FieldResult; #[derive(SqlType)] #[postgres(type_name = "episode")] pub struct EpisodeSqlType; #[derive(GraphQLEnum, Debug, PartialEq...
use crate::completions::{Completer, CompletionOptions, MatchAlgorithm, SortBy}; use nu_parser::FlatShape; use nu_protocol::{ engine::{EngineState, StateWorkingSet}, Span, }; use reedline::Suggestion; use std::sync::Arc; pub struct CommandCompletion { engine_state: Arc<EngineState>, flattened: Vec<(Span...
use anyhow::bail; use std::process::Command; pub fn execute_gnuplot(script_path: impl AsRef<std::path::Path>) -> anyhow::Result<()> { let output = Command::new("gnuplot") .args(&[script_path.as_ref()]) .output()?; if !output.status.success() { if let Ok(err) = String::from_utf8(output.s...
#[test] fn ui() { if option_env!("CARGO") .unwrap_or("cargo") .ends_with("cargo-tarpaulin") { eprintln!( "Skipping ui tests to avoid incompatibility between cargo-tarpaulin and trybuild" ); return; } let t = trybuild::TestCases::new(); t.compile_fa...
use crate::common::head_list_node; use crate::common::ListNode; struct Solution; impl Solution { // 参考别人的 pub fn swap_pairs(mut head: Option<Box<ListNode>>) -> Option<Box<ListNode>> { let mut dummy = ListNode::new(0); let mut tail = &mut dummy; while let Some(mut n1) = head { ...
use wasm_bindgen::prelude::*; use mycrate_core; #[wasm_bindgen] pub fn add(a: i32, b: i32) -> i32 { mycrate_core::add(a, b) }
extern crate num_bigint; use num_bigint::BigUint; use std::collections::HashMap; pub fn hash_map_to_string<T, R>(num: &HashMap<T, R>) -> String where T: std::cmp::Ord + std::hash::Hash + std::fmt::Display, R: std::fmt::Display { let mut num_list = vec![]; for k in num.keys() { num_list.push(k); ...
/* https://projecteuler.net The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317. Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000. NOTES: */ fn mypow(n : u64) -> u64 { let mut rv = n; for _ in 1..n { if rv == 0 { // exit early if we get to 0 value break; ...
fn main() { 'outer: loop { println!("Entered the outer dungeon - "); 'inner: loop { println!("Entered the inner dungeon - "); break 'outer; } println!("This treasure can sadly never be reached - "); } println!("Exited the outer dungeon!"); }
pub mod sha3_512; pub struct Hash { pub mac: [u8; 32], pub encrypt: [u8; 32], } pub trait Hasher { fn make(key: &str) -> Hash; }
use std::collections::{HashMap, HashSet}; use std::fs; use std::path::Path; use std::sync::{Arc, Mutex}; use ignore::Walk as WalkDir; use json5; use regex::Regex; use serde::{Deserialize, Serialize}; use serde_json::{json, Map, Value}; #[derive(Debug)] pub struct Database { pub basic_data: BasicData, pub api_...
//! The `ncp` module implements the network control plane. use crdt; use packet; use result::Result; use std::net::UdpSocket; use std::sync::atomic::AtomicBool; use std::sync::mpsc::channel; use std::sync::{Arc, RwLock}; use std::thread::JoinHandle; use streamer; pub struct Ncp { pub thread_hdls: Vec<JoinHandle<(...
use std::rc::Rc; fn main() { // concstructs a new Rc let five = Rc::new(5); // try_unwrap assert_eq!(Rc::try_unwrap(five),Ok(5)); }
use crate::{grid::builder::Builder, undo_redo_buffer, util, Grid, State}; use std::{borrow::Cow, time::Instant}; use terminal::{ util::{Color, Point}, Terminal, }; #[derive(Debug, Clone, Copy, PartialEq)] pub enum Cell { /// An umarked cell. Empty, /// Used to mark filled cells. Filled, ///...
use std::cell::RefCell; use std::fs::File; use bodyparser::{Json, MaxBodyLength}; use iron::{AfterMiddleware, Chain, Iron, IronResult, Plugin, Request, Response}; use iron::error::IronError; use iron::headers::{ContentType, UserAgent}; use iron::mime::{Mime, TopLevel, SubLevel, Attr, Value}; use iron::status; use pers...
//Copyright (c) 2019 #UlinProject Denis Kotlyarov (Денис Котляров) //----------------------------------------------------------------------------- //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 ...
fn main() -> Result<()> { { let addr = "127.0.0.1:34254" let mut socket = UdpSocket::bind(addr)?; let mut buf = [0; 10]; let (amt, src) = socket.recv_from(&mut buf)?; let buf = &mut buf[..amt]; buf.reverse(); socket.send_to(buf, &src)?; } // the socket is closed here Ok(()) }
mod atc_button; mod error; mod navbar; mod product_card; mod spinner; pub use atc_button::AtcButton; pub use error::Error; pub use navbar::Navbar; pub use spinner::Spinner;
pub mod byte_ops;
use serde::Serialize; use std::sync::{atomic::AtomicBool, atomic::Ordering, Arc, RwLock}; use crate::config::ConfigFromFile; use crate::config_store::{ConfigStore, ConfigStoreFunc, Monitor}; use crate::file_store::{FileStore, FileStoreFunc}; use crate::stat_store::{StatStore, StatStoreFunc, Stats}; /* AppState * A...
// Copyright (c) 2017 oic developers // // 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>, at your // option. All files in the project carrying such notice may not be copied, // mo...
/// Service identifier. pub const SERVICE_ID: u16 = 2;
use std::{cell::RefCell, collections::HashMap, env, error::Error, fs, rc::Rc}; use typed_arena::Arena; type Result<T> = std::result::Result<T, Box<dyn Error>>; fn main() -> Result<()> { let code = fs::read_to_string(env::args().nth(1).ok_or("no file")?)? + " $"; run(code)?; Ok(()) } enum Val<'a> { Nil()...
const MEM_LEN: usize = 165; static STARTING_MEM: [i32; MEM_LEN] = [ 1,12,2,3,1,1,2,3,1,3,4,3,1,5,0,3,2,1,10,19,1,9,19,23,1,13,23,27,1,5,27,31,2,31,6,35,1,35,5,39,1,9,39,43,1,43,5,47,1,47,5,51,2,10,51,55,1,5,55,59,1,59,5,63,2,63,9,67,1,67,5,71,2,9,71,75,1,75,5,79,1,10,79,83,1,83,10,87,1,10,87,91,1,6,91,95,2,95,6,99,...
pub fn race(v1: i32, v2: i32, g: i32) -> Option<Vec<i32>> { if v1 >= v2 { None } else { let d = (3600 * g) / (v2 - v1); println!("{:?}", vec![d / 3600, d / 60 % 60, d % 60]); Some(vec![d / 3600, d / 60 % 60, d % 60]) } }
use std::iter::FromIterator; #[derive(Debug, Clone)] struct Node<T> { data: T, next: Option<Box<Node<T>>>, } pub struct SimpleLinkedList<T> { head: Option<Box<Node<T>>> } impl<T> SimpleLinkedList<T> where T: PartialOrd + Clone { pub fn new() -> Self { SimpleLinkedList { head: None...
use azure_core::prelude::*; use azure_storage::blob::prelude::*; use azure_storage::core::prelude::*; use chrono::{Duration, Utc}; use std::error::Error; fn main() { env_logger::init(); code().unwrap(); } fn code() -> Result<(), Box<dyn Error + Sync + Send>> { // First we retrieve the account name and mas...
#[doc = "Register `DMADSR` reader"] pub type R = crate::R<DMADSR_SPEC>; #[doc = "Register `DMADSR` writer"] pub type W = crate::W<DMADSR_SPEC>; #[doc = "Field `AXWHSTS` reader - AHB Master Write Channel"] pub type AXWHSTS_R = crate::BitReader; #[doc = "Field `AXWHSTS` writer - AHB Master Write Channel"] pub type AXWHST...
fn main() { let mut prod = 1; for num in (2..21) { //let oldprod = prod; //println!("{}, {}, {}", oldprod, num, gcd(oldprod, num)); prod = prod * num / gcd(prod, num); } println!("LCM is: {}", prod); } fn gcd(num1:u64, num2:u64) -> u64 { if num2 == 0 { return num1; ...
#![feature(advanced_slice_patterns, slice_patterns)] extern crate sexp; mod phym; use std::env; /*----------------------------------------------------------------------------*/ /* main */ /*---------------------------------------------------------...
use app_dirs::{app_dir, AppDataType, AppInfo}; use std::env; use std::path::PathBuf; const ATA_PATH_NAME: &'static str = "ATADB_PATH"; const APP_INFO: AppInfo = AppInfo { name: "atadb", author: "atadb", }; pub fn locate_on_db_path(dbname: String) -> Option<PathBuf> { let mut paths: Vec<PathBuf> = Vec::new...
#![feature(proc_macro)] extern crate gobject_gen; extern crate gobject_sys; #[macro_use] extern crate glib; extern crate glib_sys; extern crate libc; use gobject_gen::gobject_gen; use std::cell::Cell; use std::ffi::CStr; use std::mem; use std::slice; use glib::object::*; use glib::translate::*; gobject_gen! { ...
/*--------------------------------------------------------------------------------------------- * Copyright © 2016-present Earth Computing Corporation. All rights reserved. * Licensed under the MIT License. See LICENSE.txt in the project root for license information. *----------------------------------------------...
use mongodb::{Client, Database , options:: {ClientOptions, StreamAddress} }; use rocket::request::{self, FromRequest}; use rocket::{Outcome, Request, State}; use std::env; use std::ops::Deref; pub struct Conn(pub Database); pub fn init() -> Database { let host = env::var("MONGO_HOST").expect("MONGO_HOST env not set...
// Copyright (C) 2021 Subspace Labs, Inc. // SPDX-License-Identifier: Apache-2.0 // 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 // // Unle...
use crate::common::*; use anyhow::Result; use chrono::serde::ts_seconds; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use serde_aux::prelude::*; use std::str; #[derive(Serialize, Deserialize, Debug)] pub struct Friend { #[serde(deserialize_with = "deserialize_number_from_string")] pub stea...
use bindgen::{ callbacks::{EnumVariantValue, ParseCallbacks}, Builder, CargoCallbacks, }; use std::{env, path::PathBuf, process::Command}; #[derive(Debug)] struct CustomPrefixCallbacks; impl ParseCallbacks for CustomPrefixCallbacks { fn enum_variant_name( &self, _enum_name: Option<&str...
//! AES related functionality. // TODO: Similarly optimized version for aarch64 #[cfg(target_arch = "x86_64")] mod x86_64; extern crate alloc; use aes::cipher::generic_array::GenericArray; use aes::cipher::{BlockDecrypt, BlockEncrypt, KeyInit}; use aes::Aes128; use alloc::vec::Vec; use subspace_core_primitives::{Pot...
use jsonrpc_pubsub::typed::{Sink, Subscriber}; use jsonrpc_pubsub::SubscriptionId; use std::collections::HashMap; use std::ops; pub struct Subscribers<T> { id: u64, subscriptions: HashMap<SubscriptionId, T>, } impl<T> Default for Subscribers<T> { fn default() -> Self { Self { id: 0, ...
use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, PartialEq)] pub struct Segment { id: Option<String>, name: Option<String>, value: Option<String>, ext: Option<SegmentExt>, } #[derive(Serialize, Deserialize, Debug, PartialEq)] pub struct SegmentExt {}
struct Solution {} impl Solution { pub fn is_palindrome(x: i32) -> bool { // Returns whether the given number is a palindrome. if a negative // number is given, the sign position is not preserved. So "-1" // reversed becomes "1-". let forward: String = x.to_string(); le...
pub mod emitter; pub mod lexer; pub mod parser;
#[doc = "Register `APBENR1` reader"] pub type R = crate::R<APBENR1_SPEC>; #[doc = "Register `APBENR1` writer"] pub type W = crate::W<APBENR1_SPEC>; #[doc = "Field `TIM2EN` reader - TIM2 timer clock enable"] pub type TIM2EN_R = crate::BitReader; #[doc = "Field `TIM2EN` writer - TIM2 timer clock enable"] pub type TIM2EN_...
use crate :: { import::*, WsErr }; /// Indicates the state of a Websocket connection. The only state in which it's valid to send and receive messages /// is [WsState::Open]. /// /// See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/readyState) for the ready state values. // #[ allow( missing_docs )...
#[allow(dead_code)] fn calculate_fuel_part1(mass: u32) -> u32 { (mass / 3) - 2 } fn calculate_fuel_part2(mass: u32) -> u32 { let mass_over_3 = mass / 3; if mass_over_3 <= 2 { 0 } else { let fuel = mass_over_3 - 2; fuel + calculate_fuel_part2(fuel) } } fn main() { le...
use ncurses; use ncurses::{WchResult}; use std::sync::mpsc::{channel, Sender}; use std::thread::spawn; use num::rational::Ratio; use clock; use metronome; // https://unicode.org/charts/PDF/U0000.pdf static CHAR_SPACE: u32 = 0x0020; #[allow(dead_code)] static CHAR_RETURN: u32 = 0x000D; static CHAR_NEWLINE: u32 = 0x000...
#[cfg(target_os = "macos")] #[nolink] extern mod uuid { fn uuid_generate(out: UUID); fn uuid_generate_random(out: UUID); fn uuid_generate_time(out: UUID); fn uuid_parse(s: *u8, uuid: UUID) -> libc::c_int; fn uuid_unparse(uuid: UUID, out: *u8); fn uuid_unparse_lower(uuid: UUID, out: *u8); f...
#![allow(non_snake_case,unused)] use libc;use std::slice;pub type C=libc::c_char;pub type J=libc::c_long; pub type G=libc::c_uchar;pub type S=*const C;pub type SC=libc::c_schar; pub type H=libc::c_short;pub type I=libc::c_int;pub type E=libc::c_float; pub type F=libc::c_double;pub type K=*const K0; pub const KCAP:u8=3;...
extern crate susanoo; use susanoo::{Context, Server, Response, AsyncResult}; use susanoo::contrib::hyper::{Get, Post, StatusCode}; use susanoo::contrib::futures::{future, Future, Stream}; fn index(_ctx: Context) -> AsyncResult { future::ok( Response::new() .with_status(StatusCode::Ok) ...
pub type ReplaceStoredProcedureResponse = crate::responses::CreateStoredProcedureResponse;
pub type H256 = [u8; 32]; pub type H512 = [u8; 64];
use rand::prelude::*; use web_sys::WebGlRenderingContext as GL; use crate::rendering::{Rectangle, Instance}; pub struct GoL { dimensions: (u32, u32), tiles: Vec<bool>, renderer: Rectangle, } impl GoL { pub fn new(gl: &GL, width: u32, height: u32) -> Self { let mut tiles = Vec::<bool>::new(); ...
use serde::{Deserialize, Serialize}; #[cfg(test)] use std::fs; use std::fs::File; use std::io::prelude::*; #[cfg(test)] use std::path::PathBuf; #[derive(Debug, Deserialize, PartialEq, Serialize, Clone)] struct KeyConf { pri_file: Option<String>, } #[derive(Debug, Deserialize, PartialEq, Serialize, Clone)] struct ...
mod command; mod entity; pub mod interpreter;
use indexmap::IndexMap; use std::{ convert::TryFrom, }; use syn::{ Error, Ident, Visibility, }; use crate::parsing::ParseEcs; use crate::TypeId; pub mod component; pub mod query; pub mod system; pub mod task; pub mod unique; use component::Component; use unique::Unique; use query::Query; pub type AllCompone...
#![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate rocket; use rocket_contrib::json; use rocket_contrib::json::{Json, JsonValue}; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] struct Message { contents: String, } #[put("/", data = "<msg>")] fn update(msg: Json<Message...
use { crate::Error, rewryte_parser::models::{Column, ColumnDefault, Enum, ForeignKey, Item, Schema, Table, Types}, std::io, }; pub fn write_schema(schema: &Schema, writer: &mut impl io::Write) -> Result<(), Error> { for (i, item) in schema.items.iter().enumerate() { write_item(item, writer)?; ...
mod back_of_house; mod front_of_house; // use self::front_of_house::hosting; pub use crate::front_of_house::hosting; pub fn eat_at_restaurant() { // absolute path hosting::add_to_waitlist(); // relative path hosting::seat_at_table(); hosting::seat_at_table(); let mut meal = back_of_house::...
mod deserialize; mod error; mod osekai; mod osu_daily; mod osu_stats; mod osu_tracker; mod rkyv_impls; mod score; mod snipe; mod twitch; use std::{ borrow::Cow, fmt::{Display, Write}, hash::Hash, }; use bytes::Bytes; use chrono::{DateTime, Utc}; use hashbrown::HashSet; use http::{ header::{CONTENT_LEN...
#[doc = "Register `MTLTxQDR` reader"] pub type R = crate::R<MTLTX_QDR_SPEC>; #[doc = "Register `MTLTxQDR` writer"] pub type W = crate::W<MTLTX_QDR_SPEC>; #[doc = "Field `TXQPAUSED` reader - Transmit Queue in Pause"] pub type TXQPAUSED_R = crate::BitReader; #[doc = "Field `TXQPAUSED` writer - Transmit Queue in Pause"] p...
pub mod prefab; use amethyst::prelude::*; use amethyst::renderer::{Event, VirtualKeyCode, WindowEvent, MouseButton, ElementState}; use amethyst::input::{is_key_down, is_close_requested, get_key}; use amethyst::assets::{PrefabLoader, RonFormat}; use amethyst::ecs::prelude::Entity; use amethyst::core::Transform; use ame...
// Copyright (c) 2019 Georg Brandl. 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>, at // your option. This file may not be copied, modified, or distributed except // according to...
use cgmath::Vector2; use specs::{self, Component}; use components::InitFromBlueprint; #[derive(Clone, Debug, Deserialize)] pub enum FireState { Idle, Fire(Vector2<f32>), Cooldown(f32) } impl Default for FireState { fn default() -> Self { FireState::Idle } } #[derive(Clone, Debug, Deseria...
use async_std::task; use clap::Clap; use hyperspace_server::{listen, run_bootstrap_node, Opts}; fn main() -> anyhow::Result<()> { env_logger::from_env(env_logger::Env::default().default_filter_or("info")).init(); let opts: Opts = Opts::parse(); task::block_on(async_main(opts)) } async fn async_main(opts: ...
use nix::errno::Errno; use nix::sys::termios; use nix::{Error, unistd}; #[test] fn test_tcgetattr() { for fd in 0..5 { let termios = termios::tcgetattr(fd); match unistd::isatty(fd) { // If `fd` is a TTY, tcgetattr must succeed. Ok(true) => assert!(termios.is_ok()), ...
#[cfg(feature = "case_mod")] pub mod case_mod; pub use super::parser::TeraFilter;
// q0112_path_sum struct Solution; use crate::util::TreeNode; use std::cell::RefCell; use std::rc::Rc; impl Solution { pub fn has_path_sum(root: Option<Rc<RefCell<TreeNode>>>, sum: i32) -> bool { if let Some(rrc_t) = root { let tn = rrc_t.borrow(); match (&tn.left, &tn.right) { ...
pub fn vec_macro() { let mut v = vec![2, 3, 5, 7]; println!("{:?}", v); assert_eq!(v.iter().fold(1, |a, b| a * b), 210); v.push(11); v.push(13); let fun1 = v.iter().fold(1, |a, b| a * b); println!("{:?}", fun1); assert_eq!(fun1, 30030); }
/* * 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 */ /// AwsAccountAndLambdaRequest : AWS account ID and Lambda ARN. #[derive(Clone, Debug, PartialEq, Ser...
extern crate wikipedia; use std::env::args; use std::io::stdin; fn pick_a_number() -> usize { let mut selection = String::new(); println!("Please enter the number of the result you want to translate."); stdin().read_line(&mut selection).unwrap(); selection.trim().parse().unwrap() } fn main() { l...
pub struct Sprite { pub rows: Vec<u8>, } pub const SPRITE_SIZE: u8 = 5; pub fn init_sprites() -> [Sprite; 0x10] { [Sprite { rows: vec![0xF0, 0x90, 0x90, 0x90, 0xF0], }, Sprite { rows: vec![0x20, 0x60, 0x20, 0x20, 0x70], }, Sprite { rows: vec![0xF0, 0x10, 0xF0, 0x80, 0xF0], }, Sprite { rows: vec...
#[doc = "Reader of register HVLDO_CTRL"] pub type R = crate::R<u32, super::HVLDO_CTRL>; #[doc = "Writer for register HVLDO_CTRL"] pub type W = crate::W<u32, super::HVLDO_CTRL>; #[doc = "Register HVLDO_CTRL `reset()`'s with value 0"] impl crate::ResetValue for super::HVLDO_CTRL { type Type = u32; #[inline(always...
use chrono::{DateTime, Local, Duration}; use arduino_mqtt_pin::pin::{PinState, PinValue, Temperature}; use crate::config::{ControlNodes, Settings}; use crate::repository::PinStateRepository; use arduino_mqtt_pin::helper::percent_to_analog; use crate::zone::{Zone}; use derive_new::{new}; #[derive(new)] pub struct ZoneS...
use parquet_format_async_temp::DataPageHeaderV2; use crate::compression::{create_codec, Codec}; use crate::error::Result; use super::{PageIterator, StreamingIterator}; use crate::page::{CompressedDataPage, DataPage, DataPageHeader}; fn decompress_v1(compressed: &[u8], decompressor: &mut dyn Codec, buffer: &mut [u8])...
use std::collections::{HashMap, HashSet}; use Index; use Retriever; pub struct BM25 { index: Index, avdl: f64, // Term to number of documents containing that term doc_freq: HashMap<String, usize>, // Document id to length cache doc_len: HashMap<String, usize>, corpus_size: f64, } impl BM2...
/* Copyright 2016 Robert Lathrop 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, softwar...
use parameterized_macro::parameterized; // a trailing comma after v and w's arguments (multiple inputs) and after every attribute list #[parameterized( v = { 1, 2, 3, }, w = { 1, 2, 3, }, )] fn my_test(v: u32, w: u32) {} fn main() {}
mod bundle; pub mod components; mod resource; mod system; pub mod traits; pub use crate::bundle::DebugSystemBundle;
use crate::node; use std::any::Any; pub trait NodeBuilderResolver { fn get_pattern(&self) -> &str; fn resolve(&self, indents: usize, line: String) -> Box<dyn NodeBuilder>; } pub trait NodeBuilder { fn append_or_throwback(&mut self, line: String) -> Option<String>; fn build(self: Box<Self>) -> node::No...
extern crate image; extern crate line_drawing; use line_drawing::*; use image::{DynamicImage, ImageBuffer, Rgb}; type Image = ImageBuffer<Rgb<u8>, Vec<u8>>; // Draw a line of pixels onto the image with a specific colour fn draw_line<T>(image: &mut Image, line: T, colour: [u8; 3]) where T: Iterator<Item = Point<i...
//! Configuration utilities for game engine and your game. use semver::Version; /// This struct represents general configuration of game engine. #[derive(Debug, Clone)] pub struct Config { name: String, version: Version, enable_validation: bool, } pub const ENGINE_NAME: &str = env!("CARGO_CRATE_NAME", "l...
use crate::cell; use crate::cell::{Cell, Event, Merge}; use crate::propagator; use crate::propagator::{Propagator}; //use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::collections::HashSet; use std::fmt::Debug; pub struct Network<A> { cells: Vec<Cell<A>>, cell_neighbours: HashMap<ce...
use {Linkage, ValueRef, TypeRef, ModuleRef}; use libc; cpp! { #include "ffi_helpers.h" #include "llvm/IR/Module.h" pub fn LLVMRustFunctionCreate(ty: TypeRef as "llvm::Type*", linkage: Linkage as "unsigned", name: *const libc::c_char as "...
use ::structs::*; pub fn tick(event: Coordinate) { println!("Data is sinking in: {:?}", &event); }
use std::net::Ipv4Addr; use dhcp; /// DHCP message length pub const MESSAGE_LEN: usize = 548; const MAGIC_COOKIE: [u8; 4] = [99, 130, 83, 99]; pub struct Message { pub op: u8, pub htype: u8, pub hlen: u8, pub hops: u8, pub xid: u32, pub secs: u16, pub flags: u16, pub ciaddr: Ipv4Add...
use dwdemo::*; fn main() { let _b = Bsim4Model::default(); println!("main ran! "); }
use std::sync::Arc; use eyre::Report; use rosu_v2::prelude::{GameMode, OsuError, Score, Username}; use twilight_model::{ application::interaction::{ application_command::{CommandDataOption, CommandOptionValue}, ApplicationCommand, }, id::{marker::UserMarker, Id}, }; use crate::{ comman...
use context::Context; use discovery::{Discovery, ServiceDiscovery}; use net::listener::Listener; use std::io::{Error, ErrorKind, Result}; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; use std::time::Duration; use stream::io::copy_bidirectional; use tokio::spawn; use tokio::sync::mpsc::{self, Sen...
// This file is part of Substrate. // Copyright (C) 2019-2020 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // 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 // // ht...
#[macro_use] extern crate quote; extern crate syn; use syn::{Attribute, Item, ItemFn, ItemMod, Lit, Meta, MetaNameValue}; use std::env; use std::io::{Read, Write}; use std::fs::File; use std::path::{Path, PathBuf}; /// Look for a simple attribute matching a string fn any_attr_is(attrs: &[Attribute], ident: &str) -> b...
use super::rand_string; use crate::db::DBConnection; use crate::prelude::*; impl Users { /// It creates a `Users` instance by connecting it to a redis database. /// If the database does not yet exist it will be created. By default, /// sessions will be stored on a concurrent HashMap. In order to have pers...
// q0007_reverse_integer struct Solution; impl Solution { pub fn reverse(x: i32) -> i32 { let mut n: i32 = 0; let mut x = x; loop { let b = x % 10; if x == 0 && b == 0 { break; } if let Some(t1) = n.checked_mul(10) { ...
#[cfg(target_arch = "x86_64")] #[path = "arch/x86_64/arch.rs"] pub mod arch;