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 |
|---|---|---|---|---|---|
283b34d583fc5b7027ee1ebc5ba6ab788ece106d | 4,735 | //! RPC request support.
use http;
use hyper;
use prost;
use futures::prelude::*;
use super::frame;
use futures::{future, stream};
use super::future::*;
use super::metadata::*;
use super::status::*;
/// Common trait for RPC request types.
pub trait Request {
/// Converts an HTTP request into a future that prod... | 28.871951 | 99 | 0.574234 |
76e5fd2026991698ba3ab138e9d9b498a34968ca | 2,554 | //! @ \TeX\ always knows at least one font, namely the null font. It has no
//! characters, and its seven parameters are all equal to zero.
//
// @<Initialize table...@>=
#[allow(unused_variables)]
pub(crate) macro Initialize_table_entries_done_by_initex_only_0552($globals:expr) {{
let globals = &mut *$globals;
... | 43.288136 | 84 | 0.696554 |
1dd46efd8003c70418c52a322ded6217a463b47b | 1,009 | // option2.rs
// Make me compile! Execute `rustlings hint option2` for hints
fn main() {
let optional_value = Some(String::from("rustlings"));
// TODO: Make this an if let statement whose value is "Some" type
if let value = optional_value {
println!("the value of optional value is: {:?}", So... | 33.633333 | 109 | 0.564916 |
d9a7a7726ed3417c6275530efdfb08c80a02531b | 7,738 | use derivative::Derivative;
use futures::{stream::BoxStream, Stream, StreamExt};
use kube::{
api::{ListParams, Meta, WatchEvent},
Api,
};
use serde::de::DeserializeOwned;
use smallvec::SmallVec;
use snafu::{Backtrace, ResultExt, Snafu};
use std::clone::Clone;
#[derive(Snafu, Debug)]
pub enum Error {
#[snaf... | 37.563107 | 110 | 0.588912 |
9c98dc1e84fa5e0a7b8a4c0f09562453297b3979 | 1,223 | use std::io;
use sdl2::video::WindowBuildError;
use sdl2::IntegerOrSdlError;
use sdl2::render::TextureValueError;
use sdl2::render::TargetRenderError;
use sdl2::render::UpdateTextureError;
#[derive(Debug)]
pub enum Error {
Io(io::Error),
Text(String),
WindowBuildError,
IntegerOrSdlError,
TextureVa... | 20.04918 | 45 | 0.659035 |
8abea75a5f4b74fed1d5d7a6513d0f37c3ed752c | 1,690 | #[allow(unused_imports)]
use serde_json::Value;
#[allow(unused_imports)]
use std::borrow::Borrow;
#[allow(unused_imports)]
use super::*;
#[derive(Debug, Default, Serialize, Deserialize, PartialEq)]
pub struct r#GroupProfile {
#[serde(rename = "description", skip_serializing_if = "Option::is_none")]
r#descrip... | 23.802817 | 85 | 0.590533 |
d60bdb6899c574a11ba09496d1bbf188e7b7d54d | 5,007 | //! A simple GVN pass.
use cursor::{Cursor, FuncCursor};
use dominator_tree::DominatorTree;
use ir::{Function, Inst, InstructionData, Opcode, Type};
use scoped_hash_map::ScopedHashMap;
use std::cell::{Ref, RefCell};
use std::hash::{Hash, Hasher};
use std::vec::Vec;
use timing;
/// Test whether the given opcode is uns... | 34.061224 | 94 | 0.540643 |
50c82fe63e3abfdbcc5aa385c6282c680911d128 | 193 | mod api;
mod dispath_request;
mod method;
mod request;
pub use api::API;
pub use dispath_request::{DispatchRequest, GetRequest, PostRequest};
pub use method::Method;
pub use request::Request;
| 19.3 | 68 | 0.777202 |
bb31f072c638517c0fbfd9821cd3017e32876447 | 768 | // traits2.rs
//
// Your task is to implement the trait
// `AppendBar' for a vector of strings.
//
// To implement this trait, consider for
// a moment what it means to 'append "Bar"'
// to a vector of strings.
//
// No boiler plate code this time,
// you can do this!
trait AppendBar {
fn append_bar(self) -> Self... | 20.756757 | 61 | 0.60026 |
09a7464253d392d8e2dc057c60845a9f426f02f5 | 1,357 | extern crate px4_ulog;
use px4_ulog::models::ULogData;
use px4_ulog::parser::dataset::*;
use std::collections::HashSet;
use std::fs::File;
fn main() {
let mut args = std::env::args();
let cmd = args.next();
if let Some(filename) = args.next() {
let mut log_file = File::open(&filename).unwrap();
... | 31.55814 | 97 | 0.484893 |
f88d7d07fa562c6fc724d28b4fb9d2e97ad63725 | 8,236 | extern crate redis;
use self::redis::aio::ConnectionManager;
use self::redis::ConnectionInfo;
use crate::counter::Counter;
use crate::limit::{Limit, Namespace};
use crate::storage::keys::*;
use crate::storage::redis::scripts::{SCRIPT_DELETE_LIMIT, SCRIPT_UPDATE_COUNTER};
use crate::storage::{AsyncStorage, Authorizatio... | 32.812749 | 100 | 0.581472 |
ff801b67045c53335c7c48470ff04639c1b9111a | 4,098 | use std::borrow::Cow;
use std::fs;
use std::io::{self, BufRead, BufReader};
use std::path::PathBuf;
use std::process;
use structopt::StructOpt;
use sudachi::prelude::*;
#[cfg(feature = "bake_dictionary")]
const BAKED_DICTIONARY_BYTES: &[u8] = include_bytes!(env!("SUDACHI_DICT_PATH"));
/// A Japanese tokenizer
#[der... | 30.81203 | 85 | 0.537335 |
1c0605888aad5e41cce8e3342b9c0ad32f32eebe | 40 | pub mod fft;
use fft::*;
pub mod plot;
| 8 | 13 | 0.625 |
48379601414f34a039339394de4479683516afcd | 220 | fn main() {
// `n` will take the values: 1, 2, ..., 100 in each iteration
for n in 1..101 {
if n % 2 == 0 {
println!("even");
} else {
println!("{}", n);
}
}
}
| 20 | 65 | 0.372727 |
33b4957f75872a0aee22246eeacb3c42508d9fa1 | 1,589 | //! Crate name parsing.
use anyhow::Context as _;
use super::Dependency;
use super::RegistrySource;
use crate::util::validate_package_name;
use crate::CargoResult;
/// User-specified crate
///
/// This can be a
/// - Name (e.g. `docopt`)
/// - Name and a version req (e.g. `docopt@^0.8`)
/// - Path
#[derive(Debug)]
p... | 24.828125 | 86 | 0.569541 |
50830fa69f96562c362f124785c5dde9314a948a | 1,109 | /// If this is a valid NUL terminated C string, this function will return
/// it as a Rust str reference. If there is no NUL terminator, this will just consider
/// the entire array as the C string.
///
/// **NOTE** This function is only for debug purposes and may allocate if invalud UTF-8 sequences
/// are present in ... | 41.074074 | 101 | 0.669071 |
39cc8bced5005f793b4222bd3ac73f84f37db973 | 25,792 | #[doc = "Register `TCD0_CSR` reader"]
pub struct R(crate::R<TCD0_CSR_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<TCD0_CSR_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<TCD0_CSR_SPEC>> for R {
#[inline(always)]
fn from(reader: ... | 30.925659 | 411 | 0.578241 |
5b0a539a8944dbcb38ca0b84cf52f5f8433c43c3 | 3,456 | use anyhow::Context;
use crate::{
nlas::nsid::Nla,
traits::{Emitable, Parseable},
DecodeError, NsidHeader, NsidMessageBuffer,
};
#[derive(Debug, PartialEq, Eq, Clone, Default)]
pub struct NsidMessage {
pub header: NsidHeader,
pub nlas: Vec<Nla>,
}
impl<'a, T: AsRef<[u8]> + 'a> Parseable<NsidMessa... | 32 | 136 | 0.554398 |
5007d585fb92b94d05b1027899af5c3279b3c7e1 | 830 | // Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
use move_vm_types::{
gas_schedule::NativeCostIndex,
loaded_data::runtime_types::Type,
natives::function::{native_gas, NativeContext, NativeResult},
values::{values_impl::SignerRef, Value},
};
use std::collections::VecDe... | 28.62069 | 83 | 0.7 |
6702e253920927b2c97dffd5c38ee7afdb261999 | 65,840 | // Copyright 2013-2019, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <https://opensource.org/licenses/MIT>
#![allow(non_camel_case_types)]
#![cfg_attr(feature = "cargo-clippy", allow(unreadable_liter... | 39.28401 | 187 | 0.685556 |
c1a9636c415d574c9e68b159ced4b4a6a29dbed0 | 183 | #[derive(Debug, Clone)]
pub struct Memory {
pub items: Vec<u64>,
}
impl Memory {
pub fn new() -> Memory {
Memory {
items: vec![0; 100],
}
}
}
| 14.076923 | 32 | 0.47541 |
fc1380c50d2d1daa0c6af4f531214865a9de0d4e | 10,110 | use crate::result::*;
use crate::service::applet;
use crate::service::hid;
use crate::service::hid::IAppletResource;
use crate::service::hid::IHidServer;
use crate::ipc::sf;
use crate::svc;
use crate::mem;
use crate::vmem;
use crate::service;
use core::mem as cmem;
bit_enum! {
Key (u64) {
A = bit!(0),
... | 33.58804 | 331 | 0.653215 |
016b5fbb9625c12db721c3064393ad2bc7684367 | 15,427 | use crate::collection::CollectionName;
use crate::collection::{Collection, IndexingPolicy, PartitionKey};
use crate::prelude::*;
use crate::responses::CreateCollectionResponse;
use crate::{Offer, ResourceType};
use azure_core::errors::{check_status_extract_headers_and_body, AzureError};
use azure_core::prelude::*;
use ... | 30.308448 | 99 | 0.648538 |
01b0d3416dff7509c7daa8f1b7444261c938e141 | 4,240 | //! ListGroupsRequest
//!
//! See the schema for this message [here](https://github.com/apache/kafka/blob/trunk/clients/src/main/resources/common/message/ListGroupsRequest.json).
// WARNING: the items of this module are generated and should not be edited directly
#![allow(unused)]
use std::borrow::Borrow;
use std::col... | 34.193548 | 152 | 0.607075 |
09b7c0bb15d77366e5c05122ef977a41a2f87e4c | 281 | use tokio::sync::oneshot;
#[derive(Debug)]
pub enum Command {
Get {
key: Key,
cb: oneshot::Sender<Option<Value>>,
},
Set {
key: Key,
value: Value,
},
}
pub type Key = String;
pub type KeyRef<'a> = &'a str;
pub type Value = String;
| 15.611111 | 43 | 0.533808 |
ffc61a1d75f2eec5277045c42f85ece967ebe11d | 17,954 | #![cfg_attr(not(feature = "std"), no_std)]
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
#![recursion_limit = "256"]
// Make the WASM binary available.
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
use pallet_grandpa::{
fg_primitives, A... | 32.703097 | 106 | 0.743066 |
796c4d76096b5ac6bd96bbf26c3c5e32f6b7800c | 103 | #![feature(try_from)]
extern crate combine;
extern crate pretty;
pub mod cst;
mod lexer;
mod parser;
| 11.444444 | 21 | 0.737864 |
50d3c4096a20538f74be13ecbb95d414f817c694 | 2,574 | #[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::DATA_10_IN {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&... | 25.74 | 74 | 0.544678 |
2325de001a53a374e027ffe3ff01557c84738cfd | 1,059 | use serde::Serialize;
use crate::{
net,
requests::{Request, ResponseResult},
types::{Chat, ChatId, User, ChatMember},
Bot,
};
use std::sync::Arc;
/// Use this method to get up to date information about the chat (current name
/// of the user for one-on-one conversations, current username of a user, gro... | 26.475 | 90 | 0.66289 |
752bbc65dd37137de70beb873808f1ece020a4dd | 5,601 | #[doc = "Register `MATRIX_WPMR` reader"]
pub struct R(crate::R<MATRIX_WPMR_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<MATRIX_WPMR_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl core::convert::From<crate::R<MATRIX_WPMR_SPEC>> for R {
fn from(rea... | 30.774725 | 422 | 0.595429 |
640bb19a0d9c843d7e0e92a996454f6aa631b90b | 9,367 | use crate::cli::{
show_values, API_KEY_OPT, CONFIRM_FLAG, DELETE_SUBCMD, DESCRIPTION_OPT, EDIT_SUBCMD,
FORMAT_OPT, LIST_SUBCMD, NAME_ARG, SECRETS_FLAG, SET_SUBCMD,
};
use crate::config::{
Config, ConfigValue, PARAM_API_KEY, PARAM_ORG, PARAM_PROFILE, PARAM_ROLE, PARAM_USER,
};
use crate::database::{OpenApiCo... | 34.311355 | 115 | 0.601687 |
72c5a040c6d03f5ea38ddf538c796f3304e2cbf8 | 3,722 | use boring::ssl::{SslAcceptor, SslConnector, SslFiletype, SslMethod};
use futures::future;
use std::future::Future;
use std::net::{SocketAddr, ToSocketAddrs};
use std::pin::Pin;
use tokio::io::{AsyncReadExt, AsyncWrite, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tokio_boring::{HandshakeError, SslStre... | 29.539683 | 88 | 0.611231 |
f7eb7b47df07c1c4def219ed6cee8325b036c8d0 | 1,076 | //! Wasmtime's embedding API
//!
//! This crate contains a high-level API used to interact with WebAssembly
//! modules. The API here is intended to mirror the proposed [WebAssembly C
//! API](https://github.com/WebAssembly/wasm-c-api), with small extensions here
//! and there to implement Rust idioms. This crate also ... | 25.023256 | 80 | 0.693309 |
086ee4ffbcc6279709b175aa3e6e43008b247910 | 7,920 | // Copyright 2020 WeDPR Lab Project Authors. Licensed under Apache-2.0.
//! Signature function wrappers.
#![cfg(all(
feature = "wedpr_f_signature_secp256k1",
feature = "wedpr_f_signature_sm2"
))]
use wedpr_l_utils::traits::Signature;
#[cfg(feature = "wedpr_f_signature_secp256k1")]
use crate::config::SIGNATU... | 28.387097 | 88 | 0.671086 |
de65d9bbaba2b97863f157ea8ca1ad3af53d40ac | 592 | // Copyright 2012 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 ... | 25.73913 | 68 | 0.699324 |
3884efc13210e94703fd0671490d257f6926a3d5 | 1,363 | #[doc = "Reader of register AFEC_COSR"]
pub type R = crate::R<u32, super::AFEC_COSR>;
#[doc = "Writer for register AFEC_COSR"]
pub type W = crate::W<u32, super::AFEC_COSR>;
#[doc = "Register AFEC_COSR `reset()`'s with value 0"]
impl crate::ResetValue for super::AFEC_COSR {
type Type = u32;
#[inline(always)]
... | 26.72549 | 70 | 0.558327 |
338becabd381f9fb7f069cfa0c93bd9c1e22740e | 225 | #![deny(warnings, rust_2018_idioms)]
#![allow(clippy::inconsistent_struct_constructor)]
mod body;
mod request;
mod response;
pub use self::{
body::{BoxBody, Data},
request::BoxRequest,
response::BoxResponse,
};
| 17.307692 | 50 | 0.706667 |
f7c3a6d26422644303a674c2719218f4d5faa38e | 19,117 | /* EVMC: Ethereum Client-VM Connector API.
* Copyright 2019 The EVMC Authors.
* Licensed under the Apache License, Version 2.0.
*/
mod container;
pub use container::EvmcContainer;
pub use evmc_sys as ffi;
pub trait EvmcVm {
fn init() -> Self;
fn execute(&self, code: &[u8], context: &ExecutionContext) -> E... | 32.511905 | 98 | 0.551603 |
d732b1071d8a94830543dfde91f7fbbd82932dd2 | 451 | // build-pass
// compile-flags:-Zpolymorphize=on
pub trait ParallelIterator: Sized {
fn drive<C: Consumer<()>>(_: C) {
C::into_folder();
}
}
pub trait Consumer<T>: Sized {
type Result;
fn into_folder() -> Self::Result;
}
impl ParallelIterator for () {}
impl<F: Fn(), T> Consumer<T> for F {
... | 16.703704 | 38 | 0.556541 |
4b7c88029d35f1d5f1f510427add353a6a189fac | 14,329 | // This file is generated automatically. Do not edit it directly.
// See the Contributing section in README on how to make changes to it.
use std::cmp;
use rand::Rng;
use tcod::colors::*;
use tcod::console::*;
use tcod::map::{FovAlgorithm, Map as FovMap};
// actual size of the window
const SCREEN_WIDTH: i32 = 80;
con... | 29.006073 | 93 | 0.541419 |
e28d2db9076433aebeb547f7e5743bf634c2486a | 1,286 | // ======================================
// This file was automatically generated.
// ======================================
use crate::ids::{BitcoinTransactionId};
use crate::params::{Object, Timestamp};
use crate::resources::{Currency};
use serde_derive::{Deserialize, Serialize};
/// The resource representing a St... | 29.906977 | 125 | 0.643857 |
6a7fd36c643df2cffb70de339fa534494e666660 | 32,839 | //! A hash set implemented using `OrderMap`
use std::cmp::Ordering;
use std::collections::hash_map::RandomState;
use std::fmt;
use std::iter::{FromIterator, Chain};
use std::hash::{Hash, BuildHasher};
use std::mem::replace;
use std::ops::RangeFull;
use std::ops::{BitAnd, BitOr, BitXor, Sub};
use std::slice;
use std::v... | 28.882146 | 96 | 0.53945 |
08d6bbc6fb7518c3d36055e48de7a96c4120d3bb | 5,123 | //! A scalar that represents a number or a string.
use serde::{Deserialize, Serialize};
/// An int, float or a string value.
#[allow(missing_docs)]
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
#[cfg_attr(feature = "graphql", derive(async_graphql::Description))]
#[serde(untagged)]
pub enum SortedValue {
... | 30.494048 | 99 | 0.555924 |
11f27dd52984f5e85ef5c5d08c6426efe70998a4 | 70,295 | // Copyright © 2019 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
extern crate hypervisor;
#[cfg(target_arch = "x86_64")]
use crate::config::SgxEpcConfig;
use crate::config::{HotplugMethod, MemoryConfig, MemoryZoneConfig};
use crate::MEMORY_MANAGER_SNAPSHOT_ID;
#[cfg(feature = "acpi")]
use acpi_tables:... | 36.861563 | 116 | 0.496707 |
21d90c2bb9ffd16b79982425732fcd1683b73966 | 5,983 | // Copyright 2020 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.
pub mod task {
use core::task::{Context, Poll};
use std::future::Future;
use std::pin::Pin;
/// A handle to a task.
///
/// A task... | 32.873626 | 100 | 0.55875 |
188db9ac45a0a502e7c5b440cebec42008e5e1c0 | 1,612 | // Copyright 2014-2015 The GeoRust 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 a... | 29.309091 | 96 | 0.643921 |
ccc7d30b37992d96f5c1d3536d2003290567a7a2 | 9,197 | use std::{thread, time};
use ftp::FtpStream;
use pretty_assertions::assert_eq;
macro_rules! start_server {
( $addr:expr, $path:expr ) => {
thread::spawn(move || {
let server = firetrap::Server::with_root($path);
server.listen($addr.clone());
});
// Give the server s... | 29.477564 | 101 | 0.624225 |
71d616338eed06fbf4b29bf1c29337e975901730 | 42,254 | use crate::gen::block::Block;
use crate::gen::nested::NamespaceEntries;
use crate::gen::out::OutFile;
use crate::gen::{builtin, include, Opt};
use crate::syntax::atom::Atom::{self, *};
use crate::syntax::symbol::Symbol;
use crate::syntax::{
mangle, Api, Enum, ExternFn, ExternType, Pair, ResolvableName, Signature, S... | 32.959438 | 124 | 0.520258 |
626003adaad86e16357c5e3a79a20da2f2e8808f | 1,284 | use std::fmt::Debug;
use std::rc::Rc;
use crate::Color;
use crate::focus::Focus;
pub use crate::state::value_cell::{ValueCell, ValueRef, ValueRefMut};
pub use self::animated_state::*;
pub use self::animation_curve::*;
pub use self::env_state::EnvState;
pub use self::global_state::GlobalState;
pub use self::local_stat... | 25.176471 | 69 | 0.753894 |
87c428aa05aa6b409a647794a8795191796e92ed | 3,487 | use crate::{
interfaces::{LinearFeeDef, ValueDef},
time::SystemTime,
};
use chain_addr::Discrimination;
use chain_impl_mockchain::block::Epoch;
use chain_impl_mockchain::fee::LinearFee;
use chain_impl_mockchain::rewards::{CompoundingType, Limit, Parameters, Ratio, TaxType};
use chain_impl_mockchain::value::Valu... | 31.990826 | 88 | 0.692859 |
6a8828e45d2027751d507c4a68420937ab8a5930 | 12,478 | // Copyright 2015 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 ... | 30.508557 | 118 | 0.571406 |
d6e169279054920d89573c8bd5edb2d6718d87e2 | 5,285 | use crate::gimli_common::gimli;
use std::io;
pub struct GimliAeadEncryptIter{
state: [u32; 12],
message_len: usize,
message: Box<dyn Iterator<Item = Result<u8, io::Error>>>,
output_buffer: Vec<u8>,
complete: bool,
last_blocksize: usize,
}
impl GimliAeadEncryptIter{
pub fn new(key: [u8; 32]... | 34.318182 | 106 | 0.5614 |
146e0c712a33de3d3843f670365e0bc91212ada6 | 12,304 | // Copyright 2012 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 ... | 40.20915 | 77 | 0.568839 |
1101861c09edd4cd95d7a8e6738c1cfefd2c3bc7 | 621 | // 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 ... | 31.05 | 76 | 0.702093 |
e9fd7e353ba61cf7116af0a85a9eebbe56aae7de | 409 | /// Global ID generator.
/// It is needed to uniquely identify a variable across scopes.
/// In the canonical jlox implementation it's not needed because all Java objects
/// have a globally unique ID provided by JVM.
use std::sync::atomic::{AtomicUsize, Ordering};
static ID_GENERATOR: AtomicUsize = AtomicUsize::new(0... | 34.083333 | 81 | 0.738386 |
d7391b3c85ad7d75ad74c44a1c16e1ffb3d1ebfb | 1,215 | #![feature(test)]
use edit_tree::{Apply, EditTree, ToLowerCharVec};
extern crate test;
use test::{black_box, Bencher};
static FORM: &'static [&'static str] = &[
"ist",
"Gelegenheiten",
"aufgegangen",
"letzte",
"storniert",
"gratulierte",
"gelenkt",
"abgesessen",
];
static LEMMA: &'s... | 20.59322 | 87 | 0.542387 |
333fc5dc6e9629bae4b2ca85611bd37fc8944ab7 | 300 | extern crate reqwest;
pub struct Endpoint {
base_url: String
}
impl Endpoint {
pub fn new(base_url: String) -> Endpoint {
Endpoint {
base_url
}
}
pub fn all(&self) -> Result<String, reqwest::Error> {
reqwest::get(&self.base_url)?.text()
}
}
| 16.666667 | 57 | 0.563333 |
11e23403e43d3d91b91f9af02f74257f2aeb5ab5 | 8,039 | #![crate_name = "wc"]
#![feature(path_ext)]
/*
* This file is part of the uutils coreutils package.
*
* (c) Boden Garman <bpgarman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
extern crate getopts;
extern crate libc... | 28.608541 | 100 | 0.550939 |
e90835dd89d709984d207b6c97237157afab2dd8 | 1,254 | struct Solution;
#[allow(clippy::wrong_self_convention)]
impl Solution {
fn to_goat_latin(s: String) -> String {
let words: Vec<&str> = s.split_whitespace().map(|s| s.chars().as_str()).collect();
let mut res: String = "".to_string();
let mut n = 1;
for word in words {
if... | 30.585366 | 136 | 0.460925 |
16de45e4d64804bd15d83ead5f0716b92ce82b1b | 6,528 | use swc_common::{Spanned, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_transforms_base::perf::Check;
use swc_ecma_transforms_macros::fast_path;
use swc_ecma_utils::UsageFinder;
use swc_ecma_visit::noop_visit_type;
use swc_ecma_visit::Node;
use swc_ecma_visit::Visit;
use swc_ecma_visit::VisitWith;
use swc_ecma_visit::{n... | 25.802372 | 99 | 0.514246 |
b971edf17944859f2e0cfd3e3d8f0d2b7a3fd822 | 24,901 | // Copyright 2015-2016 Brian Smith.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAI... | 30.18303 | 100 | 0.597767 |
8f60bb0de0e6648566fd1e835bca74f3fa292720 | 9,635 | use core::pin::Pin;
use core::task::{Context, Poll};
use std::collections::HashSet;
use std::sync::Arc;
use crate::contribution::AggregatableContribution;
use crate::evaluator::Evaluator;
use crate::update::LevelUpdate;
use futures::stream::{BoxStream, Stream, StreamExt};
/// A TodoItem represents a contribution whic... | 49.92228 | 152 | 0.553088 |
f7a14a278030fda5a1c3ae6fbad0a3e98dfd7d0a | 368 | /// 颠倒二进制位
/// 颠倒给定的 32 位无符号整数的二进制位。翻转二进制数
pub fn reverse_bits(x: u32) -> u32 {
let mut res = 0;
let mut n = x;
let mut count = 31;
while n > 0 {
res += (n & 1) << count; // 获取最后一位数字 移位到正确位置
n >>= 1; // 右移一位, 去掉末尾数字
count -= 1;
}
res
}
#[test]
fn test_reverse_bits() {
... | 20.444444 | 52 | 0.540761 |
ff99a4b7ff63828a17b5fd2d44cd4144e63b7428 | 8,731 | // Copyright 2012 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 ... | 45.952632 | 98 | 0.565571 |
72778fda19ba5b05d0b76802390201fab51210ff | 51,326 | // Copyright (C) 2022 Scott Lamb <slamb@slamb.org>
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Message layer: statelessly converts [`crate::pkt`] packets into higher-level
//! messages and vice versa.
#[cfg(feature = "arbitrary")]
use arbitrary::Arbitrary;
#[cfg(feature = "serde")]
use serde::{de::Error as _, ... | 31.201216 | 99 | 0.535128 |
9ce6ca7b37119fd0dc83537d38c13193540d2eaa | 2,157 | /*
* Copyright 2019 The Starlark in Rust Authors.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* 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/lic... | 30.814286 | 91 | 0.642559 |
e4355c7e02f35ab6435a5e410aa7f8506b457c92 | 665 | // Copyright 2012 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 ... | 25.576923 | 68 | 0.664662 |
0aaa44d539b835eadeadb8abfed59134f01e4a18 | 4,537 | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// 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.o... | 28.35625 | 83 | 0.610095 |
7a6f2e25c398373e8590b77908a57602b536fba7 | 10,833 | // Copyright 2022 TiKV Project Authors. Licensed under Apache-2.0.
use cc::Build;
use cmake::Config;
use std::path::{Path, PathBuf};
use std::{env, str};
// On these platforms jemalloc-sys will use a prefixed jemalloc which cannot be linked together
// with RocksDB.
// See https://github.com/gnzlbg/jemallocator/blob/... | 35.058252 | 117 | 0.592541 |
87597d640ea223959b1c39c796c9d8769c609f18 | 639 | /*
*
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/
/// LogSeverityLevels : Allowable severity levels for log events.
/// Allowable severity leve... | 21.3 | 109 | 0.666667 |
acdea52c55e4882d9940870460d54b3e9bcf16e1 | 5,644 | // Copyright 2021 Datafuse Labs.
//
// 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 agre... | 32.436782 | 147 | 0.593373 |
09a234e0316d36891699669c45b3b58b65e27f21 | 3,036 | use crate::changelog::fs_utils::{read_and_filter_dir, read_to_string_opt};
use crate::changelog::parsing_utils::trim_newlines;
use crate::{ChangeSetSection, Config, Error, Result};
use log::debug;
use std::fs;
use std::path::{Path, PathBuf};
/// A set of changes, either associated with a release or not.
#[derive(Debug... | 33.733333 | 95 | 0.608037 |
1ae4a366ce6e920d63c62a17626ca1c0fac5ba55 | 121,701 | use crate::{
checks::*,
cli::{
log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError,
ProcessResult,
},
};
use bip39::{Language, Mnemonic, MnemonicType, Seed};
use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
use log::*;
use solana_account_decoder::{UiAccoun... | 38.795346 | 141 | 0.516027 |
564c4d3ef3ffbfbd22a3d23261e364854753ac20 | 26,842 | use std::{cell::RefCell, fmt, future::Future, marker::PhantomData, rc::Rc};
use actix_http::{body::BoxBody, Extensions};
use actix_router::{IntoPatterns, Patterns};
use actix_service::{
apply, apply_fn_factory, boxed, fn_service, IntoServiceFactory, Service, ServiceFactory,
ServiceFactoryExt, Transform,
};
use... | 32.300842 | 100 | 0.504731 |
e228bafe7a39ea81673c73bcaa280a7da71a2a54 | 7,962 | use kzg::{Fr, G1, G1Mul, G2, G2Mul};
use rand::{Rng, thread_rng};
use crate::consts::{BlstFp, BlstFp2, BlstP1, BlstP2, G1_NEGATIVE_GENERATOR, G2_NEGATIVE_GENERATOR};
extern "C" {
// Fr
fn fr_from_uint64(out: *mut BlstFr, n: u64);
fn fr_from_uint64s(out: *mut BlstFr, vals: *const u64);
fn fr_to_uint64s(... | 23.348974 | 107 | 0.475132 |
f733697a5e970ed349c2eb5faf8bcd046291b44b | 1,319 | //! A good way of displaying an SVG image in egui.
//!
//! Requires the dependency `egui_extras` with the `svg` feature.
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
use eframe::egui;
fn main() {
let options = eframe::NativeOptions {
init... | 26.38 | 111 | 0.580743 |
f8625202b4114109040bd25b0c587bd9a47be739 | 1,448 | use std::time::Duration;
use futures::future::join_all;
use futures::FutureExt;
use tokio::time::timeout;
use ractor::{Actor, Broker, Context, MessageHandler};
#[derive(Debug)]
struct Sleep(u64);
#[derive(Default)]
struct MyActor;
#[async_trait::async_trait]
impl Actor for MyActor {
const MAIL_BOX_SIZE: u32 = ... | 23.737705 | 91 | 0.629144 |
ab48ecb22d31b2f71bbe20e015d40eeac032831e | 18,469 | //! Derive a builder for a struct
//!
//! This crate implements the [builder pattern] for you.
//! Just apply `#[derive(Builder)]` to a struct `Foo`, and it will derive an additional
//! struct `FooBuilder` with **setter**-methods for all fields and a **build**-method
//! — the way you want it.
//!
//! # Quick Start
//... | 32.921569 | 120 | 0.607883 |
9b3a617eecf2c6d75c9780f1295d64fe4bec956c | 11,446 | //! An easy to use library for pretty print tables of Rust `struct`s and `enum`s.
//!
//! The library is based on a [Tabled] trait which is used to actually build tables.
//! It also provides an variate of dynamic settings for customization of a [Table].
//!
//! [Table] can be build from vast majority of Rust's standar... | 26.868545 | 98 | 0.520531 |
d9eec480cd0c613a1df6e309619526d4c37f1afc | 278 | #![feature(core_intrinsics)]
fn main() {
let x = 5;
unsafe {
std::intrinsics::assume(x < 10);
std::intrinsics::assume(x > 1);
std::intrinsics::assume(x > 42); //~ ERROR constant evaluation error
//~^ NOTE `assume` argument was false
}
}
| 23.166667 | 76 | 0.568345 |
1d66be29f63cb188d0a3831338d881a29dacf301 | 15,995 | #[doc = "Register `EVCTRL` reader"]
pub struct R(crate::R<EVCTRL_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<EVCTRL_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<EVCTRL_SPEC>> for R {
#[inline(always)]
fn from(reader: crate::R... | 29.785847 | 406 | 0.571741 |
1426174b482b64af54495f376ab182502ea48096 | 2,727 | // Copyright 2017 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 ... | 27 | 78 | 0.508984 |
4b6f03c0331801498b9b92f3891201db7fe891fb | 7,169 | /// A set of possible key presses, equivalent to the one in `termion@1.5.5::event::Key`
#[derive(Debug, Clone, Copy)]
pub enum Key {
Backspace,
Left,
Right,
Up,
Down,
Home,
End,
PageUp,
PageDown,
BackTab,
Delete,
Insert,
F(u8),
Char(char),
Alt(char),
Ctrl(... | 33.189815 | 92 | 0.469382 |
e69ca971b5234f3533f871dd8920d6fe1678335a | 6,965 | // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
use crate::colors;
use crate::version;
use deno_core::error::type_error;
use deno_core::error::AnyError;
use deno_core::error::Context;
use deno_core::futures::FutureExt;
use deno_core::resolve_url;
use deno_core::serde::Deserialize;
use deno_c... | 31.515837 | 78 | 0.702513 |
ffb6f47fd05a515a0b267eaae571e5e8672861fd | 4,130 | #![no_main]
#![no_std]
#![feature(default_alloc_error_handler)]
extern crate alloc;
use alloc::vec;
use alloc_cortex_m::CortexMHeap;
use cherry::widget::{
container::{Alignment, Axis, Border, Container, Insets, Justification},
Widget,
};
use defmt_rtt as _;
use embedded_graphics::{pixelcolor::BinaryColor, pre... | 25.493827 | 90 | 0.606295 |
fbc294081fc5205f0869a7b8bb2079a5bb63e97a | 41,544 | use super::grammars::{ExternalToken, LexicalGrammar, SyntaxGrammar, VariableType};
use super::nfa::CharacterSet;
use super::rules::{Alias, AliasMap, Symbol, SymbolType};
use super::tables::{
AdvanceAction, FieldLocation, LexState, LexTable, ParseAction, ParseTable, ParseTableEntry,
};
use core::ops::Range;
use hash... | 34.248969 | 98 | 0.467601 |
cccae303889f2f774ce53117b51e20c1ff96e9e7 | 1,219 | // CATCHUp query experiments with pregenerated queries with source and target drawn uniformly at random.
// Takes as input one directory arg which should contain the all data.
use std::{env, error::Error, path::Path};
use rust_road_router::{
algo::customizable_contraction_hierarchy::*,
cli::CliErr,
datast... | 32.945946 | 104 | 0.674323 |
891c6656d66b62b11d0475b0d637d27b35d7d86e | 15,913 | /*
* MIT License
*
* Copyright (c) 2020 Reto Achermann
*
* 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, m... | 25.874797 | 136 | 0.526299 |
2f28c94c43667488ac2c6c7eda2ce12e87da5a06 | 1,450 | // Copyright (C) 2019 Martin Mroz
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
use std::error;
use std::fmt;
use std::result;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub enum Error {
/// The BCBP string does not... | 32.954545 | 79 | 0.626897 |
1db97d5d36149d28aedc8196fb70850cca251d68 | 4,266 | // The From trait is used for value-to-value conversions.
// If From is implemented correctly for a type, the Into trait should work conversely.
// You can read more about it at https://doc.rust-lang.org/std/convert/trait.From.html
#[derive(Debug)]
struct Person {
name: String,
age: usize,
}
// We implement th... | 29.832168 | 96 | 0.576653 |
6ae3bc285dfc37dcd18aeac06b760d62a6a54eeb | 708 | use algebra_core::Field;
use r1cs_core::{ConstraintSystem, SynthesisError};
use r1cs_std::prelude::*;
use crate::signature::SignatureScheme;
pub trait SigRandomizePkGadget<S: SignatureScheme, ConstraintF: Field> {
type ParametersGadget: AllocGadget<S::Parameters, ConstraintF> + Clone;
type PublicKeyGadget: T... | 32.181818 | 75 | 0.710452 |
de4b8dea115b4bb514a8b87477347f962c62095d | 10,790 | /*
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 02/07/2017
Last Modified: 13/10/2018
License: MIT
*/
use whitebox_raster::*;
use crate::tools::*;
use num_cpus;
use std::env;
use std::f64;
use std::io::{Error, ErrorKind};
use std::path;
use std::sync::mpsc;
use ... | 35.610561 | 161 | 0.503429 |
90d2c5fe00718579b63a712debe0ade09b769a13 | 8,574 | use crate::ciphersuite::{signable::*, *};
use crate::codec::*;
use crate::config::Config;
use crate::config::ProtocolVersion;
use crate::extensions::*;
use crate::group::*;
use crate::schedule::psk::PreSharedKeys;
use crate::schedule::JoinerSecret;
use crate::tree::{index::*, *};
use serde::{Deserialize, Serialize};
... | 26.140244 | 93 | 0.605668 |
d9c91a4222ad3b3972c4ad0fbc5ce90445ab8ee7 | 178 | use bracket_random::prelude::*;
fn main() {
let mut rng = RandomNumberGenerator::new();
DiceIterator::new(6, &mut rng).take(10).for_each(|n| println!("Rolled {}", n));
} | 29.666667 | 83 | 0.640449 |
3376274b7b9eeed8b1e0aa27f2f4f302a526dfd3 | 918 | use std::sync::atomic::{self, Ordering};
#[cfg_attr(nightly, repr(align(64)))]
#[derive(Debug)]
struct AtomicBool(atomic::AtomicBool);
impl AtomicBool {
#[inline]
fn new(v: bool) -> Self {
AtomicBool(atomic::AtomicBool::new(v))
}
#[inline]
fn load(&self, order: Ordering) -> bool {
... | 19.531915 | 52 | 0.62963 |
912200d25ca732408abe4b4272a0406aa24e76c7 | 2,697 | // I was going to write a linked-list but then I read Learning Rust With Entirely Too Many Linked
// Lists (http://cglab.ca/~abeinges/blah/too-many-lists/book/README.html) which is worth reading
// but also convinced me to use a Vec instead.
//
// Note: this puzzle is very similar to https://en.wikipedia.org/wiki/Josep... | 31.360465 | 97 | 0.602521 |
03c559aad268c45484dd08d843a71d72b7a5cbfa | 3,795 | use liturgy::{Psalm, PsalmSection, PsalmVerse, Reference, Source};
lazy_static! {
pub static ref PSALM_7: Psalm = Psalm {
number: 7,
citation: None,
sections: vec![PsalmSection {
reference: Reference {
source: Source::BCP1979,
page: 590
... | 35.138889 | 104 | 0.562319 |
017e6bff543692b8c810f9cef7f4ebff9e79204f | 927 | pub fn map_values(
value: u32,
input_min: u32,
input_max: u32,
target_min: u32,
target_max: u32,
) -> f32 {
let slope = (target_max - target_min) as f32 / (input_max - input_min) as f32;
(value - input_min) as f32 * slope + target_min as f32
}
#[cfg(test)]
mod tests {
use crate::map_val... | 23.175 | 82 | 0.582524 |
f95544cdcd9493c61d4155210ff168b6d26275e1 | 9,577 | mod converters;
mod winit_config;
mod winit_windows;
use bevy_input::{
keyboard::KeyboardInput,
mouse::{MouseButtonInput, MouseMotion, MouseScrollUnit, MouseWheel},
};
pub use winit_config::*;
pub use winit_windows::*;
use bevy_app::{prelude::*, AppExit};
use bevy_ecs::Resources;
use bevy_math::Vec2;
use bevy_... | 40.07113 | 117 | 0.558004 |
e4ce049eea5f6032001ce642609d33aacf2b4ceb | 79 | //! Reexport odbc-sys as ffi
extern crate odbc_sys;
pub use self::odbc_sys::*;
| 19.75 | 28 | 0.721519 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.