text stringlengths 3.09k 13.9k |
|---|
// Copyright (c) 2016 The vulkano developers
// 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. All files in the project carrying such
// notice may not be ... |
use ethabi::Token;
use ethereum_tx_sign::RawTransaction;
use lazy_static::lazy_static;
use log::error;
use std::str::FromStr;
use web3::{
api::Web3,
futures::future::Future,
transports::Http,
types::{Address, BlockNumber, FilterBuilder, Transaction, H160, H256, U256},
};
lazy_static! {
/// This is ... |
use futures::prelude::*;
use futures::{failed, finished};
use hex_literal::hex;
use std::collections::VecDeque;
use std::str::FromStr;
use std::sync::{Arc, Mutex};
use ethabi::{Function, Param, ParamType, Token};
use graph::components::ethereum::EthereumContractCall;
use graph::prelude::EthereumAdapter as EthereumAdap... |
#![cfg_attr(not(feature = "std"), no_std)]
use codec::Encode;
use core::convert::TryFrom;
use frame_support::{
log::{error, trace},
traits::Randomness,
};
use nftmart_traits::{BitFlags, ClassId, ClassProperty, GlobalId, Properties, Signature, TokenId};
use pallet_contracts::chain_extension::{
ChainExtension, Enviro... |
use std::sync::Arc;
use criterion::criterion_group;
use criterion::criterion_main;
use criterion::BenchmarkId;
use criterion::Criterion;
use holo_hash::EntryHash;
use holo_hash::EntryHashes;
use holochain::conductor::handle::DevSettingsDelta;
use holochain::sweettest::*;
use holochain_conductor_api::conductor::Conduc... |
use onig::Regex;
use serde::{Deserialize, Deserializer, Serialize};
use crate::tokenizer::{
pattern::Invert, PreTokenizedString, PreTokenizer, Result, SplitDelimiterBehavior,
};
/// Represents the different patterns that `Split` can use
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum SplitPatt... |
use crate::{Buffer, Input, Node, BoxedNodeSend, NodeData, Message, impl_to_boxed_nodedata};
use hashbrown::HashMap;
#[derive(Debug, Clone)]
pub struct MsgSynth {
synth_list: Vec<(usize, f32)>,
phase_list: Vec<f32>,
att: f32,
dec: f32,
events: Vec<(usize, f32)>, // event.0 is step to play the note, ... |
use std::sync::mpsc;
use std::{sync::mpsc::Sender, time::Duration};
#[cfg(test)]
use std::thread::JoinHandle;
use cursive_core::theme::Style;
use cursive_core::views::TextView;
use cursive_core::CbSink;
use cursive_core::{views::TextContent, Printer, Vec2, View};
use crate::{
spinner::Spinner, Frames, ACCCEL_FAC... |
//! # Import library
//!
//! Based on Legilibre/legi.py.
// node2object à la place de xmlJSON
use std::io::{
stdout,
Write,
};
use std::path::Path;
use std::process::Command;
use curl::easy::{
Easy,
};
use libarchive::reader::{Builder, Reader};
use libarchive::archive as archive;
use treexml::Document;
use std:... |
// Copyright 2021 Red Hat, Inc.
//
// 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 i... |
#![allow(clippy::manual_find_map)]
#![allow(clippy::must_use_candidate)]
#![allow(clippy::option_if_let_else)]
use honggfuzz::fuzz;
use rutenspitz::arbitrary_stateful_operations;
use indexmap::IndexMap;
use std::fmt::Debug;
use std::hash::Hash;
#[derive(Default)]
pub struct ModelHashMap<K, V>
where
K: Eq + Hash... |
//! Unit test helpers for dealing with environment variables.
//!
//! A lot of our functionality can change depending on how certain
//! environment variables are set. This complicates unit testing,
//! because Rust runs test cases in parallel on separate threads, but
//! environment variables are shared across threads... |
use std::io;
use std::net::{SocketAddr, ToSocketAddrs};
use std::sync::Arc;
use super::{ServerConfig, TlsIncoming};
use crate::tcp::TcpIncoming;
use crate::{App, Endpoint, Executor, Server, State};
impl TlsIncoming<TcpIncoming> {
/// Bind a socket addr.
#[cfg_attr(feature = "docs", doc(cfg(feature = "tcp")))]... |
use crate::types::{
primitive::Integer,
text::{RawTextEntity, Text},
user::User,
};
use serde::{de::Error as _, Deserialize, Deserializer, Serialize};
use vec1::Vec1;
/// Contains information about a poll
#[derive(Clone, Debug, Deserialize)]
#[serde(tag = "type")]
#[serde(rename_all = "snake_case")]
pub en... |
use std::time::Duration;
use bevy::{
prelude::*,
window::{PresentMode, RequestRedraw},
winit::WinitSettings,
};
/// This example illustrates how to run a winit window in a reactive, low power mode. This is useful
/// for making desktop applications, or any other program that doesn't need to be running the... |
use core::{char, mem, slice};
use core::ops::{Deref, DerefMut};
pub const EVENT_NONE: i64 = 0;
pub const EVENT_MOUSE: i64 = 1;
pub const EVENT_KEY: i64 = 2;
pub const EVENT_QUIT: i64 = 3;
/// An optional event
#[derive(Copy, Clone, Debug)]
pub enum EventOption {
/// A mouse event
Mouse(MouseEvent),
/// A ... |
/// Represents the major, minor, and patch (if any) versions of this interpreter.
///
/// This struct is usually created with [`Python::version`].
///
/// # Examples
///
/// ```rust
/// # use pyo3::Python;
/// Python::with_gil(|py| {
/// // PyO3 supports Python 3.7 and up.
/// assert!(py.version_info() >= (3, 7... |
//! Provides a `spec` attribute that defines a specification.
extern crate proc_macro;
use ::rustfmt::{config::Config, Input};
use proc_macro::TokenStream;
use proc_macro2::{Span, TokenStream as TokenStream2};
use quote::{quote, ToTokens};
use syn::{
braced, parse::ParseStream, parse_macro_input, parse_macro_input... |
use crate::rand;
use crate::server::ProducesTickets;
use crate::Error;
use ring::aead;
use std::mem;
use std::sync::{Arc, Mutex, MutexGuard};
use std::time;
/// The timebase for expiring and rolling tickets and ticketing
/// keys. This is UNIX wall time in seconds.
///
/// This is guaranteed to be on or after the UN... |
use std::{convert::TryInto, sync::Arc};
use dioxus::{events::MouseData, prelude::*};
use dioxus_core::UiEvent;
fn main() {
dioxus::tui::launch(app);
}
fn app(cx: Scope) -> Element {
fn to_str(c: &[i32; 3]) -> String {
"#".to_string() + &c.iter().map(|c| format!("{c:02X?}")).collect::<String>()
}
... |
use crate::Error;
use anyhow::{ensure, Context as _};
use std::path::PathBuf;
pub fn register_app(app: super::Application) -> Result<(), Error> {
use super::LaunchCommand;
fn inner(app: super::Application) -> anyhow::Result<()> {
match app.command {
LaunchCommand::Url(url) => {
... |
use std::collections::{HashMap, HashSet};
use std::sync::Arc;
use tokio::sync::Notify;
use k8s_openapi::api::core::v1::Pod as KubePod;
use k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta;
use kube::api::Meta;
use kube::Client as KubeClient;
use kube_runtime::watcher::Event;
use log::{debug, error, warn};
u... |
use crate::module::{
Module, ModuleBuilder, ModulePeripherals, PlatformConstraints, RequestHandler,
};
use crate::platform::{Action, DeviceInformation, HandleError, Platform};
use byteorder::{ByteOrder, NetworkEndian};
use core::num::NonZeroU16;
use sensor_common::props::Property;
use sensor_common::props::{ModuleI... |
use ndarray::{Axis, Ix2};
use crate::functions::*;
use crate::*;
pub fn matmul(lhs: &Computed, rhs: &Computed) -> Computed {
let y = Computed::new(forward(&lhs, &rhs));
chain(
&[lhs.clone(), rhs.clone()],
&[y.clone()],
false,
"matmul",
|xs, _, gys| {
let x ... |
use rand::Rng;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Gene {
pub encoding: u16,
pub weight: i16
}
pub const SENSOR: bool = true;
pub const ACTION: bool = true;
pub const NEURON: bool = false;
// This is quite more messy than the C++ version, as Rust doesn't have bitfields.
/// Each gene spec... |
use colored::Colorize;
use std::io::prelude::*;
use structopt::StructOpt;
use rsc::{
parse, tokenize, InterpretError, Interpreter, Num, ParseError, ParseErrorCode, TokenizeError,
Variant,
};
use std::fmt::Display;
use std::ops::Range;
#[derive(StructOpt)]
#[structopt(about = "A scientific calculator for the t... |
#[doc = "Reader of register TWIHS_IMR"]
pub type R = crate::R<u32, super::TWIHS_IMR>;
#[doc = "Reader of field `TXCOMP`"]
pub type TXCOMP_R = crate::R<bool, bool>;
#[doc = "Reader of field `RXRDY`"]
pub type RXRDY_R = crate::R<bool, bool>;
#[doc = "Reader of field `TXRDY`"]
pub type TXRDY_R = crate::R<bool, bool>;
#[do... |
use chrono::Duration;
use serde::{Deserialize, Serialize};
use std::fmt;
use std::fmt::Formatter;
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
pub enum WorkoutType {
Interval,
Tempo,
Long,
}
impl WorkoutType {
pub fn new(input: String) -> Self {
match input.as_str() {
... |
mod bike_network;
mod explore;
mod layers;
//mod magnifying;
mod predict;
mod quick_sketch;
mod trip;
use geom::CornerRadii;
use map_gui::tools::CityPicker;
use widgetry::{
EventCtx, HorizontalAlignment, Key, Line, Panel, ScreenDims, State, VerticalAlignment, Widget,
DEFAULT_CORNER_RADIUS,
};
pub use self::ex... |
// Copyright (c) 2021 <NAME> and WormieCorp.
// Licensed under the MIT license. See LICENSE.txt file in the project
pub mod logging;
use std::fmt::Display;
use std::fs::File;
use std::io::Write;
use std::ops::Add;
use std::path::Path;
use std::str::FromStr;
use md5::Md5;
use sha1::Sha1;
use sha2::digest::generic_arr... |
#[macro_use]
extern crate pretty_assertions;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
// we get an unused import when using macro use, but a
// "this has no effect without macro_use" message otherwise
#[allow(unused_imports)]
#[macro_use]
extern crate snapshot_proc_macro;
p... |
#[proc_macro_derive(SpecifiedAsComputed)]
pub fn derive_specified_as_computed(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
let name = input.ident;
quote!(
impl crate::style::values::SpecifiedValue for #name {
type SpecifiedValue = Self;
... |
#![doc = include_str!("../docs/error_handling.md")]
use crate::{
body::{boxed, Bytes, Full, HttpBody},
extract::{FromRequest, RequestParts},
http::{Request, StatusCode},
response::{IntoResponse, Response},
BoxError,
};
use std::{
convert::Infallible,
fmt,
future::Future,
marker::Pha... |
use std::{collections::BTreeMap, ops::Not};
use super::Authorization;
use crate::deserializers::comma_separated_string;
/// Kong setup for a service
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[serde(default)]
#[cfg_attr(feature = "filesystem", serde(deny_unknown_fields))]
pub struct Kong {
/// Auto... |
// Copyright 2021 Red Hat, Inc.
//
// 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 t... |
// uses some code/ideas from https://github.com/schulke-214/connect-four
// Basic flashcard program written to practice Rust,
// TODO: (* done - not done)
// - "youre close" message for typos
// - accept alternative spellings eg umlauts
// - fix the panic on custom loading
// - improve performance by loading dictiona... |
extern crate nom;
use nom::number::complete::{le_u16, le_u8};
use std::str;
use encoding::all::ISO_8859_1;
use encoding::{DecoderTrap, Encoding};
#[derive(Debug)]
pub struct PuzFile {
pub preamble: Vec<u8>,
pub checksum: u16,
pub magic: String,
pub cib_checksum: u16,
pub masked_low_checksum_1: u... |
//! # Date Picker Element
//!
//! An element which lets users easily select a date from a calendar style UI.
//!
//! [slack api docs 🔗]
//!
//! Works in [blocks 🔗]: Section, Actions, Input
//!
//! [slack api docs 🔗]: https://api.slack.com/reference/block-kit/block-elements#datepicker
//! [blocks 🔗]: https://api.sla... |
use crate::mail::send::EmailSender;
#[cfg(all(not(test), not(feature = "local")))]
use crate::mail::send::SesSender;
use crate::mail::templates::Template;
use crate::mail::templates::TemplateManager;
use crate::mail::Email;
#[cfg(all(not(test), not(feature = "local")))]
use crate::settings::Settings;
use actix_rt::Arbi... |
// Copyright (C) 2020-2021 The RustyBGP Authors.
//
// 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 la... |
//! <div align="center">
//! <img alt="Rune Logo" src="https://raw.githubusercontent.com/rune-rs/rune/master/assets/icon.png" />
//! </div>
//!
//! <br>
//!
//! <div align="center">
//! <a href="https://rune-rs.github.io">
//! <b>Visit the site 🌐</b>
//! </a>
//! -
//! <a href="https://rune-rs.github.io/bool/"... |
use crate::pool::Pool;
use crate::state::NetworkState;
use crate::verifiable::Verifiable;
use crate::wallet::WalletAccount;
use bytebuffer::ByteBuffer;
use secp256k1::{Message, PublicKey, Secp256k1, Signature};
use serde::{Deserialize, Serialize};
use sha256::digest_bytes;
use std::collections::HashMap;
use std::fmt;
u... |
use std::borrow::Borrow;
use std::cmp::Eq;
use std::collections::vec_deque::VecDeque;
use std::collections::HashMap;
use std::hash::Hash;
use std::option::Option;
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
#[allow(dead_code)]
pub struct Cache<K, V> {
intern: Mutex<Intern<K, V>>,
}
struct Int... |
pub mod day_9 {
#[derive(Debug, Eq, PartialEq)]
pub(crate) struct GroupIndex {
pub(crate) i: usize,
}
#[derive(Debug)]
pub(crate) struct Group {
pub(crate) entries: Vec<GroupIndex>,
}
#[derive(Debug)]
pub(crate) enum GroupEntry<'a> {
Garbage(&'a str),
G... |
use std::env;
use std::net::IpAddr;
pub struct Config<'a> {
prefix: &'a str,
}
impl<'a> Config<'a> {
pub fn new(prefix: &'a str) -> Self {
Self { prefix }
}
fn vars(&self) -> impl Iterator<Item = (String, String)> + '_ {
env::vars().filter(move |(n, _)| n.starts_with(self.prefix))
... |
use bytes::{
Buf,
BufMut
};
use crate::{
error::Error,
};
use hyper::{
client::connect::{
Connected,
Connection,
HttpConnector
},
service::Service,
};
use std::{
fmt,
future::Future,
marker::Unpin,
pin::Pin,
task::{
Context,
Poll,
}... |
use crate::angle::NewAngle;
use crate::vector::{VecBaseFloat, Vector3, Vector4};
use crate::Degrees;
use crate::{Quat, Quaternion};
pub use cgmath::{Deg, InnerSpace, Matrix, SquareMatrix, Transform};
pub type Matrix3 = cgmath::Matrix3<f32>;
pub type Matrix4 = cgmath::Matrix4<f32>;
pub trait MatBase {
fn default_i... |
use std::ffi::OsStr;
use std::fs::File;
use std::io::Write;
use std::path::Path;
use std::{env, io};
use log::{debug, warn};
use nmk::consts::env::{
EDITOR, LD_LIBRARY_PATH, NMK_HOME, NMK_LAUNCH_MODE, NMK_TMUX_VERSION, PATH, VIMINIT, ZDOTDIR,
};
use nmk::human_time::{seconds_since_build, HumanTime};
use nmk::laun... |
use crate::data::{Interaction, Response, Sender};
use anyhow::Result as AnyResult;
use log::*;
use reqwest::header::{HeaderMap, HeaderName, HeaderValue};
use rusoto_core::credential::AwsCredentials;
use rusoto_core::signature::SignedRequest;
use rusoto_core::Region;
use std::collections::HashMap;
use std::str::FromStr... |
//! unit system
/// Follows [CSS Values 3][1] drafted in [csswg.org][2].
///
/// ## Absolute Lengths
/// | unit | name | equivalence |
/// |------|---------------------|----------------------|
/// | cm | centermeters | 1cm = 96px/2.54 |
/// | mm | millimeters | 1mm == 1/1... |
use std::collections::HashSet;
impl Solution {
pub fn pacific_atlantic(matrix: Vec<Vec<i32>>) -> Vec<Vec<i32>> {
let n = matrix.len();
if n == 0 {
return vec![];
}
let m = matrix[0].len();
if m == 0 {
return vec![];
}
if n == 1 {
... |
use std::sync::{Condvar, Mutex};
use rustler::{
resource::ResourceArc, types::tuple, Atom, Encoder, Error, ListIterator, MapIterator, OwnedEnv,
Term,
};
use wasmer::{
imports, namespace, Exports, Function, FunctionType, ImportObject, LazyInit, Memory,
RuntimeError, Store, Type, Val, WasmerEnv,
};
use ... |
use crate::data::primitive::boolean::PrimitiveBoolean;
use crate::data::{
ast::{Block, Expr, IfStatement, Infix, InstructionInfo},
Data, Literal, MessageData, MSG,
};
use crate::error_format::ErrorInfo;
use crate::interpreter::{
// ast_interpreter::match_functions,
interpret_scope,
variable_handler:... |
//! Touch event types
use super::EventTrait;
use {AsRaw, Context, FromRaw};
use ffi;
/// Common functions all Touch-Events implement.
pub trait TouchEventTrait: AsRaw<ffi::libinput_event_touch> + Context {
ffi_func!(
/// The event time for this event
fn time, ffi::libinput_event_touch_get_time, u32);
... |
#[derive(Deserialize, Debug, Clone)]
pub struct Config {
consumer_key: String,
consumer_secret: String,
access_token: String,
access_token_secret: String,
track: String,
slack_url: String,
pub is_debug: bool,
pub post_slack_enabled: bool,
filter_lang: String,
}
pub const RESET_FLAG:... |
#![deny(warnings, rust_2018_idioms)]
mod admin;
mod metrics;
mod rate_limit;
mod runner;
mod timeout;
use self::{
admin::Admin, metrics::MakeMetrics, rate_limit::RateLimit, runner::Runner,
timeout::MakeRequestTimeout,
};
use ort_core::{latency, parse_duration, Distribution, Error, MakeOrt, Ort, Reply, Spec};
... |
#![cfg_attr(not(feature = "mock"), no_std)]
extern crate ontio_std as ostd;
use ostd::abi::Dispatcher;
use ostd::abi::Encoder;
use ostd::prelude::*;
use ostd::{database, runtime};
const KEY_TOTAL_SUPPLY: &str = "total_supply";
const INITED: &str = "Initialized";
const PREFIX_INDEX: &str = "01";
const PREFIX_APPROVE: &... |
#[doc = "Clock divider register for state machine 0\\n Frequency = clock freq / (CLKDIV_INT + CLKDIV_FRAC / 256)\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify... |
/*
--- Day 2: I Was Told There Would Be No Math ---
The elves are running low on wrapping paper, and so they need to submit an order for more. They have a list of the dimensions (length l, width w, and height h) of each present, and only want to order exactly as much as they need.
Fortunately, every present is a box ... |
//! RTC peripheral abstraction
use crate::datetime::*;
use crate::rcc::{Rcc, RtcClkSrc};
use crate::stm32::RTC;
use crate::time::U32Ext;
/// RTC Abstraction
pub struct Rtc {
rtc: RTC,
}
const RTC_CLK_DIV: u8 = 16;
const ASYNCH_PREDIV: u8 = RTC_CLK_DIV - 1;
const SYNCH_PREDIV: u16 = 0x7FFF;
impl Rtc {
#[inli... |
use std::env;
use std::path::{Path, PathBuf};
use std::*;
extern crate dirs;
use std::collections::HashMap;
use std::fs::*;
pub fn example_add(a: f32, b: f32) -> f32 {
println!("[from native lib] example_add start");
println!("[from native lib] a = {}, b = {}", a, b);
let c = a + b;
println!("[from native lib] c =... |
use git2::{Commit, Oid};
use std::collections::HashSet;
use std::hash::Hash;
use std::io::prelude::*;
use super::util::short_id;
/// Given a start and end point, returns a linear series of commits to traverse.
/// The correct ordering here is not always clear; we adopt reverse-post-order,
/// which yields "reasonable... |
use std::{
cmp::Ordering,
collections::{BTreeMap, BinaryHeap},
};
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default)]
pub struct HuffmanValue {
// For the `value` to overflow, the sum of frequencies should be bigger
// than u64. So we should be safe here
/// The encoded value
... |
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::ops::{Add, Sub};
use std::time::{Duration, SystemTime};
use time::{at_utc, get_time, strftime, strptime, ParseError, Timespec, Tm};
/// Unix-time in milliseconds
///
/// This type is intended for compact representation of real time.
/// The values... |
// `error_chain!` can recurse deeply
#![recursion_limit = "1024"]
extern crate clap;
extern crate regex;
#[macro_use]
extern crate log;
extern crate log4rs;
#[macro_use]
extern crate error_chain;
// For testing in submodules
#[cfg(test)]
extern crate rand;
use clap::{App, Arg, ArgMatches};
use log::LevelFilter;
use ... |
// Buttplug Rust Source Code File - See https://buttplug.io for more info.
//
// Copyright 2016-2021 Nonpolynomial Labs LLC. All rights reserved.
//
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.
//! Handling of named pipes and unix domain sockets, via... |
// Copyright (c) 2019 - 2020 ESRLabs
//
// 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 ... |
mod tezos_send_transaction;
use lib::functions::*;
use ureq::Agent;
use std::fs;
use serde_json::Value;
use tezos_send_transaction::transfer as tezos_transfer;
fn tezos_get_transactions() -> Value {
let agent = Agent::new();
let path = format!("https://api.hangzhounet.tzkt.io/v1/accounts/{}/operations", serde_... |
use std::io;
use std::fmt::Write;
use chrono::Timelike;
use crate::brush;
use crate::font;
use crate::time;
// H : M : S
// ...|...|...|...|...|...|...|...
// ...|...|...|...|...|...|...|...
// ...|...|...|...|...|...|...|...
// ...|...|...|...|...|...|...|...
// ...|...|...|...|...|...|...|...
//
/... |
use std::os::raw::{c_char};
use std::ffi::{CString, CStr};
//use std::{thread, time, io::{stdout, Write}};
use std::str::FromStr;
use url::{Url, ParseError};
use anyhow::{Error, anyhow};
//use cli::{diem_client::DiemClient, AccountData, AccountStatus};
//use cli::{diem_client::{DiemClient, views::VMStatusView}, Account... |
use crate::config::{CONFIGURATION, PROGRESS_PRINTER};
use crate::utils::{ferox_print, status_colorizer};
use crate::FeroxChannel;
use console::strip_ansi_codes;
use reqwest::Response;
use std::io::Write;
use std::sync::{Arc, Once, RwLock};
use std::{fs, io};
use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSen... |
use anyhow::Error;
use handlebars::Handlebars;
use rweb::{
filters::BoxedFilter,
http::header::CONTENT_TYPE,
openapi::{self, Info},
reply, Filter, Reply,
};
use std::{net::SocketAddr, sync::Arc};
use weather_util_rust::weather_api::WeatherApi;
use super::{
config::Config,
errors::error_respons... |
use crate::util::{clamp, random_double, random_double_range};
use std::io::{Write};
use std::ops::{Neg, Index, Add, Sub, Mul, IndexMut};
use std::io;
use std::f64;
use nalgebra::Vector3;
#[derive(Debug, Copy, Clone)]
pub struct Vec3 {
pub v: Vector3<f64>
}
impl Vec3 {
pub fn new(x: f64, y: f64, z: f64) -> Se... |
use std::fs::File;
use std::path::Path;
use serde::{Deserialize, Serialize};
use tera::{Context, Tera};
use crate::cmd::library::generate::config::Config;
use crate::cmd::library::generate::task::{CleanupScope, Task};
use crate::error::Error;
use crate::manifest::library::Library;
use crate::manifest::module::Module;... |
use num_bigint::RandBigInt;
use quickcheck::{Arbitrary, Gen};
use quickcheck_macros::quickcheck;
use super::*;
use crate::consts::M521_STR;
const M: &'static str = M521_STR;
impl<const MOD: &'static str> Arbitrary for Octonion<MOD> {
fn arbitrary(_: &mut Gen) -> Self {
let m = BigInt::from_str(MOD).unwra... |
use std::path::Path;
use std::fs;
use std::collections::{HashMap, HashSet};
use ansi_term::Colour;
use ansi_term::{ANSIString, ANSIStrings};
use std::{thread, time};
fn parse_input(content: &str) -> HashMap<(usize, usize), usize> {
let mut map = HashMap::new();
const RADIX: u32 = 10;
content
... |
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use maplit::btreemap;
use once_cell::sync::Lazy;
use regex::Regex;
use std::collections::BTreeMap;
/// A lazy constant which defines placeholders which can be referenced as `${NAME}`
/// in emitted code. All emitted strings have those ... |
extern crate bytes;
extern crate env_logger;
extern crate futures;
extern crate http;
extern crate h2;
extern crate tokio_connect;
extern crate tokio_core;
extern crate tower;
extern crate tower_grpc;
extern crate tower_h2;
use std::net::SocketAddr;
use bytes::{Buf, BufMut};
use futures::Future;
use tokio_connect::Co... |
use anyhow::anyhow;
use anyhow::Result;
use futures::FutureExt;
use futures::TryStreamExt;
use http::HeaderMap;
use hyper::service::{make_service_fn, service_fn};
use hyper::{Body, Method, Request, Response, Server, StatusCode};
use hyperlocal::UnixServerExt;
use serde::de::DeserializeOwned;
use serde::{Deserialize, Se... |
use serde::de::{Deserialize, Deserializer};
use std::borrow::Cow;
use std::fmt;
use std::fs::File;
use std::io::{BufRead, BufReader, Error as IoError, Lines, Read};
use std::iter::FusedIterator;
use std::path::{Path, PathBuf};
/// Wrapper type for a list of string values.
///
/// These lists are often used in configur... |
use std::fmt::Debug;
use crossbeam_channel::Receiver;
use rsmpeg::avutil::AVFrame;
use rsmpeg::ffi::av_q2d;
use rsmpeg::ffi::{self, AVRational};
use rsmpeg::swscale::SwsContext;
use crate::defines::PLAY_MIN_INTERVAL;
use crate::error::Result;
use crate::services::player::stream::{decode_frame, DecodeContext};
use cra... |
#[deny(missing_docs)]
/// Encodes bytes into a uuencoded string.
pub fn uuencode(filename: &str, input: &[u8]) -> String {
let mut output : Vec<u8> = Vec::new();
// in rust, char != u8, so we need to prefix with a b
output.extend(b"begin 644 ");
output.extend(filename.as_bytes());
output.extend(b"\... |
// Copyright 2020 Google 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writ... |
#[macro_use]
extern crate criterion;
extern crate bv;
extern crate fp_succinct_trees_1;
extern crate id_tree;
use criterion::Criterion;
use criterion::Fun;
use fp_succinct_trees_1::bp_tree::BPTree;
use fp_succinct_trees_1::common::succinct_tree::SuccinctTree;
use fp_succinct_trees_1::louds_tree::LOUDSTree;
use id_tree... |
//! Structures for iterating over the words in a bitboard.
use std::fmt;
use crate::{
game::tile::Tile,
util::{
bitboard::{BitBoard, Bits},
grid::Grid,
pos::Pos,
},
};
/// Stores a start and end position for a word.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct WordBound... |
extern crate minifb;
extern crate rodio;
use minifb::{Key, Scale, Window, WindowOptions};
use std::collections::HashSet;
use std::fs::File;
use std::io;
use std::io::Read;
use std::io::Write;
use std::process;
use structopt::StructOpt;
use libchipolata::chip8;
#[derive(StructOpt)]
struct Cli {
/// Enable debug m... |
use crate::{Connection, Error, MessageHeader, Proxy, Result};
use static_assertions::assert_impl_all;
use std::{
borrow::Cow,
collections::HashMap,
convert::{AsRef, TryFrom},
sync::Arc,
};
use zvariant::ObjectPath;
#[derive(Hash, Eq, PartialEq)]
struct ProxyKey<'key> {
interface: Cow<'key, str>,
... |
use crate::core::{return_none, Parsable, Parser};
/// # Combinator: `bind` (function ver.)
///
/// Monadic bind operator `(>>=)` for context sensitive parsing.
///
/// # Properties
///
/// Should satisfy [Monad laws](https://wiki.haskell.org/Typeclassopedia#Laws_3):
///
/// - **Left-identity**: `bind(pure(x), f) ~ f(x... |
use bip32::DerivationPath;
use ledger_transport::APDUTransport;
use ledger::TransportNativeHID;
use ledger_apdu::{map_apdu_error_description, APDUAnswer, APDUCommand};
use serde_json::Value;
use crate::error::Error;
use crate::Result;
// https://github.com/cosmos/ledger-cosmos#apdu-specifications
// https://gith... |
use super::Command;
use crate::world::World;
struct CommandMeta {
offset: usize,
func: unsafe fn(value: *mut u8, world: &mut World),
}
/// A queue of [`Command`]s
//
// NOTE: [`CommandQueue`] is implemented via a `Vec<u8>` over a `Vec<Box<dyn Command>>`
// as an optimization. Since commands are used frequentl... |
// Deps
use amethyst::SimpleState;
// Game state struct.
pub struct Pong;
// Implement SimpleState, which adds type info to the game state that tells Amethyst what to do when the close signal is received from the OS.
//
// See: https://docs.amethyst.rs/stable/src/amethyst/state.rs.html#265
//
// We can then additiona... |
use rustc_serialize::hex::FromHex;
use std::str;
use std::collections::HashMap;
use std::collections::HashSet;
use std::hash::Hash;
use std::cmp::Eq;
use std::fmt::Debug;
use lib::cryptor::Decryptor;
use lib::cryptor::XorDecryptor;
// Data from http://www.data-compression.com/english.html
const ENGLISH_CHAR_FREQ: &'... |
// Copyright (c) 2017 <NAME>, RWTH Aachen University
//
// MIT License
//
// 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... |
// Implementation borrowed from parking_lot_core:
// Copyright 2016 <NAME>
//
// 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, modifi... |
use data_encoding::BASE32_NOPAD;
use errors::{Error, Result};
use ring::hmac;
use std::time::{SystemTime, UNIX_EPOCH};
// Define the types of hash functions supported
#[derive(Debug)]
pub enum HashFunction {
Sha1,
Sha256,
Sha384,
Sha512,
}
// Structure representing a One Time Password
#[derive(Debug)]... |
#![allow(non_snake_case)]
extern crate cryptopals;
use cryptopals::rsa::RSA;
use std::io::Read;
use num_bigint::{BigUint, ToBigUint};
struct Oracle {
rsa: RSA,
}
impl Oracle {
pub fn get_rsa_n(&self) -> BigUint {
self.rsa.n.clone()
}
pub fn pad_encrypt(&self, pt: &BigUint) -> BigUint {
... |
use anyhow::anyhow;
use aoc_core::Tap as _;
use reqwest::blocking;
use reqwest::header;
use crate::cache;
use crate::leaderboard;
use crate::markdown;
pub static ROOT: &str = "https://adventofcode.com";
static CORRECT: &str = "That's the right answer!";
static INCORRECT: &str = "That's not the right answer.";
static... |
use crate::data::AtomicWindowedHistogram;
use metrics_core::{Key, ScopedString};
use metrics_util::StreamingIntegers;
use quanta::Clock;
use std::{
ops::Deref,
sync::{
atomic::{AtomicI64, AtomicU64, Ordering},
Arc,
},
time::{Duration, Instant},
};
/// A scope, or context, for a metric.
... |
use bendy::{
decoding::{self, FromBencode, Object},
encoding::{self, SingleItemEncoder, ToBencode},
};
use crate::{error::*, file_info::FileInfo};
#[derive(Debug, PartialEq, Eq)]
pub struct Info {
name: String,
piece_length: u64,
pieces: Vec<u8>,
length: Option<u64>,
files: Option<Vec<File... |
#[doc = "Reader of register INTSTAT"]
pub type R = crate::R<u32, super::INTSTAT>;
#[doc = "Reader of field `INX_INT`"]
pub type INX_INT_R = crate::R<bool, bool>;
#[doc = "Reader of field `TIM_INT`"]
pub type TIM_INT_R = crate::R<bool, bool>;
#[doc = "Reader of field `VELC_INT`"]
pub type VELC_INT_R = crate::R<bool, boo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.