text stringlengths 8 4.13M |
|---|
use crate::prelude::*;
use crate::actor::*;
use crate::context::{Context, ContextRef};
use futures::{
SinkExt,
channel::mpsc::Sender,
channel::oneshot::{Sender as OneSender, Receiver as OneReceiver, channel as oneshot, Canceled},
executor::LocalSpawner,
};
use async_trait::async_trait;
use crate::addr:... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - MPCBB control register"]
pub cr: CR,
_reserved1: [u8; 0x0c],
#[doc = "0x10 - MPCBB control register"]
pub lckvtr1: LCKVTR1,
#[doc = "0x14 - MPCBB control register"]
pub lckvtr2: LCKVTR2,
_reserved3: [u8; 0xe... |
use std::str::FromStr;
use http::uri::Authority;
use serde::{Deserialize, Serialize};
use crate::config::{
default_localstorage_addr, default_path, default_serve_at, DataServerConfig, KeyPairScheme,
};
use crate::types::Scheme;
fn default_authority() -> Authority {
Authority::from_static(default_localstorage_add... |
use crate::prelude::*;
pub use wasm_bindgen::{prelude::*,JsCast};
use web_sys::*;
mod render; pub use render::*;
pub macro log( $( $t:tt )* ) {{
let s = format!( $( $t )* );
console::log_1(&s.clone().into());
//tmp_logs().push(s);
}}
pub fn request_animation_frame(f: &Closure<dyn FnMut()>) {
window()
.request_... |
use crate::{AliasId, BlockId, DeclId};
pub enum Exportable {
Decl(DeclId),
Alias(AliasId),
EnvVar(BlockId),
}
|
use std::fs::File;
use std::sync::Arc;
use serde_json::from_reader;
use tokio::sync::Mutex;
use crate::models::Customer;
/// Represents an in memory data store of customer data
pub type Db = Arc<Mutex<Vec<Customer>>>;
/// Initializes the data store
///
/// Returns a Db type that either contains customer data
/// or... |
use simplelog::{Config, LevelFilter, SimpleLogger};
const DEFAULT_LOG_LEVEL: LevelFilter = LevelFilter::Trace;
pub fn init() {
SimpleLogger::init(DEFAULT_LOG_LEVEL, Config::default()).unwrap();
}
|
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use core::time::Duration;
use reverie_rpc::MakeClient;
use reverie_syscalls::LocalMemory;
use reve... |
use std::collections::HashSet;
use std::path::{Path, PathBuf};
use anyhow::Result;
use csv::{Reader, Writer};
use crate::io;
pub fn parse_args(
input: &Path,
gene_list: Option<&PathBuf>,
output: Option<&PathBuf>,
rank_cutoff: Option<&f64>,
pcc_cutoff: Option<&f64>,
) -> Result<()> {
let mut r... |
pub mod command;
pub mod drawer;
pub mod event_emitter;
pub mod input;
pub mod main_loop;
pub mod output;
pub mod stream_util;
pub mod timer;
pub use glium;
pub use im;
pub use sodium_rust;
|
use super::prelude::*;
#[derive(Debug, Clone, PartialEq)]
pub struct ExprStmt {
pub expr: Expr,
}
impl Display for ExprStmt {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.expr)
}
}
impl TryFrom<Stmt> for ExprStmt {
type Error = Error;
fn try_from(value: Stmt... |
#[derive(Copy, Clone, Debug, Default)]
pub struct Stream<'a> {
src: &'a [u8],
offset: usize,
}
impl<'a> Stream<'a> {
pub fn new(src: &'a str) -> Self {
Self {
src: src.as_bytes(),
offset: 0,
}
}
pub fn offset(&self) -> usize {
self.offset
}
... |
/*
Copyright 2019-2023 Didier Plaindoux
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 hacspec_dev::prelude::*;
#[test]
fn test_read_test_vectors() {
create_test_vectors!(MyTestVectors, info: String, tests: Vec<MyTestVector>);
create_test_vectors!(MyTestVector, x: u32, s: String);
let tests: MyTestVectors = MyTestVectors::from_file("tests/sample_test_vector.json");
assert_eq!(tests... |
use super::num_traits::Float;
use super::rand::distributions::{Binomial, Distribution};
use super::rand::{RngCore, ChaChaRng};
pub fn normalize_array(rate: f64, arr: &mut Vec<f64> ) -> Vec<f64> {
//Take the input vec
let mod_array = arr.iter()
//log of each
.map(|x| x.log(super::std::f64::consts::... |
use crate::Count;
use crate::MultiWindow;
use alga::general::AbstractGroup;
use alga::general::Operator;
use std::marker::PhantomData;
use std::ops::Range;
pub struct SlideSide<Value, BinOp>
where
Value: AbstractGroup<BinOp> + Clone,
BinOp: Operator,
{
front: Vec<Value>,
back: Vec<Value>,
elems: Ve... |
#[doc = "Register `CR` reader"]
pub type R = crate::R<CR_SPEC>;
#[doc = "Register `CR` writer"]
pub type W = crate::W<CR_SPEC>;
#[doc = "Field `SYNCOKIE` reader - SYNC event OK interrupt enable"]
pub type SYNCOKIE_R = crate::BitReader;
#[doc = "Field `SYNCOKIE` writer - SYNC event OK interrupt enable"]
pub type SYNCOKI... |
#![allow(dead_code)]
use crate::item::*;
use crate::colour::*;
use crate::image_data::ImageData;
use crate::geometry::{Geometry, BasicGeometry, BasicFnGeometry, GeometryDamageFlags};
use crate::resources::GraphicResourceManager;
use crate::texture_resource::{get_texture_resource, TextureHandle};
use crate::font_resourc... |
use hydroflow::util::collect_ready;
use hydroflow_macro::hydroflow_syntax;
use multiplatform_test::multiplatform_test;
#[multiplatform_test]
pub fn test_lattice_join_fused_join_reducing_behavior() {
// lattice_fold has the following particular initialization behavior. It uses LatticeFrom to convert the first eleme... |
#[doc = "Register `SR` reader"]
pub type R = crate::R<SR_SPEC>;
#[doc = "Field `TAMP1F` reader - TAMP1F"]
pub type TAMP1F_R = crate::BitReader;
#[doc = "Field `TAMP2F` reader - TAMP2F"]
pub type TAMP2F_R = crate::BitReader;
#[doc = "Field `TAMP3F` reader - TAMP3F"]
pub type TAMP3F_R = crate::BitReader;
#[doc = "Field `... |
use crate::common::Solution;
use std::{
collections::{hash_map::DefaultHasher, HashSet, VecDeque},
hash::{Hash, Hasher},
};
#[derive(Clone)]
struct Combat {
player1: VecDeque<u8>,
player2: VecDeque<u8>,
seen_states: HashSet<u64>,
}
impl Combat {
fn new(p1: VecDeque<u8>, p2: VecDeque<u8>) -> Co... |
use predicates::prelude::Predicate;
use predicates::prelude::predicate::path::exists;
use short::BIN_NAME;
use test_utils::init;
use test_utils::{HOME_DIR};
mod test_utils;
#[test]
fn check_update() {
let e = init("cmd_env_dir");
e.setup();
let mut command = e.command(BIN_NAME).unwrap();
let _r = c... |
#![cfg(feature = "unstable-testing")]
include!(concat!(env!("OUT_DIR"), "/skeptic-tests.rs"));
|
pub mod postgras;
pub mod sqlite;
|
//use super::*;
use crate::errors::*;
use std::collections::HashMap;
use std::fmt;
use util::Error;
const NAME_LEN: usize = 255;
// A Name is a non-encoded domain name. It is used instead of strings to avoid
// allocations.
#[derive(Default, PartialEq, Debug, Clone)]
pub struct Name {
pub data: String,
}
// St... |
#[macro_use]
extern crate log;
extern crate pretty_env_logger;
extern crate config;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate hyper;
extern crate futures;
extern crate tokio_core;
extern crate num_cpus;
extern crate net2;
extern crate ipc_channel;
use std::thread;
use std::net::Socket... |
use std::io::Write;
fn main() {
let mut m = walrus::Module::from_file(
std::env::args()
.nth(1)
.expect("must provide the input wasm file as the first argument"),
)
.expect("invalid wasm");
let mut fix = |name| {
m.exports.add(name, m.funcs.by_name(name).unwrap(... |
// The MIT License (MIT)
//
// Copyright (c) 2015 Johan Johansson
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use,... |
use util::*;
parseable_struct! {
Password = "{}-{} {}: {}" {
from: usize = "[0-9]+",
to: usize = "[0-9]+",
character: char = "[a-z]",
pass: String = "[a-z]+",
}
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let input = input::lines::<Password>(&std::env::args().nt... |
use super::{ByBlocks, ByBlocksIter, Deadline};
use rayon::prelude::*;
use std::time::Duration;
// this is not meant as a new trait.
// this method should go inside IndexedParallelIterator
pub trait BlockedParallelIterator: IndexedParallelIterator {
fn by_blocks<S: Iterator<Item = usize>>(self, sizes: S) -> ByBlock... |
use std::fs::File;
use serde_derive::Deserialize;
use std::io::prelude::*;
/// 配置对象
#[derive(Debug, Deserialize)]
pub struct Config {
pub title: String,
// 数据库配置
pub database: Database
}
/// 数据库配置信息
#[derive(Debug, Deserialize)]
pub struct Database {
// 数据库类型
pub db_type: String,
// 服务器地址
... |
// Copyright (C) 2017 1aim GmbH
//
// 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 wr... |
//! This module contains transport definitions for the sources and destinations implemented in ConnectorX.
#[cfg(all(feature = "src_bigquery", feature = "dst_arrow"))]
mod bigquery_arrow;
#[cfg(all(feature = "src_bigquery", feature = "dst_arrow2"))]
mod bigquery_arrow2;
#[cfg(all(feature = "src_csv", feature = "dst_ar... |
pub use crate::clients::{AsPopReceiptClient, AsQueueClient};
pub use crate::{
AsQueueServiceClient, MessageTTL, NumberOfMessages, PopReceipt, QueueClient,
QueueServiceClient, QueueStoredAccessPolicy, VisibilityTimeout,
};
|
use std::io::Error;
use std::fs::File;
use std::io::prelude::*;
fn main() {
match read_input("input.txt") {
Ok(input) => println!("Part 1 answer: {}", part1(&input).step),
Err(e) => println!("Error: {}", e),
}
match read_input("input.txt") {
Ok(input) => println!("Part 2 answer: {}", part2(&input).st... |
extern crate blake2;
extern crate crypto_mac;
extern crate ed25519_dalek;
extern crate generic_array;
extern crate rand;
extern crate time;
use blake2::{Blake2s, Blake2b, Digest}; // Blake2bs == 32 bytes ... Blake2b == 64 bytes
use crypto_mac::MacResult;
use ed25519_dalek::Keypair;
use ed25519_dalek::Signature;
use ge... |
#![ cfg( feature = "tokio_io" ) ]
wasm_bindgen_test_configure!(run_in_browser);
// What's tested:
//
// Tests send to an echo server which just bounces back all data.
//
// ✔ Frame with a BytesCodec and verify that a round trip returns identical data
// ✔ Send 1MB data in a custom struct serialized with cbor_codec
/... |
struct FillMeIn;
#[derive(Debug)]
struct Vec3 { x: i32, y: i32, z: i32 }
fn vec_eq(v1: &Vec3, v1: &Vec3) -> bool {
v1.x == v2.x &&
v1.y == v2.y &&
v1.z == v2.z
}
// The dot product of two vectors is simply the sum of each index multiplied.
// Ex. (1 2 3) dot (4 5 6) = (1 * 4) + (2 * 5) + (3 * 6)
fn vec... |
#[doc = "Register `HLCR` reader"]
pub type R = crate::R<HLCR_SPEC>;
#[doc = "Register `HLCR` writer"]
pub type W = crate::W<HLCR_SPEC>;
#[doc = "Field `LM` reader - Latency mode"]
pub type LM_R = crate::BitReader<LM_A>;
#[doc = "Latency mode\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum L... |
// functions - used to store blocks of code for re-use
pub fn run(){
greeting("Hello", "James");
// bind function values to variables
let get_sum = add(3, 3);
println!("Sum: {}", get_sum);
// Closure
let num3: i32 = 10;
let add_nums = |num1: i32, num2: i32| num1 + num2 + num3;
println... |
extern crate winapi;
extern crate advapi32;
mod util;
pub mod service;
use winapi::winsvc;
use winapi::{DWORD, LPWSTR};
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn can_register_new_service() {
unsafe extern "system" fn testfunc(argc: u32, argv: *mut *mut u16) {
loop {
... |
use clap::crate_version;
use clap::{App, Arg};
use serde::Deserialize;
use std::env;
use std::fs;
use std::path::Path;
static ARG_CONFIG: &str = "config";
static ARG_LOCATION_PROJECTS: &str = "location-projects";
static ARG_LOCATION_BIN: &str = "location-bin";
static ARG_LOCATION_LOG: &str = "location-log";
static ARG... |
extern crate sdl2;
mod phi;
mod views;
fn main() {
::phi::spawn("ArcadeRS Shooter", |_| {
Box::new(::views::ViewA)
});
}
|
//! Module for the [`Hydroflow`] struct and helper items.
use std::any::Any;
use std::borrow::Cow;
use std::cell::Cell;
use std::collections::VecDeque;
use std::future::Future;
use std::marker::PhantomData;
use hydroflow_lang::diagnostic::{Diagnostic, SerdeSpan};
use hydroflow_lang::graph::HydroflowGraph;
use instant... |
#![recursion_limit = "1024"]
#[macro_use]
extern crate error_chain;
extern crate lemurdb;
use lemurdb::{Schema, DataType};
use lemurdb::executor::DbIterator;
use lemurdb::executor::io::CsvSource;
use lemurdb::executor::simplesort::SortOrder;
use lemurdb::executor::aggregate::{AggregateType};
mod error {
use lemu... |
#[doc = "Reader of register DDRPHYC_MR3"]
pub type R = crate::R<u8, super::DDRPHYC_MR3>;
#[doc = "Writer for register DDRPHYC_MR3"]
pub type W = crate::W<u8, super::DDRPHYC_MR3>;
#[doc = "Register DDRPHYC_MR3 `reset()`'s with value 0"]
impl crate::ResetValue for super::DDRPHYC_MR3 {
type Type = u8;
#[inline(alw... |
// Comparison - equality and ordering
use super::u512;
// Equality
impl std::cmp::PartialEq for u512 {
fn eq(&self, other: &u512) -> bool {
return self.data == other.data;
}
}
impl std::cmp::Eq for u512 {}
// Ordering
impl Ord for u512 {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
... |
// Copyright 2019 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 agree... |
#[derive(Debug)]
struct Rectangle {
width: u32,
height: u32
}
impl Rectangle {
fn area(&self) -> u32 {
self.width * self.height
}
fn can_hold(&self, other: &Rectangle) -> bool {
self.width > other.width && self.height > other.height
}
fn square(size: u32) -> Rectangle {
Rectangle { width: size, height: ... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu};
pub mod database_accounts {
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu};
pub ... |
// This file is part of dpdk. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/dpdk/master/COPYRIGHT. No part of dpdk, including this file, may be copied, modified, propagated, or distributed except accordin... |
use std::collections::HashSet;
use svm_types::{Address, SectionKind, Template, TemplateAddr};
use crate::env::{ExtAccount, TemplateHash};
/// A persistent store for [`Template`](svm_types::Template)s.
pub trait TemplateStore {
/// Stores a [`Template`].
///
/// parameters:
///
/// `template` - St... |
use cirrus_peer::errors::Result;
use cirrus_peer::MessagePacket;
pub trait Message: Sized {
fn command() -> &'static [u8];
fn packet(&self) -> MessagePacket;
fn from_payload(payload: &[u8]) -> Result<Self>;
}
|
use rocket::Rocket;
use rocket::config::Environment;
use rocket_contrib::serve::StaticFiles;
use rocket_contrib::templates::Template;
use crate::web::db::init_pool;
use logging::RequestLogger;
pub mod auth;
pub mod context;
pub mod db;
pub mod models;
pub mod oauth;
pub mod routes;
pub mod schema;
mod logging;
lazy... |
mod math;
mod vec2;
mod vec3;
mod quat;
|
extern crate actix_web;
extern crate getopts;
use std::env;
use std::process;
use actix_web::{http, server, App};
use getopts::Options;
use sua;
struct Config {
port: u16,
}
impl Config {
fn new(port: u16) -> Config {
Config{port}
}
}
fn parse_options() -> Config {
let args: Vec<String> = ... |
/*
* 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
*/
/// UsageFargateHour : Number of Fargate tasks run and hourly usage.
#[derive(Clone, Debug, PartialEq... |
use futures::sink::SinkExt;
use tokio::net::UnixStream;
use tokio_util::codec::{Framed, LinesCodec};
use persist_core::error::Error;
use persist_core::protocol::{Response, VersionResponse};
pub async fn handle(conn: &mut Framed<UnixStream, LinesCodec>) -> Result<(), Error> {
let version = env!("CARGO_PKG_VERSION"... |
// AppendEntriesRequest is the command used to add entries to the log.
pub struct AppendEntriesRequest {
// Current term and leader.
term: u64,
leader: u64, // may want a string
// Provide the previous entries for integrity checking.
prev_log_index: u64,
prev_log_term: u64,
// New entries ... |
//! Bindings to libkmod to manage linux kernel modules.
//!
//! # Example
//! ```
//! fn main() -> Result<(), Box<dyn std::error::Error>>{
//! // create a new kmod context
//! let ctx = kmod::Context::new()?;
//!
//! // get a kmod_list of all loaded modules
//! for module in ctx.modules_loaded()? {
//! ... |
/*!
This crate provides a `parse` function to convert English time expressions into a pair
of timestamps representing a time range. It converts "today" into the first and last
moments of today, "May 6, 1968" into the first and last moments of that day, "last year"
into the first and last moments of that year, and so o... |
use std::collections::VecDeque;
use super::{MercuryFuture, MercuryManager, MercuryResponse};
use crate::Error;
pub struct MercurySender {
mercury: MercuryManager,
uri: String,
pending: VecDeque<MercuryFuture<MercuryResponse>>,
buffered_future: Option<MercuryFuture<MercuryResponse>>,
}
impl MercurySe... |
use std::fmt::Display;
use aes_gcm_siv::Aes256GcmSiv; // Or `Aes128GcmSiv`
use aes_gcm_siv::aead::{Aead, NewAead, generic_array::GenericArray};
use num::Num;
use rand_core::OsRng;
use rsa::{BigUint, PaddingScheme, PublicKey, PublicKeyParts, RSAPrivateKey, RSAPublicKey, errors::Error};
use serde::{Serialize, Deserializ... |
use serde_derive::{Serialize,Deserialize};
use serde_json::to_writer;
use std::collections::HashMap;
use nix::sys::{ptrace,wait};
use std::fs::File;
use std::io::{BufReader,BufRead,Write,Read};
use crate::debugger::Debugger;
use crate::misc::{regs_to_dict,dict_to_regs};
use crate::breakpoint::breakpoint;
#[derive(P... |
use axum::{response::Json, routing::get, Router};
#[tokio::main]
async fn main() {
let app = Router::new().route("/", get(handler));
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
.serve(app.into_make_service())
.await
.unwrap();
}
async fn handler() -> Json<JsonAPI> {
let c... |
extern crate netstats;
use std::env::args_os;
fn main() {
if let Some(file_name) = args_os().nth(1) {
println!("going to read file: {:?}", file_name);
match netstats::analyze_file(file_name.to_str().unwrap()) {
Ok(report) => println!("Report:\n{:?}", report),
Err(err) => ep... |
pub mod lsb_png_steganography;
|
#[allow(dead_code)]
pub fn run(){
let a:i32 = 99;
let b:bool = true;
let c:char = 'c';
println!("hello {} , {} , {}",a,b,c);
//The type for Binary Hex and Octo
println!("Binary: {:b} ,Hex: {:x} , Octo:{:0}",10,10,10);
//Debug trait is used to print entire array etc
//Here we will print... |
use core::fmt;
use core::str;
use x86_64::instructions::port::Port;
use ::mem::malloc;
#[allow(non_camel_case_types)]
type ACPI_SIZE = usize;
#[allow(non_camel_case_types)]
type ACPI_PHYSICAL_ADDRESS = usize;
#[allow(non_camel_case_types)]
type ACPI_STATUS = u32;
#[allow(non_camel_case_types)]
type VOID_PTR = usize;
#... |
#[doc = "Register `BCR1` reader"]
pub type R = crate::R<BCR1_SPEC>;
#[doc = "Register `BCR1` writer"]
pub type W = crate::W<BCR1_SPEC>;
#[doc = "Field `MBKEN` reader - Memory bank enable bit Enables the memory bank. After reset Bank1 is enabled, all others are disabled. Accessing a disabled bank causes an ERROR on AHB ... |
use crate::utils::span_lint_and_help;
use rustc_hir as hir;
use rustc_lint::LateContext;
use super::SUSPICIOUS_MAP;
pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>) {
span_lint_and_help(
cx,
SUSPICIOUS_MAP,
expr.span,
"this call to `map()` won't have an effect on the... |
extern crate serde;
use std::collections::HashSet;
use std::process::exit;
mod catalogs;
mod file_info;
mod fs_reader;
mod pkg_reader;
mod settings;
use file_info::FileInfo;
use fs_reader::FsReader;
use pkg_reader::PkgReader;
use settings::Settings;
fn main() {
let settings = Settings::new();
if let Err(e) ... |
use crate::command_prelude::*;
use cargo::ops;
pub fn cli() -> App {
subcommand("yank")
.about("Remove a pushed crate from the index")
.arg(opt("quiet", "No output printed to stdout").short("q"))
.arg(Arg::with_name("crate"))
.arg(
opt("vers", "The version to yank or un... |
pub mod attack_system;
pub mod death_system;
pub mod decay_system;
pub mod dropoff_intent_system;
pub mod energy_system;
pub mod log_intent_system;
pub mod log_system;
pub mod mine_intent_system;
pub mod mineral_system;
pub mod move_intent_system;
pub mod path_cache_intent_system;
pub mod positions_system;
pub mod say_... |
use std::io::prelude::*;
use std::net::TcpListener;
use std::net::TcpStream;
use std::sync::mpsc;
use std::sync::Arc;
use std::sync::Mutex;
use std::thread;
use serde::Serialize;
use log::{debug, info};
pub struct ThreadPool {
workers: Vec<Worker>,
sender: mpsc::Sender<Message>,
}
type Job = Box<dyn FnOnce()... |
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
use crate::abstract_value;
use crate::abstract_value::AbstractValue;
use crate::abstract_value::AbstractValueTrait;
use crate::expression:... |
use callbacks::Callbacks;
fn main() {
let mut listeners = Callbacks::new();
listeners += |(a, b, c): &(i32, i32, i32)|
println!("Listener 1 received message: ({}, {}, {})", a, b, c);
listeners += |msg: &(i32, i32, i32)|
println!("Listener 2 received message: {:?}", msg);
listeners += |(a, b, c): &(i32, ... |
// Licensed under either of Apache License, Version 2.0 or MIT license at your option.
// Copyright 2021 Hwakyeom Kim(=just-do-halee)
#[macro_export]
macro_rules! optionee {
(@transform (>))
=> {
$crate::private::Ordering::Greater
};
(@transform (<))
=> {
$crate::private::Ordering::... |
/*
* Copyright (c) 2013, David Renshaw (dwrenshaw@gmail.com)
*
* See the LICENSE file in the capnproto-rust root directory.
*/
#[link(name = "capnproto-rust-test", vers = "alpha", author = "dwrensha")];
#[crate_type = "bin"];
extern mod capnprust;
use capnprust::*;
pub mod addressbook_capnp;
fn writeAddressBo... |
fn get_count(string: &str) -> usize {
string.chars().filter(|c| (['a', 'e', 'i', 'o', 'u']).contains(c)).count()
}
#[test]
fn test0() {
assert_eq!(get_count("abracadabra"), 5);
}
#[test]
fn test1() {
assert_eq!(get_count("a"), 1);
}
#[test]
fn test2() {
assert_eq!(get_count("aeiou"), 5);
}
#[test]
fn test3(... |
use authentication::auth11::Auth11;
use authentication::auth13::Auth13;
use config::Config;
use http_headers::*;
use hyper::Client as HyperClient;
use hyper::header::{qitem, Accept, ContentLength, ContentType};
use hyper::{Method, Request};
use hyper::mime::APPLICATION_JSON;
use hyper_openssl::HttpsConnector;
use tok... |
#[cfg(test)]
mod tests;
mod filter;
mod parse_error;
mod parser;
use filter::Filter;
use parse_error::ParseError;
// parser::Rule is generated by Pest but rust-analyzer shows it as an unresolved import
use parser::{Rule, ZeroConfParser};
use pest::Parser;
pub fn parse(filter: &str) -> Result<Filter, ParseError> {
... |
use std::collections::HashMap;
use source::Source;
use storage::StorageBackend;
use storage::error::{StorageError, StorageResult};
use storage::util::*;
use storage::record::StorageRecord;
use storage::fs::FsStorage;
pub struct StoragePool {
units: HashMap<DeviceId, FsStorage>,
master: Option<DeviceId>
}
impl... |
use crate::{
dump,
common::{
AdnlHandshake, AdnlStream, AdnlStreamCrypto, deserialize, KeyId,
KeyOption, KeyOptionJson, Query, serialize_inplace, Subscriber, TARGET, Timeouts
}
};
use std::{
net::SocketAddr, sync::Arc
};
use stream_cancel::StreamExt;
use futures::prelude::*;
use ton_ap... |
//! The `dealer` module contains the API for the dealer state while the dealer is
//! engaging in an aggregated multiparty computation protocol.
//!
//! For more explanation of how the `dealer`, `party`, and `messages` modules orchestrate the protocol execution, see
//! [the API for the aggregated multiparty computatio... |
pub fn count_range_sum(nums: Vec<i32>, lower: i32, upper: i32) -> i32 {
use std::collections::*;
use std::ops::Bound::Included;
let mut cumsums = BTreeMap::new();
let mut cumsum = 0;
let mut count = 0;
let lower = lower as i64;
let upper = upper as i64;
cumsums.insert(cumsum, 1);
fo... |
use anyhow::Result;
use futures::executor::ThreadPool;
use futures::task::SpawnExt;
use std::sync::Arc;
use crate::geometry::Point;
use crate::gluon::repl::GluonRepl;
pub struct ReplWindow {
repl: GluonRepl,
line_input: String,
output: String,
}
impl ReplWindow {
pub const ID: &'static str = "rep... |
mod error;
mod wm;
#[doc(inline)]
pub use wm::*;
pub type X11RustAdapter<B> = X11Adapter<B, x11rb::rust_connection::RustConnection>;
#[cfg(feature = "wm-x11-xcb")]
pub type X11XcbAdapter<B> = X11Adapter<B, x11rb::xcb_ffi::XCBConnection>;
pub type X11RustAdapterError<B> = <X11RustAdapter<B> as super::bar::WmAdapter<B>... |
fn main() {
println!("Hello world!");
let x: i32 = 273942569;//默认不可变
//let mut x :i32 = 273942569 //这样就是可变变量
println!("The value of x is: {}", x);
// if
let x = 5;
if x == 5 {
println!("x is five!");
} else {
println!("x is not five :(");
};
let y = if x == 5 ... |
use std::fs;
use std::io;
fn calc_fft(input: &mut Vec<i8>, cycles: usize) -> isize {
let base_pattern = vec![0, 1, 0, -1];
for _ in 0..cycles {
for i in 0..input.len() - 1 {
input[i] = (input
.iter()
.enumerate()
.skip(i)
.map(... |
#[cfg(feature = "secp")]
pub mod secp;
|
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate hyper;
extern crate ratelimit;
extern crate getopts;
mod database; // TODO: "use database::Database"
mod musicbrainz;
use std::env;
use std::string::String;
use getopts::Options;
use std::process::exit;
use musicbrainz::MusicBrainz;
const ... |
macro_rules! read_bytes_le {
($Src:expr, $Type: ty, $Size:expr) => {{
let src = $Src;
assert!($Size <= std::mem::size_of::<$Type>());
assert!($Size <= src.len());
let mut data: $Type = 0;
unsafe {
std::ptr::copy_nonoverlapping(src.as_ptr(), &mut data as *mut $Ty... |
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*/
/// The module provides unsafe wrappers around two Windows API functions: `ReadFile` and `GetQueuedCompletionStatus`.
///
/// These wrappers aim to simplify and abstract the use of these functions, providing easier er... |
use vendored_sha3::{Digest, Sha3_256};
/// SHA3_256 alias Sha3_256 and implements crate::Hash.
pub type SHA3_256 = Sha3_256;
/// The blocksize of SHA3-256 and Keccak-256 in bytes.
pub const BLOCK_SIZE256: usize = 136;
/// The size of a SHA3-256 and Keccak-256 checksum in bytes.
pub const SIZE256: usize = 32;
impl cr... |
use chrono::{NaiveDateTime, Local};
use crate::schema::{users, roles};
use crate::models::role::Role;
use bcrypt::{hash, DEFAULT_COST};
use diesel::PgConnection;
use crate::errors::MyError;
#[derive(Debug, Serialize, Deserialize, Queryable, Insertable , Associations, PartialEq)]
#[belongs_to(Role)]
#[table_name = ... |
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::PathBuf;
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct DBConfig {
#[serde(default)]
pub path: PathBuf,
pub options: Option<HashMap<String, String>>,
}
|
use crate::{
ast_types::{
ast_base::AstBase,
boxed_val::BoxedValue,
},
primitive_values::primitive_base::PrimitiveValueBase,
utils::Ops,
};
use serde::Serialize;
use std::any::Any;
/* FUNCTION CALL */
#[derive(Clone, Serialize, Debug)]
pub struct FnCall {
pub token_type: Ops,
... |
use unicode_width::UnicodeWidthChar;
#[derive(Debug, Copy, Clone)]
pub struct Config {
pub filled: char,
pub empty: char,
pub arrow: Option<char>,
pub left_border: Option<char>,
pub right_border: Option<char>,
pub error: char,
pub bar_width: u16,
}
#[derive(Debug)]
pub struct ErrMsg(String... |
// El discurso de Zoe
//
// Copyright (C) 2016 GUL UC3M
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Th... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.