text stringlengths 8 4.13M |
|---|
use necsim_core_bond::ClosedUnitF64;
use crate::{cogs::Habitat, landscape::Location};
#[allow(clippy::inline_always, clippy::inline_fn_without_body)]
#[contract_trait]
pub trait SpeciationProbability<H: Habitat>: crate::cogs::Backup + core::fmt::Debug {
#[must_use]
#[debug_requires(habitat.contains(location),... |
use super::*;
use guion::{util::bounds::Dims, event::{imp::StdVarSup, variant::VariantSupport, standard::variants::RootEvent, variant::Variant}};
use SDLKeycode;
#[allow(unused)]
pub fn parse_event<E>(s: &SDLEvent, window_size: (u32,u32)) -> ParsedEvent<E>
where
E: Env,
EEDest<E>: SDLDestination,
EEKey<E>:... |
use blake2b_simd::{Hash as Blake2bHash, Params as Blake2bParams};
use group::{cofactor::CofactorGroup, GroupEncoding};
pub const KDF_SAPLING_PERSONALIZATION: &[u8; 16] = b"DarkFiSaplingKDF";
/// Functions used for encrypting the note in transaction outputs.
/// Sapling key agreement for note encryption.
///
/// Impl... |
use std::rc::Rc;
use super::configuration::Configuration;
pub struct APIClient {
accounts_api: Box<dyn crate::apis::AccountsApi>,
budgets_api: Box<dyn crate::apis::BudgetsApi>,
categories_api: Box<dyn crate::apis::CategoriesApi>,
deprecated_api: Box<dyn crate::apis::DeprecatedApi>,
months_api: Box... |
use ws::{Handler, Sender, Handshake, Result, Message, Request};
use url;
use base64;
pub struct Client {
pub out: Sender,
pub auth_pass : String
}
impl Handler for Client {
fn on_open(&mut self, _shake: Handshake) -> Result<()> {
debug!("Socket opened");
self.out.send("[5, \"OnJsonApiEvent... |
use std::cell::Cell;
use chiropterm::{Brush};
use crate::{UI, ui::Selection};
use super::{WidgetDimensions, InternalWidgetDimensions, WidgetMenu, Widgetlike};
pub struct WidgetCommon<T> {
pub unique: T,
pub(in crate) selection: Selection,
pub(in crate) layout_token: Cell<u64>,
last_dimensions: Cell... |
use super::{
annotate_types, apply_macros_to_function_map, build_functions, parse,
parse_functions_and_macros, Builder, Compiler, GenericResult,
};
use std::time::Instant;
/// runs through the workflow as described
/// in compiler-design.
pub fn load_string_into_compiler(compiler: &mut Compiler, input: &str) -... |
use std::fs::File;
use std::io::prelude::*;
#[derive(Debug, Deserialize)]
pub struct Config {
database: Database,
}
#[derive(Debug, Deserialize)]
pub struct Database {
url: Option<String>,
pool_size: Option<u32>,
}
pub fn read_toml() -> Config {
let config_path = "config.toml";
let mut config_fi... |
#[doc = "Reader of register CONN_1_CE_DATA_LIST_CFG"]
pub type R = crate::R<u32, super::CONN_1_CE_DATA_LIST_CFG>;
#[doc = "Writer for register CONN_1_CE_DATA_LIST_CFG"]
pub type W = crate::W<u32, super::CONN_1_CE_DATA_LIST_CFG>;
#[doc = "Register CONN_1_CE_DATA_LIST_CFG `reset()`'s with value 0"]
impl crate::ResetValue... |
use std::f64::consts::PI;
pub struct Mercator {
tile_size: f64,
}
impl Mercator {
/// Create a new Mercator with custom tile size. Tile sizes must be a power of two (256, 512,
/// and so on).
pub fn with_size(tile_size: usize) -> Mercator {
Mercator { tile_size: tile_size as f64 }
}
/... |
mod assembly;
mod assembly_helper;
mod assembly_printer;
mod ast;
mod ast_helper;
mod code_block;
mod code_generator;
mod lexeme;
mod parser;
mod pointer_arithmetic_transformer;
mod representation_manager;
mod scanner;
mod struct_analyzer;
mod token_stream;
mod type_checker;
mod type_checker_helper;
mod x86_code_genera... |
//! Rejections
//!
//! Part of the power of the [`Filter`](../trait.Filter.html) system is being able to
//! reject a request from a filter chain. This allows for filters to be
//! combined with `or`, so that if one side of the chain finds that a request
//! doesn't fulfill its requirements, the other side can try to p... |
#[cfg(windows)]
fn main() {
println!("cargo:rustc-link-search=native=./");
println!("cargo:rustc-link-lib=static=sciter.static");
println!("cargo:rustc-link-lib=comdlg32");
println!("cargo:rustc-link-lib=wininet");
println!("cargo:rustc-link-lib=windowscodecs");
}
#[cfg(not(windows))]
fn main() {}
|
use std::time::{Duration, Instant};
enum Event {
Key(crate::Keys),
Delete,
Finished,
}
pub struct Res {
text: text::Text,
inputs: Vec<(Event, Duration)>,
last_input: Option<Instant>,
}
impl Res {
pub fn new(text: text::Text) -> Self {
Res {
text: text,
inpu... |
#[doc = "Register `AR` reader"]
pub type R = crate::R<AR_SPEC>;
#[doc = "Register `AR` writer"]
pub type W = crate::W<AR_SPEC>;
#[doc = "Field `ADDRESS` reader - Address Address to be sent to the external device. In HyperBus protocol, this field must be even as this protocol is 16-bit word oriented. In dual-memory conf... |
use num::{BigUint, FromPrimitive, ToPrimitive};
use util::factorial;
pub fn run() -> u64 {
let n = BigUint::from_u8(20).unwrap();
(factorial(BigUint::from_u8(2).unwrap() * n.clone()) / sq(factorial(n))).to_u64().unwrap()
}
fn sq(n: BigUint) -> BigUint {
n.clone() * n
}
|
#[derive(Debug, PartialEq)]
pub struct City {
pub size_in_sqm: u32
}
impl City {
pub fn new(size: u32) -> City {
City { size_in_sqm: size }
}
}
// pub fn compare_size(city: &City, city2: &City) -> &City {
// if &city.size_in_sqm <= &city2.size_in_sqm {
// city2
// } els... |
fn main() {
let if_zero = false as i32;
let if_one = true as i32;
print!("{}\n{}", if_zero, if_one)
}
|
use seed::prelude::*;
use crate::chart;
use crate::utils::*;
use common::weather::WeatherEvent;
type WeatherData = Vec<WeatherEvent>;
#[derive(Clone, Debug)]
pub enum Model {
NotLoaded,
Loading { duration: u32 },
Loaded { duration: u32, data: WeatherData },
Failed(String)
}
impl Default for Model {
... |
/*
SPDX-License-Identifier: Apache-2.0 OR MIT
Copyright 2020 The arboard contributors
The project to which this file belongs is licensed under either of
the Apache 2.0 or the MIT license at the licensee's choice. The terms
and conditions of the chosen license apply to this file.
*/
use std::borrow::Cow;
use std::con... |
use crate::*;
use sqlx::SqlitePool;
mod models;
pub use models::*;
mod findable;
pub use findable::*;
pub(crate) async fn user_from_discord_user_id(
discord_user_id: i64,
db_pool: &SqlitePool,
) -> Result<QueryOnRead<User>, sqlx::Error> {
let existing_user_id: Option<i64> = sqlx::query!(
"SELECT... |
use std::path::Path;
use serde::de::DeserializeOwned;
use std::fs::OpenOptions;
use std::error::Error;
use std::str;
pub fn deserialize_object<T>(source_path: impl AsRef<Path>) -> Result<T, Box<dyn Error>>
where
T: DeserializeOwned,
{
let file = OpenOptions::new().read(true).open(source_path.as_ref())?... |
extern crate rustc_serialize;
extern crate hyper;
use rustc_serialize::json;
use rustc_serialize::json::Json;
#[macro_use] extern crate nickel;
use nickel::status::StatusCode;
use nickel::{Nickel, HttpRouter, MediaType, JsonBody};
#[derive(RustcDecodable, RustcEncodable)]
struct Todo {
status: i32,
title: String... |
//! The load option iterator.
use crate::error::GetLoadOptionError;
use crate::Adapter;
use crate::LoadOption;
use std::iter::Iterator;
/// The load option iterator.
pub struct LoadOptionIter<'a, I>
where
I: Iterator<Item = u16>,
{
/// The adapter reference.
adapter: &'a Adapter,
/// The numeric itera... |
// mod human
#[repr(C)]
struct Brain {
/*Internal State*/
pub fn get_next_move() -> Option<Direction> {
/*
* Things to consider:
* 1. Meeting people ->
* lower priority as neared to 300 friends
* gender matters a bit
* share 'some' of past ex... |
#[doc = "Register `LTDC_ICR` writer"]
pub type W = crate::W<LTDC_ICR_SPEC>;
#[doc = "Field `CLIF` writer - CLIF"]
pub type CLIF_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>;
#[doc = "Field `CFUIF` writer - CFUIF"]
pub type CFUIF_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>;
#[doc = "Field `CTERRIF` ... |
use protobuf;
use protobuf::CodedInputStream;
use protobuf::CodedOutputStream;
use misc::*;
pub fn protobuf_message_read <
Type: protobuf::MessageStatic,
NameFunction: Fn () -> String,
> (
coded_input_stream: & mut CodedInputStream,
name_function: NameFunction,
) -> Result <Type, String> {
let message_length =
... |
use crate::tokens::{CommentKind, Keyword, NumberKind, Punct};
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
pub enum RawToken {
/// `true` of `false`
Boolean(bool),
/// The end of the file
EoF,
/// An identifier this will be either a variable name
/// or a function/method name
Ident,
///... |
//! A newtype with alignment of at least `A` bytes
//!
//! # Examples
//!
//! ```
//! use std::mem;
//!
//! use aligned_array::{Aligned, A2, A4, A16};
//!
//! // Array aligned to a 2 byte boundary
//! static X: Aligned<A2, [u8; 3]> = Aligned([0; 3]);
//!
//! // Array aligned to a 4 byte boundary
//! static Y: Aligned<A... |
use std::cmp::min;
fn read_line() -> String {
let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim_end().to_owned()
}
fn main() {
let stdin = read_line();
let mut iter = stdin.split_whitespace();
let n: i64 = iter.next().unwrap().parse().unwrap();
let m: ... |
extern crate std;
use super::super::prelude::{
LPCTSTR
};
pub type Text = LPCTSTR; |
use base64;
use std::{error, fmt};
use serde_json;
use openssl;
#[derive(Debug)]
pub enum Error {
DecodeBase64(base64::DecodeError),
DecodeJson(serde_json::Error),
OpensslError(openssl::error::ErrorStack),
InvalidToken,
InvalidIssuer,
InvalidAudience,
InvalidSignature,
NoMatchingSigning... |
// Unit testing for bitcountry currency, bitcountry treasury
#[cfg(test)]
use super::*;
use frame_support::{assert_noop, assert_ok};
use mock::{Event, *};
use primitives::Balance;
use sp_core::blake2_256;
use sp_runtime::traits::BadOrigin;
use sp_runtime::AccountId32;
use sp_std::vec::Vec;
fn get_mining_balance() -> B... |
use std::fs;
use std::env;
use std::collections::HashMap;
struct OccupiedSeatCounter {
size: (usize, usize),
layout: HashMap<String, char>,
}
impl OccupiedSeatCounter {
fn count(&mut self) -> i32 {
let mut rounds = 0;
loop {
let new_layout = self.process();
rounds ... |
#[doc = "Register `CR3` reader"]
pub type R = crate::R<CR3_SPEC>;
#[doc = "Register `CR3` writer"]
pub type W = crate::W<CR3_SPEC>;
#[doc = "Field `ITAMP1NOER` reader - Internal Tamper 1 no erase"]
pub type ITAMP1NOER_R = crate::BitReader;
#[doc = "Field `ITAMP1NOER` writer - Internal Tamper 1 no erase"]
pub type ITAMP... |
use num::complex::Complex64;
use rand::prelude::*;
use rustfft::FftPlanner;
fn main() {
let n = 3;
let len = 1 << n;
let mut rng = rand::thread_rng();
let mut rustfft: Vec<_> = (0..len)
.map(|_| Complex64::new(rng.gen(), rng.gen()))
.collect();
let mut my_fft = rustfft.clone();
... |
pub(crate) trait StringExt {
fn add(&mut self, ch: char) -> &mut Self;
fn add_str(&mut self, s: &str) -> &mut Self;
fn add_sep(&mut self, sep: char) -> &mut Self;
fn add_sep_str(&mut self, sep: &str) -> &mut Self;
}
impl StringExt for String {
fn add(&mut self, ch: char) -> &mut Self {
s... |
#[doc = "Register `MMCCR` reader"]
pub type R = crate::R<MMCCR_SPEC>;
#[doc = "Register `MMCCR` writer"]
pub type W = crate::W<MMCCR_SPEC>;
#[doc = "Field `CR` reader - Counter reset"]
pub type CR_R = crate::BitReader<CR_A>;
#[doc = "Counter reset\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub ... |
use std::cmp::Ordering;
use crate::hit_record::HitRecord;
use crate::hittable::Hittable;
use crate::material::Material;
use crate::object::Object;
use crate::ray::Ray;
trait ObjectLike: Hittable + Material {}
pub struct ObjectList<'a> {
pub objects: Vec<Box<dyn Object + 'a>>,
}
fn f64_cmp(x: f64, y: f64) -> Ord... |
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::PCFG {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut ... |
fn main(){
let names = vec!["Kannan", "Mohtashim", "Kiran"];
for name in names.into_iter() {
match name {
"Mohtashim" => println!("There is a rustacean among us!"),
_ => println!("Hello {}", name),
}
}
// cannot reuse the collection after iteration
println!("{:?}",n... |
use winit::{ElementState, Event, MouseButton, MouseScrollDelta, TouchPhase, VirtualKeyCode,
WindowEvent, KeyboardInput};
use resource::Input;
use util::Direction;
pub struct MenuGameControlSystem;
impl<'a> ::specs::System<'a> for MenuGameControlSystem {
type SystemData = (
::specs::Fetch<'a, :... |
use std::{
collections::VecDeque,
ffi::OsStr,
io::{Result, Write},
path::{Path, PathBuf},
process::{Command, Output},
};
fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
if Command::new("glslc").output().is_err() {
eprintln!("Error compiling shaders: 'glslc' not found,... |
#[doc = "Reader of register PWR_TRIM_BODOVP_CTL"]
pub type R = crate::R<u32, super::PWR_TRIM_BODOVP_CTL>;
#[doc = "Writer for register PWR_TRIM_BODOVP_CTL"]
pub type W = crate::W<u32, super::PWR_TRIM_BODOVP_CTL>;
#[doc = "Register PWR_TRIM_BODOVP_CTL `reset()`'s with value 0x0004_0d04"]
impl crate::ResetValue for super... |
use std::collections::HashMap;
use std::collections::HashSet;
pub fn solve_part_one(input: &str) -> usize {
let mut containers = HashMap::new();
input
.lines()
.for_each(|line| {
let parts: Vec<&str> = line.split(" bags contain ").collect();
let container = parts[0];
... |
use serde::Serialize;
const PROTOCOL_VER: u8 = 1;
const CLIENT: &str = "vndb_rs";
const CLIENT_VER: &str = env!("CARGO_PKG_VERSION");
#[derive(Serialize, Debug)]
pub(crate) struct LoginRequest<'a> {
protocol: u8,
client: &'static str,
clientver: &'static str,
#[serde(skip_serializing_if = "Option::is_... |
//https://tools.ietf.org/html/rfc2616
// SP = <US-ASCII SP, space (32)>
// CTL = <any US-ASCII control character
// (octets 0 - 31) and DEL (127)>
// HTTP-message = Request | Response
// generic-message = start-line
// *(message-header CRLF)
... |
extern crate sdl2;
use super::renderer;
use sdl2::render;
use sdl2::ttf;
use sdl2::video;
pub struct Window {
canvas: render::Canvas<video::Window>,
}
impl Window {
pub fn from(window: video::Window) -> Result<Window, String> {
Ok(Window {
canvas: window
.into_canvas()
.present_vsync()
.index(find... |
use std::time::Duration;
use bson::doc;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use typed_builder::TypedBuilder;
use crate::{
bson::{Bson, Document},
concern::{ReadConcern, WriteConcern},
options::{Collation, CursorType},
selection_criteria::SelectionCriteria,
s... |
use crate::services::bicycle_manager::*;
use serde::{Deserialize, Serialize};
#[derive(Deserialize)]
pub struct BicycleRequest {
pub wheel_size: i32,
pub description: String,
}
#[derive(Serialize)]
pub struct BicycleResponse {
pub id: i32,
pub wheel_size: i32,
pub description: String,
}
impl Bicy... |
use std::{time::Duration, u64};
use dbus::blocking::Connection;
const DBUS_COMPIZ_ROOT: &str = "org.freedesktop.compiz";
const DBUS_EXPO_KEY: &str = "/org/freedesktop/compiz/expo/allscreens/expo_key";
/// The command to do this from the command line is:
///
/// dbus-send --print-reply --type=method_call --dest=org.f... |
use crate::{
app::util::arg::{category, formatter},
repository::{Package, Repository},
util::{optfilter::OptFilter, repoobject::RepoObject},
};
use clap::{App, ArgMatches, Error, SubCommand};
use std::path::Path;
pub(crate) const NAME: &str = "packages";
pub(crate) const ABOUT: &str = "Iterate all packages ... |
use sha2::{Sha256, Sha512, Digest};
use crate::blockchain::block::Block;
#[derive(Debug)]
pub struct Verifier{
}
impl Verifier {
pub fn hash_block(&self, block: &Block) -> Vec<u8> {
return self.hash_string_sha256(block.to_string())
}
pub fn hash_string_sha256(&self, str: String) -> Vec<u8> {
... |
pub fn sample() {
println!("Lib");
}
|
extern crate clap;
extern crate rust_htslib;
extern crate bio;
use clap::{Arg, App};
use rust_htslib::bam;
use rust_htslib::prelude::*;
use bio::io::fasta;
#[derive(Clone)]
pub struct GenomicInterval {
pub tid: u32,
pub chrom: String,
// chromosome name
pub start_pos: u32,
// start of interval
... |
use std::error::Error;
use std::fs;
pub fn run(config: Config) -> Result<(), Box<dyn Error>> {
let file_contents =
fs::read_to_string(config.filename).expect("something went wrong in reading file");
let result = search(&config.query, &file_contents);
let number_of_result = result.len();
print... |
use std::cmp;
use std::ops::Range;
use std::path::{Path, PathBuf};
use std::rc::Rc;
#[derive(Debug)]
pub struct Loc {
path: Rc<PathBuf>,
byte_range: Range<usize>,
}
impl Loc {
pub fn new(path: Rc<PathBuf>, byte_range: Range<usize>) -> Self {
Loc { path, byte_range }
}
pub fn path(&self) -... |
use super::Part;
use crate::util::int_code_computer::*;
pub fn solve(input : String, part: Part) -> String {
let opcodes:Vec<i64> = input.split(',')
.map(|op| op.trim().parse().unwrap())
.collect();
let result = match part {
Part::Part1 => part1(opcodes),
Part::Part2 => part2... |
use base64;
use crypto;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
fn main() {
let input = File::open("10.txt").unwrap();
println!(
"{}",
String::from_utf8(decrypt(
&base64::decode(
&BufReader::new(input)
.lines()
... |
fn main() {
let n = {
let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim_end().parse().unwrap()
};
let a = {
let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim_end()
.split_w... |
use ::mem::malloc;
// pub struct Context {
// /// FX valid?
// loadable: bool,
// /// FX location
// fx: usize,
// /// Page table pointer
// cr3: usize,
// /// RFLAGS register
// rflags: usize,
// /// RBX register
// rbx: usize,
// /// R12 register
// r12: usize,
// ... |
extern crate reqwest;
use std::collections::HashMap;
//holds data for instructor and students
pub struct ClassIssueRequester {
pub class_repo_address: String,
pub username: String,
pub password: String,
}
impl ClassIssueRequester {
pub fn new(
class_repo_address: String,
username: Str... |
pub mod credential;
pub mod http;
pub mod oauth_client;
pub use credential::authorize;
pub use http::HttpClient;
pub use oauth_client::{
DiscordOauthProvider, DiscordOauthProviderBuilder, DiscordOauthScope, OauthClient,
OauthProvider,
};
|
use std::fs::File;
use std::io::{prelude::*, BufReader};
use super::Tile;
/// This is also known as the joker
pub const WILDCARD : char = '*';
/// Simple struct that stores information about how many times we add this tile
/// in the tileset
pub struct TileInfo {
tile : Tile,
occurences : u32,
}
/// Stores a... |
use predicates::prelude::Predicate;
use predicates::str::contains;
use short::BIN_NAME;
use test_utils::init;
use test_utils::{HOME_CFG_FILE, PROJECT_CFG_FILE};
mod test_utils;
#[test]
fn cmd_show_no_setup_no_env() {
let mut e = init("cmd_show_no_setup_no_env");
e.add_file(
PROJECT_CFG_FILE,
... |
// and enums
use std::fmt::Display;
pub trait Euclidean {
fn cross();
fn magnitude() {
println!("Hello World");
}
}
#[derive(Debug)]
pub struct Vector3 {
pub x: i32,
pub y: i32,
pub z: i32,
}
impl Vector3 {
fn dot(&self, other: &Vector3) -> i32 {
self.x * other.x
... |
mod test_support;
use apllodb_immutable_schema_engine::ApllodbImmutableSchemaEngine;
use apllodb_immutable_schema_engine_infra::test_support::{session_with_tx, test_setup};
use apllodb_shared_components::{
ApllodbError, ApllodbResult, Expression, NnSqlValue, Schema, SchemaIndex, SqlState, SqlType,
SqlValue,
};... |
struct Solution;
struct BytePos {
idx: Option<usize>,
byte: u8,
}
impl Solution {
pub fn is_palindrome(s: String) -> bool {
if s.len() == 0 {
return true;
}
let chars = s.as_bytes();
let mut left = 0;
let mut right = chars.len() - 1;
while left ... |
use crate::models::player::Player;
use crate::models::pressure_plate::{Plate, PlateMaterial};
use bevy::prelude::*;
use bevy::sprite::collide_aabb::collide;
use crate::models::explosion::Explosion;
use crate::level;
use crate::models::points::Points;
use crate::systems::gravity::GravityLevel;
pub fn init(
mut pl... |
//#[path = "common.rs"]
//mod common;
use crate::common;
#[derive(Debug)]
pub struct XMLSimpParser {
xml: Vec<char>,
p: usize,
xml_buf: Vec<char>,
pub tokenized_text_list: Vec<common::TokenizedText>, // why need pub?
}
impl XMLSimpParser {
pub fn new(s: &String) -> Self {
XMLSimpParser {
... |
#![allow(non_snake_case, non_upper_case_globals)]
const G_RAW: f64 = 6.674e-11;
#[derive(Copy, Clone)]
struct RawNBody {
position: Raw2D,
accel: Raw2D,
velocity: Raw2D,
mass: f64,
}
#[derive(Copy, Clone, Debug)]
struct Raw2D(f64, f64);
impl Raw2D {
fn dist(&self, other: &Raw2D) -> (f64, f64, f64... |
/*
* @author :: Preston Wang-Stosur-Bassett
* @date :: October 8, 2020
* @description :: This package returns the hsk level for a simplified chinese character
*/
use std::collections::HashMap;
use bincode::deserialize_from;
static HSK_DATA: &'static [u8] = include_bytes!("../data/hsk.data");
pu... |
use priv_prelude::*;
use spawn;
/// Spawn a thread with a single interface, operating a behind a NAT.
pub fn behind_nat_v4<F, R>(
handle: &Handle,
nat: NatV4Builder,
public_ip: Ipv4Addr,
func: F,
) -> (SpawnComplete<R>, Ipv4Plug)
where
R: Send + 'static,
F: FnOnce() -> R + Send + 'static,
{
... |
use crate::NewService;
use std::task::{Context, Poll};
use tower::util::{Oneshot, ServiceExt};
pub trait RecognizeRoute<T> {
type Key: Clone;
fn recognize(&self, t: &T) -> Self::Key;
}
#[derive(Clone, Debug)]
pub struct NewRouter<T, N> {
new_recgonize: T,
inner: N,
}
#[derive(Clone, Debug)]
pub stru... |
//! Provides the [logistic](http://en.wikipedia.org/wiki/Logistic_function) and
//! related functions
use crate::error::StatsError;
use crate::Result;
/// Computes the logistic function
pub fn logistic(p: f64) -> f64 {
1.0 / ((-p).exp() + 1.0)
}
/// Computes the logit function
///
/// # Panics
///
/// If `p < 0.... |
pub fn intersection(mut nums1: Vec<i32>, mut nums2: Vec<i32>) -> Vec<i32> {
use std::cmp::Ordering::*;
nums1.sort();
nums2.sort();
let mut p1 = 0;
let mut p2 = 0;
let mut result: Vec<i32> = vec![];
while p1 < nums1.len() && p2 < nums2.len() {
match nums1[p1].cmp(&nums2[p2]) {
... |
/// An enum to represent all characters in the ArabicPresentationFormsA block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum ArabicPresentationFormsA {
/// \u{fb50}: 'ﭐ'
ArabicLetterAlefWaslaIsolatedForm,
/// \u{fb51}: 'ﭑ'
ArabicLetterAlefWaslaFinalForm,
/// \u{fb52}: 'ﭒ'
ArabicLe... |
$NetBSD: patch-third__party_rust_authenticator_src_netbsd_fd.rs,v 1.1 2023/02/05 08:32:24 he Exp $
--- third_party/rust/authenticator/src/netbsd/fd.rs.orig 2020-09-02 20:55:30.875594185 +0000
+++ third_party/rust/authenticator/src/netbsd/fd.rs
@@ -0,0 +1,47 @@
+/* This Source Code Form is subject to the terms of the M... |
use glium::glutin::{self, event_loop::EventLoop, window::WindowBuilder, dpi::PhysicalSize};
use glium::{Display, Program, DrawParameters, texture::Texture2d};
use crate::textures::create_texture_map;
use std::collections::HashMap;
use crate::shaders;
#[cfg(windows)]
use glium::glutin::platform::windows::WindowBuilderE... |
use std::env;
use std::fs::{copy, File, OpenOptions};
use std::io::Write;
use std::path::{Path, PathBuf};
use cargo::ops::NewOptions;
use cargo::ops::VersionControl::NoVcs;
use cargo::Config;
fn main() {
let (year, problem_number) = extract_args();
let proj_dir = create_package(year, problem_number);
wri... |
mod device;
mod messages;
mod noise;
mod peer;
mod timestamp;
mod types;
// publicly exposed interface
pub use device::Device;
|
use jsonrpc_client_core::{expand_params, jsonrpc_client};
use jsonrpc_types::{
Block, BlockTemplate, Header, Node, Transaction, TransactionWithStatus, TxPoolInfo, TxTrace,
};
use numext_fixed_hash::H256;
jsonrpc_client!(pub struct RpcClient {
pub fn local_node_info(&mut self) -> RpcRequest<Node>;
pub fn ge... |
extern mod rustcheck;
use rustcheck::*;
use std::*;
fn prop_even(x : int) -> bool {
return x % 2 == 0;
}
fn gen_even() -> int {
let i : int = rustcheck::gen_int();
if i % 2 == 0 {
i
}
else {
i + 1
}
}
fn main() {
for_all(prop_even, [gen_int]);
for_all(prop_even, [gen_even]);
} |
use std::collections::HashMap;
use serde::Deserialize;
use serde_derive::{Serialize, Deserialize};
use erased_serde::Serialize;
// macros
use erased_serde::{serialize_trait_object, __internal_serialize_trait_object};
pub trait SerializeDebug: erased_serde::Serialize + std::fmt::Debug {}
serialize_trait_object!(Seriali... |
//! This is the x86_64 implementation of the `AddressSpaceManager` trait.
use super::paging::inactive_page_table::InactivePageTable;
use super::paging::page_table_entry::*;
use super::paging::page_table_manager::PageTableManager;
use super::paging::{convert_flags, Page, PageFrame, CURRENT_PAGE_TABLE};
use super::PAGE_... |
use block::Block;
use util::run_command;
pub struct Title {
max_chars: usize,
}
impl Title {
pub fn new(max: usize) -> Title {
Title {
max_chars: max,
}
}
pub fn get_title(&self) -> String {
let title = run_command("xdotool getwindowname $(xdotool getactivewindow)"... |
use super::token::literal::OperatorKind;
use super::types::Type;
#[derive(Debug, Clone)]
pub enum Operator {
Plus,
Minus,
Times,
Devide,
Equal,
NotEqual,
}
impl Operator {
pub fn from_ope_kind(kind: OperatorKind) -> Self {
use OperatorKind::*;
match kind {
Plus... |
#[doc = "Reader of register RCC_FMCCKSELR"]
pub type R = crate::R<u32, super::RCC_FMCCKSELR>;
#[doc = "Writer for register RCC_FMCCKSELR"]
pub type W = crate::W<u32, super::RCC_FMCCKSELR>;
#[doc = "Register RCC_FMCCKSELR `reset()`'s with value 0"]
impl crate::ResetValue for super::RCC_FMCCKSELR {
type Type = u32;
... |
use super::super::prelude::{
HICON
};
pub type Icon = HICON;
//TODO there some function define at : Icon Functions (Windows) need reinterfacing |
use std::borrow::Cow;
#[derive(Debug, serde::Serialize)]
#[serde(rename_all = "snake_case", tag = "type")]
pub enum TestCaseResult {
Pass,
Skip { kind: SkipKind, reason: String },
Recommendation { kind: String },
Failure { kind: FailureKind },
Error { kind: ErrorKind },
}
#[derive(Debug, serde::Ser... |
pub mod beacon_state_accessors;
pub mod beacon_state_mutators;
pub mod crypto;
pub mod math;
pub mod misc;
pub mod predicates;
|
use envconfig::Envconfig;
#[derive(Envconfig)]
pub struct Config {
#[envconfig(from = "mutate_wall", default = "0.05")]
pub mutate_wall: f64,
#[envconfig(from = "mutate_passage", default = "0.05")]
pub mutate_passage: f64,
#[envconfig(from = "mutate_waypoint", default = "0.05")]
pub mutate_wa... |
use crate::Result;
use rumqtt::{MqttClient, QoS};
use std::sync::{Arc, Mutex};
pub struct Subscriber {
client: Arc<Mutex<MqttClient>>,
/// FIXME: resubscribe when clcean_session == true
subscriptions: Vec<String>,
}
impl Subscriber {
pub fn new(client: Arc<Mutex<MqttClient>>) -> Self {
Self {
... |
#[doc = "Register `OPTSR_PRG` reader"]
pub type R = crate::R<OPTSR_PRG_SPEC>;
#[doc = "Register `OPTSR_PRG` writer"]
pub type W = crate::W<OPTSR_PRG_SPEC>;
#[doc = "Field `BOR_LEV` reader - BOR reset level option configuration bits"]
pub type BOR_LEV_R = crate::FieldReader;
#[doc = "Field `BOR_LEV` writer - BOR reset l... |
use std::error::Error;
use std::net::SocketAddr;
use futures::{future, Future, Stream};
use hyper;
use hyper::{Body, Method, Request, Response, StatusCode};
use serde_json as json;
use nodes;
use nodes::{NodeInfo, NodeKeys};
use log;
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone)]
pub struct Validator... |
use super::{color::Color, TexstureLayer};
use crate::JsObject;
use std::{cell::Cell, ops::Deref, rc::Rc};
use wasm_bindgen::prelude::*;
pub struct Table {
name: String,
size: [f64; 2],
pixel_ratio: [f64; 2],
is_bind_to_grid: bool,
drawing_texture: TexstureLayer,
drawing_texture_is_changed: Cell... |
#![no_main]
#![no_std]
extern crate cortex_m_rt;
extern crate panic_halt;
use cortex_m_rt::{entry, exception};
#[entry]
fn foo() -> ! {
loop {}
}
#[exception]
fn DefaultHandler(_irq: i16) {}
//~^ ERROR defining a `DefaultHandler` is unsafe and requires an `unsafe fn`
#[exception]
fn HardFault() {}
//~^ ERROR d... |
#[doc = "Reader of register MDMA_C7ISR"]
pub type R = crate::R<u32, super::MDMA_C7ISR>;
#[doc = "TEIF7\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TEIF7_A {
#[doc = "0: No transfer error on stream\r\n x"]
B_0X0 = 0,
#[doc = "1: A transfer error occurred on strea... |
use std::io::Write;
use std::io::BufReader;
use std::io::BufRead;
fn main() {
let mut rd = BufReader::new(std::io::stdin());
let stdin = std::str::from_utf8;
let mut input = Vec::new();
rd.read_until(b'\n', &mut input).unwrap();
let n: i32 = stdin(&mut input).unwrap()
.trim().parse().unwr... |
//! Testing doctest with tarpaulin
use std::env;
use std::path::PathBuf;
// doctest
/// Get my own package path for e.g. setting configuration from
/// ```rust
/// # use test_tarpaulin_env::cargo_manifest_path::*;
/// # use std::path::PathBuf;
/// #
/// # fn main() {
/// let test_dir = get_my_path("test_data");
/... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.