text stringlengths 3.09k 13.9k |
|---|
use crypto_market_type::MarketType;
use crate::exchanges::utils::calc_quantity_and_volume;
use crate::Order;
use crate::{FundingRateMsg, MessageType, OrderBookMsg, TradeMsg, TradeSide};
use chrono::prelude::*;
use chrono::DateTime;
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use serde_json::{Re... |
use super::*;
pub struct JavaScript {}
impl JavaScript {
// Generate javascript code using tokens from parser
pub fn generate(lb: &mut LangBuilder, t: AnilizedTokens) -> Result<(), LocationError> {
let mut code = Self {};
// define functions
for (_, func) in t.functions {
code.function(func, lb... |
const VERSION: &str = env!("CARGO_PKG_VERSION");
use cargo_metadata::MetadataCommand;
use clap::{App, AppSettings, Arg, ArgMatches};
use semver::{Identifier, SemVerError, Version};
use std::path::PathBuf;
use std::str::FromStr;
pub fn get_config() -> Config {
let matches = build_cli_parser().get_matches();
Co... |
// Copyright (c) 2020 Velothi
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
use std::env;
use std::str;
#[rustfmt::skip]
/// Takes an integer and turns it into target base number.
/// Uses: [number: i64,
/// base_to: i64,
/// alphabet_a: Vec<&str>,
/// ... |
use std::borrow::Cow;
use std::cmp::Ordering;
use std::fmt::{self, Display};
use std::hash::{Hash, Hasher};
use proc_macro2::Term;
use unicode_xid::UnicodeXID;
use Span;
use tokens;
/// A word of Rust code, such as a keyword or variable name.
///
/// An identifier consists of at least one Unicode code point, the fir... |
//! Implementation of pseudocode from chapter 6 of <NAME>'s
//! [Computer Graphics from Scratch](https://gabrielgambetta.com/computer-graphics-from-scratch/)
//! book. I am not affiliated with Gabriel or his book in any way.
//!
//! This code implements the first sections of chapter 6 to draw lines.
use rust_computer_... |
use solana_program::{
borsh,
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
program_error::ProgramError,
msg,
pubkey::Pubkey,
program_pack::{Pack, IsInitialized},
sysvar::{rent::Rent, Sysvar},
program::{invoke, invoke_signed},
};
use ::borsh::{BorshSerial... |
//! An implementation of the eager version of Prim's algorithm which relies on using an indexed
//! priority queue data structure to query the next best edge.
//!
//! # Resources
//!
//! - [<NAME>'s video 1](https://www.youtube.com/watch?v=jsmMtJpPnhU&list=PLDV1Zeh2NRsDGO4--qE8yH72HFL1Km93P&index=30)
//! - [<NAME>'s vi... |
#[macro_use]
extern crate lazy_static;
extern crate rand;
//extern crate rand;
use seed::{*, prelude::*};
use rand::prelude::*;
struct Model {
pub out_val: f32,
pub in_curr: String,
pub out_curr: String,
pub in_val: String,
pub random_number: u32,
pub random_message: String,
pub trying:... |
use dcc_tiler::board::RectangularBoard;
use dcc_tiler::tile::{Tile, TileCollection};
use clap::{App, Arg};
use dcc_tiler::render::render_single_tiling_from_vec;
use std::io::Result;
use tiler::Tiler;
#[macro_use]
extern crate clap;
arg_enum! {
#[derive(Debug, Copy, Clone)]
pub enum BoardType {
Recta... |
/// The simple union-find algorithm
use std::fmt;
/// The union-find algorithm trait
pub trait UnionFind {
type K;
/// union the union by index of vector
/// param k1: key of one item in union
/// param k2: key of one item in union
fn union(&mut self, k1: Self::K, k2: Self::K);
/// find is th... |
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;
use serde::{Serialize, Deserialize};
use crate::err::Error;
use crate::helper;
use crate::env::GitCredentials;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Credentials {
Token(String, String),
Ssh(String),
Empty
}
impl Def... |
use super::*;
#[derive(Debug)]
pub enum Ctx<'a> {
Nil,
Snoc(&'a Ctx<'a>, RcType)
}
impl<'a> Ctx<'a> {
pub fn nil() -> Ctx<'a> { Ctx::Nil }
pub fn snoc(&'a self, ty: RcType) -> Ctx<'a> {
Ctx::Snoc (self, ty)
}
pub fn lookup(&self, idx: u32) -> Option<RcType> {
match &self {
... |
use crate::constants::{ALL_DBS, COUCHDB_PREFIX, DB_ALL_DOCS, DB_CHANGES, DB_STATS};
use crate::fdb;
use crate::fdb::unpack_with_prefix;
use crate::CouchError;
use crate::defs::{ChangeRow, Database, DbInfo, Id, Rev, Row};
use crate::util::bin_to_int;
use foundationdb::tuple::{unpack, Bytes, Element, Versionstamp};
use ... |
use std::collections::BTreeMap;
use std::collections::HashSet;
use std::env;
use std::fs;
use std::mem;
use std::path;
use std::time::Instant;
use crate::module::SoftwareModule;
use flatpak_rs::module::FlatpakModule;
pub const MODULES_DB_SUBDIR: &str = "/modules";
pub struct Database {
pub modules: Vec<SoftwareM... |
use super::{preservation_bucket::PreservationBucket, typedefs::PreservationBucketsMap};
use itertools::Itertools;
use std::{
io::{Error, Write},
ops::{Deref, DerefMut},
};
#[cfg(feature = "pyo3")]
use pyo3::prelude::*;
use crate::{
processing::aggregator::{typedefs::AggregatesCountMap, value_combination::... |
use std::fmt;
#[cfg(feature = "async")]
use std::task::Waker;
use bytes::{Buf, Bytes, BytesMut};
use memchr::memmem;
use crate::{
utils::{CRLF, CRLFS, DASHES},
Limits,
};
#[derive(Debug, PartialEq)]
pub(crate) enum Flag {
Delimiting(bool),
Heading(usize),
Headed,
Header,
Next,
Eof,
}... |
// For benchmark, run:
// RAYON_NUM_THREADS=N cargo bench --no-default-features --features "std parallel" -- --nocapture
// where N is the number of threads you want to use (N = 1 for single-thread).
use ark_bls12_381::{Bls12_381, Fr as BlsFr};
use ark_crypto_primitives::SNARK;
use ark_ff::{PrimeField, UniformRand... |
use std::path::{PathBuf, Path};
use std::fs;
use std::error::Error;
use std::fmt;
#[cfg(feature = "cache")]
use time::{self, Timespec};
#[cfg(feature = "cache")]
use std::time::Duration;
use iron::prelude::*;
use iron::{Handler, status};
#[cfg(feature = "cache")]
use iron::modifier::Modifier;
use iron::modifiers::Red... |
use std::str;
use std::time::Duration;
use indicatif::{ProgressBar, ProgressStyle};
use regex::Regex;
use tokio::sync::oneshot::{Receiver, Sender};
use tokio::time::{delay_for, Delay};
use cloudflare::endpoints::workers::{CreateTail, CreateTailParams, DeleteTail, SendTailHeartbeat};
use cloudflare::framework::HttpApi... |
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! Initializers for ICU data files.
//!
//! Use the library by instantiating a `Loader` and keeping a reference to it for as long as you
//! need access t... |
use std::env;
use std::fmt::{self, Display, Formatter};
use std::fs;
use std::io;
use std::path::PathBuf;
#[cfg(windows)]
use dirs;
use log::{error, warn};
use alacritty_terminal::config::{Config as TermConfig, LOG_TARGET_CONFIG};
mod bindings;
pub mod debug;
pub mod font;
pub mod monitor;
mod mouse;
pub mod ui_conf... |
use ansi_term::Colour::{Fixed, Green, Red};
use ansi_term::Style;
use difference::{Changeset, Difference};
use std::fmt;
macro_rules! paint {
($f:ident, $colour:expr, $fmt:expr, $($args:tt)*) => (
write!($f, "{}", $colour.paint(format!($fmt, $($args)*)))
)
}
const SIGN_RIGHT: char = '>'; // + > →
cons... |
use crate::Interval;
use nom::{branch::alt, bytes::complete::tag, combinator::map};
use std::{
cmp::Ordering,
fmt,
ops::{Add, Sub},
str::FromStr,
};
/// A musical note, represented as a single positive integer.
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
pub struct Note {
pub value: usize,
}
impl... |
use std::num::Wrapping as W;
struct TeaContext {
key0: u64,
key1: u64,
}
impl TeaContext {
pub fn new(key: &[u64; 2]) -> TeaContext {
TeaContext {
key0: key[0],
key1: key[1],
}
}
pub fn encrypt_block(&self, block: u64) -> u64 {
let (mut b0, mut b1) ... |
//! Configuration Handling.
//
// Copyright (c) 2018 Stegos AG
//
// 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, c... |
use std::rc::Rc;
use bounded_integer::bounded_integer;
use crate::memory::Cartridge;
#[cfg(feature = "minifb")]
pub mod backend;
mod loopy;
mod nametable;
mod oam;
mod palette;
pub mod pattern;
mod regs;
pub mod render;
pub use loopy::AddrReg;
use loopy::Time;
pub use nametable::Nametable;
pub use palette::{PaletteR... |
use std::collections::HashMap;
use std::env::var;
use std::path::{
Path, PathBuf,
};
use bindgen::{
callbacks::{EnumVariantValue, ParseCallbacks},
};
use once_cell::sync::Lazy;
#[derive(Debug, Copy, Clone)]
pub enum StripMode {
/// Strip N items at front, e.g N=1: FOO_BAR_ZOO => BAR_ZOO
StripFront(u8)... |
/*
Copyright 2021 JFrog Ltd
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 writi... |
//! Traits and helper for writing Egui apps.
//!
//! This module is very experimental, and you don't need to use it.
//!
//! Egui can be used as a library, but you can also use it as a framework to write apps in.
//! This module defined the `App` trait that can be implemented and used with the `egui_web` and `egui_gliu... |
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use crate::core::{Error, Method, PeriodType, ValueType, OHLCV};
use crate::core::{IndicatorConfig, IndicatorInstance, IndicatorResult};
use crate::methods::{Cross, HighestIndex, LowestIndex};
// https://www.fidelity.com/learning-center/trading-investing/t... |
extern crate nalgebra as na;
extern crate ncollide2d;
extern crate nphysics2d;
extern crate nphysics_testbed2d;
use na::{Isometry2, Point2, Vector2};
use ncollide2d::shape::{Ball, Cuboid, ShapeHandle};
use nphysics2d::{
joint::RevoluteJoint,
math::{Inertia, Velocity},
object::{BodyHandle, BodyStatus, Mater... |
use std::collections::{BinaryHeap, HashMap};
use std::hash::BuildHasherDefault;
use std::usize;
use needletail::Sequence;
use crate::sketch_schemes::hashing::{hash_f, HashedItem, NoHashHasher};
use crate::sketch_schemes::{ItemHash, KmerCount, SketchParams, SketchScheme};
use needletail::parser::SequenceRecord;
#[der... |
use database::Pool;
use fetch::{FetchBuilder, Fetcher};
use jsonwebtoken::EncodingKey;
use reqwest::IntoUrl;
use serde::Deserialize;
use snafu::{ResultExt, Snafu};
use std::convert::TryFrom;
use std::path::PathBuf;
use std::sync::Arc;
use tracing::info;
mod changes;
mod database;
mod fetch;
mod model;
pub use changes... |
//! SchedAgent manages the CPU scheduler settings for a thread.
//!
//! # Scheduler Settings
//!
//! Currently, the only scheduler setting that SchedAgent can access and update
//! is the CPU affinity of a thread. Other settings will be added in the future.
//!
//! # The Two Modes: Attached vs Detached
//!
//! SchedAge... |
use crate::*;
use helpers::check_arg_count;
use rustc_middle::ty::{self, TypeAndMut};
use rustc_ast::ast::Mutability;
use rustc_span::BytePos;
use rustc_target::abi::Size;
use std::convert::TryInto as _;
use crate::rustc_target::abi::LayoutOf as _;
impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalC... |
//! Vertical floating-point `tanh`
#![allow(unused)]
// FIXME 64-bit 1 elem vectors tanh
use crate::*;
crate trait Tanh {
fn tanh(self) -> Self;
}
macro_rules! define_tanh {
($name:ident, $basetype:ty, $simdtype:ty, $lanes:expr, $method:ident) => {
fn $name(x: $simdtype) -> $simdtype {
u... |
use nom::{
bytes::streaming::{tag, take, take_while1},
character::streaming::{line_ending, not_line_ending, space0},
error::ErrorKind,
multi::many1,
sequence::tuple,
IResult,
};
use std::str;
// TODO: evaluate the use of `ErrorKind::Verify` here.
fn version(input: &[u8]) -> IResult<&[u8], &str>... |
use base::fnv::FnvMap;
use base::kind::{ArcKind, Kind, KindEnv};
use base::symbol::{Symbol, SymbolRef};
use base::types::{Alias, ArcType, Type, TypeEnv};
pub use self::Instruction::*;
pub type VmIndex = u32;
pub type VmTag = u32;
pub type VmInt = isize;
/// Enum which represent the instructions executed by the virtu... |
// Copyright Cryptape Technologies LLC.
//
// 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 crate::cty::c_void;
// aarch64 uses user_pt_regs instead of pt_regs
#[cfg(not(bpf_target_arch = "aarch64"))]
use crate::bindings::pt_regs;
#[cfg(bpf_target_arch = "aarch64")]
use crate::bindings::user_pt_regs as pt_regs;
/// A trait that indicates a valid type for an argument which can be coerced from a BTF
/// c... |
#![cfg_attr(
debug_assertions,
allow(dead_code, unused_imports, unused_variables, unused_mut)
)]
//! ## 市场信息
//! ----
//!
//! ### Trait QuantitativeMarket
//! ----
//! 定义市场行情数据的获取方法
//! + get_info_datetime: 获取当前市场行情的时间信息
//! + query_history_info: 获取指定时间范围内某具体投资标的(由code指定)的行情信息
//!
//! ### Struct InfoMixer
//... |
use serde::Deserialize;
use serde_json::json;
use std::time::Duration;
use thirtyfour::{extensions::chrome::ChromeDevTools, prelude::*};
use tokio;
use crate::consts::NEW_BINUSMAYA;
#[derive(Clone, Copy)]
pub struct BrowserMobProxy {
pub host: &'static str,
pub port: u16,
}
pub struct Selenium {
pub driv... |
//! This module provides functionality to aid managing routing requests between [`Service`]s.
//!
//! # Example
//!
//! [`Steer`] can for example be used to create a router, akin to what you might find in web
//! frameworks.
//!
//! Here, `GET /` will be sent to the `root` service, while all other requests go to `not_f... |
mod opts;
use std::collections::{HashMap, HashSet};
use std::env;
use std::fs::File;
use std::io::{BufRead, BufReader, Error as IOError, stdin};
use std::iter::FromIterator;
use std::process;
use clap::derive::Clap;
use rand::Rng;
use adaptive_hangman::dict;
use crate::opts::Opts;
fn load_dictionary(file_name: &s... |
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
use std::fmt;
use std::mem;
use std::collections::HashMap;
use std::io;
use std::io::{Write, Read};
#[allow(non_camel_case_types)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ValueType {
... |
use syn::FnArg;
use syn::Ident;
use syn::Type;
use syn::Pat;
use syn::Error;
use syn::Generics;
use syn::TypeParam;
use syn::Signature;
use syn::TypeParamBound;
use syn::PathArguments;
use syn::Result;
use syn::spanned::Spanned;
use syn::ParenthesizedGenericArguments;
use syn::Receiver;
use super::MyTypePath;
use supe... |
use crate::account::Account;
use crate::config::TransactionType;
use crate::global::{METRICS_RECORDER, MIN_SECP_CELL_CAPACITY};
use crate::net::Net;
use crate::net_monitor::wait_network_stabled;
use crate::rpc::Jsonrpc;
use crate::transfer::{construct_unsigned_transaction, sign_transaction};
use crate::util::estimate_f... |
// This file holds a number of functions which aid in tx creation.
use crate::error::{HeadlessDappError, Result};
use crate::{
encoding::address_string_to_ergo_tree, encoding::serialize_p2s_from_ergo_tree,
P2PKAddressString, P2SAddressString,
};
use crate::{BlockHeight, ErgoAddressString, NanoErg};
use ergo_lib... |
use crate::prelude::*;
pub type BlockNumber = U64;
pub type EstimateGas = U64;
pub type Balance = U256;
pub type TxCount = U64;
pub type StoragePos = U256;
pub type StorageData = U256;
pub type TxIndex = U64;
pub type UncleIndex = U64;
pub type UncleCount = U64;
#[derive(Clone, Debug, PartialEq, Serialize, Deserializ... |
use regex::Regex;
use std::fs;
use crate::{palette::ColorPalette, runtime::lua_runtime::LuaRuntime, set_map, set_sprite, MEM};
use super::Cart;
pub struct P8Script {
path: String,
name: String,
script: Vec<u8>,
sprites: Vec<[[ColorPalette; 8]; 8]>,
spritesheet: [i32; 128 * 128],
map: [i32; 12... |
// Copyright 2018-2020 argmin 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... |
// Copyright 2020 - developers of the `grammers` project.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distr... |
use super::{
BaseDirectory,
ServiceConfig,
};
use crate::http_service::{
HttpError,
HttpResponse,
HttpResult,
};
use async_std::{
fs::File,
prelude::*,
};
use hyper::{
header::{
self,
HeaderMap,
HeaderValue,
},
Body,
Response,
StatusCode,
};
use la... |
use clap::{App, AppSettings, Arg};
use indoc::indoc;
use once_cell::sync::Lazy;
use rayon::prelude::*;
use rustywind::options::{Options, WriteMode};
use std::fs;
use std::path::Path;
use std::path::PathBuf;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
static EXIT_ERROR: Lazy<AtomicBool> = Lazy::... |
use crate::{dom::dom_updater::DomUpdater, Cmd, Component, Dispatch};
use std::{cell::RefCell, rc::Rc};
#[cfg(feature = "with-request-animation-frame")]
use wasm_bindgen::closure::Closure;
use web_sys::Node;
/// Holds the user App and the dom updater
/// This is passed into the event listener and the dispatch program
/... |
// LNP/BP Core Library implementing LNPBP specifications & standards
// Written in 2020 by
// <NAME>
// <NAME>
// <NAME>
// <NAME>
// <NAME>
//
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public doma... |
use bencher::Bencher;
pub fn baseline(b: &mut Bencher) {
b.iter(|| {
let json_build = json!({
"test": "abc"
});
assert_eq!(json_build.to_string(), super::BASELINE);
});
}
/*_serde_json returns this out of order
pub fn serial(b: &mut Bencher) {
b.iter(|| {
let json_build = json!({
"test1": ... |
//! --- Part Two ---
//!
//! After a while, you realize your shuffling skill won't improve much more with merely a single
//! deck of cards. You ask every 3D printer on the ship to make you some more cards while you check
//! on the ship repairs. While reviewing the work the droids have finished so far, you think you
/... |
#![no_std]
#![feature(start)]
extern crate alloc;
use core::ffi::c_void;
mod graphics;
use graphics::{Graphics, Image};
mod audio;
use audio::Audio;
use ogc_rs::{
ffi::{TPL_GetTexture, TPL_OpenTPLFromMemory},
prelude::*,
};
use void_audio::player::{AudioPlayer,AudioFormat, AudioFrequency, AudioOptions};
u... |
extern crate tokenizers as tk;
use crate::container::Container;
use crate::tasks::models::{BPEFromFilesTask, WordPieceFromFilesTask};
use neon::prelude::*;
use std::path::Path;
/// Model
pub struct Model {
pub model: Container<dyn tk::tokenizer::Model + Sync>,
}
declare_types! {
pub class JsModel for Model {... |
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
use std::collections::{HashMap, HashSet};
use network_partitions::clustering::Clustering;
use network_partitions::errors::CoreError;
use network_partitions::leiden;
use network_partitions::log;
use network_partitions::network::prelude::*;
use ... |
use std::error::Error;
use std::fs;
use std::path::PathBuf;
use clap::Parser;
use futures::future;
use helper::entry_watcher;
use tracing::{debug, error};
use quake_core::entry::entry_defines::EntryDefines;
use quake_core::quake::QuakeActionNode;
use quake_core::QuakeConfig;
use quake_tui::tui_main_loop;
use crate::... |
use seahash::hash;
use serde_json::{Map, Value};
use std::{collections::HashMap, vec};
use crate::{error::Error, Result};
#[derive(Debug)]
pub struct Compressor {
refs: HashMap<String, (usize, Value)>,
input: Value,
output: Value,
}
impl Compressor {
/// Construct a new Compressor using a serde::Valu... |
// DHT22 Spec Sheet:
// https://cdn-shop.adafruit.com/datasheets/Digital+humidity+and+temperature+sensor+AM2302.pdf
#![allow(dead_code)]
use embedded_hal::{
blocking::delay::{DelayMs, DelayUs},
digital::v2::{InputPin, OutputPin},
};
use esp_idf_hal::{delay::Ets, interrupt::CriticalSection};
#[derive(Debug)]
pu... |
use anyhow::{anyhow, Result};
use crossterm::{
cursor::{Hide, Show},
event::{self, Event, KeyCode::*, KeyEvent},
queue,
style::{Attribute, Color::*},
terminal::{self, Clear, ClearType, EnterAlternateScreen, LeaveAlternateScreen},
};
use ego_tree::NodeRef;
use itertools::Itertools;
use scraper::Node;... |
use crate::yul::mappers::{assignments, declarations, expressions};
use crate::yul::names;
use crate::yul::operations::data as data_operations;
use fe_analyzer::context::{Context, ExpressionAttributes};
use fe_analyzer::namespace::types::{FeSized, Type};
use fe_parser::ast as fe;
use fe_parser::node::Node;
use yultsur::... |
use std::fs;
use std::path::Path;
use std::str;
use std::time::Duration;
use regex::Regex;
use crate::component::Component;
use crate::config::Config;
use crate::error::*;
use crate::generators::Generators;
use crate::outlines::Outlines;
use crate::packages::Packages;
use crate::symbols::Symbols;
const ID_SEPARATOR:... |
// Chariot: An open source reimplementation of Age of Empires (1997)
// Copyright (c) 2016 <NAME>
//
// 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 ... |
// MIT License
// Copyright (c) 2018 brycx
// 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, copy, modify, merge, pu... |
extern crate infinity;
use std::time::Instant;
// ------ Helpers ----------
mod helpers {
#[inline]
pub fn get_page_size() -> usize {
4096
}
}
// ------ HDHistogram ------
const HDHISTOGRAM_BITS: usize = 4;
#[derive(Clone, Debug)]
struct HDHistogram {
counts: Vec<[u64; 1 << HDHISTOGRAM_BIT... |
/* Copyright (c) 2018-2021 <NAME> (<EMAIL>)
*
* 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, copy, modify, merge,... |
use super::Network;
use super::PeerId;
use futures::future::{self, Future};
use futures::stream::FuturesUnordered;
use futures::Stream;
use libp2p::core::Multiaddr;
use libp2p::core::SwarmController;
use libp2p::core::{upgrade, MuxedTransport};
use libp2p::{self, ping};
use peer_store::Behaviour;
use protocol::Protocol... |
use super::*;
pub fn derive(gen: &Generics, ident: &Ident, variant: &Vec<Variant>) -> quote::Tokens {
let dummy = Ident::new(format!("_IMPL_PREFIXOPT_FOR_{}", ident));
let mut collect = CollectVariants::empty();
for var in variant {
let one = OneVariant::build(var);
collect.append_variant(i... |
use std::{
env,
fs::File,
io::{stderr, Read, Write},
path::Path,
process,
};
use cfgrammar::yacc::{YaccGrammar, YaccKind, YaccOriginalActionKind};
use getopts::Options;
use lrlex::{LRNonStreamingLexerDef, LexerDef};
use lrpar::parser::{RTParserBuilder, RecoveryKind};
use lrtable::{from_yacc, Minimi... |
use std::collections::BTreeMap;
use std::fmt;
use std::fmt::Formatter;
use std::fs::File;
pub struct UploadValue {
pub filename: String,
pub content_type: Option<String>,
pub content: File,
}
impl fmt::Debug for UploadValue {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "Upl... |
use std::fs;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let filename = "src/bin/day10/input.txt";
let input = fs::read_to_string(filename).map_err(|_| "Could not read input contents")?;
let illegal_score = score_illegal_lines(&input);
println!("Syntax error score: {}", illegal_score);
... |
use crate::{
colors::*,
constants::PLAYER,
position::Position,
};
use tcod::colors::{Color};
#[derive(Debug)]
pub struct Element {
pub position: Position,
pub char: char,
pub color: Color,
pub block_movement: bool,
pub alive: bool,
pub display_name: String,
pub fighter: Option<F... |
use std::str::FromStr;
use once_cell::sync::Lazy;
use regex::Regex;
static REGEX_PARSE_SEMVER: Lazy<Regex> =
Lazy::new(|| Regex::new(r#"^(\d+)\.(\d+)\.(\d+)(?:-([\w\d\-\.]+))?(?:\+([\w\d\-\.]+))?"#).unwrap());
static REGEX_SPLIT_NUMBERED_PRERELEASE: Lazy<Regex> = Lazy::new(|| Regex::new(r#"([\w\-\.]*?)(\d+)"#).un... |
use crate::config::{ConfigHash, ConfigObject};
use crate::error::{user_error, user_error_result, Result};
use crate::scripting::ScriptCommand;
use std::collections::HashSet;
use std::env;
use std::path::{Path, PathBuf};
const WORKSPACE_CONFIG_FILE_NAME: &str = "rws-workspace.yaml";
mod config_helper {
use crate:... |
//! Module containing the formal definition of the query.
//!
//! This is different from `ast.rs` from `plbot_parser`,
//! because we can define different query syntax,
//! but all of them should be converted into the query syntax
//! defined here.
//!
//! Just like the intermediate representation (IR) in a compiler... |
extern crate byteorder;
extern crate futures;
extern crate pnetlink;
extern crate pnet_macros_support;
extern crate tokio;
extern crate tokio_util;
use std::net::{Ipv4Addr, Ipv6Addr, IpAddr};
use pnetlink::tokio::*;
use pnetlink::socket;
use pnetlink::packet::netlink::{NetlinkMsgFlags, NetlinkPacket};
use pnetlink::p... |
//! An SMTP library for [Tokio].
//!
//! The toplevel module exports a basic interface to send mail, through the
//! `Mailer` type. This interface is hopefully sufficient for the common use
//! case where mail just needs to be delivered to a trusted local mail server
//! or remote mail service.
//!
//! A low-level clie... |
use algebra::Monoid;
use my_range::MyRange;
use std::mem::{replace, swap};
use std::ops::Range;
// 列をあつかうやーつ
#[derive(Debug)]
pub struct SplayTree<T: Monoid>(Option<Box<Node<T>>>);
impl<T: Monoid> SplayTree<T> {
pub fn size(&self) -> usize {
if let Some(ref x) = self.0 {
x.size
} else {... |
use crate::client::{
constants::{
datetime::{deserialize_without_tz, Date, Time},
fare_type::FareType,
station::Station,
PUBLIC_KEY,
},
serde_helpers::{bool_from_number_str, from_str},
};
use anyhow::Result;
use chrono::{NaiveDate, NaiveTime};
use reqwest;
use serde::{Deseria... |
extern crate nalgebra as na;
use na::{Isometry3, Point3, RealField, Vector3};
use ncollide3d::shape::{Ball, Capsule, Cuboid, ShapeHandle};
use nphysics3d::force_generator::DefaultForceGeneratorSet;
use nphysics3d::joint::DefaultJointConstraintSet;
use nphysics3d::joint::{BallJoint, FreeJoint};
use nphysics3d::object::... |
use serde::Serialize;
use wasm_bindgen::{JsCast, JsValue};
use wasm_bindgen_futures::JsFuture;
use worker_sys::cache::Cache as EdgeCache;
use worker_sys::Response as EdgeResponse;
use worker_sys::WorkerGlobalScope;
use crate::request::Request;
use crate::response::Response;
use crate::Result;
/// Provides access to t... |
use std::{slice, str};
use super::*;
use crate::event::ModifiersState;
pub const VIRTUAL_CORE_POINTER: c_int = 2;
pub const VIRTUAL_CORE_KEYBOARD: c_int = 3;
// A base buffer size of 1kB uses a negligible amount of RAM while preventing us from having to
// re-allocate (and make another round-trip) in the *vast* majo... |
use super::{Display, Field, InformationElement};
use std::{collections::HashSet, convert::TryFrom};
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub enum DataRate {
OneMbps(bool),
TwoMbps(bool),
FivePointFiveMbps(bool),
SixMbps(bool),
NineMbps(bool),
ElevenMbps(bool),
... |
use cfg_if::cfg_if;
use stm32f0xx_hal as hal;
use hal::{
stm32,
delay::Delay,
pac,
};
use cortex_m::interrupt::{CriticalSection};
use stm32f0xx_hal::stm32::RCC;
use stm32f0xx_hal::{
gpio::gpioa::{PA6},
gpio::gpiob::{PB3},
gpio::{Alternate, Output, PushPull},
};
use pac::{Interrupt,SPI1};
use ... |
//! Uncategorized collection of tiny useful functions
//!
//! All the functions are simple wrappers around functions from
//! other crates.
use crate::{Error, JsonDict};
use serde::Serialize;
use serde_json::Value;
use std::path::Path;
use std::path::PathBuf;
/// Shortcut function to encode an object as a Json diction... |
use std::os::raw::{c_char, c_double, c_int};
use std::f64;
use std::ffi::CStr;
use lbfgsb::step;
use string::stringfy;
pub struct Lbfgsb<'a> {
n: c_int,
m: c_int,
x: &'a mut Vec<c_double>,
l: Vec<c_double>,
u: Vec<c_double>,
nbd: Vec<c_int>,
f: &'a Fn(&Vec<c_double>) -> c_double,
g: Opt... |
use crate::event::EventReceiver;
use crate::util::escape_and_elide;
use crate::{BodyAsyncReader, BodyReader};
use std::convert::{TryFrom, TryInto};
use std::fmt::Debug;
use std::io::{ErrorKind, Read};
use std::path::PathBuf;
use std::sync::Mutex;
use temp_file::TempFile;
pub enum ResponseBody {
EventStream(Mutex<E... |
use kubernetes::client::APIClient;
use std::collections::BTreeMap;
use shipcat_definitions::{Crd, CrdList, CrdEvent, CrdEventType, Manifest, Config};
use super::{Result, Error};
static GROUPNAME: &str = "babylontech.co.uk";
static SHIPCATMANIFESTS: &str = "shipcatmanifests";
static SHIPCATCONFIGS: &str = "shipcatconf... |
use crate::{
config::{rhai::engine, rule::Rule},
display::get_display_by_idx,
event::Event,
hot_reload::update_config,
keybindings::{self, keybinding::Keybinding, keybinding_type::KeybindingType},
with_current_grid, with_grid_by_id,
workspace::change_workspace,
ADDITIONAL_RULES, CHANNEL,... |
pub mod app_info;
mod compat_tool;
pub mod registry;
pub mod shortcuts;
pub use self::compat_tool::parse_compat_tool_mapping;
use derive_more::{Constructor, Display, FromStr};
use std::collections::{HashMap, HashSet};
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
#[derive(Constructor, Display,... |
// account for border width
// iterate and == diff on the decoration side
// XWindows struct .update()
// https://stackoverflow.com/questions/31225743/x11-non-clipped-child-windows/31436071#31436071
// https://turbomack.github.io/posts/2019-07-28-rust-vs-gui.html
// https://jichu4n.com/posts/how-x-window-managers-wor... |
#![allow(clippy::unwrap_used)]
use crate::tls_utils::{temp_crypto_component_with_tls_keys, REG_V1};
use ic_crypto::utils::TempCryptoComponent;
use ic_crypto_tls_interfaces::TlsPublicKeyCert;
use ic_crypto_tls_interfaces::{
AllowedClients, AuthenticatedPeer, Peer, SomeOrAllNodes, TlsHandshake, TlsReadHalf,
TlsSe... |
use crate::ast::expr::BlockExpr;
use crate::ast::item::{
ExternalItem, ExternalItemFn, FnParam, FnParams, Item, ItemExternalBlock, ItemFn, ItemStruct,
StructField, TupleField, TypeEnum, ABI,
};
use crate::ast::pattern::Pattern;
use crate::ast::types::TypeAnnotation;
use crate::ast::{TokenStart, Visibility};
use... |
use server::{PeerId, Disconnect};
use crate::apps::pusoy::Member;
use pusoy::{GameState, all_plays, Card, Cards, Play, RandomPlayer, Player};
use json::{Json, jsons, json};
use std::collections::HashMap;
use rand::thread_rng;
use rand::seq::SliceRandom;
use std::time::{Duration, Instant};
use std::str::FromStr;
const ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.