text stringlengths 3.09k 13.9k |
|---|
extern crate yn;
#[test]
fn test_yes() {
assert!(yn::yes("y"));
assert!(yn::yes("yes"));
assert!(yn::yes("yes"));
assert!(yn::yes("yes"));
assert!(yn::yes("this contains a yes"));
assert!(yn::yes("true"));
assert!(yn::yes("1"));
assert!(yn::yes("NO. Stop it. NOOO! haha jk it's actually yes"));
assert... |
// 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
use std::{
fmt,
sync::{Arc, Mutex},
};
use anyhow::{anyhow, Result};
use async_trait::async_trait;
use chrono::{DateTime, Local};
use tracing::trace;
use super::{Store, DEFAULT_HISTORY_SIZE};
use crate::measure::Measurement;
pub struct InMemory {
inner: Arc<Mutex<Inner>>,
history_size: usize,
}
#[de... |
use crate::{from_params, into_params, Params};
use bytes::buf::ext::BufExt;
use failure::Error;
pub use failure::SyncFailure;
use futures::{future, TryFutureExt};
use hyper::{http, service::Service, Body, Request};
use std::future::Future;
use std::pin::Pin;
use std::{
collections::HashMap,
net::SocketAddr,
... |
use proc_macro::TokenStream;
use proc_macro2::Span;
use quote::quote;
use syn::parse::{Parse, ParseStream};
use syn::{parse_macro_input, Ident, Result, Token, Type};
mod kw {
syn::custom_keyword!(to);
syn::custom_keyword!(with);
}
#[proc_macro]
pub fn attach(input: TokenStream) -> TokenStream {
// parse i... |
//! Block Devs provides safe wrappers for the ioctl calls for
//! dealing with block devices (USB sticks, SSDs, hard drives etc).
//!
//! It aims to provide a consitent interface across all platforms for things like
//! getting the number of bytes a disk has.
//!
//! So far Linux, macOS and Open BSD are supported
//!
/... |
#[macro_use]
extern crate lazy_static;
extern crate discord;
extern crate common_void;
mod managed_channel;
use std::sync::Mutex;
use std::collections::HashMap;
use discord::Discord;
use discord::model::{ServerId, VoiceState, ChannelId, UserId, Channel, ChannelType};
use managed_channel::ManagedChannel;
use common_vo... |
use log::debug;
use rustc_serialize::hex::{FromHex, ToHex};
use std::iter;
use std::ops::BitXor;
use std::ops::BitXorAssign;
use std::vec;
pub fn l2norm(a: &[f64]) -> f64 {
let mut r;
let mut s = 1.0;
let mut t = 0.0;
for val in a {
let abs = val.abs();
if abs > t {
r = t /... |
/// The entry is a type of change that needs to be applied. It contains two data fields.
/// While the fields are built into the model; their usage is determined by the entry_type.
///
/// For normal entries, the data field should contain the data change that should be applied.
/// The context field can be used for any... |
extern crate mackerel_plugin;
use mackerel_plugin::*;
use std::collections::HashMap;
use std::io::{BufRead, BufReader};
use std::process::{Command, Stdio};
use std::str::FromStr;
#[derive(PartialEq, Debug)]
struct NtpInfo {
pub when: Interval,
pub poll: Interval,
pub reach: Reach,
pub delay: f64,
... |
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor 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 ... |
use crate::lib::environment::Environment;
use crate::lib::error::DfxResult;
use crate::lib::identity::identity_utils::CallSender;
use crate::lib::models::canister_id_store::CanisterIdStore;
use crate::lib::operations::canister;
use crate::lib::root_key::fetch_root_key_or_anyhow;
use crate::util::clap::validators::{
... |
// MIT License
// Copyright (c) 2019 <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 limitation the rights
// to use, copy, modify, merge, p... |
use dacite::core::{Device, RenderPass, Framebuffer, Extent2D, ImageView,
CommandBuffer};
use crate::error::Error;
use crate::renderer::swapchain_data::SwapchainData;
use crate::renderer::image_wrap::ImageWrap;
pub struct UiPass {
pub framebuffers: Vec<Framebuffer>,
pub swapchain_image_views... |
use std::iter;
use std::collections::HashMap;
#[allow(dead_code)]
const TEST: &str = r#"ecl:gry pid:860033327 eyr:2020 hcl:#fffffd
byr:1937 iyr:2017 cid:147 hgt:183cm
iyr:2013 ecl:amb cid:350 eyr:2023 pid:028048884
hcl:#cfa07d byr:1929
hcl:#ae17e1 iyr:2013
eyr:2024
ecl:brn pid:760753108 byr:1931
hgt:179cm
hcl:#cfa0... |
use std::{
fs::File,
io::{prelude::*, BufReader},
path::Path,
};
struct HydrothermalLineSegment {
x1: usize,
y1: usize,
x2: usize,
y2: usize,
}
pub struct HydrothermalMap {
line_segments: Vec<HydrothermalLineSegment>,
point_map: Vec<Vec<usize>>,
}
impl Default for HydrothermalMap ... |
use jlrs::prelude::*;
use std::time::Duration;
// This struct contains the data our task will need. This struct must implement `Send`, `Sync`,
// and contain no borrowed data.
struct AccumulatorTask {
init_value: f64,
}
// `Implement `GeneratorTask` for `AccumulatorTask`. This requires `async_trait` because trait... |
use anyhow::{anyhow, bail, Context, Result};
use tokio::sync::oneshot;
use glib::{MainContext, MainLoop};
use std::collections::HashSet;
use std::future::Future;
use serde::Serialize;
use nm::*;
const WIFI_SCAN_TIMEOUT_SECONDS: usize = 45;
type TokioResponder = oneshot::Sender<Result<NetworkResponse>>;
#[derive... |
//! As the name implies, d3-core is the core foundation for the server. It is responsible for creating
//! a d3 machine from a raw implementation, scheduling that machine to run and running it. Creating a
//! machine is trivial, as the exmples illustate.
//!
//! # examples
//! ```
//! # use std::sync::Arc;
//! # use pa... |
//! A library wrapping various IPC mechanisms with a datagram-oriented
//! messaging layer. This is how CCP communicates with the datapath.
use super::Error;
use super::Result;
use std::rc::{Rc, Weak};
use std::sync::{atomic, Arc};
use tracing::{info, trace};
/// Thread-channel implementation
pub mod chan;
#[cfg(all(... |
//! `ws` contains the types and functions for the web socket notifications API of the Liquid Network hub.
//! The notifications can be sent and received on both HTTP and HTTPS.
use crate::utils::UUID;
use serde::{Deserialize, Serialize};
/// `GenericRequest` is a generic request in the WS Notification API.
#[derive(... |
use crate::mode::Mode::{self, Command, Insert, Normal};
use crate::revi_command::ReViCommand::{
self, Backspace, ChangeMode, CursorDown, CursorLeft, CursorRight, CursorUp, DeleteChar,
DeleteLine, End, EnterCommandMode, ExcuteCommandLine, ExitCommandMode, FirstCharInLine, Home,
JumpToFirstLineBuffer, JumpToL... |
use std::str::FromStr;
use crate::util::get_file_lines;
use crate::structs::Block;
use crate::structs::BlockConf;
use crate::structs::Colors;
#[derive(Debug, Default)]
struct MemInfo {
mem_total: f32,
mem_free: f32,
mem_free_percent: f32,
mem_used: f32,
mem_used_percent: f32,
swap_total: f32,
swap_free: f32,
... |
/*
* Copyright (c) 2015-2021, SALT.
* This file is part of HashtagBlessedII and is distributed under the 3-clause BSD license.
* See LICENSE.md for terms of use.
*/
use core::{future::Future, pin::Pin};
use crate::hos::{hport::HPort, hhandle::HHandle, hclientsession::HClientSession, hclientsession::HClientSessionH... |
use schemars::schema::{RootSchema, Schema};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
/// Current version of the ABI schema format.
const ABI_SCHEMA_SEMVER: &str = "0.1.0";
/// Contract ABI.
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
pub struct AbiRoot {
/// Semver of the... |
use std::error::Error;
use std::fmt;
use std::time::SystemTime;
use rusqlite::{ Connection };
use reqwest::header;
//##: Global definitions
static USERAGENT: &str = "Hydra (PodcastIndex)/v0.1";
struct Podcast {
id: u64,
url: String,
title: String
}
#[derive(Debug)]
struct HydraError(String);
//##: Impleme... |
use ansi_term::Style;
use eyre::{eyre, Report, Result, WrapErr};
use indenter::indented;
use ini::Ini;
use std::convert::TryFrom;
use std::fmt::Write;
use std::fs;
use std::{
fmt::Display,
path::{Path, PathBuf},
};
use super::creation::{link_path::link_path, python_version::PythonVersion};
pub struct Virtuale... |
// Copyright 2018 Google 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... |
extern crate sdl2;
use sdl2::pixels::Color;
use sdl2::rect::Rect;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use crate::view_components::{ViewComponent, IntoViewComponent};
use crate::backend::system::window::Window;
use crate::colors;
use super::{Widget, WidgetState};
use super::Text;
/// TextBox widget
... |
use arrayvec::ArrayString;
use itertools::Itertools;
use std::fmt;
use std::fmt::Write;
use std::iter;
use std::ops;
use std::slice;
const SEGMENT_LENGTH: usize = 4;
// CHUNK_LENGTH should be a multiple of SEGMENT_LENGTH
const CHUNK_LENGTH: usize = 16;
const NUM_SEGMENTS_PER_CHUNK: usize = ((CHUNK_LENGTH + SEGMENT_LE... |
//! The ``video`` module of ``ogc-rs``.
//!
//! This module implements a safe wrapper around video functions.
use crate::{mem_cached_to_uncached, system::System};
use alloc::boxed::Box;
use core::{convert::TryFrom, ffi::c_void, mem, ptr};
use num_enum::{IntoPrimitive, TryFromPrimitive};
pub struct RenderConfig {
... |
use anyhow::Error;
use derive_more::{Display, Into};
use serde::{Deserialize, Serialize};
use std::{
convert::TryFrom,
f64::consts::PI,
fmt,
hash::{Hash, Hasher},
str::FromStr,
};
const RADIANS_PER_TURN: f64 = 2.0 * PI;
/// Angle in degrees
#[derive(Into, Debug, Copy, Clone, PartialOrd, Serialize,... |
use std::collections::HashMap;
use std::collections::HashSet;
use regex::Regex;
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub struct Rule {
field: String,
bounds: Vec<(i64, i64)>,
}
impl From<&str> for Rule {
fn from(s: &str) -> Self {
let re = Regex::new(r"(.*): (\d+)-(\d+) or (\d+)-(\d+)").u... |
use std::fmt;
pub const KEY_LENGTH_IN_BYTES: usize = 16;
#[derive(Clone, Copy)]
pub struct Key {
bytes: [u8; KEY_LENGTH_IN_BYTES],
}
struct KeyRegister {
a: u64,
b: u64,
}
impl Key {
pub fn new(bytes: &[u8]) -> Key {
let mut b = [0u8; KEY_LENGTH_IN_BYTES];
match bytes.len() {
... |
use reqwest::blocking::multipart;
use serde::{Deserialize, Serialize};
use std::fmt;
use std::fs::OpenOptions;
use std::io::copy;
use std::time::SystemTime;
/// Representa una conexion, contiene ip y puerto.
#[derive(Deserialize, Serialize, Clone)]
pub struct Connection {
pub ip: String,
pub port: String,
}
i... |
// The MIT License (MIT)
//
// Copyright (c) 2015 <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 limitation the rights
// to use, copy, mo... |
mod listener;
mod tcp;
mod unix;
use std::{
borrow::Borrow,
collections::{HashMap, HashSet},
error::Error,
ffi::CString,
fmt::Debug,
hash::Hash,
io,
marker::Unpin,
sync::Arc,
};
use futures::stream::StreamExt;
use hyper::{body::to_bytes, server::conn::Http, service, Body, Request, ... |
use blockchain::{
Block,
Transaction,
};
use jsonrpc_derive::rpc;
use crate::methods::{
add_block,
get_address_ammount,
get_block_with_hash,
get_block_with_prev_hash,
get_chain_length,
get_node_address,
make_handshake,
};
use client::{
HandshakeRequest,
NodeClient,
};
use fu... |
use crate::float;
use super::{ComplexNumberType, KalkValue, CONSTANTS};
pub(super) fn estimate(
input: &KalkValue,
complex_number_type: ComplexNumberType,
) -> Option<String> {
let (real, imaginary, _) = if let KalkValue::Number(real, imaginary, unit) = input {
(real, imaginary, unit)
} else {... |
use std::cmp::min;
use bytes::Bytes;
use ethereum_types::{Address, H256};
use super::*;
use crate::{
common::{address_to_u256, u256_to_address},
host::AccessStatus,
instructions::{memory::MemoryRegion, properties::*},
CallKind, Host, Message,
};
pub(crate) async fn call<H: Host>(
host: &mut H,
... |
use blog_common::dto::post::PostDetail as PostDetailDto;
use blog_common::dto::Response;
use gloo::utils::document;
use time::format_description;
use time::OffsetDateTime;
use wasm_bindgen::prelude::*;
use web_sys::{Element, Node};
use yew::prelude::*;
use yew_router::prelude::*;
use crate::i18n;
use crate::router::Ro... |
use crate::consts;
use crate::instruction::Instruction;
use crate::typedef::*;
use flate2::{read::GzDecoder, write::GzEncoder, Compression};
use semver::Version;
use serde::{Deserialize, Serialize};
use std::{
fs,
io::{Read, Write},
path::Path,
};
/// The container for a program
///
/// You can load a `Pro... |
use rstest::rstest;
use autorel_chlg::{BreakingInfo, Change, ChangeLog, ChangeType, SemverScope};
fn semver_scope_of(message: &str) -> Option<SemverScope> {
let change = Change::parse_conventional_commit(message).expect("Not a conventional commit");
let changelog = ChangeLog::default() + change;
changelog... |
mod date;
mod filetype;
mod indicator;
mod inode;
mod links;
pub mod name;
mod owner;
mod permissions;
mod size;
mod symlink;
#[cfg(windows)]
mod windows_utils;
pub use self::date::Date;
pub use self::filetype::FileType;
pub use self::indicator::Indicator;
pub use self::inode::INode;
pub use self::links::Links;
pub u... |
use serde::{Deserialize, Serialize};
use swc_common::{collections::AHashSet, errors::HANDLER, Span, SyntaxContext};
use swc_ecma_ast::*;
use swc_ecma_utils::{collect_decls_with_ctxt, ident::IdentLike};
use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
use crate::{
config::{LintRuleReaction, RuleConfig},
... |
use std::cmp::Ordering;
use std::fmt::{Display, Formatter};
use std::net::IpAddr;
use std::str::FromStr;
use itertools::Itertools;
use crate::bgp::attributes::{AsPath, AtomicAggregate, Origin};
use crate::bgp::community::*;
use crate::network::{Asn, NetworkPrefix};
use serde::Serialize;
/// Element type.
///
/// - ANN... |
//! Utilities for mapping between offset:length bytes and col:row character positions.
use rowan::{TextRange, TextSize};
use std::collections::BTreeMap;
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Copy, Clone, Default)]
pub struct Position {
/// Line position in a document (could be zero-based or one-based b... |
//! Parse syntax for `view!` macro.
use std::fmt;
use syn::ext::IdentExt;
use syn::parse::{Parse, ParseStream};
use syn::punctuated::Punctuated;
use syn::token::{Brace, Paren};
use syn::{braced, parenthesized, token, Expr, FieldValue, Ident, LitStr, Result, Token};
use super::ir::*;
impl Parse for ViewRoot {
fn... |
//! Parse options parameter to `Regexp#initialize` and `Regexp::compile`.
use onig::RegexOptions;
use crate::extn::core::regexp::Regexp;
use crate::types::Int;
use crate::value::{Value, ValueLike};
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
pub struct Options {
pub multiline: bool,
pub ignor... |
//! IANA Media Types.
//!
//! [Read more](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types).
mod constants;
mod parse;
pub use constants::*;
use std::borrow::Cow;
use std::fmt::{self, Debug, Display};
use std::option;
use std::str::FromStr;
use crate::headers::{HeaderValue, ToHeaderValues... |
use crate::segment_manager::holders::segment_holder::{SegmentId, LockedSegment, LockedSegmentHolder};
use segment::types::{SegmentType, SegmentConfig};
use ordered_float::OrderedFloat;
use crate::segment_manager::optimizers::segment_optimizer::{SegmentOptimizer, OptimizerThresholds};
use std::path::{PathBuf, Path};
p... |
// Copyright © 2021 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
// bindgen /usr/include/linux/sockios.h --no-layout-tests
/* automatically generated by rust-bindgen 0.58.1 */
pub const __BITS_PER_LONG: u32 = 64;
pub const FIOSETOWN: u32 = 35073;
pub const SIOCSPGRP: u32 = 35074;
pub const FIOGETOW... |
/*
MIT License
Copyright (c) 2021 <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 limitation the rights
to use, copy, modify, merge, publish, distribut... |
//! Soft-link with `config.toml`
//!
//! leetcode-cli will generate a `leetcode.toml` by default,
//! if you wanna change to it, you can:
//!
//! + Edit leetcode.toml at `~/.leetcode/leetcode.toml` directly
//! + Use `leetcode config` to update it
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, fs,... |
use crate::prelude::String;
use core::fmt::Debug;
use displaydoc::Display;
pub struct WrappedError<T: Debug>(pub T);
#[derive(Display, Debug)]
pub enum Errors {
//////////
// Generic
//////////
/// Max size exceeded (expected: {0}, found: {1})
MaxSizeExceeded(usize, usize),
/// Value out of r... |
//
// ISO/IEC 14496-12:2015(E)
// 8.9.3 Sample Group Description Box
//
use std::fmt::Debug;
use std::io;
use crate::boxes::prelude::*;
def_box! {
/// 8.9.3 Sample Group Description Box
SampleGroupDescriptionBox {
grouping_type: FourCC,
default_length: {Option<u32>},
... |
use super::*;
use crate::auth::*;
use crate::relay::relay_static::*;
use crate::server::{config::*, *};
use std::net::IpAddr;
use tokio::net::UdpSocket;
use tokio::time::Duration;
use util::vnet::net::*;
async fn create_listening_test_client(rto_in_ms: u16) -> Result<Client> {
let conn = UdpSocket::bind("0.0.0.0... |
//
// Copyright (c) 2017, 2020 ADLINK Technology Inc.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.or... |
// Copyright 2019 Parity Technologies (UK) Ltd.
//
// 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, mer... |
#![deny(
missing_debug_implementations,
missing_copy_implementations,
trivial_casts,
trivial_numeric_casts,
unsafe_code,
unused_import_braces,
unused_qualifications
)]
#[macro_use]
extern crate clap;
extern crate base64;
extern crate md5;
extern crate pbr;
extern crate reqwest;
extern crate... |
// This file is part of Substrate.
// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the F... |
use clap::ArgMatches;
use client::client::Github;
use config::context::BardoContext;
use std::env;
use crate::commands::issues::get::GetIssuesCommandExecutor;
use crate::commands::labels::get::GetLabelsCommand;
use crate::commands::pulls::get::GetPullsCommand;
use crate::commands::repo::clone::CloneRepoCommandExecutor... |
use std::{
fmt::{Display, Formatter, Result as FmtResult},
fs, io,
path::{Path, PathBuf},
process::Command,
};
use serde::{Serialize, Serializer};
use tempfile::Builder as TempFileBuilder;
use thiserror::Error;
use crate::artifacts_bundle;
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
pub enum Bitness... |
//! Destination implementation for Arrow2.
mod arrow_assoc;
mod errors;
mod funcs;
pub mod typesystem;
use super::{Consume, Destination, DestinationPartition};
use crate::constants::RECORD_BATCH_SIZE;
use crate::data_order::DataOrder;
use crate::typesystem::{Realize, TypeAssoc, TypeSystem};
use anyhow::anyhow;
use ar... |
use crate::actors::message::{EventMessage, TornadoCommonActorError};
use crate::TornadoError;
use actix::prelude::*;
use async_nats::{Connection, Options};
use log::*;
use serde::{Deserialize, Serialize};
use std::io::Error;
use std::ops::Deref;
use std::rc::Rc;
use tokio::time;
use tracing_futures::Instrument;
const ... |
#![recursion_limit = "1000"]
extern crate lalrpop_util;
extern crate num_bigint;
extern crate reproto_ast as ast;
extern crate reproto_core as core;
extern crate reproto_lexer as lexer;
#[allow(unused)]
mod parser;
mod utils;
use core::errors::Result;
use core::Diagnostics;
use std::io::Read;
use std::result;
/// R... |
use postgres::error::Error;
use db;
use models;
use helper;
use chrono::{NaiveDateTime};
#[derive(Serialize, Debug)]
pub struct Gist {
pub id: i32,
pub user_id: i32,
pub description: String,
pub filename: String,
pub code: String,
pub created: NaiveDateTime,
pub formated_created: String,
... |
extern crate criterion;
extern crate snapshot;
extern crate versionize;
extern crate versionize_derive;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use snapshot::Snapshot;
use versionize::{VersionMap, Versionize, VersionizeError, VersionizeResult};
use versionize_derive::Versionize;
#[deri... |
#[macro_use]
extern crate clap;
use clap::App;
use terminal_size::{Width, Height, terminal_size};
use console_engine::{ConsoleEngine, Color, KeyCode, KeyModifiers};
use rand::Rng;
use rand::prelude::ThreadRng;
use rand::distributions::{Distribution, Uniform};
use std::io;
use std::thread;
use std::sync::mpsc::{self... |
use std::fs::File;
use std::io::{self, Read, Write};
use crate::cli::config::{Config, InputOutputMode, InputOutputModeType, PathVariant};
use crate::cli::license::LicenseTexts;
use crate::cli::license::PrintTextFor;
use crate::cli::pipeline::fallback::{guess_output_by_identifier, guess_output_by_path};
use crate::comb... |
// Copyright 2018 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// http://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD
// https://opensource.org/licenses/BSD-3-Clause>, at your option. This file may not be copied,
// modified, or di... |
use ::neural_network as nn;
extern crate num_cpus;
extern crate rayon;
use algebra::{fields::near_mersenne_64::F, FixedPoint, FixedPointParameters, Polynomial};
use nn::tensors::*;
use protocols::AdditiveShare;
use rand::{CryptoRng, Rng, RngCore};
use nn::{
layers::{
average_pooling::AvgPoolParams,
... |
use crate::{api_client::{self,
retry_builder_api,
APIFailure,
BuilderAPIClient,
Client,
Error::APIClientError,
API_RETRY_COUNT,
API_RETRY_DELAY},... |
//! The syntax of the language, unchecked and with implicit parts that need to
//! be elaborated in a type-directed way during type checking and inference
use codespan::ByteSpan;
use moniker::{Binder, Embed, Nest, Scope, Var};
use num_bigint::BigInt;
use std::fmt;
use std::ops;
use std::rc::Rc;
use crate::syntax::pre... |
//! Implementation of baby steps giant step algorithm to solve the discrete logarithm over
//! a group of prime order.
#[cfg(crypto_backend = "__internal_ex_backend_p256k1")]
use crate::Coordinate;
use crate::{GroupElement, Scalar};
use rayon::prelude::*;
use std::{collections::HashMap, num::NonZeroU64};
// make steps... |
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
/* ************************************************************************ **
** This file is part of rsp2, and is licensed under EITHER the MIT license **
** or the Apache 2.0 license, at your option. **
** **
** ... |
//! Segger J-Link.
use super::{
begin_log_output, gdb_script_command, gdb_script_continue, gdb_script_wait, run_gdb_client,
run_gdb_server, rustc_substitute_path, setup_serial_endpoint,
};
use crate::{
cli::{FlashCmd, GdbCmd, LogCmd, ResetCmd},
color::Color,
log,
templates::Registry,
utils:... |
use crate::arch::ps2_mouse::Ps2Mouse;
use crate::arch::thread as arch_thread;
use crate::arch::vga_bochs;
use crate::io::Pipe;
use crate::kobj::KObj;
use crate::mutex::UntypedMutex;
use crate::phys_mem;
use crate::prelude::*;
use crate::process::{self, SharedMemBlock};
use crate::semaphore::Semaphore;
use crate::single... |
use std::{
collections::HashSet,
fs::File,
io::{BufRead, BufReader},
};
use bit_set::BitSet;
#[derive(Debug)]
struct Board {
lines: [BitSet; 10],
}
impl Board {
fn from_lines<I: Iterator<Item = String>>(lines: &mut I) -> Option<Self> {
let mut line_sets = vec([JP](http://www.odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2024))
use super::common::fact;
pub const NUMS: &[u64] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
pub const N: usize = 1_000_000;
pub fn solve(input: &[u64], n: usize) -> i64 {
// input = [... |
#[cfg(feature = "compression")]
use super::compression::{compress, CompressionEncoding, SingleMessageCompressionOverride};
use super::{EncodeBuf, Encoder, HEADER_SIZE};
use crate::{Code, Status};
use bytes::{BufMut, Bytes, BytesMut};
use futures_core::{Stream, TryStream};
use futures_util::{ready, StreamExt, TryStreamE... |
// Copyright 2018 The xi-editor 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 law or ag... |
use std::io::{self, Read};
use std::cmp;
use std::collections::HashSet;
use std::collections::HashMap;
fn build_kmp_table( pattern: &[u8], table: & mut Vec<i32> ){
let mut pos = 1isize; //position in table
let mut cnd = 0isize; //index in pattern of next character of the current candidate substring
table.c... |
//! "Big" ASN.1 `INTEGER` types.
use crate::{
Any, ByteSlice, Encodable, Encoder, Error, ErrorKind, Header, Length, Result, Tag, Tagged,
};
use core::{convert::TryFrom, marker::PhantomData};
use typenum::{NonZero, Unsigned};
/// "Big" unsigned ASN.1 `INTEGER` type.
///
/// Provides direct access to the underlying... |
use super::consts::*;
use super::*;
use core::marker::PhantomData;
use core::mem::swap;
use postcard;
use serde::{de::DeserializeOwned, Serialize};
// TODO Use custom Error
pub type Result<T> = postcard::Result<T>;
pub type Error = postcard::Error;
/// Type used to handle a Request for a particular RPC Call.
#[deri... |
use std::{
collections::VecDeque,
time::{Duration, Instant},
};
use nalgebra::distance;
use crate::{camera::Camera, math::Point};
pub struct Zoom {
events: VecDeque<(Instant, f64)>,
target_speed: f64,
current_speed: f64,
last_direction: Direction,
idle_since: Option<Instant>,
}
impl Zo... |
use {
super::{
id_cache::*, Id
},
std::iter::Extend
};
pub struct CacheStorage<T> {
data: Vec<T>,
id_cache: IdCache,
}
impl<T> CacheStorage<T> {
pub fn new() -> Self {
Self {
data: Vec::default(),
id_cache: IdCache::new(),
}
}
pub fn wit... |
extern crate structopt;
#[macro_use]
extern crate clap;
#[macro_use]
extern crate failure;
use failure::Error;
use structopt::StructOpt;
use std::fs::File;
use std::io::Write;
use std::time::Instant;
mod rand;
mod utils;
/// Run beaconfuzz_v2
#[derive(StructOpt, Debug)]
enum Cli {
/// Run debug command
#[st... |
use std::io::Write;
use std::mem;
use crate::data_source::IonDataSource;
use crate::result::{decoding_error, IonResult};
type UIntStorage = u64;
const MAX_UINT_SIZE_IN_BYTES: usize = mem::size_of::<UIntStorage>();
/// Represents a fixed-length unsigned integer. See the
/// [UInt and Int Fields](http://amzn.github.io... |
use crate::config::Config;
use crate::device::{device_watcher, get_input_devices, output_device};
use crate::event_handler::EventHandler;
use anyhow::{anyhow, bail, Context};
use clap::{AppSettings, ArgEnum, IntoApp, Parser};
use clap_complete::Shell;
use config::{config_watcher, load_config};
use device::InputDevice;
... |
use std::ffi::{c_void, CString};
use once_cell::sync::Lazy;
use spdk_sys::{
spdk_bdev_fn_table,
spdk_bdev_io,
spdk_bdev_io_type,
spdk_get_io_channel,
spdk_io_channel,
spdk_json_write_array_end,
spdk_json_write_ctx,
spdk_json_write_named_array_begin,
spdk_json_write_val_raw,
};
use... |
extern crate reqwest;
extern crate rustyline;
extern crate protocol;
extern crate base64;
extern crate ring;
extern crate untrusted;
extern crate serde;
#[macro_use]
extern crate serde_derive;
use protocol::*;
use rustyline::error::ReadlineError;
use rustyline::Editor;
use std::str;
use std::io::Read;
use ring::{sign... |
use std::borrow::{Borrow, Cow, ToOwned};
use std::ops::Deref;
use std::str::Utf8Error;
use std::vec::Vec;
/// OsStr, but specifically for Linux (since we aren't always processing native dumps).
#[derive(Debug, PartialOrd, Ord, Eq, PartialEq)]
pub struct LinuxOsStr([u8]);
/// OsString, but specifically for Linux (sinc... |
use pinochle_lib::{
command::PlayingInput,
game::{self, Game, Input},
Card, Player, Suit,
};
use std::convert::TryInto;
use std::string::ToString;
use strum::IntoEnumIterator;
use yew::callback::Callback;
use yew::html::{Component, ComponentLink, Html, ShouldRender};
use yew::macros::{html, Properties};
us... |
use sdl2::pixels::Color;
use sdl2::rect::Rect;
use std::path::Path;
use std::string::String;
use std::time::Duration;
use std::ops::Deref;
use gilrs::{Gilrs, Axis, Event, Button, EventType};
use std::net::UdpSocket;
use tello::{Drone, Flip, Message, Package, PackageData, ResponseMsg};
const WINDOW_WIDTH: u32 = 1280;
... |
// Copyright 2016 GFX developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to tho... |
#[macro_use]
extern crate clap;
use rand::prelude::{thread_rng, SliceRandom};
use rust_sc2::prelude::*;
#[bot]
#[derive(Default)]
struct WorkerRushAI {
mineral_forward: u64,
mineral_back: u64,
}
impl Player for WorkerRushAI {
fn on_start(&mut self) -> SC2Result<()> {
if let Some(townhall) = self.units.my.townha... |
use syn::{*, punctuated::Punctuated, token::Comma};
pub trait PathExt {
fn is(&self, global: bool, segments: &[&str]) -> bool;
fn is_local(&self, segments: &[&str]) -> bool;
fn is_global(&self, segments: &[&str]) -> bool;
fn last_ident(&self) -> Option<&Ident>;
fn generics(&self) -> Option<&Punctua... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.