text stringlengths 8 4.13M |
|---|
use ckb_types::core::Capacity;
use serde::{Deserialize, Serialize};
/// shannons per kilobytes
#[derive(Clone, Copy, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct FeeRate(u64);
const KB: u64 = 1000;
impl FeeRate {
pub fn calculate(fee: Capacity, vbytes: usize) -> Self {
... |
use chrono::{DateTime, Local};
use configuration::EmailConfig;
use failure::Error;
use lettre::{
smtp::{authentication::Credentials, SmtpClient},
Transport,
};
use lettre_email::EmailBuilder;
use mime::TEXT_HTML;
use parser::ParsedDocument;
pub fn send(doc: ParsedDocument, config: EmailConfig) -> Result<(), Er... |
use gl::types::*;
use std::ffi::c_void;
pub type EBO = ElementBufferObject;
pub struct ElementBufferObject {
pub id: GLuint,
}
impl EBO {
pub fn bind(&self) {
unsafe { gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, self.id) }
}
pub fn unbind(&self) {
unsafe { gl::BindBuffer(gl::ELEMENT_ARRAY_... |
use super::*;
use hyper::header::HeaderValue;
enum ResponseHolder {
Resp(body::Sender),
Tx(ResponseResultSender),
}
thread_local! {
static REQ_ID_TO_TX: RefCell<HashMap<i32, ResponseHolder>> = RefCell::new(HashMap::new());
}
thread_local! {
static NEXT_REQ_ID: RefCell<i32> = RefCell::new(0);
}
lazy_th... |
// This file was generated
pub mod any;
pub mod cmp;
pub mod collections;
pub mod error;
pub mod ffi;
pub mod fmt;
pub mod fs;
pub mod iter;
pub mod net;
pub mod ops;
pub mod option;
pub mod os;
pub mod path;
pub mod primitive;
pub mod process;
pub mod rc;
pub mod result;
pub mod string;
pub mod sync;
pub mod task;
pu... |
extern crate glutin_window;
extern crate graphics;
extern crate opengl_graphics;
extern crate piston;
extern crate rand;
use glutin_window::GlutinWindow as Window;
use opengl_graphics::*;
use piston::event_loop::{EventSettings, Events};
use piston::input::{Button, Key, PressEvent, RenderArgs, RenderEvent, UpdateArgs, ... |
use libsyntax2::{
ast, AstNode,
TextRange, SyntaxNodeRef,
SyntaxKind::WHITESPACE,
algo::{find_leaf_at_offset, find_covering_node, ancestors},
};
pub fn extend_selection(file: &ast::File, range: TextRange) -> Option<TextRange> {
let syntax = file.syntax();
extend(syntax.as_ref(), range)
}
pub(c... |
use std::sync::Arc;
use std::sync::atomic::AtomicUsize;
use atomic::Ordering;
pub mod pwm;
pub trait AnalogOutput: Send {
fn set_value(&mut self, val: f32);
}
pub trait PwmOutput: AnalogOutput {
fn set_pulse_duty_cycle(&mut self, val: u32);
fn set_period(&mut self, val: u32);
}
pub struct TestPwm {
... |
#[macro_use] extern crate nickel;
extern crate hyper;
use nickel::{Nickel, HttpRouter, Request, Response, MiddlewareResult};
use hyper::header::{AccessControlAllowOrigin, AccessControlAllowHeaders};
fn enable_cors<'mw>(_req: &mut Request, mut res: Response<'mw>) -> MiddlewareResult<'mw> {
res.set(AccessControlAll... |
use crate::{
hex::coordinates::{
axial::AxialVector, cubic::CubicVector, direction::HexagonalDirection, HexagonalVector,
},
vector::Vector2ISize,
};
use std::{cmp::Ordering, fmt::Debug};
#[derive(Default, Debug)]
pub struct FieldOfView<V: HexagonalVector> {
center: V,
radius: usize,
arc... |
fn main() {
let a = read::<String>().parse::<i32>().unwrap();
let bc = read::<String>();
let b_c = bc.split(' ').map(|x| x.parse::<i32>().unwrap());
let mut sum = a;
for b in b_c {
sum += b;
}
let s = read::<String>();
println!("{} {}", sum, s);
}
pub fn read<T: std::str::FromSt... |
pub mod endpoint;
//pub mod file;
pub mod list;
pub mod num;
|
use super::helpers::auth::*;
use crate::models::user::*;
use crate::validation::Validate;
use actix_web::{cookie::Cookie, get, post, web, HttpResponse, Responder};
use time::Duration;
#[post("/register")]
/// User registration route
pub async fn register(
pool: web::Data<sqlx::PgPool>,
_: web::Data<r2d2::Pool<... |
//! Runtime is a wasm go runtime
#![deny(
missing_docs,
trivial_numeric_casts,
unstable_features,
unused_extern_crates,
unused_features
)]
#![warn(unused_import_braces, unused_parens)]
#![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
#![cfg_attr(
feature = "carg... |
// https://adventofcode.com/2017/day/24
use std::fs::File;
use std::collections::HashSet;
use std::io::{BufRead, BufReader};
use std::iter::FromIterator;
fn main() {
let f = BufReader::new(File::open("input.txt").expect("Opening input.txt failed"));
// Parse components
let mut components = Vec::new();
... |
#![feature(test)]
use dev_util::impl_benchmark;
impl_benchmark!(keccak, Keccak224);
impl_benchmark!(keccak, Keccak256);
impl_benchmark!(keccak, Keccak384);
impl_benchmark!(keccak, Keccak512);
|
pub const MAKEFILE: &[u8] = b"# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile ... |
mod utils;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use ffi::*;
use libc::size_t;
use libmdbx::{ObjectLength, WriteFlags};
use rand::{prelude::SliceRandom, SeedableRng};
use rand_xorshift::XorShiftRng;
use std::ptr;
use utils::*;
fn bench_get_rand(c: &mut Criterion) {
let n = 100u32... |
/*
* 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
*/
/// SyntheticsTriggerCiTestRunResult : Information about a single test run.
#[derive(Clone, Debug, Pa... |
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate jellyschema;
extern crate serde_yaml;
use std::str::FromStr;
use jellyschema::{
schema::Schema,
generator::generate_json_ui_schema
};
// this is a fuzz target that makes sure that we do not crash given arbitrary data
fuzz_target!(|data: &[u8]| ... |
use actix::*;
#[derive(Message)]
struct Ping;
#[derive(Default)]
struct SystemActor;
impl Actor for SystemActor {
type Context = Context<Self>;
}
impl actix::Supervised for SystemActor {}
impl SystemService for SystemActor {
fn service_started(&mut self, _ctx: &mut Context<Self>) {
println!("System ... |
mod error_message;
mod product;
mod source;
mod wishlist;
pub use self::error_message::ErrorMessage;
pub use self::product::Product;
pub use self::source::Source;
pub use self::wishlist::Wishlist;
|
// ===============================================================================
// Authors: AFRL/RQQA
// Organization: Air Force Research Laboratory, Aerospace Systems Directorate, Power and Control Division
//
// Copyright (c) 2017 Government of the United State of America, as represented by
// the Secretary of th... |
/*
* 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
*/
/// IpPrefixesWebhooks : Available prefix information for the Webhook endpoints.
#[derive(Clone, Debu... |
//! Utilities for cleaning strings.
use std::iter::FromIterator;
use std::borrow::Cow;
use unicode_normalization::*;
/// Normalize Unicode character representations in a string.
pub fn norm_unicode<'a>(s: &'a str) -> Cow<'a, str> {
if is_nfd_quick(s.chars()) == IsNormalized::Yes {
s.into()
} else {
... |
extern crate futures;
extern crate hyper;
extern crate serde_json;
extern crate stq_http;
extern crate tokio_core;
extern crate users_lib;
mod client_test;
|
#[doc = "Register `TR3` reader"]
pub type R = crate::R<TR3_SPEC>;
#[doc = "Register `TR3` writer"]
pub type W = crate::W<TR3_SPEC>;
#[doc = "Field `LT3` reader - LT3"]
pub type LT3_R = crate::FieldReader;
#[doc = "Field `LT3` writer - LT3"]
pub type LT3_W<'a, REG, const O: u8> = crate::FieldWriter<'a, REG, 8, O>;
#[doc... |
use super::{api::*, util::*};
use crate::{Error, PrefixContext};
/// Compile and use a procedural macro
#[poise::command(
prefix_command,
track_edits,
broadcast_typing,
explanation_fn = "procmacro_help"
)]
pub async fn procmacro(
ctx: PrefixContext<'_>,
flags: poise::KeyValueArgs,
macro_cod... |
//! Module contains sdl thread local static initialization
use sdl2::{self, Sdl};
use std::cell::RefCell;
thread_local! (pub static SDL_CONTEXT: RefCell<Sdl> = RefCell::new(
sdl2::init().expect("SDL init failed")));
|
use cao_lang::prelude::Value;
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
#[derive(Debug, Serialize, Clone, Copy, Deserialize)]
#[serde(rename_all = "camelCase")]
#[repr(u8)]
pub enum Resource {
Empty = 0,
Energy = 1,
}
impl Default for Resource {
fn default() -> Self {
Resourc... |
mod area_allowance;
mod max_distance;
mod shift_time;
mod tour_size;
|
use crate::MssqlProvider;
use std::{env::var, ffi::OsStr};
use storm::{provider::ProviderFactory, BoxFuture, Error, Result};
use tiberius::Config;
pub struct MssqlFactory(pub Config);
impl MssqlFactory {
pub fn from_env<K>(var_name: K) -> Result<Self>
where
K: AsRef<OsStr>,
{
Ok(Self(Confi... |
#[derive(PartialEq, Eq, Debug, Hash)]
pub struct BitMatrix {
rows: usize,
columns: usize,
data: Vec<bool>,
}
impl BitMatrix {
pub fn shape(data: Vec<bool>, rows: usize, columns: usize) -> BitMatrix {
if rows * columns != data.len() {
panic!(
"wrong size of data: {} v... |
use raylib::prelude::*;
pub use raylib::prelude::Vector3;
pub fn unsigned_angle_vector2(a: Vector2, b: Vector2) -> f32 {
let mut angle = a.angle_to(b).to_degrees().abs();
if angle > 180. { angle -= 180. }
angle
}
pub fn slerp(start: Vector2, end: Vector2, time: f32) -> Vector2 {
// https://en.wikipe... |
extern crate ipfs_api;
use ipfs_api::IpfsApi;
use std::path::Path;
fn main() {
let mut ipfs = IpfsApi::default();
let add_info = ipfs.add(&[Path::new("wireshark_capture/moloch.txt"),
Path::new("Cargo.toml")])
.expect("Error adding");
for info in add_info {... |
use boxcars::ParserBuilder;
macro_rules! run {
($test_name:ident, $replay:expr) => {
#[test]
fn $test_name() {
let data = include_bytes!($replay);
let parsed = ParserBuilder::new(&data[..])
.always_check_crc()
.must_parse_network_data()
... |
mod physical_disk;
pub use physical_disk::PhysicalDisk;
mod file;
pub use file::File;
pub type Error = nt_native::Error;
impl From<Error> for crate::Error {
fn from(err: Error) -> Self {
Self::Platform(err)
}
}
|
// Copyright © 2015, Peter Atashian
// Licensed under the MIT License <LICENSE.md>
#![feature(io, old_io, os, std_misc)]
extern crate "winapi" as w;
extern crate "kernel32-sys" as k32;
pub mod file;
use std::error::FromError;
use std::ffi::OsString;
use std::fmt::{self, Display, Formatter};
use std::ptr::{null, nul... |
pub mod cmark;
pub trait Generator {
fn generate(&self);
}
pub struct HTMLGenerator {
}
pub struct CopyGenerator {
}
pub trait Collector {
}
pub struct MDCollector {
}
pub struct DirCollector {
}
pub struct Watcher {
}
pub struct Router {
}
|
pub struct ZXSpecs {
// frequencies
pub freq_cpu: usize,
// first_pixel_read_clocks (contention start)
pub clocks_first_pixel: usize,
// row clocks
pub clocks_left_border: usize,
pub clocks_screen_row: usize,
pub clocks_right_border: usize,
pub clocks_retrace: usize,
pub clocks_l... |
//! For when you want to actually run the editor
use crate::{message::Message, pane_zone::PaneZone, theme::Theme, Field, Kind, ObjectStore};
use iced::{Element, Sandbox};
/// State of our actual editor.
pub struct AppState<K: Kind, C: ObjectStore<K>> {
/// Currently selected object
selected: Option<K::Key>,
... |
use view::{View, ViewWrapper};
use vec::Vec2;
/// Simple wrapper view that asks for all the space it can get.
pub struct FullView<T: View> {
view: T,
}
impl<T: View> FullView<T> {
/// Wraps the given view into a new FullView.
pub fn new(view: T) -> Self {
FullView { view: view }
}
}
impl<T: V... |
#[cfg(test)]
#[path = "../../../tests/unit/solver/mutation/decompose_search_test.rs"]
mod decompose_search_test;
use super::super::rand::prelude::SliceRandom;
use crate::algorithms::nsga2::Objective;
use crate::construction::heuristics::*;
use crate::solver::mutation::Mutation;
use crate::solver::population::{Greedy, ... |
use super::{use_hook, Hook};
use std::rc::Rc;
/// This hook is an alternative to [`use_state`]. It is used to handle component's state and is used
/// when complex actions needs to be performed on said state.
///
/// For lazy initialization, consider using [`use_reducer_with_init`] instead.
///
/// # Example
/// ```ru... |
use sdl2::ttf;
use sdl2::ttf::Sdl2TtfContext;
use std::collections::HashMap;
use std::marker::PhantomData;
pub struct Font {
context: Sdl2TtfContext,
}
impl Font {
pub fn new(context: Sdl2TtfContext) -> Font {
Font { context }
}
pub fn build(&self, path: &str, size: u16) -> Result<Text, Strin... |
use shred::{
Dispatcher, DispatcherBuilder, Read, ResourceId, RunningTime, System, SystemData, World, Write,
};
fn sleep_short() {
use std::{thread::sleep, time::Duration};
sleep(Duration::new(0, 1_000));
}
#[derive(Default)]
struct Res;
#[derive(Default)]
struct ResB;
#[cfg(feature = "shred-derive")]
#... |
use async_executor::Executor;
use log::*;
use std::net::SocketAddr;
use std::sync::{Arc, Weak};
use crate::net::error::{NetError, NetResult};
use crate::net::protocols::{ProtocolAddress, ProtocolPing};
use crate::net::sessions::Session;
use crate::net::{Acceptor, AcceptorPtr};
use crate::net::{ChannelPtr, P2p};
use cr... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use super::{models, API_VERSION};
#[non_exhaustive]
#[derive(Debug, thiserror :: Error)]
#[allow(non_camel_case_types)]
pub enum Error {
#[error(transparent)]
SecurityConnectors_List(#[from] secur... |
#[allow(unused_imports)]
use super::util::prelude::*;
use super::super::ImageData;
use super::util::{Pack, PackDepth};
use super::BlockMut;
use super::BlockRef;
use super::CanvasTexture;
block! {
[pub Drawing(constructor, pack)]
(local_drawing_texture): BlockMut<CanvasTexture>;
(drawed_texture): BlockMut<... |
use std::cell::RefCell;
use std::path::PathBuf;
use std::rc::Rc;
use anyhow::{Context, Result};
pub use error::CfgError;
pub use file::global_cfg_directory;
pub use file::load_local_cfg;
pub use file::FileCfg;
pub use global::GlobalCfg;
pub use local::LocalCfg;
pub use local::LocalSetupCfg;
pub use local::{ArrayVar, ... |
//! define the error enum for the result of regressions
use ndarray_linalg::error::LinalgError;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum RegressionError {
#[error("Inconsistent input: {0}")]
BadInput(String),
#[error("Invalid response data: {0}")]
InvalidY(String),
#[error("Linear al... |
extern crate proc_macro;
use proc_macro::TokenStream;
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use std::iter::FromIterator;
#[proc_macro_attribute]
pub fn type_code(args: TokenStream, input: TokenStream) -> TokenStream {
let args = syn::parse_macro_input!(args as syn::AttributeArgs);
le... |
use anyhow::*;
use ncollide3d::pipeline::CollisionObjectSlabHandle;
use std::{collections::HashMap, path::Path};
use crate::{
render::{
binding, model, state, texture,
traits::{Binding, DrawModel},
Layouts,
},
transform,
};
use legion::IntoQuery;
#[derive(Debug, PartialEq, Eq, Ha... |
pub mod amazon_aws;
pub mod http_bin;
pub mod if_config;
pub mod prelude;
use std::net::IpAddr;
use anyhow::Result;
use async_trait::async_trait;
use reqwest::Client;
pub use amazon_aws::AmazonAws;
pub use http_bin::HttpBin;
pub use if_config::IfConfig;
#[async_trait]
pub trait IpAddrClient {
fn get_url(&self) ... |
pub(crate) trait MakingString {
/// stringifies given data structure whether struct or enum.
fn stringify(&self) -> String;
}
|
use futures_util::stream::TryStreamExt;
use std::str;
use lazy_static::lazy_static;
use mongodb::{bson::doc, Client};
use regex::Regex;
use serde::{Deserialize, Serialize};
lazy_static! {
static ref RE: Regex = Regex::new(r"[^.a-zA-Z0-9-]").unwrap();
}
#[derive(Debug, PartialEq)]
pub enum Error {
Write(Stri... |
use crate::goodreads::*;
use crate::io::object::ThreadObjectWriter;
use crate::prelude::*;
use crate::util::logging::data_progress;
use serde::de::DeserializeOwned;
#[derive(clap::Subcommand, Debug)]
pub enum GRScan {
/// Scan GoodReads works.
Works(ScanInput),
/// Scan GoodReads books.
Books(ScanInput... |
#[doc = "Reader of register CONN_PARAM_ACC_WIN_WIDEN"]
pub type R = crate::R<u32, super::CONN_PARAM_ACC_WIN_WIDEN>;
#[doc = "Writer for register CONN_PARAM_ACC_WIN_WIDEN"]
pub type W = crate::W<u32, super::CONN_PARAM_ACC_WIN_WIDEN>;
#[doc = "Register CONN_PARAM_ACC_WIN_WIDEN `reset()`'s with value 0"]
impl crate::Reset... |
use crate::{
inspector::{
editors::{
Layout, PropertyEditorBuildContext, PropertyEditorDefinition, PropertyEditorInstance,
PropertyEditorMessageContext,
},
InspectorError,
},
message::{
FieldKind, MessageDirection, PropertyChanged, TextBoxMessage, UiMe... |
use std::io;
use std::io::prelude;
use std::io::BufRead;
fn main()
{
print_single_line("name ?");
let for_name = read_line_iter();
print_single_line("sur?:");
let sur = read_line_buffer();
print!("Hello {} {} ", for_name, sur);
}
fn print_single_line(text: &str)
{
println!("{}", text);
/... |
// Copyright © 2017, ACM@UIUC
//
// This file is part of the Groot Project.
//
// The Groot Project is open source software, released under the
// University of Illinois/NCSA Open Source License. You should have
// received a copy of this license in a file with the distribution.
extern crate iron;
use iron::prelu... |
use crate::Error;
use ark_std::rand::{CryptoRng, Rng, SeedableRng};
use ark_std::{
cfg_chunks,
fmt::{Debug, Formatter, Result as FmtResult},
marker::PhantomData,
vec,
vec::Vec,
};
#[cfg(feature = "parallel")]
use rayon::prelude::*;
use super::pedersen;
use crate::variable_length_crh::VariableLength... |
extern crate cpal;
use std::sync::Arc;
use std::sync::Mutex;
mod synth;
use synth::nodes::*;
fn main() {
//Setup cpal
let device = cpal::default_output_device().expect("Failed to get default output device");
let format = device.default_output_format().expect("Failed to get default output format");
l... |
#[doc = "Register `WCCR` reader"]
pub type R = crate::R<WCCR_SPEC>;
#[doc = "Register `WCCR` writer"]
pub type W = crate::W<WCCR_SPEC>;
#[doc = "Field `REFRESH` reader - REFRESH"]
pub type REFRESH_R = crate::FieldReader<u16>;
#[doc = "Field `REFRESH` writer - REFRESH"]
pub type REFRESH_W<'a, REG, const O: u8> = crate::... |
use critical_section::{set_impl, Impl, RawRestoreState};
use crate::interrupt;
use crate::register::primask;
struct SingleCoreCriticalSection;
set_impl!(SingleCoreCriticalSection);
unsafe impl Impl for SingleCoreCriticalSection {
unsafe fn acquire() -> RawRestoreState {
let was_active = primask::read().i... |
use core::{self, async, Async, Bytes, Pair, Sender};
use mio::{NonBlock, Token};
use mio::tcp::TcpListener;
use net::{Action, Stream};
use reactor::Notify;
use std::{fmt, mem};
// ## Implementation notes
//
// It's important that a listener is never dropped while in the Waiting
// state as the reactor may receive even... |
#![deny(rust_2018_idioms, unused, unused_crate_dependencies, unused_import_braces, unused_lifetimes, unused_qualifications, warnings)]
#![forbid(unsafe_code)]
use {
std::{
env,
io,
},
serenity::{
model::prelude::*,
prelude::*,
},
sqlx::PgPool,
};
pub mod config;
pub... |
pub mod chip8;
|
// ===============================================================================
// Authors: AFRL/RQQA
// Organization: Air Force Research Laboratory, Aerospace Systems Directorate, Power and Control Division
//
// Copyright (c) 2017 Government of the United State of America, as represented by
// the Secretary of th... |
// https://adventofcode.com/2017/day/4
use std::io::{BufRead, BufReader};
use std::fs::File;
fn main() {
let f = BufReader::new(File::open("input.txt").expect("Opening input.txt failed"));
let lines: Vec<String> = f.lines()
.map(|l| l.expect("Reading lines failed"))
.collect();
// First s... |
extern crate byteorder;
use byteorder::ReadBytesExt;
pub enum Context {
WorldReceive {
width: u32,
height: u32,
data: Option<Vec<u8>>,
player: Option<u32>,
},
PlayerReceive,
PlayerIdReceive,
MoveReceive,
}
pub struct Handler {
status: Option<u16>,
context: Option<Context>,
}
impl Handler {
pub fn ne... |
#[doc = "Reader of register SPINLOCK13"]
pub type R = crate::R<u32, super::SPINLOCK13>;
impl R {}
|
use super::SharableReceiver;
use std::net::{TcpListener, TcpStream};
use std::sync::{
mpsc::{self, Receiver, Sender, TryRecvError},
Arc,
};
use std::time::Duration;
const LISTENER_TIMEOUT_DUR: Duration = Duration::from_millis(15 * 1000);
pub struct Listener {
listener: Arc<TcpListener>,
tcp_sender: Sender<Tcp... |
//! # Jak czytać dokumentację API HTTP?
//!
//! Wszystkie funkcje które pełnią rolę endpointu mają w pierwszej linijce dokumentacji metodę i
//! adres endpointu. Aby dowiedzieć się co przyjmują należy zwrócić uwagę na argumenty funkcji.
//! Np. `Json<LoginData>` oznacza, że należy podać dane jako JSON zgodne z `LoginDa... |
pub fn is_leap_year(year: u64) -> bool {
let div_by = c_div_by(year);
match year {
_ if div_by(400) => true,
_ if div_by(100) => false,
_ if div_by(4) => true,
_ => false,
}
}
fn c_div_by(y: u64) -> impl Fn(u64) -> bool {
move |num| y % num == 0
}
|
use std::{fs::File, io::{BufRead, BufReader}, vec};
struct Password {
letter: char,
min_amount: u8,
max_amount: u8,
password: String,
}
fn main() {
let file = File::open("inputs/input-2.txt").unwrap();
let lines = BufReader::new(file).lines();
let mut passwords: Vec<Password> = vec![];
... |
#![allow(non_snake_case)]
extern crate glob;
extern crate cc;
extern crate bindgen;
use glob::glob;
use std::env;
use std::path::PathBuf;
fn main() {
let stark = glob("./libSTARK/libstark/src/**/*.cpp").unwrap().map(|e| e.unwrap()).into_iter();
let algebralib = glob("./libSTARK/algebra/algebralib/**/*.cp... |
// This file is part of rdma-core. 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/rdma-core/master/COPYRIGHT. No part of rdma-core, including this file, may be copied, modified, propagated, or distributed ... |
// std::cmp::PartialOrd;
use std::cmp::Ordering;
#[derive(Eq)]
struct Class {
size: u32,
section: u32,
grade: u32
}
// impl Eq for Class {}
impl PartialOrd for Class {
fn partial_cmp(&self, rhs: &Class) -> Option<Ordering> {
Some(self.cmp(rhs))
}
}
impl Ord for Class {
fn cmp(&self, ... |
// Copyright 2017 pdb Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://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 tho... |
use std::cmp::Ordering;
use std::io::{self, BufRead};
use std::{env, error, fmt, fs, path, result};
#[derive(fmt::Debug)]
struct Error {
message: String,
}
impl Error {
fn new(message: String) -> Error {
Error { message }
}
}
type Result<T> = result::Result<T, Error>;
impl fmt::Display for Error... |
//! an infrastructure library for 'cargo-pack'ers.
//! This crate provides only common features of `pack`ers, currently, files to package.
//! Currently, you can write these metadata in Cargo.toml:
//!
//! ```toml
//! [package.metadata.pack]
//! # Not used for now. Reserved for future use
//! default-packers = ["docker... |
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
use cuda::ffi::driver_types::{cudaStream_t};
include!(concat!(env!("OUT_DIR"), "/nccl_bind.rs"));
|
//! Entities related to and within guilds.
pub mod emoji;
pub mod member;
pub mod role;
pub use self::{
emoji::{EmojiEntity, EmojiRepository},
member::{MemberEntity, MemberRepository},
role::{RoleEntity, RoleRepository},
};
use super::{
channel::{GuildChannelEntity, TextChannelEntity, VoiceChannelEnt... |
extern crate rusty_machine;
use rusty_machine::linalg::{Matrix,Vector};
use rusty_machine::learning::gp::{GaussianProcess,ConstMean};
use rusty_machine::learning::toolkit::kernel;
use rusty_machine::learning::SupModel;
fn main() {
let inputs = Matrix::new(3,3,vec![1.1,1.2,1.3,2.1,2.2,2.3,3.1,3.2,3.3]);
let tar... |
use std::marker::PhantomData;
use std::ptr;
use std::sync::Arc;
#[derive(Debug)]
struct Node<T> {
data: T,
next: Option<Arc<Node<T>>>,
}
#[derive(Debug)]
pub struct ArcList<T> {
inner: Option<Arc<Node<T>>>,
}
impl<T> ArcList<T> {
pub fn new() -> Self {
Self { inner: None }
}
pub fn i... |
mod config;
mod db;
mod entities;
mod lang_cmd;
mod models;
mod repository;
mod task;
mod utils;
use anyhow::Result;
use bollard::API_DEFAULT_VERSION;
use config::ENV_CONFIG;
use core::time::Duration;
use futures::future::join_all;
use std::sync::Arc;
// TODO(magurotuna): ここの値も要検討
const JOB_THREADS: us... |
use serde::Deserialize;
use std::{
cmp,
convert::{TryFrom, TryInto},
time,
};
use crate::{core::MAX_CONNS, endpoints::State, verify, Error, Info, Random, Result};
pub(crate) const MAX_ELAPSED_WINDOW: usize = 32;
pub(crate) const MAX_ELAPSED: time::Duration = time::Duration::from_secs(3600 * 24);
macro_... |
extern crate clap;
mod shifumi;
use clap::{App, SubCommand};
use std::io::{self, Write};
fn main() {
let matches = App::new("shifumi")
.version("0.1.0")
.author("Edouard Paris")
.about("shifumi game written in Rust")
.subcommand(SubCommand::with_name("play").about("start a new game... |
//! PoT state management.
use crate::PotConfig;
use async_trait::async_trait;
use core::num::NonZeroUsize;
use parking_lot::Mutex;
use sc_network::PeerId;
use sp_consensus_subspace::digests::PotPreDigest;
use std::collections::btree_map::Entry;
use std::collections::{BTreeMap, VecDeque};
use std::sync::Arc;
use std::t... |
use libc::{c_int, off_t};
use mio::{Evented, Poll, Token, Ready, PollOpt};
use mio::unix::UnixReady;
use nix;
use nix::sys::aio;
use nix::sys::signal::SigevNotify;
use std::cell::RefCell;
use std::io;
use std::os::unix::io::AsRawFd;
use std::os::unix::io::RawFd;
use std::rc::Rc;
#[derive(Debug)]
pub struct AioCb<'a> ... |
extern crate exact_cover;
use exact_cover::{Problem, Solver};
fn main() {
const NUM_COLUMNS: usize = 7;
// This problem is equivalent to the problem in subsets.rs.
// However, we express it directly as the matrix. We want to find
// a subset of rows such that every column has exactly one 1.
let m... |
use serde::Serialize;
#[derive(Debug, Serialize)]
pub struct Domain(pub String);
#[derive(Debug, Serialize)]
pub struct DisplayName(pub String);
#[derive(Debug, Serialize)]
pub struct ShortName(pub String);
#[derive(Debug, Serialize)]
pub struct Hostname(pub String);
#[derive(Debug, Serialize)]
pub struct Port(pub... |
//! **Sh**ared **re**source **d**ispatcher
//!
//! This library allows to dispatch
//! systems, which can have interdependencies,
//! shared and exclusive resource access, in parallel.
//!
//! # Examples
//!
//! ```rust
//! extern crate shred;
//!
//! use shred::{DispatcherBuilder, Read, Resource, ResourceId, System, S... |
pub mod littleroot_town;
use super::Location;
use std::collections::HashMap;
pub fn all<'a>() -> HashMap<u16, Location<'a>> {
let mut cities: HashMap<u16, Location> = HashMap::new();
for (key, val) in littleroot_town::all().iter() {
cities.insert(key.clone(), val.clone());
}
cities
}
|
#[macro_use]
extern crate glium;
extern crate rusttype;
extern crate rand;
extern crate time;
#[macro_use]
extern crate more_asserts;
#[macro_use]
mod util;
mod math;
mod font;
mod manifold;
mod bsp;
use bsp::{BspNode, Face};
use manifold::Manifold;
use math::*;
use math::pose::Pose;
use glium::{DisplayBuild, Surfa... |
#![recursion_limit = "2048"]
use std::collections::HashMap;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use web_sys::SvggElement;
use yew::prelude::*;
extern crate console_error_panic_hook;
use anyhow::Error;
use std::panic;
use http::{Request, Response};
use yew::html::ComponentLink;
use yew::services::f... |
use crate::parse;
use crate::parse::{Code, LineNumber, Register, Span, Stmt, StmtIdx};
use std::io::Write;
use std::path::Path;
#[derive(Debug, Clone)]
struct Vm<'a> {
stmts: Vec<Stmt>,
span: Vec<Span>,
code_lines: Vec<&'a str>,
pc: StmtIdx,
registers: Vec<usize>,
breakpoints: Vec<StmtIdx>,
... |
use std::fmt;
use std::time::SystemTime;
pub struct ElapsedMetrics {
load:String,
resize:String,
save:String,
timer:SystemTime,
}
impl ElapsedMetrics {
pub fn new() -> ElapsedMetrics {
ElapsedMetrics {
load: String::new(),
resize: String::new(),
save: St... |
use sample_web_app::{init_db, users_api};
#[tokio::main]
async fn main() {
let database = init_db();
warp::serve(users_api(database))
.run(([127, 0, 0, 1], 3030))
.await;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.