text stringlengths 8 4.13M |
|---|
use crate::engine::write::parse::Collection;
pub enum WriteResult {
Error(ERROR),
Success(SUCCESS)
}
pub struct SUCCESS{
pub collection:String
}
impl SUCCESS {
pub fn new(c:Collection) -> SUCCESS {
SUCCESS {
collection:c.cuid.clone()
}
}
}
pub struct ERROR{
pub co... |
//! This plugin implements the fetching of dynamic metadata from quay.io.
//!
//! The fetch process is all or nothing, i.e. it fails in these cases:
//! * a Release doesn't contain the manifestref in its metadata
//! * the dynamic metadata can't be fetched for a single manifestref
use crate as cincinnati;
use self::c... |
header! {
#[doc="`Server` header, defined in [RFC7231](http://tools.ietf.org/html/rfc7231#section-7.4.2)"]
#[doc=""]
#[doc="The `Server` header field contains information about the software"]
#[doc="used by the origin server to handle the request, which is often used"]
#[doc="by clients to help iden... |
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
pub mod playground;
|
use lazy_static::lazy_static;
use rand::{prelude::*, distributions::WeightedIndex};
// The parameters in this mod are just set arbitrarily.
// For now network partition is implicitly implemented (by dropping messages).
#[derive(Debug)]
pub enum Event {
/// Time tick (delta)
Tick(u64),
/// Fetches a rando... |
//
//! Copyright 2020 Alibaba Group Holding Limited.
//!
//! 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 ... |
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
// Reaching definition analysis with subsequent copy propagation.
//
// This analysis and transformation only propagates definitions, leaving dead assignments
// in the code. The subsequent livevar_analysis takes care of removing those... |
use std::{fs, path::Path};
/// Copy the `instance-uid` contained in one db to another. Ignore all errors.
pub fn copy_user_id(src: &Path, dst: &Path) {
if let Ok(user_id) = fs::read_to_string(src.join("instance-uid")) {
let _ = fs::write(dst.join("instance-uid"), &user_id);
}
}
|
use actix_web::web;
use crate::handlers::{on, off, setb};
pub fn url_config(cfg: &mut web::ServiceConfig) {
cfg.service(
web::resource("/setb/{val}").route(web::post().to(setb))
);
cfg.service(
web::resource("/on").route(web::post().to(on))
);
cfg.service(
web::resource("/of... |
use std::io::prelude::*;
use std::fs::File;
use std::env;
use std::path::Path;
fn main() {
let mut arguments: Vec<String> = env::args().collect();
arguments.remove(0);
let out_file = arguments.pop().unwrap();
let out_path = Path::new(&out_file);
let mut file_open = File::create(&out_path).unwrap();... |
pub mod analyze;
pub mod meta;
pub mod owner;
|
use std::error::Error;
use std::fmt;
#[derive(Debug)]
pub struct UpdateError(String);
impl Error for UpdateError {}
impl fmt::Display for UpdateError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "failed to update recorded IP: {}", self.0)
}
}
impl From<reqwest::Error> for Updat... |
use std::fmt;
use beef::lean::Cow;
use proc_macro2::{Span, TokenStream};
use quote::{quote_spanned, ToTokens, TokenStreamExt};
pub type Result<T> = std::result::Result<T, Error>;
pub struct Error(Cow<'static, str>);
#[derive(Debug)]
pub struct SpannedError {
message: Cow<'static, str>,
span: Span,
}
impl E... |
pub fn primes_up_to(n: u32) -> Vec<u32> {
let working_vec: Vec<u32> = (2..n+1).collect();
let mut count_vec: Vec<u32> = vec![0; (n-1) as usize];
let mut prime_vec: Vec<u32> = Vec::new();
let mut i: u32 = 0;
while i < n-1 && n >= 2 {
let prime = working_vec[i as usize];
if count... |
use super::*;
use bcs_ext::BCSCodec;
use starcoin_crypto::HashValue;
use starcoin_types::block::BlockHeader;
#[test]
fn test() {
let u = U256::from(1024);
let encoded = u.encode().unwrap();
let u_decoded = U256::decode(&encoded).unwrap();
assert_eq!(u, u_decoded);
let max_hash: HashValue = U256::ma... |
use bevy::prelude::*;
fn main() {
App::build()
.insert_resource(Msaa { samples: 4 })
.add_plugins(DefaultPlugins)
// .add_startup_system(bevy_editor_pls::setup_default_keybindings.system())
// .insert_resource(bevy_editor_pls::EditorSettings::automagic())
// .add_plugin(bevy... |
use std::fs::File;
use std::io::{BufReader, BufRead};
pub fn day1() -> i32 {
let mut res: i32 = 0;
let file = File::open("src/day1/input.txt").unwrap();
let buffer = BufReader::new(file);
for line in buffer.lines() {
let num: i32 = line.unwrap().parse().unwrap();
res += (num / 3) - ... |
pub mod qafetch;
pub mod qamongo;
pub mod qasu;
pub mod tkread;
pub mod qaparquet;
|
use std::error::Error;
use std::ffi::c_void;
use std::fmt::{Display, Formatter};
use std::os::raw::c_char;
use std::path::Path;
/// Statically known path to library.
#[cfg(target_os = "linux")]
pub fn lib_path() -> &'static Path {
Path::new("target/release/libimage_sl.so")
}
/// Statically known path to library.
... |
use tasks::CompileState;
use crate::{get_template_file, render_includes, Render};
pub struct IndexPage {
pub user: String,
}
impl IndexPage {
pub fn new(user: String) -> Self {
IndexPage { user }
}
}
impl Render for IndexPage {
fn render(&self, state: &CompileState) -> String {
let m... |
//use rm::linalg::Matrix;
use rm::prelude::*;
use tracking_sim::Hypothesis;
use tracking_sim::IsSimilar;
pub struct Track {
pub state : Matrix<f64>,
pub covar : Matrix<f64>,
pub time : f64,
pub hypotheses : Vec<Hypothesis>,
dim : usize,
pub id : i64,
pub lr : f64,
}
impl Track {
pub f... |
#![deny(deprecated)]
use pin_project::{project, project_ref, project_replace};
#[project]
#[project_ref]
#[project_replace]
fn main() {}
|
//! Implementations of MerkleTree(MT) and SortedMerkleTree(SMT).
//! Use at least 2 tx-node(hashes of transactions) to build a MT or SMT.
//!
//! MT and SMT use `mysha_256::SHA256` for internal hashing to compute the hash of transactions,
//! but it's ok to use other hash function to compute hashes as input of `creat... |
#![deny(missing_docs)]
//! This crate is made as a test of skills of some sort.
//! It Takes code inputs and returns numeric outputs for the most part.
use std::collections::HashMap;
use std::fs;
use std::io::stdin;
use std::iter::FromIterator;
use std::path::PathBuf;
use structopt::StructOpt;
// use std::mem::discrimi... |
/// make all names in a module absolute
use super::ast;
use super::loader;
use super::makro;
use super::name::Name;
use super::parser::{emit_error, emit_warn};
use std::collections::HashMap;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
static ABORT: AtomicBool = AtomicBool::new(false);
... |
use crate::{rand_f64, rand_in_range};
use std::{
fmt,
ops::{Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Neg, Sub},
};
#[derive(Copy, Clone, Debug)]
pub struct Vec3 {
v: [f64; 3],
}
impl Vec3 {
pub fn new(first: f64, second: f64, third: f64) -> Self {
Self {
v: ... |
#![feature(core_intrinsics)]
fn main() {
unsafe {
let _x: f32 = core::intrinsics::fsub_fast(f32::NAN, f32::NAN); //~ ERROR: `fsub_fast` intrinsic called with non-finite value as both parameters
}
}
|
// This file is part of Substrate.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.a... |
/*
* Copyright 2018-2020 TON DEV SOLUTIONS LTD.
*
* Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use
* this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS I... |
use crate::TokenType;
use crate::Lexer;
use crate::parser::expect_peek;
use crate::Result;
use crate::error::ParseError;
use crate::traits::ParseTrait;
use crate::traits::LexerTrait;
use crate::program::expression::Expression;
use crate::program::expression::Identifier;
/// Define
///
/// mod Sine {
/// t: INPU... |
#[macro_use]
extern crate nom;
#[derive(Debug)]
struct KvPair<'a> {
key : &'a [u8],
value : &'a [u8],
}
#[derive(Debug)]
struct OfPartitionHdr<'a> {
signature : u8,
length : u16,
name : &'a[u8]
}
#[derive(Debug)]
struct OfPartition<'a> {
header : OfPartitionHdr<'a>,
pairs : V... |
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
pub mod memory;
pub mod name;
pub mod network;
//======================================================================================================================
// Imports
//==============================================================... |
// Copyright 2018 Mozilla
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
// License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software... |
mod cli;
use serde_json::json;
use serde_json::Value;
use io::prelude::BufRead;
use std::fs;
use std::io;
use std::io::Seek;
use std::io::Write;
fn json_value_from_str(line: &str, key: &str) -> Value {
let empty_str = json!("");
let jv: Value = serde_json::from_str(line).unwrap();
match jv.get(&key) {
... |
pub mod font;
pub mod glyph;
pub mod load;
pub mod mapping;
pub mod sym;
pub mod sym_id;
pub mod types;
#[doc(inline)]
pub use font::*;
#[doc(inline)]
pub use glyph::*;
#[doc(inline)]
pub use load::*;
#[doc(inline)]
pub use mapping::*;
#[doc(inline)]
pub use sym::*;
#[doc(inline)]
pub use sym_id::*;
#[doc(inline)]
pub... |
//! Core suite of tests which should work on all supported macOS platforms.
//!
//! This suite is mainly intended to run in CI. See `tests/interactive.rs`
//! for notes on how to run the full test suite.
use keychain_services::*;
const TEST_MESSAGE: &[u8] = b"Embed confidential information in items that you store in ... |
use logicmap::{Brick, Card, Config, ExpResult, Statement};
use serde::{Deserialize, Serialize};
// Here we make the entity we want to test our logicmaps against
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Cat {
pub name: String,
pub hair_color: String,
}
// create match type
#[derive(Debug)]
pu... |
#[macro_export]
macro_rules! impl_tinyint_sql_op {
($enum_name:ident) => {
impl<DB> ToSql<TinyInt, DB> for $enum_name
where
DB: Backend,
i8: ToSql<TinyInt, DB>,
{
fn to_sql<W: Write>(&self, out: &mut Output<W, DB>) -> serialize::Result {
... |
use std::{fmt, io};
use crate::ast::Pos;
#[derive(Debug)]
pub enum Error {
IOError(io::Error),
DecompileError(String),
SyntaxError(String),
CompileError(String, Pos),
FunctionResolutionError(String, Pos),
PoolError(String),
FormatError(fmt::Error),
}
impl Error {
pub fn eof(hint: Stri... |
use aoc_runner_derive::{aoc, aoc_generator};
use std::cmp::Ordering;
#[aoc_generator(day9)]
fn parse_input_day9(input: &str) -> Vec<usize> {
input
.lines()
.map(|line| line.parse::<usize>().unwrap())
.collect::<Vec<_>>()
}
#[aoc(day9, part1)]
fn day9_part1(input: &[usize]) -> Option<usize>... |
use crate::{
benchmarks::{elapsed, now, BYTES_LEN as BENCHMARK_LEN},
MAX_DATAGRAM_SIZE, ONE_GB,
};
use anyhow::bail;
use dashmap::DashMap;
use log::{debug, error, info, warn};
use quiche::{
h3::{self, NameValue},
Connection, ConnectionId, Header, MAX_CONN_ID_LEN,
};
use ring::{
hmac::{self, Key, HMA... |
use std::cmp::Ordering::{Less, Equal, Greater};
pub use self::Token::*;
#[derive(PartialEq, Clone, Debug)]
pub enum Token<'a> {
LBracket,
RBracket,
LParen,
RParen,
Colon,
RightArrow,
Underscore,
At,
Equals,
Comma,
Type,
Alias,
Port,
Module,
Exposing,
... |
// This file is part of Substrate.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.a... |
#[doc = "Register `ISOINCONFIG` reader"]
pub struct R(crate::R<ISOINCONFIG_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<ISOINCONFIG_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<ISOINCONFIG_SPEC>> for R {
#[inline(always)]
fn f... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - SHRTIMER control register 0"]
pub ctl0: CTL0,
#[doc = "0x04 - SHRTIMER control register 1"]
pub ctl1: CTL1,
#[doc = "0x08 - SHRTIMER interrupt flag register"]
pub intf: INTF,
#[doc = "0x0c - SHRTIMER interrupt f... |
use std::{
env,
error::Error,
process::{self, Command},
};
fn main() -> Result<(), Box<Error>> {
if let Some(path) = env::args().nth(1) {
let mut c = Command::new("sudo");
c.args(&["setcap", "cap_sys_nice+ep", &path]);
eprintln!("$ {:?}", c);
let status = c.status()?;
... |
use std::sync::atomic::{AtomicUsize, Ordering};
use std::marker::PhantomData;
use handle::{HandleInner, Handle, IdHandle, ResizingHandle, BoundedHandle, Like};
use primitives::atomic_ext::AtomicExt;
use primitives::index_allocator::IndexAllocator;
use containers::storage::{Place, Storage};
use containers::scratch::Scr... |
/**
* [11] Container With Most Water
*
* Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the containe... |
//! obsahuje modely
//! pro přidávání nového modelu viz [dokumentace Diesel ORM](https://diesel.rs)
use rocket_contrib::databases::diesel;
use serde::{Serialize, Deserialize};
use diesel::Connection;
use std::env;
use crate::schema::*;
#[database("postgres_db")]
pub struct DbConn(diesel::SqliteConnection);
/// vrac... |
use rustix::process::nice;
#[cfg(not(target_os = "redox"))]
use rustix::process::{getpriority_process, setpriority_process};
// FreeBSD's [`nice`] doesn't return the old value.
//
// [`nice`]: https://man.freebsd.org/cgi/man.cgi?query=nice&sektion=3
#[cfg(not(target_os = "freebsd"))]
#[test]
fn test_priorities() {
... |
use std::ops::{Neg, Sub, Add, Mul, Div};
use ::sdl2::pixels::Color;
use ::rand::thread_rng;
use ::rand::Rng;
#[derive(Debug, PartialEq, Clone)]
pub struct Space {
pub planets: Vec<Planet>,
}
#[derive(Debug, PartialEq, Clone)]
pub struct Planet {
pub mass: f64,
pub position: Position,
pub last_position... |
#![deny(missing_docs)]
//! A simple key/value store in memory.
use std::collections::HashMap;
/// The `KvStore` stores string key/value pairs.
///
/// It uses `HashMap<String, String>` to store pairs only in memory.
#[derive(Default)]
pub struct KvStore {
map: HashMap<String, String>,
}
impl KvStore {
/// C... |
#![crate_name="tavern_client"]
#![allow(dead_code)]
extern crate time;
extern crate cgmath;
extern crate rand;
//#[macro_use]
//extern crate serde_derive;
#[macro_use]
extern crate aphid;
extern crate jam;
extern crate howl;
extern crate psyk;
extern crate tavern_core;
extern crate tavern_service;
pub mod app;
pub ... |
// This file is part of Substrate.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.a... |
use std::sync::Arc;
use lfr_base_db::{
impl_intern_key,
salsa,
};
use crate::db;
trait Intern
{
type ID;
fn intern(self, db: &dyn db::DefDatabase) -> Self::ID;
}
pub trait Lookup
{
type Data;
fn lookup(&self, db: &dyn db::DefDatabase) -> Self::Data;
}
macro_rules! impl_intern {
($id:ide... |
use crate::RootTemplate;
use actix::{Actor, Addr, AsyncContext, Context, Handler, Message, Recipient};
use actix_identity::Identity;
use actix_web::{http, web, HttpRequest, Responder};
use alcova::{
LiveHandler, LiveMessage, LiveSocketContext, LiveTemplate, LiveView, LiveViewContext,
};
use serde::{Deserialize, Ser... |
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
use crate::error::{Error, ErrorResponse};
impl From<Error> for http::Response<hyper::Body> {
fn from(err: Error) -> Self {
let body = ErrorResponse::new(err);
let bytes = serde_json::to_vec(&body).unwrap();
http::Response::new(hyper::Body::from(bytes))
}
}
|
use super::IResult;
use crate::ast::*;
use crate::parser::general::Input;
use nom::bytes::complete::tag;
use nom::character::complete::{anychar, multispace0};
use nom::combinator::map;
use nom::multi::many_till;
use nom::sequence::{preceded, terminated};
/// parses any {{ ... }} block. It could be a twig output expres... |
// TODO: possibly set sender here?
#[derive(Clone)]
pub struct Connection
{
pub ip: String,
pub port: String
}
impl Connection
{
pub fn new() -> Connection
{
Connection
{
ip: String::new(),
port: String::new()
}
}
} |
extern crate hex;
// CryptoPals Set 1 Challenge 5 - Implement repeating-key XOR
// https://cryptopals.com/sets/1/challenges/5
pub fn repeating_key_xor(plaintext: &str, key: &str) -> String {
let key_bytes: Vec<u8> = key.to_string().into_bytes();
let pt_bytes: Vec<u8> = plaintext.to_string().into_bytes();
let xored... |
//! The Node debugger module
mod analyser;
mod debugger;
mod process;
mod ws;
pub use self::debugger::ImplDebugger;
|
// #[macro_use]
pub mod base;
pub mod func;
pub mod path;
pub mod stack;
pub mod tactics;
use base::Tactic;
use stack::Stack;
fn main() {
func_let![
let _a = ((proj 2 3) (int 0) (int 1) (int 2));
let _t1 = ((const 3 Z) (int 0) (int 1) (int 2));
let _t2 = ((const 3 Z) (const 2 (int 0)) (cons... |
// If no features are used, there is an "unused mut" warning in `ALL_EXTENSIONS`
// BUG: ? For some reason this doesn't do anything if I try and function scope this
#![allow(unused_mut)]
use std::collections::HashMap;
use std::error::Error;
use crate::value::Value;
#[cfg(feature = "toml")]
mod toml;
#[cfg(feature =... |
pub mod bundle;
pub mod font;
pub mod plugin;
mod glyph_mapping;
pub(crate) mod renderer_tile_data;
pub(crate) mod renderer_vertex_data;
use self::{
renderer_tile_data::TerminalRendererTileData, renderer_vertex_data::TerminalRendererVertexData,
};
use crate::terminal::{Terminal, TerminalSize};
use bevy::{
pr... |
/*!
Selector matching
Select matching is performed on generic node types. Client-specific details
about the DOM are encapsulated in the `SelectHandler` type which the `SelectCtx`
uses to query various DOM and UA properties.
*/
use stylesheet::Stylesheet;
use computed::ComputedStyle;
use util::VoidPtrLike;
use wapcapl... |
use crate::{
db::{
load::{create_preserved_catalog, load_or_create_preserved_catalog},
DatabaseToCommit,
},
rules::ProvidedDatabaseRules,
ApplicationState, Db,
};
use data_types::{database_state::DatabaseStateCode, server_id::ServerId, DatabaseName};
use futures::{
future::{BoxFuture... |
use crate::{
mem::{Address, VAddr},
Architecture,
};
/// A physical or virtual page.
pub trait Page {
/// Page alignment.
const SHIFT: usize;
/// The size of a page in bytes.
const SIZE: usize;
/// The type of address used to address this `Page`.
///
/// If this is a physical page... |
use anyhow::Result;
use diesel::prelude::*;
use diesel::r2d2::{ConnectionManager, Pool};
use crate::database::schema::index_state;
use crate::database::schema::index_state::dsl::*;
use super::entity::IndexState;
#[derive(Clone)]
pub struct IndexStateRepository {
connection: Pool<ConnectionManager<SqliteConnectio... |
use codec::UserError;
use frame::Reason;
use proto::{self, WindowSize};
use bytes::{Bytes, IntoBuf};
use futures::{self, Poll, Async};
use http::{HeaderMap};
use std::fmt;
/// Send frames to a remote.
#[derive(Debug)]
pub struct SendStream<B: IntoBuf> {
inner: proto::StreamRef<B::Buf>,
}
/// Receive frames from... |
use std::{error, fmt, io, path::PathBuf};
/// The result type.
pub type Result<T> = std::result::Result<T, Error>;
/// A generic error.
#[derive(Debug)]
pub enum Error {
// From Oppai
OppaiReturns(OppaiError),
OppaiFails(&'static str),
/// Unknown mode returned from Oppai
OppaiUnknownMode(libc::c_... |
/*
* Copyright (C) 2020, The Android Open Source Project
*
* 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 app... |
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{
data_cache::{RemoteCache, TransactionDataCache, TransactionEffects},
runtime::VMRuntime,
};
use move_core_types::{
account_address::AccountAddress,
identifier::IdentStr,
language_storage::{ModuleId, Typ... |
use std::io;
use std::cmp::Ordering;
use rand::Rng;
fn main() {
println!("Guess the number!");
}
|
//! A module containing a virtio network driver.
//!
//! The module contains ...
use alloc::collections::VecDeque;
use alloc::rc::Rc;
use alloc::vec::Vec;
use core::cell::RefCell;
use core::cmp::Ordering;
use core::mem;
use core::result::Result;
use align_address::Align;
use pci_types::InterruptLine;
use smoltcp::phy... |
use crate::commands::{command_register, command_service};
use crate::message_handlers::lesser_cameras::handle_lesser_brand_messages;
use serenity::{
async_trait,
model::{application::interaction::*, gateway::Ready, id::GuildId, prelude::Message},
prelude::*,
};
use std::env;
use tracing::error;
pub struct ... |
use crate::prelude::{AgeDistribution10, Real};
///////////////////////////////////////////////////////////////////////////////
// Default param for COVID-19
///////////////////////////////////////////////////////////////////////////////
pub const PROB_ASYMPTOMATIC: Real = 0.42;
pub const PROB_SEVERE: Real = 0.18;
pu... |
use std::env;
use std::mem;
use std::old_io::File;
static FILE_HEADER_SIZE : usize = 4*4;
static PAGE_HEADER_SIZE : usize = 3;
static PAGE_USER_DATA : usize = 0;
static PAGE_LINKS : usize = 1;
static PAGE_BID_LINKS : usize = 2;
pub struct Graph {
data : Vec<u32>,
}
pub struct PageIter<'a> {
g : &'a Graph,
... |
use serde::{Deserialize, Serialize};
use thiserror::Error;
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct AdmissionRequest {
pub uid: String,
pub object: serde_json::Value,
pub namespace: String,
pub operation: String, //CREATE, UPDATE, DELETE, CONNECT
... |
use crate::opts::Command::Transpile;
use crate::opts::Opts;
use crate::transpile;
use anyhow::Error;
pub fn handle(opts: Opts) -> Result<(), Error> {
match opts.cmd {
Transpile { filename } => transpile::main(&filename),
}
}
|
use std::collections::HashMap;
use std::io::{self, BufRead};
type GuardId = u16;
#[derive(Default)]
struct GuardSchedule {
asleep_dur: u16, // in minutes
sleep_interval: Vec<(u8, u8)>, // [a, b) in minutes
}
fn main() {
// parse and order chronologically
let mut s: Vec<String> =
io::stdin()... |
// Copyright 2019. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclai... |
use std::ops::Deref;
use rocket_contrib::json::Json;
use validator::Validate;
use super::super::super::super::super::super::{errors::JsonResult, orm::Database};
use super::super::super::super::{
models::category::{Dao as CategoryDao, Item as Tag},
request::Administrator,
};
#[derive(Debug, Validate, Deserial... |
//
// Use this to allow ProtocolHandler enum
// to use case similar to other properties (specifically avoiding CamelCase,
// in favor of camelCase)
//
#![allow(non_camel_case_types)]
use super::API_CONFIGURATIONS;
use super::API_NAMESPACE;
use super::API_VERSION;
use k8s_openapi::api::core::v1::PodSpec;
use k8s_openap... |
use std::str::from_utf8;
use std::net::SocketAddr;
use http::Header;
use http::Protocol;
use http::Method;
use http::Connection;
pub mod http;
pub mod url;
pub mod html;
pub trait Handler {
fn handle(&self, &Request) -> Response;
}
pub trait Request {
fn peer_addr(&self) -> Option<SocketAddr>;
fn protocol(&self)... |
use crate::raw::{Config as RawConfig, Rules as RawRules};
use config_macro::env_config;
use http::types::params::{Params, Tags};
use serde::Deserialize;
use std::ops::{Deref, DerefMut};
use std::path::PathBuf;
use std::str::FromStr;
#[env_config]
#[derive(Deserialize, Debug, Clone)]
pub struct Config {
#[env(LOGDN... |
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ContentPack {
pub name: String,
pub dashboards: Vec<Dashboard>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Dashboard {
pub title: String,
pub description: String,
pub dashboard_widgets... |
use std::sync::Arc;
use druid::{
widget::{Controller, ControllerHost, Flex, Label, List, ListIter, Painter, Scroll, SizedBox,},
Color, Command, Data, Env, Event, RenderContext, Selector, Target, Widget, WidgetExt,
};
use crate::data::appdata::AppState;
use crate::data::family_data::Family;
use crate:... |
use crate::app::App;
use crate::info::{building, header_btns, make_table, make_tabs, trip, Details, Tab};
use crate::render::Renderable;
use ezgui::{
hotkey, Btn, Color, EventCtx, Key, Line, RewriteColor, Text, TextExt, TextSpan, Widget,
};
use geom::Duration;
use map_model::Map;
use maplit::btreeset;
use sim::{
... |
use rusty_engine::prelude::*;
const ANCHOR_SPOT: (f32, f32) = (0.0, -200.0);
fn main() {
let mut game = Game::new();
let mut race_car = game.add_actor("Race Car", ActorPreset::RacingCarGreen);
race_car.translation = Vec2::new(0.0, 0.0);
race_car.rotation = UP;
race_car.scale = 1.0;
race_car.l... |
// Copyright (c) 2022 PHPER Framework Team
// PHPER is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan
// PSL v2. You may obtain a copy of Mulan PSL v2 at:
// http://license.coscl.org.cn/MulanPSL2
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WIT... |
#![allow(unused_imports, dead_code, non_snake_case, unused_variables)]
#![feature(test)]
extern crate test;
use rand::seq::SliceRandom;
use rand::{thread_rng, Rng};
use test::Bencher;
use num::complex::Complex;
pub mod mul;
pub mod fft;
pub mod sorting;
// #[bench]
// fn merge_test(b: &mut Bencher) {
// b.iter(... |
pub mod hash;
mod merkle;
pub use merkle::{ MerkleTree, BatchMerkleProof };
pub type HashFunction = fn(&[u64], &mut [u64]); |
extern crate permutohedron;
use permutohedron::heap_recursive;
use permutohedron::control::Control;
type Domino = (usize, usize);
pub fn chain(dominoes: &Vec<Domino>) -> Option<Vec<Domino>> {
match dominoes.len() {
0 => Some(vec!()),
1 => {
match dominoes[0] {
(l, r) i... |
//! Create and map Rust to WebAssembly values.
use wasmer_runtime::Value;
use wasmer_runtime_core::types::Type;
#[allow(non_camel_case_types)]
#[repr(u32)]
#[derive(Clone)]
pub enum wasmer_value_tag {
WASM_I32,
WASM_I64,
WASM_F32,
WASM_F64,
}
#[repr(C)]
#[derive(Clone, Copy)]
#[allow(non_snake_case)]... |
use fltk::{app, button::Button,input, enums::{CallbackTrigger, Color, Key, Shortcut}, frame::Frame, group::{Pack, PackType}, prelude::*, window::{self, Window}};
use fltk_flex::{Flex, FlexType};
use std::{borrow::{Borrow, BorrowMut}, ops::{Deref}};
use std::env;
use std::fs;
#[derive(Debug, Copy, Clone)]
enum Message... |
use crate::bencoding::{BDict, BInt, BList, BString};
use rand::Rng;
use std::convert::TryInto;
#[derive(Clone, Debug)]
pub struct SingleFileMetaInfo {
info: SingleFileInfo,
announce: String,
pieces: Vec<u8>,
}
#[derive(Clone, Debug)]
struct SingleFileInfo {
name: String,
length: i64,
piece_le... |
use crate::{distribution::dist_index_from_genotype, genotype::Genotype};
use serde::Serialize;
#[derive(Debug, Eq, PartialEq, Hash, Copy, Clone, Serialize)]
pub enum FlowerType {
Rose,
Cosmo,
Lily,
Pansy,
Tulip,
Hyacinth,
Mum,
Windflower,
}
#[derive(Debug, Eq, PartialEq, Hash, Copy, Cl... |
use core::fmt;
use iota_streams_core_edsig::signature::ed25519;
use super::hdf::HDF;
/// Type of "absolute" links. For http it's the absolute URL.
pub trait HasLink: Sized + Default + Clone + Eq {
/// Type of "base" links. For http it's domain name.
type Base: Default + Clone;
/// Get base part of the l... |
#![allow(dead_code)]
#[derive(Debug)]
enum Person {
Engineer,
Scientist,
Height(f32),
Weight(f32),
Info { name: String, age: i32 },
}
enum Work {
Programmer,
Architect,
}
enum Condition {
Poor,
Rich,
}
enum Number {
Zero,
Three,
Two
}
enum Color {
Red = 0xff0000... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.