hexsha stringlengths 40 40 | size int64 4 1.05M | content stringlengths 4 1.05M | avg_line_length float64 1.33 100 | max_line_length int64 1 1k | alphanum_fraction float64 0.25 1 |
|---|---|---|---|---|---|
ebb0ff52cdef11c2d534e290031c645c97290eba | 9,429 | #[allow(unused_imports)]
use test_env_log::test;
#[allow(unused_imports)]
use pact_models::PactSpecification;
#[allow(unused_imports)]
use serde_json;
#[allow(unused_imports)]
use expectest::prelude::*;
#[allow(unused_imports)]
use pact_matching::models::{Interaction, http_interaction_from_json};
#[allow(unused_imports... | 41.355263 | 183 | 0.617245 |
387f62dde2e4355570cea509ab51af35e9a5d77a | 5,075 | use crate::format::problem::*;
use crate::format::solution::*;
use crate::helpers::*;
#[test]
fn can_use_strict_and_any_relation_for_one_vehicle() {
let problem = Problem {
plan: Plan {
jobs: vec![
create_delivery_job("job1", vec![1., 0.]),
create_delivery_job("j... | 36.510791 | 115 | 0.349754 |
625d97336e75bf97a4988ffee216f1b8c93cd8a0 | 2,142 | use crate::errors::*;
use crate::types::*;
use uuid::Uuid;
/// Deletes a supergroup or channel along with all messages in the corresponding chat. This will release the supergroup or channel username and remove all members; requires owner privileges in the supergroup or channel. Chats with more than 1000 members can't ... | 27.461538 | 288 | 0.661064 |
8703d4132dc3aae523c16aee53d82921ceb21578 | 20,090 | mod binary;
mod boolean;
mod fixed_len_bytes;
mod levels;
mod primitive;
mod record_batch;
mod schema;
mod utf8;
mod utils;
pub mod stream;
use crate::array::*;
use crate::bitmap::Bitmap;
use crate::buffer::{Buffer, MutableBuffer};
use crate::datatypes::*;
use crate::error::{ArrowError, Result};
use crate::io::parque... | 33.427621 | 100 | 0.54674 |
5b216f0aea2b35a74656d1c940c21931342d8ddc | 1,904 | use std::{env, io, path::PathBuf, str};
use which::{self, which_in};
use crate::utils::process::{command_output, command_spawn_wait};
const INSTALL_DIRS: &[&str] = &["/usr/local", "/home/linuxbrew/.linuxbrew", "~/.linuxbrew"];
pub fn has_brew() -> bool {
match brew_exe() {
Some(exe) => command_output(ex... | 23.8 | 92 | 0.515231 |
d78d65574475df088dab76778da9e4e5eae6bc87 | 1,438 | use std::io;
use unicode_width::UnicodeWidthStr;
pub struct AsciiWriter<T: io::Write> {
writer: T,
}
impl<T: io::Write> AsciiWriter<T> {
pub fn new(writer: T) -> Self {
AsciiWriter { writer }
}
}
impl<T: io::Write> crate::Write for AsciiWriter<T> {
fn write(&mut self, table: crate::Table) -> crate::Resul... | 25.678571 | 90 | 0.570236 |
87d35cbf73c54fc9a378545f25e54c3ca0873476 | 9,080 | use crate::{error::{Error,
Result},
protocol::{self,
ShutdownMethod},
service::Service};
use core::{os::{process::{handle_from_pid,
windows_child::{ExitStatus,
Handle}},
... | 37.366255 | 100 | 0.49978 |
e2d90b7191fe104b8ee5383a429eb3ae5729cb77 | 1,307 | mod position;
mod vent;
#[cfg(test)]
mod tests;
use std::collections::HashMap;
use position::Position;
use vent::Vent;
type Input = Vec<Vent>;
pub fn parse_input(text: &str) -> Input {
text.lines().map(str::parse).map(Result::unwrap).collect()
}
pub fn solve_part1(input: Input) -> usize {
let mut position... | 25.134615 | 63 | 0.557001 |
0a363c28e6e31f90b8cc8f5de4c5faeb14f4eb1a | 2,782 | '''
Problem Challenge 1
K Pairs with Largest Sums (Hard)
Given two sorted arrays in descending order, find ‘K’ pairs with the largest sum where each pair consists of numbers from both the arrays.
Example 1:
Input: L1=[9, 8, 2], L2=[6, 3, 1], K=3
Output: [9, 3], [9, 6], [8, 6]
Explanation: These 3 pairs have the lar... | 27.544554 | 143 | 0.637311 |
01e3628ca47718a5dfcf9c00d2b4bb6bda93189e | 5,403 | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use aws_auth::Credentials;
use aws_sigv4_poc::{PayloadChecksumKind, SignableBody, SigningSettings, UriEncoding};
use aws_types::region::SigningRegion;
use aws_types::SigningService;
use http::header::He... | 34.858065 | 158 | 0.671109 |
6147b10c0af2c78a6d67f63fd54fb907f86b2632 | 9,101 | // Copyright © 2021 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
use crate::GuestMemoryMmap;
use std::fs::File;
use std::io::{Read, Seek, SeekFrom};
use thiserror::Error;
use vm_memory::{ByteValued, Bytes, GuestAddress, GuestMemoryError};
#[derive(Error, Debug)]
pub enum TdvfError {
#[error("Failed ... | 28.440625 | 119 | 0.607955 |
0e02928495f060aa008a26219b5c0952788d762d | 14,255 | //! `TcpStream` split support.
//!
//! A `TcpStream` can be split into a `ReadHalf` and a
//! `WriteHalf` with the `TcpStream::split` method. `ReadHalf`
//! implements `AsyncRead` while `WriteHalf` implements `AsyncWrite`.
//!
//! Compared to the generic split of `AsyncRead + AsyncWrite`, this specialized
//! split has... | 35.460199 | 91 | 0.595931 |
76bcbc11be3dea43ec4d1e5ff56e22297c85ab54 | 5,101 | mod client;
mod config;
mod exchange;
mod message;
mod queue;
mod restapi;
use env_logger::Builder;
use hyper::service::{make_service_fn, service_fn};
use hyper::Server;
use log::{error, info};
use std::convert::Infallible;
use std::fmt;
use std::io::Write;
use tokio::net::TcpListener;
use tokio::signal;
pub type Res... | 25.252475 | 117 | 0.563615 |
01f290248fda4a0142227e2d7ed8803cd2c5674c | 7,361 | use crate::prelude::*;
use algebra::{Field, Group};
use r1cs_core::{ConstraintSystem, SynthesisError};
use std::{borrow::Borrow, fmt::Debug};
pub mod curves;
pub use self::curves::{
short_weierstrass::bls12,
twisted_edwards::{edwards_sw6, jubjub},
};
pub trait GroupGadget<G: Group, ConstraintF: Field>:
... | 31.059072 | 96 | 0.532672 |
67b2c61ce02a215029d71ec169f1eb5241398dfd | 549 | extern crate chrono;
extern crate olin;
use self::chrono::TimeZone;
use olin::log;
/// This tests for https://github.com/CommonWA/cwa-spec/blob/master/ns/time.md
pub extern "C" fn test() -> Result<(), i32> {
log::info("running ns::time tests");
let now: i64 = olin::time::ts();
let dt = chrono::Utc.timest... | 24.954545 | 78 | 0.593807 |
8ff7c51c8685aa8f496fe1a093467684dbf5d830 | 155 | use proconio::input;
fn main() {
input! {
s: String,
}
let ans = if s == "ABC" { "ARC" } else { "ABC" };
println!("{}", ans);
}
| 12.916667 | 53 | 0.425806 |
29f92a389345fad0cd048f86d4269db99d809f86 | 8,315 | use ic_btc_types_internal::{
BitcoinAdapterRequest, BitcoinAdapterRequestWrapper, BitcoinAdapterResponse,
};
use ic_protobuf::{
bitcoin::v1 as pb_bitcoin,
proxy::{try_from_option_field, ProxyDecodeError},
};
use serde::{Deserialize, Serialize};
use std::{
collections::{BTreeMap, VecDeque},
convert::... | 35.840517 | 113 | 0.641491 |
9c6150cfbfa7bbdc99a2da73ac65f65b0829770b | 10,239 | use std::collections::BTreeSet;
use std::fs::create_dir_all;
use std::marker::PhantomData;
use std::ops::Deref;
use std::path::Path;
use std::sync::Arc;
use fst::IntoStreamer;
use milli::heed::{EnvOpenOptions, RoTxn};
use milli::update::{IndexerConfig, Setting};
use milli::{obkv_to_json, FieldDistribution};
use serde:... | 32.198113 | 106 | 0.580818 |
4bafbac85b82b48627cb5e5d752ebe33d43c9991 | 62,526 | use std::collections::HashMap;
use crate::{
protobufs::graplinc::grapl::api::graph::v1beta1::{
DecrementOnlyIntProp as DecrementOnlyIntPropProto,
DecrementOnlyUintProp as DecrementOnlyUintPropProto,
Edge as EdgeProto,
EdgeList as EdgeListProto,
GraphDescription as GraphDescr... | 29.507315 | 119 | 0.607315 |
500431f3b4db15d1537b7d4adf28125843bcc6dc | 19,875 | #[derive(Clone)]
/// Flags group `shared`.
pub struct Flags {
bytes: [u8; 8],
}
impl Flags {
/// Create flags shared settings group.
#[allow(unused_variables)]
pub fn new(builder: Builder) -> Self {
let bvec = builder.state_for("shared");
let mut shared = Self { bytes: [0; 8] };
... | 31.8 | 99 | 0.575547 |
7a341a22d7b5bdf9d6e79e6b8bfb1c7ef233e3c1 | 25,714 | // 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... | 40.304075 | 99 | 0.614685 |
5b57bfff3ff63a7cac03b09365c8263d709b8776 | 12,365 | use nimiq_blockchain::{chain_info::ChainInfo, chain_store::ChainStore};
use nimiq_database::{volatile::VolatileEnvironment, WriteTransaction};
use nimiq_hash::{Blake2bHash, Hash};
use nimiq_network_primitives::networks::{get_network_info, NetworkId};
use nimiq_block::Difficulty;
#[test]
fn it_can_store_the_chain_head(... | 41.079734 | 114 | 0.684674 |
4a7206e39987c3637076dadf8be1052db38e2c7d | 1,292 | use std::io::Cursor;
use std::mem::size_of;
use nue::{Encode, Decode, Un, Aligned};
#[derive(NueEncode, NueDecode, PartialEq, Debug)]
struct _PodTest;
#[test]
fn encode_decode() {
#[derive(PodPacked)]
struct POD1 {
_0: u8,
_1: Un<u16>,
}
const UNIT: &'static () = &();
#[derive(Nu... | 26.367347 | 123 | 0.569659 |
5d45f5084c5eec399396315a493b2c134f4a410b | 223 | // build-pass
// only-x86_64
#![feature(llvm_asm)]
fn main() {
unsafe {
// "nop" :: "r"(x) : "eax" : "volatile"
let x = 10;
llvm_asm!("\x6Eop" :: "\x72"(x) : "\x65ax" : "\x76olatile");
}
}
| 17.153846 | 68 | 0.44843 |
bb069cb945dd24338ea7ee1526d2c2662ab94207 | 5,005 | use crate::sys::jsize;
use log::error;
use std::ptr::NonNull;
use crate::objects::release_mode::ReleaseMode;
use crate::sys::{jboolean, jbyte, jchar, jdouble, jfloat, jint, jlong, jshort};
use crate::{errors::*, objects::JObject, sys, JNIEnv};
/// Trait to define type array access/release
pub trait TypeArray {
/... | 35.246479 | 121 | 0.613387 |
d9749b031f363b36c1a759762a31de6f5cb57002 | 5,335 | use std::env;
use actix_web::{get, middleware, web, App, HttpRequest, HttpResponse, HttpServer, guard};
use dotenv::dotenv;
use serde::{Serialize, Deserialize};
use qrcode::QrCode;
use qrcode::render::svg;
use std::fs::File;
use std::io::prelude::*;
const MAX_SIZE: usize = 4096;
#[derive(Debug, Serialize, Deserialize... | 25.772947 | 116 | 0.610309 |
0e3c8fafa6fcf95220c33c2e91775f988755f2fb | 1,835 | //---------------------------------------------------------------------------//
// Copyright (c) 2017-2022 Ismael Gutiérrez González. All rights reserved.
//
// This file is part of the Rusted PackFile Manager (RPFM) project,
// which can be found here: https://github.com/Frodo45127/rpfm.
//
// This file is licensed un... | 34.622642 | 120 | 0.493733 |
219fe0263ad257776eb926c179106124e8c120ac | 6,703 | extern crate rustyline;
extern crate easy_ll;
extern crate weld;
extern crate libc;
use rustyline::error::ReadlineError;
use rustyline::Editor;
use std::env;
use std::path::Path;
use std::path::PathBuf;
use std::fs::File;
use std::error::Error;
use std::io::prelude::*;
use std::fmt;
use std::collections::HashMap;
us... | 31.767773 | 94 | 0.511114 |
3994831c0b3008f413721201c438e1c386a9b291 | 4,766 | // Copyright (c) The Dijets Core Contributors
// SPDX-License-Identifier: Apache-2.0
use dijets_types::{account_config, transaction::SignedTransaction, vm_status::VMStatus};
use language_e2e_tests::{
account::Account,
common_transactions::create_account_txn,
execution_strategies::{
basic_strategy::... | 39.38843 | 96 | 0.490138 |
3a6532dce0206e17e54ed9c66343edaba590d6cb | 18,294 | // Copyright 2015, The inlinable_string crate Developers. See the COPYRIGHT file
// at the top-level directory of this distribution.
//
// 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... | 27.760243 | 113 | 0.554717 |
6aa3ceced761eff72602067a450b93e8e2a7304d | 16,160 | #![allow(dead_code, unused_variables)]
extern crate core_compat;
extern crate png;
extern crate xml_writer;
use std::path::Path;
use std::path::PathBuf;
use std::fs::File;
use std::fs::read_dir;
use std::io::Read;
use std::io::BufWriter;
use core_compat::entity::resource_file::ResourceFile;
use core_compat::entity:... | 35.516484 | 111 | 0.532859 |
188ded8f9e5ff85f7ec997cbc7b079b0e8a3f464 | 5,526 | // Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
#![forbid(unsafe_code)]
use libra_config::config::NodeConfig;
use libra_logger::prelude::*;
use libra_types::{chain_id::ChainId, PeerId};
use std::{
path::PathBuf,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
... | 33.90184 | 97 | 0.641513 |
91d77897948e08ce86a987126c8dd75874dd35ad | 5,450 | use crate::errno::Errno;
use crate::sys::signal::Signal;
use crate::unistd::Pid;
use crate::Result;
use cfg_if::cfg_if;
use libc::{self, c_int};
use std::ptr;
pub type RequestType = c_int;
cfg_if! {
if #[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
target_os = "macos",... | 31.321839 | 99 | 0.585872 |
bb5b567aeccf142ea3f652ace5428d7d7fbbca7f | 2,061 | pub(crate) mod serial;
use std::fmt;
use std::str::FromStr;
use semver::{ReqParseError, SemVerError, Version, VersionReq};
use notion_fail::{ExitCode, Fallible, NotionFail, ResultExt};
use self::serial::parse_requirements;
#[derive(Debug, Clone)]
pub enum VersionSpec {
Latest,
Semver(VersionReq),
}
impl f... | 24.247059 | 92 | 0.622999 |
1616d8276c3957d2ae49842e77a139d2e212a2c6 | 1,792 | #[macro_use]
extern crate log;
use std::cell::RefCell;
use std::{thread::sleep, time::Duration};
thread_local!(static NOTIFY: RefCell<bool> = RefCell::new(true));
struct Context<'a> {
waker: &'a Waker,
}
impl<'a> Context<'a> {
fn from_waker(waker: &'a Waker) -> Self {
info!("Context from_waker");
... | 19.478261 | 65 | 0.491071 |
bf7153c573844a3431cc3d6166c547ff099cadcf | 31,721 | use crate::{
acknowledgement::{Acknowledgements, DeliveryTag},
auth::Credentials,
channel_status::{ChannelState, ChannelStatus},
close_on_drop,
connection_status::{ConnectionState, ConnectionStep},
consumer::Consumer,
executor::{Executor, ExecutorExt},
frames::{ExpectedReply, Frames},
... | 34.781798 | 100 | 0.546988 |
fbb33b94d95770e8e79533513af65d45f018ce14 | 1,300 | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | 25.490196 | 100 | 0.543077 |
7a48031161670564cca2563296a73dc6f0b05e0a | 28,831 | // Copyright 2014 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// 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 ... | 31.474891 | 119 | 0.552634 |
9cca9153c6c1b2716efb5378c07cdc3efdf3d139 | 28,474 | //! CodeBlock
//!
//! This module is for the CodeBlock which implements a function representation in the VM
use crate::{
builtins::function::{
arguments::Arguments, Captures, ClosureFunctionSignature, Function,
NativeFunctionSignature, ThisMode,
},
context::StandardObjects,
environment:... | 35.906683 | 132 | 0.491922 |
1d6d3c264da5568a2b64732f410d0285385a97a3 | 2,980 | use std::fmt::*;
/// Tokens in the Raptorex programming language.
#[derive(Debug, Clone, PartialEq)]
pub enum Token<'a> {
// Data types
String(String),
Num(i32),
Dec(f32),
Bool(bool),
// Identifiers, e.g. variable, function names, keywords
Identifier(&'a str),
// Keywords, e.g. struct, ... | 30.721649 | 80 | 0.434228 |
fc0f6de9785a9b424b6ca8050a6269cab3721aaf | 1,708 | /*
* Client Portal Web API
*
* Client Portal Web API
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct SummaryExcludedAccounts {
#[serde(rename = "lastUpdateAttempt", skip_serializing_... | 32.226415 | 86 | 0.653981 |
69b0734640b4b274b86a2ee7ff0d55653200681d | 434 | use doc_comment::{doc_comment, doctest};
use wasm_bindgen_test::*;
#[wasm_bindgen_test]
fn test_sample_app() {
doc_comment!(include_str!(concat!(
env!("OUT_DIR"),
"/getting-started/build-a-sample-app.md"
)));
}
#[wasm_bindgen_test]
fn test_optimizations() {
doctest!("advanced-topics/optimi... | 20.666667 | 50 | 0.68894 |
9b37ad35d765e0bff06ea5a8868fbd024bd1976c | 1,668 | use std::io;
use std::collections::VecDeque;
const PRIME: usize = 131071;
/// Reads the whole input and returns a VecDeque of chars.
///
/// Why this is needed? Rust does not provide a `read_char` function and this
/// is the only way I find to read each char withou extern crates.
fn input() -> VecDeque<char> {
// ... | 31.471698 | 77 | 0.595923 |
165100ebadd4af76e28081c4e66f7d48d0719e3f | 6,243 | // 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.
// This test is run with --test-threasds=1 to prevent any tests from running in parallel.
//
// Running in parallel is something we want to control for spe... | 35.674286 | 97 | 0.565754 |
672802951fd5ad9dc485fcc98f395e974f4021a6 | 858 | use resources::Amount;
/// A create account operation represents a new account creation.
#[derive(Debug, Clone)]
pub struct CreateAccount {
account: String,
funder: String,
starting_balance: Amount,
}
impl CreateAccount {
/// Creates a new CreateAccount
pub fn new(account: String, funder: String, ... | 24.514286 | 92 | 0.618881 |
abfda4ac4026f2ab7d3a78bc27aec00026676fc7 | 12,471 | // Copyright 2019-2021 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
//! A layer between raw [`Runtime`] webview windows and Tauri.
use crate::{
api::config::WindowConfig,
event::{Event, EventHandler},
hooks::{InvokeMessage, InvokePayload, ... | 29.763723 | 98 | 0.617914 |
6287d1b5a76c0925a9f6ac8596c9067471594ab9 | 17,380 | mod resource_id;
mod endpoint;
mod poll;
mod registry;
mod driver;
mod remote_addr;
mod transport;
mod loader;
/// Module that specify the pattern to follow to create adapters.
/// This module is not part of the public API itself,
/// it must be used from the internals to build new adapters.
pub mod adapter;
// Reexp... | 41.28266 | 102 | 0.614902 |
ef5083b833d6bc146735e53271b2c85158d98055 | 1,069 | #[doc = "Reader of register SMVAL4"]
pub type R = crate::R<u16, super::SMVAL4>;
#[doc = "Writer for register SMVAL4"]
pub type W = crate::W<u16, super::SMVAL4>;
#[doc = "Register SMVAL4 `reset()`'s with value 0"]
impl crate::ResetValue for super::SMVAL4 {
type Type = u16;
#[inline(always)]
fn reset_value() ... | 26.073171 | 74 | 0.561272 |
f5b17a614955624edd54ac44394ced91cd095e53 | 10,757 | #[doc = "Register `TX_CLR` reader"]
pub struct R(crate::R<TX_CLR_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<TX_CLR_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<TX_CLR_SPEC>> for R {
#[inline(always)]
fn from(reader: crate::R... | 32.206587 | 423 | 0.596821 |
09bfe981a717b5c11763864f9ffb2bc1653c36bb | 15,204 | use std::net::SocketAddr;
use std::time::Duration;
use futures::channel::mpsc::{channel, Receiver, Sender};
use futures::sink::SinkExt;
use futures::stream::StreamExt;
use crate::discovery;
use crate::internal::commands;
use crate::internal::driver::{Driver, Report};
use crate::internal::messaging::{Msg, OpMsg};
use ... | 34.791762 | 111 | 0.628716 |
1820ef7b6c95dc74d65121e67d7a155d8187e168 | 13,245 | use crate::{error::msg_from_errno, GroupSlice};
use libzmq_sys as sys;
use sys::errno;
use libc::size_t;
use log::error;
use serde::{Deserialize, Serialize};
use std::{
ffi::CStr,
fmt,
os::raw::c_void,
ptr, slice,
str::{self, Utf8Error},
};
/// A generated ID used to route messages to the approri... | 26.279762 | 87 | 0.516723 |
c1de4e4fecba166b8c8810a83b87c8e04083c7a5 | 8,506 | #[cfg(any(
not(unix),
target_os = "macos",
target_os = "android",
target_os = "ios",
target_os = "emscripten"
))]
fn main() {
unimplemented!()
}
#[cfg(all(
unix,
not(any(
target_os = "macos",
target_os = "android",
target_os = "ios",
target_os = "emscript... | 34.024 | 99 | 0.487068 |
b92e1b6162b9cffd4a407c2b30fe4f2add324c24 | 14,053 | use std::{
fmt::{self, Display, Formatter},
io::{self, Read, Seek, SeekFrom},
};
use thiserror::Error;
#[derive(Debug, Error)]
pub enum TokenizeError {
#[error("generic IO error: {0}")]
Io(#[from] io::Error),
#[error("unexpected character {0}")]
UnexpectedCharacter(char),
#[error("error ... | 30.55 | 116 | 0.391304 |
714fcf1d5786ab91f44e8efb17d370f2af85d094 | 4,544 | #![deny(warnings)]
//! # Sqlite support for the `r2d2` connection pool.
//!
//! Library crate: [r2d2-sqlite](https://crates.io/crates/r2d2-sqlite/)
//!
//! Integrated with: [r2d2](https://crates.io/crates/r2d2)
//! and [rusqlite](https://crates.io/crates/rusqlite)
//!
//! ## Example
//!
//! ```rust,no_run
//! extern cr... | 29.894737 | 93 | 0.567121 |
fffd4bd28eb9be10add7972b291241bbda16ced2 | 1,139 | #[doc = "Reader of register PB_OVTDIS"]
pub type R = crate::R<u32, super::PB_OVTDIS>;
#[doc = "Writer for register PB_OVTDIS"]
pub type W = crate::W<u32, super::PB_OVTDIS>;
#[doc = "Register PB_OVTDIS `reset()`'s with value 0"]
impl crate::ResetValue for super::PB_OVTDIS {
type Type = u32;
#[inline(always)]
... | 27.780488 | 74 | 0.586479 |
b9c38546717ff311ef6e0906523c45965a2d5571 | 1,635 | use structopt::StructOpt;
use structopt::clap::AppSettings::*;
use super::Commands;
#[derive(Debug, StructOpt, Default, Clone)]
#[structopt(
global_settings = &[DisableVersion, DeriveDisplayOrder, VersionlessSubcommands],
about = "\nKubectl wrapper for running bash commands on a container, it's SSH!"
)]
pub st... | 24.402985 | 84 | 0.582875 |
1c24028d7614e1378be6f3a4c333c887c0550dd8 | 2,143 | extern crate rocket;
extern crate rocket_contrib;
use std::env;
use std::path::PathBuf;
use rocket::Rocket;
use rocket::config::{Config, Environment};
use rocket_contrib::Template;
fn template_root() -> PathBuf {
let cwd = env::current_dir().expect("current working directory");
cwd.join("tests").join("templa... | 29.763889 | 85 | 0.623425 |
75294cf7ee2ab275209f9c1adff15acf579034f2 | 206 | pub mod pcalc_keywords;
pub mod pcalc_value;
pub mod pcalc_binary_ops;
pub mod pcalc_unary_ops;
pub mod pcalc_environment;
pub mod pcalc_code;
pub mod pcalc_lexer;
pub mod pcalc_parser;
pub mod pcalc_repl;
| 20.6 | 26 | 0.825243 |
149c08c793ab365cdb7b5d3bcc5f7d7f4f05c844 | 3,682 | use e2d2::operators::*;
use e2d2::scheduler::*;
use e2d2::utils::*;
use fnv::FnvHasher;
use std::collections::HashMap;
use std::hash::BuildHasherDefault;
use std::hash::{BuildHasher, Hash, Hasher};
use twox_hash::XxHash;
use uuid::Uuid;
type FnvHash = BuildHasherDefault<FnvHasher>;
type XxHashFactory = BuildHasherDefa... | 32.298246 | 111 | 0.5239 |
d615b0022f5d4a471d4afc0148834128ad28eff8 | 4,014 | // Copyright (c) 2018-2022 The MobileCoin Foundation
//! A Peer-to-Peer networking error.
use crate::ConsensusMsgError;
use displaydoc::Display;
use grpcio::Error as GrpcError;
use mc_connection::AttestationError;
use mc_consensus_api::ConversionError;
use mc_consensus_enclave_api::Error as EnclaveError;
use mc_trans... | 25.0875 | 92 | 0.659691 |
38ecee4eed58f8cddce44c5d80bc5045d520e6b1 | 27,139 | // Generated from definition io.k8s.api.storage.v1beta1.StorageClass
/// StorageClass describes the parameters for a class of storage for which PersistentVolumes can be dynamically provisioned.
///
/// StorageClasses are non-namespaced; the name of the storage class according to etcd is in ObjectMeta.Name.
#[derive(Cl... | 46.953287 | 307 | 0.607723 |
337b54fa76185a80910e553f82a61d71ff733c85 | 49 | pub mod enums;
pub mod events;
pub mod types;
| 12.25 | 16 | 0.693878 |
8f048f8de30eeb533eb145fe288a6f682007f8d1 | 619 | // DO NOT EDIT THIS FILE. IT WAS AUTOMATICALLY GENERATED BY:
//
// ucd-generate property-bool ucd-13.0.0 --chars --include whitespace
//
// ucd-generate 0.2.7 is available on crates.io.
pub const BY_NAME: &'static [(&'static str, &'static [(char, char)])] =
&[("White_Space", WHITE_SPACE)];
pub const WHITE_SPACE:... | 28.136364 | 71 | 0.494346 |
218e31e8720b779601f12697496e29b4c39ef63e | 12,039 | use geom::{Distance, Duration};
use map_gui::tools::{
cmp_dist, cmp_duration, InputWaypoints, TripManagement, TripManagementState, WaypointID,
};
use map_model::{PathfinderCaching, NORMAL_LANE_THICKNESS};
use synthpop::{TripEndpoint, TripMode};
use widgetry::mapspace::{ObjectID, ToggleZoomed, World};
use widgetry::... | 38.586538 | 100 | 0.534845 |
4a3fd08a28839e20daba02de685cb2fce52a478f | 14,522 | // Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
//! This module implements an in-memory Merkle Accumulator that is similar to what we use in
//! storage. This accumulator will only store a small ... | 47.149351 | 134 | 0.468668 |
91fa2099ab33c457aeca79a5ee6d766a75afec25 | 189 | pub mod builder;
pub mod data;
pub mod pack;
pub mod transport;
pub use self::builder::DataBuilder;
pub use self::data::{Data, Storage};
pub use self::pack::{new_pack_stream, PackStream};
| 21 | 50 | 0.740741 |
7a5d4d37020ff6c28605d7a21bd6cba5fda0ba75 | 25,682 | //! The equality sigma proof system.
//!
//! An equality proof is defined with respect to two cryptographic objects: a twisted ElGamal
//! ciphertext and a Pedersen commitment. The proof certifies that a given ciphertext and
//! commitment pair encrypts/encodes the same message. To generate the proof, a prover must pro... | 36.428369 | 102 | 0.581808 |
283a1148a9a911283aac01d82738c38aee5362b1 | 4,966 | use std::collections::HashMap;
use std::error::Error;
use std::iter;
use std::rc::Rc;
use super::{Route, RouteBuffer, StopRecord, TripBuffer, TripId, TripRecord};
use crate::line::LineId;
use crate::location::{Location, LocationId};
use crate::service::{Service, ServiceId};
use crate::shape::{Shape, ShapeId};
use crat... | 35.985507 | 93 | 0.555779 |
f7bd8cc711064e2bb362da5ed1c0b8bff97fed22 | 25,380 | use crate::types;
use actix_web::{get, web, HttpResponse};
use chrono::prelude::*;
use chrono_utilities::naive::DateTransitions;
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
#[derive(Serialize, Debug)]
struct ResponseStructure {
month: String,
positive: i32,
recovered: i32,
death... | 39.287926 | 98 | 0.411466 |
9c55119a449844c56e2dc72940f93562b40abcde | 574 | use {super::menu::Menu, screen_13::prelude_rc::*};
pub struct Load;
impl Screen<RcK> for Load {
fn render(&self, gpu: &Gpu, dims: Extent) -> Render {
let mut frame = gpu.render(dims);
frame.clear().record();
frame
}
fn update(self: Box<Self>, gpu: &Gpu, _: &Input) -> DynScreen {
... | 27.333333 | 86 | 0.585366 |
7a536ab4fb7fbdd68b7acca9025ff5e67ec0d83e | 3,265 | use std::ops::AddAssign;
use std::collections::BTreeMap;
use crate::hand_stats::HandStats;
use crate::shoe::CardShoe;
use crate::round_factory::RoundFactory;
use crate::running_stats::RunningStats;
pub struct Simulator<'a>
{
round_count: u64,
shoe: Box<dyn CardShoe>,
round_factory: &'a RoundFactory<'a>,
... | 28.146552 | 78 | 0.524043 |
1a6849137c5477ae205e98e12d9c1352ce89c383 | 48 | pub(crate) mod deep_merge;
pub(crate) mod json;
| 16 | 26 | 0.75 |
ed9c83a9e068ba56f6de0e2abfd907930bbf7787 | 991 | use sc_cli::RunCmd;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
pub struct Cli {
#[structopt(subcommand)]
pub subcommand: Option<Subcommand>,
#[structopt(flatten)]
pub run: RunCmd,
}
#[derive(Debug, StructOpt)]
pub enum Subcommand {
/// Key management cli utilities
Key(sc_cli::KeySubcommand),
/// ... | 23.046512 | 71 | 0.73663 |
ede30a0bed756d2c29e7d93be495a9904ccc8e94 | 1,154 | use super::BackendTypes;
use crate::mir::operand::OperandRef;
use rustc::ty::Ty;
use rustc_target::abi::call::FnType;
use syntax_pos::Span;
pub trait IntrinsicCallMethods<'tcx>: BackendTypes {
/// Remember to add all intrinsics here, in librustc_typeck/check/mod.rs,
/// and in libcore/intrinsics.rs; if you nee... | 38.466667 | 81 | 0.655979 |
67717f3e917d5d2b21a183612eb343591147a00e | 2,665 | //! Lazily initialized data.
//! Used in generated code.
use std::sync;
use std::sync::atomic::AtomicPtr;
use std::sync::atomic::Ordering;
/// Lazily initialized data.
pub struct LazyV2<T: Sync> {
lock: sync::Once,
ptr: AtomicPtr<T>,
}
unsafe impl<T: Sync> Sync for LazyV2<T> {}
impl<T: Sync> LazyV2<T> {
... | 28.655914 | 79 | 0.508443 |
fe961a238c738e7068230f89de1e0754bfc7527c | 8,979 | use std::sync::atomic::{AtomicBool, Ordering::Relaxed};
use std::sync::Arc;
static OPENED: AtomicBool = AtomicBool::new(false);
#[derive(Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
enum Enum {
First,
Second,
Third,
}
/// Shows off one example of each ma... | 31.840426 | 130 | 0.530014 |
1807a5131006ccb8e625bcae9fffbd68be10053a | 1,887 | use crate::defs::{self, BitSize};
use core::fmt;
use std::ops::{Add, Sub};
#[derive(Copy, Clone)]
pub struct WordSize {
pub words: usize,
}
#[allow(dead_code)]
impl WordSize {
pub const fn one() -> Self {
Self { words: 1 }
}
pub const fn new(words: usize) -> Self {
Self { words }
}
pub const fn ... | 18.144231 | 73 | 0.599364 |
de3f8766c2cecd1f40e26ed5577544c40bfd8940 | 961 | // if1.rs
pub fn bigger(a: i32, b: i32) -> i32 {
// Complete this function to return the bigger number!
// Do not use:
// - return
// - another function call
// - additional variables
// Scroll down for hints.
if (a > b) {
a
} else {
b
}
}
// Don't mind this for now... | 23.439024 | 69 | 0.582726 |
ab294800797d2e5aa6b3601b67453103d19abed3 | 14,732 | //! Explicit VR Little Endian syntax transfer implementation
use crate::decode::basic::LittleEndianBasicDecoder;
use crate::decode::{BasicDecode, Decode, DecodeFrom};
use crate::encode::basic::LittleEndianBasicEncoder;
use crate::encode::{BasicEncode, Encode};
use crate::error::Result;
use byteordered::byteorder::{Byt... | 32.095861 | 97 | 0.525115 |
e82968d4c504539b394933ec90e47fe0b7b76844 | 20,752 | #[doc = "Reader of register EMR"]
pub type R = crate::R<u32, super::EMR>;
#[doc = "Writer for register EMR"]
pub type W = crate::W<u32, super::EMR>;
#[doc = "Register EMR `reset()`'s with value 0"]
impl crate::ResetValue for super::EMR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
... | 36.729204 | 276 | 0.598207 |
7a701ddebf8f1d040d6162744c17804ae9451b36 | 12,181 | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use common::{Location, Named, WithLocation};
use graphql_syntax::{FloatValue, OperationKind};
use intern::string_key::StringKey;
us... | 29.493947 | 94 | 0.622445 |
ccbae18565edffca98d148a4791ae93bf75d842f | 9,519 | //! String interner for Boa.
//!
//! The idea behind using a string interner is that in most of the code, strings such as
//! identifiers and literals are often repeated. This causes extra burden when comparing them and
//! storing them. A string interner stores a unique `usize` symbol for each string, making sure
//! ... | 29.199387 | 105 | 0.627272 |
56853c92eccc4d03c9d4801f9f37ed0d58bd1cc5 | 204 | mod lib;
use lib::Bst;
fn main() {
let mut t = Bst::new();
t.insert(5,String::from("Hello5"));
t.insert(3,String::from("Hello3"));
t.insert(6,String::from("Hello6"));
t.bst_get(4);
}
| 18.545455 | 39 | 0.563725 |
e24b411a3b54e00ab77c63bd337f2fede2806734 | 4,661 | use crate::core::ics02_client::error as client_error;
use crate::core::ics24_host::error::ValidationError;
use crate::core::ics24_host::identifier::{ClientId, ConnectionId};
use crate::proofs::ProofError;
use crate::Height;
use flex_error::define_error;
define_error! {
#[derive(Debug, PartialEq, Eq)]
Error {
... | 30.664474 | 143 | 0.518344 |
e667c01193f12890b8de44d98a139aa1e7ef1363 | 1,687 | // Copyright 2020 Ant Group. All rights reserved.
// Copyright (C) 2020 Alibaba Cloud. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0
use std::collections::HashMap;
use std::io::Result;
use std::sync::Arc;
use nydus_utils::digest;
use storage::device::BlobInfo;
use crate::metadata::{Inode, RafsInode,... | 23.109589 | 91 | 0.594547 |
216d2800d8a0ac3e76d9fe2bcef0a286c4a304e2 | 1,360 | use byteorder::LittleEndian;
use crate::decode::Decode;
use crate::encode::Encode;
use crate::mysql::io::BufMutExt;
use crate::mysql::protocol::TypeId;
use crate::mysql::types::MySqlTypeInfo;
use crate::mysql::{MySql, MySqlData, MySqlValue};
use crate::types::Type;
impl Type<MySql> for [u8] {
fn type_info() -> My... | 24.727273 | 78 | 0.575 |
bb4a793045795df17a051729abe1f125859e6b4a | 13,102 | use crate::cli::connect::ConnectError;
use tedge_config::FilePath;
use url::Url;
#[derive(Debug, PartialEq)]
pub struct BridgeConfig {
pub cloud_name: String,
pub config_file: String,
pub connection: String,
pub address: String,
pub remote_username: Option<String>,
pub bridge_root_cert_path: F... | 33.423469 | 87 | 0.594947 |
ddabff534513cb6fb1e41eddf039b083a3cf04cc | 809 | use std::time::Instant;
use compute_shader::collatz;
use rayon::prelude::*;
fn main() {
let top = 2u32.pow(20);
let src_range = 1..top;
let start = Instant::now();
let result = src_range
.clone()
.into_par_iter()
.map(collatz)
.collect::<Vec<_>>();
let took = start.... | 24.515152 | 61 | 0.443758 |
0938504e45a70275ee210b03166072c824d08e59 | 448 | use serde::{Deserialize, Deserializer};
pub(crate) fn keywords_map<'de, D>(deserializer: D) -> Result<String, D::Error>
where
D: Deserializer<'de>,
{
String::deserialize(deserializer).map(|x| {
match x.as_str() {
"0x8020000000000000" => "Audit Success",
"0x80100000000000... | 26.352941 | 79 | 0.537946 |
712ba24fe7ca10385d1c0e546a6e0f83fa2dfa30 | 721 | // 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 w... | 36.05 | 75 | 0.742025 |
aceb351e6a527cc14020864aa60527bfcca97cec | 8,172 | use crate::{
client::{
Client,
ClientOptions,
client::ConnectionMode,
KeepAlive,
},
Error, Result,
util::{
TokioRuntime,
}
};
use url::Url;
#[cfg(any(feature = "tls", feature = "websocket"))]
use ::rustls;
#[cfg(feature = "tls")]
use std::sync::Arc;
use toki... | 36 | 145 | 0.607685 |
ddccaa20d9986d9d72d2a3953f8b8232b327ea8f | 15,984 | // This file was split off of a file that was part of https://github.com/alexheretic/glyph-brush
use gl::types::*;
use glyph_brush::rusttype::Scale;
use glyph_brush::*;
use macros::{d, invariants_checked};
use std::{ffi::CString, mem, ptr, str};
pub const EDIT_Z: f32 = 0.5;
pub const HIGHLIGHT_Z: f32 = 0.4375;
pub con... | 32.032064 | 98 | 0.532908 |
1ef17d079f0d02b2695e148055ed17a5735ec7b4 | 1,054 | use super::super::super::EnumTrait;
use std::str::FromStr;
#[derive(Clone, Debug)]
pub enum ClipboardFormatValues {
Bitmap,
Picture,
PictureOld,
PicturePrint,
PictureScreen,
}
impl Default for ClipboardFormatValues {
fn default() -> Self { Self::PictureOld }
}
impl EnumTrait for ClipboardFormatV... | 27.736842 | 57 | 0.547438 |
09cfdcef8760878a517dc3a5bfa7e1149225ef4f | 375 | #[repr(i32)]
pub enum SurfaceType {
Image = 0,
PDF = 1,
PS = 2,
XLib = 3,
XCB = 4,
Glitz = 5,
Quartz = 6,
Win32 = 7,
BeOS = 8,
DirectFB = 9,
SVG = 10,
OS2 = 11,
Win32Printing = 12,
QuartzImage = 13,
Script = 14,
Qt = 15,
Recording = 16,
VG = 17,
GL = 18,
DRM = 19,
Tee = 20,
X... | 12.931034 | 22 | 0.501333 |
7297ddbefd78b7864a989910efd78123422d5b46 | 866 | use random_nnue_eval::eval_value::{EvalValueNnue, EvalValueNnueHalfKPE9};
use std::f64::NAN;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let odir = "eval_halfkpe9";
println!("{}", &odir);
match std::fs::create_dir(&odir) {
Err(why) => println!("! {:?}", why.kind()),
Ok(_) => {}
... | 27.0625 | 73 | 0.495381 |
0309520095af24a5b4171b5ea810c7dcbdf29f44 | 5,400 | // Copyright 2013 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// 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 ... | 34.394904 | 110 | 0.568148 |
fea0f7a38699007c8f09cea186851e97aab4b8c8 | 10,378 | use crate::checks::ENABLED_CHECK;
use chrono::DateTime;
use heim::{
memory::{
Memory,
Swap,
},
units::{
frequency::{
gigahertz,
hertz,
},
information::{
byte,
gigabyte,
},
time::nanosecond,
Freque... | 30.523529 | 124 | 0.47302 |
5de6b96186ddebc2e6566f11b8d20db9840b9ded | 12,221 | // 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 crate::switchboard::base::*;
use anyhow::{format_err, Error};
use futures::channel::mpsc::UnboundedSender;
use futures::lock::Mutex;
use std::collec... | 32.245383 | 94 | 0.596023 |
0e9f46246fd26fbb2f8af6c228cdfaebd2b6783c | 2,133 | use crate::cert::NebulaCertificate;
use anyhow::Result;
use std::sync::{Arc, RwLock};
#[derive(Debug, PartialEq, Clone)]
pub struct CertStateInner<'a> {
pub certificate: &'a NebulaCertificate,
pub raw_certificate: Vec<u8>,
pub raw_certificate_no_key: Vec<u8>,
pub public_key: Vec<u8>,
pub private_ke... | 29.625 | 83 | 0.570089 |
ede255e8942e31a77641a882340ca5c41724485f | 1,664 | use std::collections::VecDeque;
#[derive(Clone)]
pub struct HistoryList<T> {
maxlen: usize,
past: VecDeque<T>,
pub current: T,
future: VecDeque<T>,
}
impl<T> HistoryList<T> {
pub fn new(init: T, maxlen: usize) -> HistoryList<T> {
let past = VecDeque::with_capacity(maxlen);
let futu... | 23.771429 | 73 | 0.492788 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.