text
stringlengths
8
4.13M
#[macro_use] extern crate json; // array!, object!, value! use postgrest::Postgrest; use std::error::Error; const REST_URL: &str = "http://localhost:3000"; #[tokio::test] async fn read_other_schema() -> Result<(), Box<dyn Error>> { let client = Postgrest::new(REST_URL); let resp = client .from("user...
use std::u8; use std::collections::BTreeMap; pub fn hamming_distance(buf1: &Vec<u8>, buf2: &Vec<u8>) -> u32 { let iter = buf1.iter().zip(buf2.iter()); iter.map(|(x, y)| (x ^ y).count_ones()).sum() } pub fn ascii_scoring(buf: &Vec<char>) -> (f32, BTreeMap<String, f32>) { let mut ascii_map: BTreeMap<Strin...
#[doc = "Reader of register SUP_TIMEOUT"] pub type R = crate::R<u32, super::SUP_TIMEOUT>; #[doc = "Writer for register SUP_TIMEOUT"] pub type W = crate::W<u32, super::SUP_TIMEOUT>; #[doc = "Register SUP_TIMEOUT `reset()`'s with value 0"] impl crate::ResetValue for super::SUP_TIMEOUT { type Type = u32; #[inline(...
use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; /// Implementation of a symbol table that /// - always maps a given index to a single string /// - allows mapping a string to several indices #[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize)] pub struct TokenSymbolTable { st...
use core::mem::replace; use core::mem::uninitialized; use mem::alloc::Box; struct ListNode<T> { elem: T, next: Option<Box<ListNode<T>>>, } pub struct List<T> { head: Option<Box<ListNode<T>>>, } impl<T> List<T> { pub fn new() -> List<T> { List { head: None } } pub fn push(&mut self, e:...
#[macro_use(Deserialize, Serialize)] extern crate serde; #[cfg(feature = "v1")] mod v1; #[cfg(feature = "v1")] pub use crate::v1::*; pub mod error; mod response; pub mod signed_url; pub mod signing; pub mod types; pub mod util; // Reexport the http crate since everything this crate does // is put in terms of http re...
pub mod types; pub mod instructions; pub mod decoder; pub mod regs; pub mod csr; pub mod context; pub mod core; pub mod immediate;
#![allow(dead_code)] #![feature(map_first_last)] mod journal; #[macro_use] extern crate clap; use chrono::{Duration, Local, NaiveDate}; use clap::ArgMatches; use journal::Journal; fn main() { #[allow(deprecated)] let matches = clap_app! { journal => (version: crate_version!()) (author: crate_authors!(",\n")) ...
use std::default::Default; #[derive(Copy, Clone, Debug, PartialEq)] pub struct FreeListHandle(pub(crate) u32); impl FreeListHandle { pub const NONE: Self = FreeListHandle(std::u32::MAX); pub fn is_none(self) -> bool { self == Self::NONE } pub fn is_some(self) -> bool { self != Self::NONE } fn to_us...
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
//! This module implements python-like `Counter` use std::cmp::Eq; use std::cmp::Ord; use std::collections::btree_map::{BTreeMap, IntoIter, Iter}; use std::fmt::Debug; use std::iter::FromIterator; use std::ops::Index; /// Structure that count occurences of `T` elements #[derive(Debug)] pub struct Counter<T> { stat...
#[macro_use] extern crate redis_module; use bitflags::_core::time::Duration; use redis_module::{Context, RedisError, RedisResult, ThreadSafeContext}; use std::thread; fn threads(_: &Context, _args: Vec<String>) -> RedisResult { thread::spawn(move || { let thread_ctx = ThreadSafeContext::new(); fo...
//! Implementation of a Merkle tree of commitments used to prove the existence of notes. //use byteorder::{LittleEndian, ReadBytesExt}; use std::collections::VecDeque; use std::io::{self, Read, Write}; //use crate::serialize::{Optional, Vector}; use super::coin::SAPLING_COMMITMENT_TREE_DEPTH; /// A hashable node wit...
//! Uses [`Mmap`](memmap2) to map a file into memory with kernel support. //! //! Choose this implementation if: //! //! 1. Your platform supports memory maps. //! 2. The input data is in a file or comes from standard input: //! a) if from a file, then you can guarantee that the file is not going to be modified //! ...
#[doc = "Register `CR2` reader"] pub type R = crate::R<CR2_SPEC>; #[doc = "Register `CR2` writer"] pub type W = crate::W<CR2_SPEC>; #[doc = "Field `ADON` reader - A/D converter ON / OFF"] pub type ADON_R = crate::BitReader<ADON_A>; #[doc = "A/D converter ON / OFF\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, Part...
use std::collections::HashMap; use std::sync::Mutex; #[derive(Default)] pub struct CallsTracker<T> { calls: Mutex<HashMap<String, Vec<T>>>, } impl<T: Clone> CallsTracker<T> { pub fn new() -> Self { CallsTracker { calls: Mutex::new(HashMap::new()), } } pub fn register<S: In...
//! Provides [ConfigBuilder] which is a convenient and safe way of collecting //! configuration parameters from various sources and combining them into one. use crate::config::{ConfigOption, Configuration, EthereumConfig}; use reqwest::Url; use std::{collections::HashMap, net::SocketAddr, path::PathBuf, str::FromStr};...
mod utf8; use super::Error; #[derive(Default, Clone, Copy)] pub struct ParsedAuthority { pub userinfo_len: Option<usize>, pub host_len: usize, pub port_len: Option<usize> } impl ParsedAuthority { #[inline] pub fn is_empty(&self) -> bool { self.userinfo_len.is_none() && self.host_len == 0 && self.port_len.is_n...
use anyhow::{anyhow, bail, ensure, Context, Result}; use crate::ast::*; use crate::atom::Atom; use crate::sexpr::{Expr, ExprKind}; use fxhash::FxHashMap; use std::sync::Arc; pub struct EdifParser {} macro_rules! next_elem { ($it:expr) => { $it.next() .ok_or_else(|| anyhow!("unexpected end of ...
// Copyright Jeron Aldaron Lau 2017 - 2020. // Distributed under either the Apache License, Version 2.0 // (See accompanying file LICENSE_APACHE_2_0.txt or copy at // https://apache.org/licenses/LICENSE-2.0), // or the Boost Software License, Version 1.0. // (See accompanying file LICENSE_BOOST_1_0.txt o...
use super::*; use crate::graphics::{*, self}; pub struct Label { foreground : Color, background : Color, text_width : usize, text_height : usize, text : &'static str } impl Label { pub fn new(text : &'static str, foreground : Color, background : Color) -> Label { Label { ...
use crate::{ helpers::{self, CallFuture}, types::{ Address, Block, BlockHeader, BlockNumber, Bytes, CallRequest, Index, SyncState, Transaction, TransactionReceipt, TransactionRequest, H256, U256, U64, }, Transport, }; /// Juice chain's client, similar to Go version's client. #[derive(De...
// run-pass #![feature(cow_is_borrowed)] use std::borrow::Cow; fn main() { const COW: Cow<str> = Cow::Borrowed("moo"); const IS_BORROWED: bool = COW.is_borrowed(); assert!(IS_BORROWED); const IS_OWNED: bool = COW.is_owned(); assert!(!IS_OWNED); }
use super::room; use crate::{ config::Config, idb, skyway::{self, Peer}, }; use kagura::prelude::*; use std::{ops::Deref, rc::Rc}; use wasm_bindgen::{prelude::*, JsCast}; pub type RoomConnection = Component<Props, Sub>; pub struct Props { pub config: Rc<Config>, pub peer: Rc<Peer>, pub room: R...
use std::fs; use std::path::{Path, PathBuf}; use walkdir::WalkDir; use guarding_core::domain::code_file::CodeFile; use crate::identify::code_ident::CodeIdent; use crate::identify::java_ident::JavaIdent; use crate::identify::js_ident::JsIdent; use crate::identify::rust_ident::RustIdent; pub struct ModelBuilder { } ...
mod context; pub use context::Context as Context; mod window; pub use window::Window as Window;
// ジェネリクスの活用 fn _main() { // マクロでベクタを定義 let v = vec![1,2,3,4,5] ; // Vet::new でベクタを初期化 let mut v: Vec<i32> = Vec::new() ; // 型を指定してVet::new でベクタを初期化 let mut v = Vec::<i32>::new() ; // 文字列(&str)のベクタ let mut v: Vec::<&str> = Vec::new(); // 文字列(&String)のベクタ let mut v: Vec::<&String> = Vec::new(...
use serde::{Deserialize, Serialize}; use steam_language_gen::generated::enums::{ETradeOfferConfirmationMethod, ETradeOfferState}; use crate::web_handler::confirmation::Confirmation; #[derive(Serialize, Debug, Clone)] pub struct ConfirmationMultiAcceptRequest<'a> { #[serde(rename = "a")] pub steamid: &'a str,...
#![feature(trait_alias)] extern crate dualib; mod basic_integration_tests;
fn fibonacci(n: i32) -> i32 { if n == 1 || n==0 { n }else{ fibonacci(n-1)+fibonacci(n-2) } } fn main() { println!("fibonacci is {}",fibonacci(7)); }
#[allow(unused_imports)] use std::io::stdin; fn main() { // println!("Put the username: "); // let mut username = String::new(); // stdin() // .read_line(&mut username) // .expect("Some error ocurred when parsing"); // println!("Email: "); // let mut email = String::new(); // s...
// https://www.codewars.com/kata/559536379512a64472000053 fn play_pass(s: &str, n: u32) -> String { s.char_indices() .map(|(i, c)| { if c.is_alphabetic() { // need to convert to lowercase so that we don't run into other alphanumeric chars let mut ascii = c.to_asc...
extern crate syntex; extern crate syntex_syntax; use syntex::Registry; use syntex_syntax::ast::MetaItem; use syntex_syntax::codemap::Span; use syntex_syntax::ext::base::{Annotatable, ExtCtxt, MacEager, MacResult}; use syntex_syntax::ext::build::AstBuilder; use syntex_syntax::parse::token::InternedString; use syntex_s...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - DMA mode register"] pub eth_dmamr: ETH_DMAMR, #[doc = "0x04 - System bus mode register"] pub eth_dmasbmr: ETH_DMASBMR, #[doc = "0x08 - Interrupt status register"] pub eth_dmaisr: ETH_DMAISR, #[doc = "0x0c - Debu...
#[doc = "Register `MDMA_C30ISR` reader"] pub type R = crate::R<MDMA_C30ISR_SPEC>; #[doc = "Field `TEIF` reader - TEIF"] pub type TEIF_R = crate::BitReader; #[doc = "Field `CTCIF` reader - CTCIF"] pub type CTCIF_R = crate::BitReader; #[doc = "Field `BRTIF` reader - BRTIF"] pub type BRTIF_R = crate::BitReader; #[doc = "F...
pub mod reminders; pub mod oauth; pub mod files; pub mod channels; pub mod api; pub mod rtm; pub mod usergroups_users; pub mod reactions; pub mod usergroups; pub mod dnd; pub mod files_comments; pub mod emoji; pub mod mpim; pub mod team_profile; pub mod bots; pub mod pins; pub mod auth; pub mod users; pub mod chat; pub...
use wasm_bindgen::prelude::*; use crate::{active_tab, goto_page}; #[wasm_bindgen] pub async fn this_website() { // Set active tab. active_tab(""); // Go to the page. goto_page( "/projects/this-website", "/api/projects/this_website/this_website.html?ver=BT3VCJaA9C8", "This Webs...
// FRCScouter is not snake case, but we want it that way #![allow(non_snake_case)] // Import rocket macros with nightly tools #![feature(proc_macro_hygiene, decl_macro)] extern crate rocket; // Import the static hosting tool use rocket_contrib::serve::StaticFiles; // WebSockets, `roboconnect`, and rocket all run in p...
use anyhow::Result; use std::io; pub fn ask_for_confirm(msg: &str) -> Result<bool> { println!("{} (Yes/No)", msg); let mut buf = String::new(); io::stdin().read_line(&mut buf)?; Ok(["y", "yes"].contains(&buf.trim().to_lowercase().as_str())) }
use crate::cartridge::Cartridge; pub struct MBC1 { rom: Vec<u8>, rom_bank: usize, rom_banking_enabled: bool, ram: [u8; 0x8000], ram_bank: usize, ram_enabled: bool, ram_changed: bool, } pub fn new(rom: Vec<u8>) -> MBC1 { MBC1 { rom, rom_bank: 1, r...
/// /// The connection class provides methods for a client /// to establish a network connection to a server, /// and for both peers to operate the connection thereafter. /// /// Grammar : /// /// connection = open-connection *use-connection close-connection /// open-connection = C:protocol-header S:START C:START-OK *c...
use bson::Timestamp; use super::RunCommand; use crate::{bson::doc, operation::test::handle_response_test}; #[test] fn handle_success() { let op = RunCommand::new("foo".into(), doc! { "hello": 1 }, None, None).unwrap(); let doc = doc! { "ok": 1, "some": "field", "other": true, ...
use errors::*; use log; struct SimpleLogger; impl log::Log for SimpleLogger { fn enabled(&self, metadata: &log::LogMetadata) -> bool { metadata.level() <= log::LogLevel::Debug } fn log(&self, record: &log::LogRecord) { if self.enabled(record.metadata()) { println!("{} - {}", r...
//! # Problem 12 from projecteuler.net //! //! You can find problem description [here][problem]. //! //! [problem]: https://projecteuler.net/problem=12 mod factorization { use std::collections::HashMap; fn ferma_factorization(number: u64) -> (u64, u64) { assert!(number % 2 != 0); let mut x = (number as f64)...
impl Solution { pub fn judge_square_sum(c: i32) -> bool { if c == 0{ return true; } let c = c as f64; let mut i:f64 = 0.0; while i * i <= c{ let j = (c - i * i).sqrt(); if j.ceil() == j.floor(){ return true; }...
/// An enum to represent all characters in the CommonIndicNumberForms block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum CommonIndicNumberForms { /// \u{a830}: '꠰' NorthIndicFractionOneQuarter, /// \u{a831}: '꠱' NorthIndicFractionOneHalf, /// \u{a832}: '꠲' NorthIndicFractionThre...
#![deny(unsafe_code)] #![warn(clippy::all, clippy::pedantic)] pub mod nix_query_tree; pub mod tree; mod opts; mod ui; pub fn default_main() { ui::run(); }
use crate::datastructures::{Entailment, Op::AtomEq, Pure::And, Rule}; use crate::misc::find_and_remove; /// Π | Σ |- Π' | Σ' ==> Π | Σ |- Π' ∧ E=E | Σ' pub struct EqReflexiveR; impl Rule for EqReflexiveR { fn predicate(&self, _goal: &Entailment) -> bool { true } fn premisses(&self,...
use bitbuffer::{ BitReadBuffer, BitReadStream, BitWrite, BitWriteSized, BitWriteStream, LittleEndian, }; use num_traits::{PrimInt, Unsigned}; use serde::{Deserialize, Serialize}; use snap::raw::{decompress_len, Decoder}; use crate::demo::lzss::decompress; use crate::demo::packet::stringtable::{ ExtraData, Fixe...
/*! * Sylphrena AI input program - https://github.com/ShardAi * Version - 1.0.0.0 * * Copyright (c) 2017 Eirik Skjeggestad Dale */ pub struct Unigram{ word: String, occurences: f64, probability: f64 } pub struct Bigram{ word1: String, word2: String, occurences: f64, probability: f64 }...
/*===============================================================================================*/ // Copyright 2016 Kyle Finlay // // 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 // // ...
use serde_json; use std::fmt; #[derive(Debug, Default, PartialEq, Serialize, Builder)] #[builder(default)] pub struct Header { version: u32, #[serde(skip_serializing_if = "Option::is_none")] stop_signal: Option<u32>, #[serde(skip_serializing_if = "Option::is_none")] cont_signal: Option<u32>, #[...
//! This module contains the core algorithms. use super::keys::{match_keys, KeyMatch}; use super::trie_node::TrieNode; use super::NibbleVec; use self::DescendantResult::*; impl<V> TrieNode<V> { pub fn get(&self, key: &NibbleVec) -> Option<&TrieNode<V>> { iterative_get(self, key) } pub fn get_mut...
extern crate diecast; extern crate sass_rs; use std::path::PathBuf; use sass_rs::sass_context::SassFileContext; use diecast::{Handle, Bind, Item}; pub struct Scss { input: PathBuf, output: PathBuf, } impl Handle<Bind> for Scss { fn handle(&self, bind: &mut Bind) -> diecast::Result<()> { let sou...
// Copyright 2021 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under The General Public License (GPL), version 3. // Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed // under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI...
pub mod payload_serializer;
use crate::ser::key::KeySink; use crate::ser::part::PartSerializer; use crate::ser::value::ValueSink; use crate::ser::Error; use form_urlencoded::Serializer as UrlEncodedSerializer; use form_urlencoded::Target as UrlEncodedTarget; use serde::ser; use std::borrow::Cow; use std::mem; pub struct PairSerializer<'input, 't...
use serde::de::{self, Deserialize, Deserializer, Error, Visitor}; use serde::ser::{Serialize, Serializer}; use std::fmt; #[derive(Clone, Copy, Debug, Default)] pub struct Timestamp { pub microseconds: i64, } struct TimestampVisitor; impl<'de> Visitor<'de> for TimestampVisitor { type Value = Timestamp; fn...
use std::collections::BTreeSet; use std::env; use std::fs; use std::time::Instant; #[derive(Clone, Debug, Eq, Hash, PartialEq)] struct Vector3 { x: i32, y: i32, z: i32, } impl Vector3 { fn from_string(s: &str) -> Result<Self, String> { let s = s.trim(); if !s.starts_with('<') || !s.end...
use core::ops::Index; use hashbrown::hash_map::HashMap; use slab::Slab; use necsim_core::{ cogs::{Backup, OriginSampler}, landscape::Location, lineage::Lineage, }; use crate::cogs::{ habitat::almost_infinite::AlmostInfiniteHabitat, lineage_reference::in_memory::InMemoryLineageReference, }; mod s...
extern crate dbus; use dbus::{Message, Connection, BusType, NameFlag}; use dbus::tree::{Factory, MethodInfo, MethodErr, MethodType, DataType}; const BUS_NAME: &str = "com.example.dbustest"; fn main() { let c = Connection::get_private(BusType::Session).unwrap(); c.register_name(BUS_NAME, NameFlag::ReplaceExi...
#[doc = "Reader of register ETZPC_DECPROT_LOCK0"] pub type R = crate::R<u32, super::ETZPC_DECPROT_LOCK0>; #[doc = "Writer for register ETZPC_DECPROT_LOCK0"] pub type W = crate::W<u32, super::ETZPC_DECPROT_LOCK0>; #[doc = "Register ETZPC_DECPROT_LOCK0 `reset()`'s with value 0"] impl crate::ResetValue for super::ETZPC_DE...
use core::fmt; use crate::sudoers::{ ast::{Authenticate, RunAs, Tag}, tokens::ChDir, }; use super::Entry; pub struct Verbose<'a>(pub Entry<'a>); impl fmt::Display for Verbose<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let Self(Entry { run_as, cmd_specs }) = self; l...
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 use libra_crypto::{ ed25519::{Ed25519PrivateKey, Ed25519PublicKey}, test_utils::KeyPair, ValidKeyStringExt, }; use libra_types::account_address::AccountAddress; use serde::{Deserialize, Serialize}; mod account_commands;...
#[derive(Debug, Clone)] pub struct Element { pub element_data: ElementData, pub children: Vec<Element>, } impl Element { pub fn new(name: String) -> Element { let elm_name = element_type(&*name); Element { element_data: ElementData { name: elm_name, ...
use anyhow::Result; use std::path::Path; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::UnixStream; use tokio::signal::unix::{signal, SignalKind}; use crate::msgs::ServerMsg; use crate::raw_term::RawTerm; pub struct Client { socket: UnixStream, raw_term: RawTerm, } impl Client { pub async ...
// Copyright 2021 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT // http://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD // https://opensource.org/licenses/BSD-3-Clause>, at your option. This file may not be copied, // modified, or di...
//! The [`Client`][client] undergoes several stages of initialization before it is ready to accept //! commands and be displayed to the player's screen. The enums in this module provides access to //! different functionality depending on what stage the [`Client`][client] is at: //! //! # Stages //! //! ## Stage 1 - Syn...
#[doc = "Register `TAFCR` reader"] pub type R = crate::R<TAFCR_SPEC>; #[doc = "Register `TAFCR` writer"] pub type W = crate::W<TAFCR_SPEC>; #[doc = "Field `TAMP1E` reader - RTC_TAMP1 input detection enable"] pub type TAMP1E_R = crate::BitReader; #[doc = "Field `TAMP1E` writer - RTC_TAMP1 input detection enable"] pub ty...
//! Split io object into read/write part //! use std::io::{self, Read, Write}; #[cfg(unix)] use std::os::fd::{AsRawFd, RawFd}; use super::AsIoData; pub struct SplitReader<T> { inner: T, } impl<T> SplitReader<T> { pub(crate) fn new(io: T) -> Self { SplitReader { inner: io } } pub fn inner(&s...
//! 请实现一个函数用来判断字符串是否表示数值(包括整数和小数)。 //! 例如,字符串"+100"、"5e2"、"-123"、"3.1416"、"-1E-16"、"0123"都表示数值, //! 但"12e"、"1a3.14"、"1.2.3"、"+-5"及"12e+5.4"都不是。 pub fn is_number(s: String) -> bool { let s = s.trim(); return s.parse::<i32>().is_ok() || s.parse::<f32>().is_ok() } #[cfg(test)] mod test { use super::*; #...
//! #649. Dota2 参议院 //!https://leetcode-cn.com/problems/dota2-senate/ //!Dota2 的世界里有两个阵营:Radiant(天辉)和 Dire(夜魇) //!Dota2 参议院由来自两派的参议员组成。现在参议院希望对一个 Dota2 游戏里的改变作出决定。他们以一个基于轮为过程的投票进行。在每一轮中,每一位参议员都可以行使两项权利中的一项: //!禁止一名参议员的权利: //!参议员可以让另一位参议员在这一轮和随后的几轮中丧失所有的权利。 //!宣布胜利: //!如果参议员发现有权利投票的参议员都是同一个阵营的,他可以宣布胜利并决定在游戏中的有关变化。 //!给定...
use futures::{ Sink, SinkExt, stream::{ FuturesUnordered } }; use std::{ env, fmt::Debug, fs, pin::Pin, task::{Context, Poll}, }; use serde::{de::DeserializeOwned, ser::Serialize}; use serde_json::from_str; pub async fn request_text(client: &reqwest::Client, url: &str) ...
use parse_display::FromStr; use std::collections::HashSet; #[derive(FromStr, PartialEq, Debug)] #[from_str(regex = "(?P<name>\\w*) (?P<arg>[0-9+-]*)")] struct Instruction { name: String, arg: i32, } struct Program { accumulator: i32, pc: usize, instructions: Vec<Instruction>, visited: HashSet<...
extern crate cascading_ui; extern crate wasm_bindgen_test; use self::{ cascading_ui::{test_header}, // wasm_bindgen_test::wasm_bindgen_test, }; test_header!(); // #[wasm_bindgen_test] // fn from_listener() { // test_setup! { // $text: "click me"; // text: $text; // ?click { // $text: "hello world"; // }...
use std::iter::{Product, Sum}; use std::ops::{Add, AddAssign, Sub, SubAssign, Mul, MulAssign, Div, DivAssign, Neg, Index, IndexMut}; use num::traits::{One, Zero}; use typehack::dim::*; pub trait Scalar: Clone + Sized + Zero + One + Add<Output = Self> + Sub<Output = ...
use std::io::stdin; mod data; mod crypto; mod requests; fn main() { // Check if new public/private key or use existing one println!("[1] Create new pub/priv key pair \n[2] Make Transaction \n[3] Show Info"); let mut line = String::new(); let _ = stdin().read_line(&mut line).unwrap(); let choice_num...
//! This module defines the trait necessary for a session storage struct. use self::session::Session; use iron::typemap; pub mod session; /// A default implementation of `SessionStore`: `Session`. pub mod hashsession; /// This `Trait` defines a session storage struct. It must be implemented on any store passed to `...
#[doc = "Reader of register RCC_APB1RSTSETR"] pub type R = crate::R<u32, super::RCC_APB1RSTSETR>; #[doc = "Writer for register RCC_APB1RSTSETR"] pub type W = crate::W<u32, super::RCC_APB1RSTSETR>; #[doc = "Register RCC_APB1RSTSETR `reset()`'s with value 0"] impl crate::ResetValue for super::RCC_APB1RSTSETR { type T...
use std::sync::Arc; use std::time::{Duration, Instant}; use benchmark_utilities::benchmark_utilities::set_realtime; use crate::convolution::convolution::convolve; use crate::image::image::Image; use crate::kernel::kernel::Kernel; mod convolution; mod kernel; mod image; mod benchmark_utilities; fn main() { // run_s...
#[macro_use] extern crate log; use azure_core::prelude::*; use azure_storage::core::prelude::*; use azure_storage_queues::prelude::*; use std::error::Error; use std::time::Duration; #[tokio::main] async fn main() -> Result<(), Box<dyn Error + Send + Sync>> { // First we retrieve the account name and master key fro...
// "Algorithms for Enumerating All Perfect, Maximum and Maximal Matchings in Bipartite Graphs" // by 1997 Takeaki Uno pub mod bipartite; pub mod contains; pub mod directedgraph;
use crate::db::FromDoc; use juniper::{GraphQLEnum, ID}; use mongodb::{oid::ObjectId, Document}; use reqwest::header; use serde::Deserialize; #[derive(Clone, Debug)] pub struct Order { pub id : ID, pub quantity : i32, pub address : Option<Address>, pub user : User, pub method : CollectionMethod, pub ...
//! Submodules for various network I/O handlers pub mod telnet; //pub mod websockets;
// Copyright (c) 2015, <daggerbot@gmail.com> // All rights reserved. use std::mem::{ size_of, zeroed, }; use std::ptr::null_mut; use libc::{ c_char, c_int, c_long, c_short, c_ulong, }; use ::display::Atom; use ::internal::{ FromNative, ToNative, }; use ::window::Window; // // ClientMessageData //...
#![allow(non_camel_case_types)] pub mod libtsm { use std::num::{FromPrimitive}; use libc::{c_void, c_uint, c_int, size_t, uint32_t, c_char}; use collections::enum_set::{EnumSet,CLike}; static RGB_LEVELS : &'static [u8] = &[0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff]; #[deriving(PartialEq,Show,Clone,FromPrimitive)]...
use std::cell::RefCell; use std::rc::Rc; use crate::treenode::TreeNode; pub fn sorted_list_to_bst(head: Option<Box<ListNode>>) -> Option<Rc<RefCell<TreeNode>>> { let mut nums = vec![]; let mut p = head.as_ref(); while let Some(q) = p { nums.push(q.val); p = q.next.as_ref(); } fn c...
use std::collections::HashMap; use chrono::DateTime; use chrono::NaiveDate; use chrono::NaiveDateTime; use chrono::Utc; use lazy_static::lazy_static; use log::debug; use regex::Regex; use warheadhateus::AWSAuth; use warheadhateus::HttpRequestMethod; use warheadhateus::Region; type HeaderMap = HashMap<String, String>;...
use super::*; pub type Result<T> = std::result::Result<T, Error>; #[derive(thiserror::Error, Debug)] pub enum Error { #[error("i/o error")] Io(#[from] std::io::Error), #[error("posix error")] Nix(#[from] nix::Error), #[error("procfs error")] Proc(#[from] procfs::ProcError), #[error("seccom...
use super::{env_or_empty, ReadsEnv}; use serde::Deserialize; // https://developers.facebook.com/docs/reference/plugins/like/ // https://developers.facebook.com/apps/110860435668134/summary #[derive(Deserialize, Debug)] pub struct FacebookConfig { pub app_id: String, pub admin_id: String, pub page_id: Strin...
use super::One; use rect::Rect; use std::ops::{Add, Sub, Mul}; use std::cmp::{Ord}; /// A type with `x` and `y` coordinates. pub trait Position2D<T> { /// Returns a copy of the `x` coordinate of the position. fn x(&self) -> T; /// Returns a copy of the `y` coordinate of the position. fn y(&...
#[macro_use] pub mod json_object; pub mod json_parser; fn main() { use json_object::*; let mut inner_obj = JsonObject::new(); inner_obj.insert("field_1_1", JsonValue::from(10)); inner_obj.insert("field_1_2", JsonValue::from(3.14)); let mut obj = JsonObject::new(); obj.insert("field_0", Json...
#[no_mangle] pub extern fn hello() { println!("Hello rust world."); }
use std::net::{Ipv4Addr, SocketAddrV4}; use haptik::models::AclId; use haptik::requests::{BackendId, ErrorFlag}; use haptik::responses; use haptik::{ConnectionBuilder, TcpSocketBuilder, UnixSocketBuilder}; #[test] #[ignore] fn unix_socket_builder_connects() { let builder = UnixSocketBuilder::new("/tmp/socket/hapr...
use failure::Error; use headless_chrome::protocol::dom; use headless_chrome::protocol::page::ScreenshotFormat; use headless_chrome::*; use std::sync::Arc; use serde::{Deserialize, Serialize}; use std::fs::File; use std::io::Write; use url::form_urlencoded::parse; use url::{ParseError, Url}; #[derive(Serialize, Deser...
//! Tests auto-converted from "sass-spec/spec/libsass-todo-tests/errors" #[allow(unused)] use super::rsass; mod import; mod unicode;
pub(crate) mod ast; pub(crate) mod semantic;
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>,...
use threadpool::{Builder, ThreadPool}; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::mpsc::{channel, sync_channel}; use std::sync::{Arc, Barrier}; use std::thread::{self, sleep}; use std::time::Duration; use std::prelude::v1::*; const TEST_TASKS: usize = 4; //#[test] pub fn test_set_num_threads_incre...
/* --- Day 9: Encoding Error --- With your neighbor happily enjoying their video game, you turn your attention to an open data port on the little screen in the seat in front of you. Though the port is non-standard, you manage to connect it to your computer through the clever use of several paperclips. Upon connectio...