text stringlengths 3.09k 13.9k |
|---|
//! lint on blocks unnecessarily using >= with a + 1 or - 1
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::source::snippet_opt;
use rustc_ast::ast::{BinOpKind, Expr, ExprKind, Lit, LitKind};
use rustc_errors::Applicability;
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_session::{declar... |
use std::{
cell::RefCell,
collections::HashMap,
future::Future,
io,
pin::Pin,
sync::atomic::{AtomicUsize, Ordering},
task::{Context, Poll},
};
use futures_core::ready;
use tokio::sync::{mpsc, oneshot};
use crate::{arbiter::ArbiterHandle, runtime::default_tokio_runtime, Arbiter, Runtime};
... |
use std::collections::HashMap;
use amethyst_animation::{
Animation, AnimationSet, InterpolationFunction, InterpolationPrimitive, Sampler,
SamplerPrimitive, TransformChannel,
};
use amethyst_assets::{
distill_importer::{Error, ImportOp, ImportedAsset},
make_handle,
prefab::{register_component_type, ... |
// Copyright 2016 <NAME> <<EMAIL>>
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.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 ... |
#[derive(Debug, Clone, PartialEq, Eq)]
#[allow(dead_code)]
pub enum LineNumbers {
RelativeNumber,
AbsoluteNumber,
None,
}
impl LineNumbers {
pub fn lines(
&self,
width: usize,
height: usize,
offset: usize,
line_len: usize,
cursor_y: usize,
) -> String... |
// Copyright 2018 The Exonum Team
//
// 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... |
use crate::plan::Plan;
use crate::scheduler::gc_work::*;
use crate::scheduler::*;
use crate::util::{Address, ObjectReference};
use crate::vm::*;
use crate::MMTK;
use std::collections::HashSet;
use std::ops::{Deref, DerefMut};
use std::sync::atomic::Ordering;
#[allow(dead_code)]
pub struct SanityChecker {
/// Visit... |
use crate::router::RaftStoreRouter;
use crate::store::{Callback, RaftRouter, ReadResponse};
use engine_rocks::RocksEngine;
use engine_traits::RaftEngine;
use futures::executor::block_on;
use futures_util::compat::Future01CompatExt;
use kvproto::kvrpcpb::{ReadIndexRequest, ReadIndexResponse};
use kvproto::raft_cmdpb::{C... |
//! Functionality related to installing and running `wasm-bindgen`.
use binaries::{self, bin_path, install_binaries_from_targz_at_url};
use emoji;
use error::Error;
use progressbar::Step;
use slog::Logger;
use std::path::{Path, PathBuf};
use std::process::Command;
use target;
use PBAR;
/// Install the `wasm-bindgen` ... |
use crate::proto;
#[derive(Debug, Copy, Clone, PartialEq)]
#[repr(u8)]
pub enum Status {
// the transaction passed the precheck
Ok = 0,
// For any error not handled by specific error codes listed below.
InvalidTransaction = 1,
// Payer account does not exist.
PayerAccountNotFound = 2,
//... |
use gamework::video::color::ColorRGBA;
use gamework::video::*;
use gamework::*;
use std::collections::{HashMap, HashSet};
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct Rect {
pub x: i16,
pub y: i16,
pub width: i16,
pub height: i16,
pub focus: bool,
}
pub struct GuiRenderer {
gl: gl::... |
//! The central Framework struct that ties everything together.
mod dispatch;
mod builder;
pub use builder::*;
use crate::{serenity_prelude as serenity, BoxFuture};
pub use dispatch::{dispatch_message, find_command};
/// The main framework struct which stores all data and handles message and interaction dispatch.
... |
#![allow(unused_variables)]
#![allow(dead_code)]
#![allow(non_snake_case)]
#![feature(test)]
extern crate bn;
extern crate rand;
extern crate test;
use bn::*;
use rand::thread_rng;
pub struct Witness {
x0: Fr,
x1: Fr,
x2: Fr,
b: Fr, // though has to be restricted to 0 / 1
}
pub fn genwitness() -> Wit... |
use super::*;
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
#[repr(C)]
pub struct XINPUT_STATE {
pub dwPacketNumber: DWORD,
pub Gamepad: XINPUT_GAMEPAD,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
pub struct XINPUT_GAMEPAD {
pub wButtons: XINPUT_BUTTONS,
pu... |
use serde::{Deserialize, Serialize};
use swc_common::{
collections::{AHashMap, AHashSet},
errors::HANDLER,
Span, DUMMY_SP,
};
use swc_ecma_ast::*;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
use crate::{
config::{LintRuleReaction, RuleConfig},
rule... |
use std::path::{Component, Path, PathBuf};
/// Try decoding hex encoding after `%` in URIs.
///
/// If the hex encoding cannot be decoded to decimal, e.g. because of `%` in
/// filenames, bad requests, etc..., [`None`] will be returned.
///
/// Code from:
/// [`https://github.com/servo/rust-url/blob/master/percent_enc... |
use crate::core::{Error, Method, MovingAverage, PeriodType, ValueType, Window};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
/// Symmetrically Weighted Moving Average of specified `length` for timeseries of [`ValueType`].
///
/// F.e. if `length = 4`, then weights are: `[ 1.0, 2.0, 2.0, 1.0 ]`.
///
... |
use anyhow::{bail, Result};
use glob::glob;
use log::Level::Debug;
use log::{debug, log_enabled, warn};
use quick_xml::de::from_reader;
use serde::Deserialize;
use std::collections::HashMap;
use std::collections::HashSet;
use std::fs::canonicalize;
use std::fs::File;
use std::io::BufReader;
use std::iter::FromIterator;... |
use std::convert::From;
#[derive(Debug, PartialEq)]
enum MyNumeral {
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Zero,
}
impl MyNumeral {
fn numeral(&self) -> &str {
match *self {
MyNumeral::One => "one",
MyNumeral::Two => "two"... |
use std::{ffi::OsString, path::PathBuf};
use anyhow::{bail, Result};
use camino::Utf8PathBuf;
use cargo_metadata::PackageId;
use crate::{
cargo::Workspace,
cli::{BuildOptions, LlvmCovOptions, ManifestOptions},
env,
process::ProcessBuilder,
term,
};
pub(crate) struct Context {
pub(crate) ws: W... |
#![allow(non_snake_case, unused_unsafe)]
use std::mem;
use std::os::raw::c_void;
use std::sync::{Once, ONCE_INIT};
use winapi::shared::minwindef::{BOOL, UINT, FALSE};
use winapi::shared::windef::{
DPI_AWARENESS_CONTEXT,
DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE,
HMONITOR,
HWND,
};
use winapi::shared::wi... |
use std::collections::HashSet;
use std::sync::Arc;
use glsl_lang::ast::*;
use indexmap::IndexMap;
use super::template::{TemplateDefinition, TryTemplate};
use super::{ResolvedArgument, ResolvedArgumentExpr, Scope};
use crate::{Error, Result};
/// Result of parsing an ExternalDeclaration
pub enum ParsedDeclaration {... |
use crate::app_message::AppMessage;
use iced::{button, Button, Column, Container, Element, Row, Sandbox, Text};
// https://pages.mtu.edu/~suits/notefreqs.html
// we must round to nearest integer due to limitation of SineWave
// (see https://github.com/RustAudio/rodio/issues/187)
// Note Frequency (Hz)
// A4 ... |
// Copyright 2018 The Exonum Team
//
// 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... |
use crate::DiffLine;
/// Represents a single set of changes
#[derive(Debug, Clone, PartialEq)]
pub struct Delta {
old_lines_start: u32,
old_number_lines: u32,
new_lines_start: u32,
new_number_lines: u32,
context: String,
lines: Vec<DiffLine>,
}
impl Delta {
/// Create a new `Delta`.
#[inline]
#[must_use]
pu... |
//! A helper module to hold utilities that are used across tests. This file
//! DOES NOT container any of its own tests.
pub mod factories;
use crate::utils::factories::*;
use diesel::{
connection::TransactionManager, Connection, PgConnection, RunQueryDsl,
};
use diesel_factories::Factory;
use gdlk_api::{
mod... |
use crate::bitboard::Bitboard;
use crate::position::Position;
use crate::types::{Color, Direction, Piece};
use enum_map::{enum_map, EnumMap};
/// A fixed-point score value on the centipawn scale.
pub type Score = i64;
pub trait Evaluation {
/// Evaluate the position from the perspective of the player who is next ... |
use crate::execution::expr_evaluation::evaluate_predicate_with_ctx;
use crate::execution::{FilterOperation, NextTuple, SubQueryTuples};
use crate::parser::ast::{AttributeValue, Expr};
use crate::planner::plan::query_plan::QueryResultSchema;
use crate::storage::error::StorageError;
use crate::storage::storage_manager::A... |
mod parse_state;
use bytes::Bytes;
use parse_state::{ParseErr, ParseResult, ParseState};
use std::collections::BTreeMap;
use std::str;
use thiserror::Error;
const STRING_LENGTH_DATA_SEP: u8 = b':';
const INT_START: u8 = b'i';
const INT_END: u8 = b'e';
const LIST_START: u8 = b'l';
const LIST_END: u8 = b'e';
const DICT... |
use regex::Regex;
use std::clone::Clone;
use std::collections::HashMap;
type Connections = HashMap<String, Connection>;
pub enum Operand {
Scalar(u32),
Wire(String),
}
impl Operand {
fn new(value: String) -> Operand {
if let Ok(scalar) = value.parse() {
return Operand::Scalar(scalar);... |
use async_trait::async_trait;
use std::collections::HashMap;
use tokio_tungstenite::tungstenite::Message;
use super::EXCHANGE_NAME;
use crate::{
clients::common_traits::{
Candlestick, Level3OrderBook, OrderBook, OrderBookTopK, Ticker, Trade, BBO,
},
common::{
command_translator::CommandTran... |
// Copyright 2018 The Grin Developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... |
use std::num::NonZeroU16;
use crate::{Color, Rect, Point, Error};
use crate::font::{FontSource, Font};
use crate::theme_definition::CharacterRange;
/// A trait to be implemented on the type to be used for Event handling. See [`WinitIO`](struct.WinitIO.html)
/// for an example implementation. The IO handles e... |
use std::env;
use std::io::Write;
use ::regex::Regex;
use common::help::highlight;
use common::input::Terminator;
use common::run::{exec_run, Io, Result, EXIT_CODE_OK};
use crate::cli::Cli;
use crate::output::write_pattern_error;
use crate::pattern::parse::Separator;
use crate::pattern::regex::RegexHolder;
use crate:... |
// Copyright Notice: The Elder Scrolls, Morrowind, Oblivion, Skyrim, and Fallout are registered trademarks or
// trademarks of ZeniMax Media Inc.
//
//! Morrowind-style BSA archive bitflag, enum, and struct definitions and parsing functions
//!
//! BSA file structure documentation credit: <http://en.uesp.net/wiki/... |
// -*- mode: rust; -*-
//
// This file is part of `scuttlebutt`.
// Copyright © 2019 Galois, Inc.
// See LICENSE for licensing information.
mod hash_channel;
mod sync_channel;
mod track_channel;
pub use hash_channel::HashChannel;
pub use sync_channel::SyncChannel;
pub use track_channel::TrackChannel;
use crate::{Blo... |
// 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.
use super::{
devices::{BindingId, DeviceSpecificInfo, Devices, EthernetInfo},
DeviceStatusNotifier, InterfaceControl as _, LockableContext, Mutable... |
use crate::fields::FieldContent;
use serde::Serialize;
#[derive(Clone, Copy, Debug, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum MesgNum {
AccelerometerData,
Activity,
AntChannelId,
AntRx,
AntTx,
AviationAttitude,
BarometerData,
BikeProfile,
BloodPressure,
CadenceZon... |
use egui::{Color32, ImageData, TextureId, TexturesDelta};
use parking_lot::{Mutex, MutexGuard};
use std::{collections::HashMap, slice::from_raw_parts_mut};
use windows::Win32::Graphics::{
Direct3D::D3D11_SRV_DIMENSION_TEXTURE2D,
Direct3D11::{
ID3D11Device, ID3D11DeviceContext, ID3D11ShaderResourceView, ... |
//! Elliptic Curve Digital Signature Algorithm (ECDSA).
//!
//! This module contains support for computing and verifying ECDSA signatures.
//! To use it, you will need to enable one of the two following Cargo features:
//!
//! - `ecdsa-core`: provides only the [`Signature`] type (which represents an
//! ECDSA/secp256... |
use api::eds_grpc::EndpointDiscoveryService;
use futures::Future;
use config::Config;
use std::sync::Arc;
use consul::Client as ConsulClient;
#[derive(Clone)]
pub struct Service {
pub config: Config,
pub consul: ConsulClient,
}
use api::discovery::{DiscoveryRequest, DiscoveryResponse};
use grpcio::{RpcStatus... |
use super::Error;
use std::fmt;
#[derive(Clone)]
pub enum Operator {
Plus,
Minus,
Multiply,
Divide,
Set,
}
impl From<String> for Operator {
fn from(item: String) -> Self {
use Operator::*;
match item.as_str() {
"+" => Plus,
"-" => Minus,
"*" ... |
use failure::{bail, Fallible};
use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::io::BufWriter;
use std::path::PathBuf;
use std::process;
use std::process::{Command, Stdio};
use std::str;
use std::time::Instant;
use cargo_mutagen::*;
use mutagen_core::comm;
use mutagen_core::comm::{BakedMutation... |
use std::fmt::Write;
use crate::error::{Error, Result};
use crate::ser::identifier::format_as_identifier;
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct Field {
pub field_type: Type,
pub field_name: Option<String>,
}
impl Field {
pub fn with_type_and_name(field_type: Type, field_name: Option<Str... |
use std::fs::File;
use std::path::{Path, PathBuf};
use rand::{thread_rng, Rng};
use hex_database::{Track, Token, TrackKey, Files};
use hex_music_container::{Container, Configuration};
use crate::error::{Error, Result};
pub struct Stream {
pub track: Track,
container: Container<File>
}
impl Stream {
pub ... |
use crate::prelude::*;
use oauth2::TokenResponse as _;
// this needs to be fixed because we listen for it in a hardcoded place
pub const CLI_REDIRECT_URL: &str = "http://localhost:44141/oauth";
pub struct Oauth {
client: oauth2::basic::BasicClient,
user_id: String,
}
impl Oauth {
pub fn new(config: Confi... |
use crate::lang::errors::{argument_error_legacy, error, CrushResult};
use crate::lang::pipe::CrushStream;
use crate::lang::{data::table::ColumnType, data::table::Row, value::Value, value::ValueType};
use crate::util::identity_arc::Identity;
use crate::util::replace::Replace;
use chrono::Duration;
use ordered_map::Order... |
use std::{collections::VecDeque, net::SocketAddr, time::Instant};
use bytes::Bytes;
use log::{debug, error, info, trace, warn};
use crate::{
connection::ConnectionStatus,
packet::{ControlPacket, ControlTypes, DataPacket, FullAckSeqNumber, Packet},
protocol::{
encryption::Cipher,
receiver::... |
//! Parser for Ook!
#![experimental]
use std::io::{EndOfFile, InvalidInput, IoError, IoResult, standard_error};
use std::str::from_utf8;
use bytecode::ByteCodeWriter;
use syntax::Compiler;
use syntax::brainfuck::{Instructions, Token, MoveRight, MoveLeft, Increment, Decrement, Put, Get, LoopStart, LoopEnd};
struct T... |
/* MIT License
*
* Copyright (c) 2019 <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, mo... |
use std::slice;
use std::ffi::{CStr, CString};
use std::ptr;
use std::sync::Mutex;
use std::collections::BTreeMap;
use libc::{c_int};
use lazy_static::lazy_static;
use epics_sys::{
self,
iocshRegister, iocshFuncDef,
iocshArg, iocshArgType, iocshArgBuf,
};
lazy_static! {
static ref COMMANDS: Mutex<BT... |
#[derive(Copy, Clone, PartialEq)]
pub enum Cell {
Wall,
Box,
Docker,
Place,
BoxOnPlace,
DockerOnPlace,
Space,
}
impl Cell {
pub const BOX: u8 = b'#';
pub const BOX_ON_PLACE: u8 = b'!';
pub const DOCKER: u8 = b'*';
pub const DOCKER_ON_PLACE: u8 = b'@';
pub const PLACE: u8... |
use crate::document::DocumentMessageHandler;
use crate::frontend::utility_types::MouseCursorIcon;
use crate::input::keyboard::{Key, MouseMotion};
use crate::input::InputPreprocessorMessageHandler;
use crate::layout::widgets::PropertyHolder;
use crate::message_prelude::*;
use crate::misc::{HintData, HintGroup, HintInfo,... |
//! A `Zome` is a module of app-defined code which can be run by Holochain.
//! A group of Zomes are composed to form a `Dna`.
//!
//! Real-world Holochain Zomes are written in Wasm.
//! This module also provides for an "inline" zome definition, which is written
//! using Rust closures, and is useful for quickly defini... |
// cli.rs
//
// Copyright (c) 2020 All The Music, LLC
//
// This work is licensed under the Creative Commons Attribution 4.0 International License.
// To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send
// a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
us... |
// Built-in uses
use std::collections::HashMap;
// External uses
use num::rational::Ratio;
use num::BigUint;
use serde::Deserialize;
// Workspace uses
use zksync_types::Address;
// Local uses
use crate::envy_load;
#[derive(Debug, Deserialize, Clone, Copy, PartialEq)]
pub enum TokenPriceSource {
CoinGecko,
Coin... |
// Copyright (C) 2021 <NAME> <<EMAIL>>
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Builds `char_class_table.bin`, a table of byte values to the character
//! classes the respective bytes are part of. Most classes are referenced from
//! [RFC 7235 Appendix B: Imported ABNF](https://datatracker.ietf.org/doc/html/r... |
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use glib;
use glib::object::Cast;
use glib::object::IsA;
use glib::object::ObjectExt;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use gl... |
#[macro_use]
extern crate clap;
extern crate colored;
extern crate xmltree;
mod utils;
use std::cmp::{Ord, Ordering};
use colored::*;
use xmltree::Element;
use crate::utils::{log_print, LogLevel};
use clap::{App, Arg};
#[derive(Debug, Eq, PartialEq, PartialOrd)]
struct Attr<'attr> {
key: &'attr str,
value: &'at... |
use native_tls::{TlsConnector, TlsStream};
use notify_rust::Notification;
use serde::Deserialize;
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::io::prelude::*;
use std::net::TcpStream;
use std::process::Command;
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
#[derive(Debug, Clone, Des... |
use super::super::components::schemas::parse_type;
use crate::paths::verb_path::VerbPath;
use openapiv3::{Parameter, ParameterData, ReferenceOr};
use regex::Regex;
use scraper::Selector;
lazy_static! {
static ref PATH_PARAM_REGEX: Regex = Regex::new(r"\{([^}]+)}").unwrap();
static ref PARAMS_TABLE_SELECTOR: Se... |
use std::fs;
fn main() {
let contents = fs::read_to_string("Day9.txt").expect("Error");
let program: Vec<String> = contents.split(",").map(|s| s.to_owned()).collect();
let mut computer = IntcodeComputer::new(program.clone(), 1);
computer.phase_setted = true;
computer.process(1);
println!("Resul... |
use crate::association::RtxTimerId;
use async_trait::async_trait;
use std::sync::Arc;
use tokio::sync::{mpsc, Mutex};
use tokio::time::Duration;
pub(crate) const RTO_INITIAL: u64 = 3000; // msec
pub(crate) const RTO_MIN: u64 = 1000; // msec
pub(crate) const RTO_MAX: u64 = 60000; // msec
pub(crate) const RTO_ALPHA: u64... |
/* Copyright (c) Fortanix, Inc.
*
* Licensed under the GNU General Public License, version 2 <LICENSE-GPL or
* https://www.gnu.org/licenses/gpl-2.0.html> or the Apache License, Version
* 2.0 <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0>, at your
* option. This file may not be copied, modified, or ... |
use std::collections::HashMap;
use std::sync::Arc;
use arret_syntax::span::Span;
use crate::context::ModuleId;
use crate::hir::macros::linker::{TemplateIdent, VarLinks};
use crate::hir::macros::matcher::MatchData;
use crate::hir::macros::{get_escaped_ident, starts_with_zero_or_more, Macro};
use crate::hir::ns::{Ident... |
// Copyright (c) 2018-2020 MobileCoin Inc.
//! Code for computing and decrypting fog hints
use crate::encrypted_fog_hint::{EncryptedFogHint, EncryptedFogHintSize};
use core::convert::TryFrom;
use mc_account_keys::PublicAddress;
use mc_crypto_box::{
generic_array::{
typenum::{Diff, Unsigned},
Gener... |
use crate::map::get_tile_renderable;
use crate::{Hidden, Map, Position, Renderable, Target, TileSize};
use rltk::prelude::*;
use specs::prelude::*;
pub fn get_screen_bounds(ecs: &World, _ctx: &mut Rltk) -> (i32, i32, i32, i32) {
let player_pos = ecs.fetch::<Point>();
//let (x_chars, y_chars) = ctx.get_char_siz... |
use std::{cell::Cell, fmt, io};
use bitflags::bitflags;
use crate::codec::{Decoder, Encoder};
use crate::http::body::BodySize;
use crate::http::config::DateService;
use crate::http::error::ParseError;
use crate::http::message::ConnectionType;
use crate::http::request::Request;
use crate::http::response::Response;
use... |
//! # Blackjack written in Rust
//! [](https://qiita.com/hirossyi73/items/cf8648c31898216312e5)
//! ## Rule
//! - A player (You) vs. dealer (Computer)
//! - A deck initially consists of 52 cards.
//! - Firstly the dealer draws 2 cards and reveals one of them.
//! - Player's turns:
//! - Draw a card.
//! - You ... |
#![allow(dead_code)]
struct DepreciationRateSchedule {
month : usize,
depreciation_rate : f64,
}
impl DepreciationRateSchedule {
fn new(initial_rate: f64) -> DepreciationRateSchedule {
DepreciationRateSchedule {
month : 0,
depreciation_rate : initial_rate,
}
}
... |
use crate::{
test_utils::{MockServer, DEFAULT_TERMINAL_BLOCK, DEFAULT_TERMINAL_DIFFICULTY, JWT_SECRET},
Config, *,
};
use environment::null_logger;
use sensitive_url::SensitiveUrl;
use std::sync::Arc;
use task_executor::TaskExecutor;
use tempfile::NamedTempFile;
use types::{Address, ChainSpec, Epoch, EthSpec, H... |
use core::convert::TryFrom;
#[derive(Debug)]
#[cfg_attr(feature = "ufmt", derive(ufmt::derive::uDebug))]
pub enum Error<I> {
/// An error occurred in the I2C communication.
I2c(I),
/// Errors produced from the original API.
St(StError),
/// A warning that was considered bad enough to be an error in... |
use std::collections::HashMap;
use crate::{
config::Config,
deps::{
holodeck_core::messages::SimulationState,
kiss3d::{
light::Light,
nalgebra::{
Point3,
Translation3,
Vector3,
},
resource::MeshManag... |
// Copyright 2020 <NAME>
//
// 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,... |
#![feature(const_vec_new)]
#![feature(vec_remove_item)]
#![feature(test)]
#![allow(dead_code)]
#[macro_use]
use std::cell::RefCell;
use crate::rng::wasm_rng;
use wasm_bindgen::prelude::*;
mod algorithms;
mod rng;
mod grid;
mod cells;
mod tests;
use crate::grid::{Grid,
standard_grid::StandardGrid,
distances::D... |
use serde::{Deserialize, Serialize};
use structopt::StructOpt;
fn commit_msg() -> String {
"$1+".to_string()
}
#[derive(Serialize, Deserialize, Debug, StructOpt, PartialEq, Clone)]
pub struct Arguments {
/// type of action. run the `action` / `actions` action to see available actions.
pub action: String,
/// arg... |
fn main() {
println!("Hello, world!");
}
// Número de Armstrong
const RADIX: u32 = 10;
pub fn is_armstrong_number(num: u32) -> bool {
let pow = num.to_string().len() as u32;
num.to_string()
.chars()
.into_iter()
// or: .map(|c| c.to_digit(RADIX).unwrap())
.filter_map(|c| c.to_dig... |
use crate::utilities::format_int;
use chrono::prelude::*;
use itertools::Itertools;
use reqwest::blocking::Client;
use reqwest::redirect::Policy;
use reqwest::StatusCode;
use serde::Deserialize;
use serenity::client::Context;
use serenity::framework::standard::macros::command;
use serenity::framework::standard::Ar... |
// external
use pyo3::prelude::*;
use rand::Rng;
use rand_distr::{Distribution, Beta, Gamma, Normal, FisherF};
#[pyclass]
#[derive(Clone)]
pub struct Agent {
a_type: usize, // 0: PHH, 1: BSLa, 2: BSLc
#[pyo3(get)]
coc: f32,
#[pyo3(get)]
demand_apv: f32,
#[pyo3(get)]
hw_demand: f32, // mea... |
use crate::Feerate;
use async_trait::async_trait;
use bitcoin::{Block, BlockHash, Network, Transaction};
use bitcoincore_rpc::bitcoincore_rpc_json::EstimateMode;
use bitcoincore_rpc::RpcApi;
use tracing::warn;
/// Trait that allows interacting with the Bitcoin blockchain
///
/// Functions may panic if if the bitcoind ... |
#[macro_use]
extern crate log;
use std::{env, process, fs, thread};
use std::collections::HashMap;
use std::net::{IpAddr, Ipv4Addr};
use std::time::Duration;
use pnet::packet::ip::IpNextHeaderProtocols;
use pnet::packet::tcp::{self, MutableTcpPacket, TcpFlags};
use pnet::transport::{
self,
TransportChannelTy... |
//! This module implements the logic needed to apply the proper analysis passes to simplify the IR.
use petgraph::algo::tarjan_scc;
use petgraph::Graph;
use rayon::prelude::*;
use std::any::Any;
use std::collections::HashMap;
use std::fmt::Debug;
use crate::analysis::analyzer;
use crate::analysis::analyzer::{
A... |
use crate::{
edge::{Edge, EdgeData},
graph::{EdgeArrayEntry, EdgeID, Graph, NodeID},
};
use core::{cmp::max, ops::Range};
pub struct NodeArrayEntry {
pub first_edge: EdgeID,
}
impl NodeArrayEntry {
pub fn new(e: EdgeID) -> NodeArrayEntry {
NodeArrayEntry { first_edge: e }
}
}
pub struct St... |
use crate::{CloneCounter, Config, Server};
use std::{
convert::{TryFrom, TryInto},
io::ErrorKind,
net::{SocketAddr, TcpListener, ToSocketAddrs},
};
use trillium::Handler;
use trillium_http::{transport::BoxedTransport, Conn as HttpConn, Error, Stopper};
use trillium_tls_common::Acceptor;
/// # Server-impleme... |
use crate::clients::api_client::{claim_item, claim_string};
use crate::clients::{
sparql_client, ApiClient, ApiError, ObjectType, PropertyDataType, SparqlClient,
};
use crate::known_entities::{EntitiesId, Items, Properties};
use anyhow::Error;
use inflector::Inflector;
pub struct Client {
pub api: ApiClient,
... |
//! cmos includes the functionality to read the CMOS/RTC, returning a
//! low-precision wall clock time.
// The cloc functionality is captured in the Time type,
// which can be produced by reading the current time from
// the CMOS/RTC. A static BOOT_TIME instance is initialsed
// with the time when ::init is called, w... |
/*
* Copyright 2022 Cargill Incorporated
*
* 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 a... |
//! Describes items defined or visible (ie, imported) in a certain scope.
//! This is shared between modules and blocks.
use hir_expand::name::Name;
use once_cell::sync::Lazy;
use rustc_hash::FxHashMap;
use crate::{per_ns::PerNs, BuiltinType, ImplId, MacroDefId, ModuleDefId, TraitId};
#[derive(Debug, Default, Partia... |
extern crate serde;
#[macro_use]
extern crate serde_derive;
// TODO(high): insert a single blank entry/line, treat it specially, such that enter on it just exits is ignored but enter on other chars actually enters them
// TODO(high): fix enter giving \n bug
// TODO(high): fix delimiter to not act up on very long strin... |
use super::*;
use exception::*;
use process::pid_t;
use std::ffi::{CStr, CString, OsString};
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Once;
use util::mem_util::from_untrusted::*;
const ENCLAVE_PATH: &'static str = ".occlum/build/lib/libocclum.signed.so";
lazy_stati... |
//! atty is a simple utility that answers one question
//! > is this a tty?
//!
//! usage is just as simple
//!
//! ```
//! if atty::is(atty::Stream::Stdout) {
//! println!("i'm a tty")
//! }
//! ```
//!
//! ```
//! if atty::isnt(atty::Stream::Stdout) {
//! println!("i'm not a tty")
//! }
//! ```
#![cfg_attr(unix,... |
use std::collections::HashSet;
use std::fs::File;
use std::io::prelude::*;
use std::io::{self, BufReader};
use std::iter::FromIterator;
use std::str::FromStr;
#[derive(Clone, Debug, Copy)]
pub struct Step {
direction: Direction,
magnitude: isize,
}
#[derive(Clone, Copy, Debug)]
pub struct Line {
x1: isize... |
use std::path::Path;
use std::fs;
use std::io::{self, Write, Read};
use std::process::{Command, Stdio};
use regex::Regex;
use semver::VersionReq;
use {Result, ResultExt};
#[derive(Debug)]
struct CrateImport {
name: String,
package_name: String,
version: String,
macro_use: bool,
}
impl CrateImport {
... |
use crate::interfaces::MacAddr;
use crate::{arp::ArpMessage, interfaces::Interface};
use pnet::{
datalink::DataLinkReceiver,
packet::{
arp::ArpPacket,
ethernet::{EtherTypes, EthernetPacket, MutableEthernetPacket},
},
};
use std::convert::TryInto;
use std::time::Duration;
use std::{
io::{... |
use crate::commands::CommandContext;
use crate::database::commit::Commit;
use crate::database::object::Object;
use crate::database::{Database, ParsedObject};
use crate::pager::Pager;
use crate::refs::Ref;
use crate::repository::Repository;
use colored::*;
use std::collections::HashMap;
use std::io::{Read, Write};
#[de... |
use crate::{errors::Smm2Error, Result};
use aes::{cipher::generic_array::GenericArray, Aes128};
use block_modes::{block_padding::ZeroPadding, BlockMode, Cbc};
use cmac::{Cmac, Mac, NewMac};
use crc::{Crc, CRC_32_ISO_HDLC};
use rand::Rng;
use std::convert::TryInto;
use typenum::*;
pub fn decrypt(bytes: &mut [u8], key_... |
// Copyright (c) SimpleStaking, Viable Systems and Tezedge Contributors
// SPDX-License-Identifier: MIT
use std::{
collections::HashMap,
convert::{TryFrom, TryInto},
};
use crate::{
kv_store::{HashId, VacantObjectHash},
persistent::DBError,
ObjectHash,
};
use super::index_map::IndexMap;
/// Cont... |
mod parse;
use derive_more::{Add, Sub};
use derive_try_from_primitive::TryFromPrimitive;
use nom::bytes::complete::{tag, take};
use nom::{error::context, sequence::tuple};
use std::convert::TryFrom;
impl_parse_for_enum!(Type, le_u16);
impl_parse_for_enum!(Machine, le_u16);
#[derive(Debug, Clone, Copy, PartialEq, Eq,... |
#[allow(dead_code)]
extern crate hex;
use std::collections::HashMap;
use std::f64;
use std::str::from_utf8;
use std::vec::Vec;
const ASCII_A: u8 = 65;
const ASCII_Z: u8 = 90;
pub fn find_key_str(hex_str: Vec<u8>) -> (f64, u8) {
let mut chi_min: f64 = 0.0;
let mut secret: u8 = 0;
for i in ASCII_A..ASCII_... |
mod utils;
use std::convert;
use std::fmt;
use std::mem;
use wasm_bindgen::prelude::*;
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
#[wasm_bindgen]
#[repr(u8)]
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.