blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
bd2282d17939d721d65552035ab9085a8a646eea | Rust | fractalide/ftpc | /src/common.rs | UTF-8 | 2,682 | 2.578125 | 3 | [] | no_license | #![allow(dead_code)]
use {
std::{
fs,
env,
path::PathBuf,
io::Write,
},
copernica_protocols::{
FilePacker,
},
copernica_common::{HBFI},
anyhow::{Result},
copernica_identity::{PrivateIdentity},
};
pub fn generate_random_dir_name() -> PathBuf {
use ... | true |
1063492095f97368571e19deef518f2518e97914 | Rust | ryanfuji/rust-book | /control_flow_if_let/src/main.rs | UTF-8 | 2,569 | 4.125 | 4 | [
"MIT"
] | permissive | // The `if let` syntax lets you combine `if` and `let` into a less verbose why to andle values that
// match one pattern while ignoring the rest. The code below matches on an `Option<u8>` value and
// only exectues code if the value is 3
fn main() {
let some_u8_value = Some(0u8);
match some_u8_value {
S... | true |
abe392a68f648d9c6afc62822650bab0d76c4134 | Rust | Ameobea/wasm-bindgen | /crates/js-sys/tests/wasm/Error.rs | UTF-8 | 1,023 | 2.8125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use wasm_bindgen::JsValue;
use wasm_bindgen_test::*;
use js_sys::*;
#[wasm_bindgen_test]
fn new() {
let error = Error::new(&"some message".into());
assert_eq!(JsValue::from(error.message()), "some message");
}
#[wasm_bindgen_test]
fn set_message() {
let error = Error::new(&"test".into());
error.set_me... | true |
98ab89e1d823d8e5c1eb882ebc185a7ec6e06538 | Rust | aidos9/CSVRust | /examples/01_generic_usage.rs | UTF-8 | 1,614 | 3.65625 | 4 | [] | no_license | // Sample code for using the library.
extern crate csv_parser;
// We want to fill out this struct.
struct Person {
first_name: String,
last_name: String,
date_of_birth: String,
email: String,
}
impl Person {
// We can define a method to construct the struct from a CSVRow
pub fn construct_from_... | true |
604aaf373b78d917cd320f931430f75b2e90a271 | Rust | brl/citadel-tools | /libcitadel/src/blockdev.rs | UTF-8 | 5,771 | 2.921875 | 3 | [] | no_license | use std::fs::{File,OpenOptions};
use std::io::{Read,Write,Seek,SeekFrom};
use std::os::unix::io::AsRawFd;
use std::os::unix::fs::OpenOptionsExt;
use std::path::Path;
use libc;
use crate::Result;
// IO on block devices requires 4096 byte aligned buffer
const REQUIRED_ALIGNMENT: usize = 4096;
const DEFAULT_ALIGNMENT: ... | true |
1eeae820322ada154565e453bd3b371c2bf1c134 | Rust | ejmahler/RustDHT | /src/scalar/dht_naive.rs | UTF-8 | 5,770 | 2.921875 | 3 | [] | no_license | use num_traits::Zero;
use rustfft::{FftNum, Length};
use crate::{Dht, twiddles, array_utils, dht_error_inplace, dht_error_outofplace};
/// Naive O(n^2 ) Discrete Hartley Transform implementation
///
/// This implementation is primarily used to test other DHT algorithms.
///
/// ~~~
/// // Computes a naive DHT of si... | true |
f3f9e6e34176cb31a28dc4a05732abe7f243b4e4 | Rust | doytsujin/heapless | /src/pool/singleton.rs | UTF-8 | 9,696 | 2.765625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! `Pool` as a global singleton
use core::{
any::TypeId,
cmp, fmt,
hash::{Hash, Hasher},
marker::PhantomData,
mem::{self, MaybeUninit},
ops::{Deref, DerefMut},
ptr::{self, NonNull},
};
use super::{Init, Node, Uninit};
pub mod arc;
/// Instantiates a pool as a global singleton
// NOTE(an... | true |
887aad6eea6a314306648186a572da196452ac75 | Rust | harieservice/RxRust | /src/processorimpl.rs | UTF-8 | 11,736 | 3.09375 | 3 | [
"MIT"
] | permissive | use std::fmt::Show;
use reactive::{Publisher, Subscriber};
use sendable::Sendable;
pub struct Trace<'a, I> where I : Show {
subscriber: Option<Box<Subscriber<Input=I> + 'a>>,
index: Option<usize>
}
impl<'a, I> Trace<'a, I> where I : Show {
pub fn new() -> Trace<'a, I>
{
Trace {
su... | true |
055cc5ca43f05b34cf4c6b4ff01cb2047fcc49fd | Rust | reproto/reproto | /lib/languageserver/loaded_file.rs | UTF-8 | 8,318 | 2.953125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! A file that is loaded into a workspace.
use crate::models::{Completion, Jump, Prefix, Range, Reference, Rename, Symbol};
use crate::triggers::Triggers;
use reproto_core::errors::Result;
use reproto_core::{Diagnostics, Encoding, Position, RpVersionedPackage, Source, Span};
use std::collections::HashMap;
use url::Ur... | true |
e9150509e275a8a8c8930f36c1df344c59fea289 | Rust | TrebledJ/aoc | /2021/rust/src/bin/d02.rs | UTF-8 | 1,618 | 3.5625 | 4 | [] | no_license | use std::fs;
use std::str::FromStr;
#[derive(Debug)]
enum Dir {
Forward,
Up,
Down,
}
#[derive(Debug)]
struct Inst {
dir: Dir,
n: i32,
}
impl FromStr for Inst {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
let split = s.split_whitespace().collect::<Vec<&str>>();... | true |
4d0c237c90ebb53ab95e27290785e2ad32d40d63 | Rust | sMorac/raytracer | /src/lib.rs | UTF-8 | 8,929 | 2.578125 | 3 | [] | no_license | use rand::prelude::*;
mod vec3;
mod color;
mod hitable;
mod ray;
mod camera;
mod material;
use camera::Camera;
use vec3::Vec3;
use color::Color;
use color::ColorU8;
use ray::Ray;
use hitable::Hitable;
use hitable::Sphere;
use hitable::Plane;
use hitable::Scene;
use material::Metal;
use material::Lambertian;
use mater... | true |
539a06397fca54fbe4b2ad8a709145f9db20ed93 | Rust | leftiness/hex_math | /src/traits/distance/distance.rs | UTF-8 | 719 | 3.734375 | 4 | [
"MIT"
] | permissive | use std::borrow::Borrow;
use structs::Point;
use traits::distance::{Base, Height};
/// Trait wrapping distance implementation
pub trait Distance: Borrow<Point> {
/// Calculate the manhattan distance between two points including height
///
/// Distance is rounded up to the next integer.
fn distance<U: Borrow<P... | true |
00527ce15e730bf8978d77056891f40cc85e3f51 | Rust | iCodeIN/cala | /examples/tcp/src/main.rs | UTF-8 | 1,874 | 3.015625 | 3 | [
"BSL-1.0",
"MIT",
"Zlib",
"Apache-2.0"
] | permissive | // Networking example
use std::sync::{Arc, Condvar, Mutex};
use cala::*;
use net::{ServerEvent, TcpConnection, TcpServer};
exec!(init);
async fn init() {
let pair = Arc::new((Mutex::new(false), Condvar::new()));
let pair2 = pair.clone();
[server(pair).fut(), client(pair2).fut()].select().await;
}
async... | true |
17a58afcc3b995645da835e7a92aa1bf343f9dc0 | Rust | MrMLynch/pirate-light-cli | /lib/src/lightwallet/bugs.rs | UTF-8 | 4,228 | 2.75 | 3 | [] | no_license | ///
/// In v1.0 of zecwallet-cli, there was a bug that incorrectly derived HD wallet keys after the first key. That is, the
/// first key, address was correct, but subsequent ones were not.
///
/// The issue was that the 32-byte seed was directly being used to derive then subsequent addresses instead of the
/// 64-... | true |
4bd852432001a59a205f1a6b8f2a5c91a3df61d2 | Rust | TheNeikos/csidh | /src/bin/main.rs | UTF-8 | 536 | 2.828125 | 3 | [
"MIT"
] | permissive | use csidh::CsidhPrivateKey;
use std::fs::File;
fn main() {
let mut rng = rand::thread_rng();
let a_private = CsidhPrivateKey::generate_new(&mut rng);
let b_private = CsidhPrivateKey::generate_new(&mut rng);
let a_public = a_private.get_public_key();
let b_public = b_private.get_public_key();
... | true |
67430ae94cc1ef1e92fce7ecc636f2d085bb4b51 | Rust | rust-lang/rust | /src/tools/jsondoclint/src/main.rs | UTF-8 | 3,615 | 2.78125 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | use std::io::{BufWriter, Write};
use std::path::{Path, PathBuf};
use anyhow::{bail, Result};
use clap::Parser;
use fs_err as fs;
use rustdoc_json_types::{Crate, Id, FORMAT_VERSION};
use serde::Serialize;
use serde_json::Value;
pub(crate) mod item_kind;
mod json_find;
mod validator;
#[derive(Debug, PartialEq, Eq, Ser... | true |
d1da38b7ce382e4c91aee234e9c9c84c32a5263c | Rust | MikeTheSapien/asfa | /src/cfg.rs | UTF-8 | 14,365 | 2.609375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use anyhow::{bail, Context, Result};
use expanduser::expanduser;
use log::{debug, warn};
use std::collections::HashMap;
use std::default::Default;
use std::fmt::Display;
use std::fs::{read_dir, read_to_string};
use std::path::PathBuf;
use yaml_rust::{yaml::Hash, Yaml, YamlLoader};
use percent_encoding::{utf8_percent_e... | true |
2138e475a4a1737b92cd97b52c463901b601473e | Rust | kylewlacy/glitter | /src/buffer.rs | UTF-8 | 2,697 | 3.5 | 4 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"Unlicense"
] | permissive | //! Exposes the OpenGL [`Buffer`](struct.Buffer.html) object, and related types.
use std::marker::PhantomData;
use gl;
use gl::types::*;
use types::GLObject;
/// An OpenGL buffer object.
///
/// In OpenGL, a buffer is essentially untyped, and what data it can contain
/// only depends on how it is used. A buffer can b... | true |
72e4b6bca54057c592862146f8ae61d9580533f4 | Rust | mental32/monty | /montyc_hlirt/src/eval/ctx/eval_glue.rs | UTF-8 | 5,896 | 2.515625 | 3 | [
"MIT"
] | permissive | use crate::exception::{PyException, PyResult, PyResultExt};
use crate::object::{PyIter, PyObject, PyValue};
use crate::rt::{Runtime, RuntimeHost};
use crate::{storage::ObjectSpace, ObjectId};
mod sealed {
use crate::{exception::PyResult, ObjectId};
use super::EvalGlue;
pub trait AnyAttr {
fn to_o... | true |
d78f6fa1f5fcd960ca460fbbee77b939526b541b | Rust | PutraKinantaa/AlephBFT | /src/creator.rs | UTF-8 | 5,894 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | use crate::{
config::{Config, DelaySchedule},
member::NotificationOut,
nodes::{NodeCount, NodeIndex, NodeMap},
units::{ControlHash, PreUnit, Unit},
Hasher, Receiver, Round, Sender,
};
use futures::{channel::oneshot, StreamExt};
use log::{debug, error};
use tokio::time::{delay_for, Duration};
/// A ... | true |
5d0fa7e7cde413f40f34428bd6e4ec91a7b0f175 | Rust | gitter-badger/arrow2 | /src/array/fixed_size_list/from.rs | UTF-8 | 4,486 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | true |
d5de9ca06ead62a64f66e465d506bb7031ffb006 | Rust | nyradr/crypta-rs | /src/utils/bytesreader.rs | UTF-8 | 600 | 3.484375 | 3 | [] | no_license | use std::io::{Read, Result};
/// Read a slice of bytes with the Read interface
pub struct BytesReader<'a>{
bytes: &'a [u8],
index: usize
}
impl<'a> BytesReader<'a>{
pub fn new(bytes: &'a [u8])->Self{
Self{
bytes: bytes,
index: 0
}
}
}
impl<'a> Read for BytesRea... | true |
f803f44886ce07a3498c783de7f307d0d8724a21 | Rust | grv07/left-right-example | /src/read.rs | UTF-8 | 2,962 | 2.71875 | 3 | [] | no_license | use std::cell::Cell;
use std::fmt::{Debug, Formatter, Result};
use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
use std::sync::Arc;
use std::ptr::NonNull;
mod factory;
mod read;
use factory::ReadHandleFactory;
use read::ReadGuard;
pub struct ReadHandle<T> {
// maintain the list if all epochs used by al... | true |
003344268ad25303dc39e37eeebecd6ebfddfc68 | Rust | iquiw/gitcop | /src/git.rs | UTF-8 | 2,174 | 2.796875 | 3 | [] | no_license | use std::fmt;
use std::future::Future;
use std::io;
use std::path::Path;
use std::process::Output;
use anyhow::Error;
use futures::future::BoxFuture;
use tokio::process::Command;
use crate::config::{GitCmd, Remote, Repo};
use crate::print;
pub trait Git<'a> {
fn cloner(&'a self, dir: &Path, repo: &Repo) -> Async... | true |
5f6ac992d1124175eb48d60d4ac99b2e95f35eaa | Rust | lukaspustina/nmap-analyze | /src/output.rs | UTF-8 | 7,712 | 2.53125 | 3 | [
"MIT"
] | permissive | use analyze::{AnalyzerResult, HostAnalysisSummary, PortAnalysisReason, PortAnalysisResult};
use prettytable::Cell;
use prettytable::Row;
use prettytable::{color, format, Attr, Table};
use serde_json;
use std::io::Write;
use std::net::IpAddr;
use std::str::FromStr;
error_chain! {
errors {
InvalidOutputForm... | true |
076ef110060e2a87d909fa6c935bf764bdd74035 | Rust | crashlabs-io/sleepyseal | /src/base_types.rs | UTF-8 | 6,276 | 3.0625 | 3 | [
"Apache-2.0"
] | permissive | //! Defines the basic types to do crypto, committees and hold basic information.
use std::borrow::Borrow;
use std::collections::HashMap;
use std::convert::TryInto;
use std::iter::FromIterator;
use sha2::{Digest, Sha512};
use serde::{Deserialize, Serialize};
use crate::crypto::{PublicKey, SecretKey, Signature};
use ... | true |
e3cedb769d6b966ced221f5c7e9c1b1e376719dc | Rust | doytsujin/yew | /examples/async_clock/src/main.rs | UTF-8 | 4,524 | 3.03125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use chrono::{DateTime, Local};
use futures::{FutureExt, StreamExt};
use services::compute_fun_score;
use yew::platform::pinned::mpsc::UnboundedSender;
use yew::{html, AttrValue, Component, Context, Html};
use crate::services::{emit_jokes, initialize_atomic_clocks, stream_time};
mod services;
/// The AsyncComponent d... | true |
966f24edd26e467c26b14b041e10562accde462b | Rust | closeio/prometheus-health-checker | /src/main.rs | UTF-8 | 5,133 | 2.640625 | 3 | [] | no_license | use crate::checks::{Check, CheckContext, CheckType};
use crate::sample_parser::parse_prometheus_sample;
use clap::{App, Arg};
use std::collections::BTreeSet;
use std::io;
use std::io::{Error, ErrorKind};
use std::process::exit;
mod checks;
mod sample;
mod sample_parser;
fn main() {
if let Err(e) = health_check() ... | true |
56221fb055818a9ba792a93020ad2a40078b57a5 | Rust | alesharik/smbios-lib | /src/structs/types/system_chassis_information.rs | UTF-8 | 30,413 | 2.890625 | 3 | [
"MIT"
] | permissive | use crate::core::UndefinedStruct;
use crate::{BoardTypeData, SMBiosStruct, SMBiosType};
use serde::{ser::SerializeSeq, ser::SerializeStruct, Serialize, Serializer};
use core::{fmt, any};
use core::ops::Deref;
#[cfg(feature = "no_std")]
use alloc::{vec::Vec, string::String};
/// # System Enclosure or Chassis (Type 3)
/... | true |
ab6c698c76c8c4196c05739280bbf806a418ea2f | Rust | Giovan/lumen | /liblumen_alloc/src/erts/process/priority.rs | UTF-8 | 1,173 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | use core::convert::{TryFrom, TryInto};
use crate::erts::exception::runtime;
use crate::erts::term::{Atom, Term, TypedTerm};
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
pub enum Priority {
Low,
Normal,
High,
Max,
}
impl Default for Priority {
fn default() -> Priority {
Priority::Normal
... | true |
2f9cd3a76a0ec3a393e2ded64965280c3e151030 | Rust | xianyuggg/json-parser-rs | /src/common/src/usize_wrapper.rs | UTF-8 | 1,650 | 3.203125 | 3 | [
"MIT"
] | permissive | use std::convert::*;
use std::fmt::{Display, Error, Formatter};
use std::ops::Deref;
// Copy is alright
//#[derive(Clone, Copy)]
pub struct USIZEWrapper(pub usize);
impl Into<usize> for USIZEWrapper {
fn into(self) -> usize {
self.0
}
}
impl Display for USIZEWrapper {
fn fmt(&self, f: &mut Formatt... | true |
c0adc30878e8dfddbbcd6e71a7f25565b7558499 | Rust | Wandalen/wCommandsAggregator | /rust/impl/ca/input.rs | UTF-8 | 280 | 2.515625 | 3 | [
"MIT"
] | permissive |
#![allow(dead_code)]
use std::io;
use std::io::Write;
//
pub fn ask( request : &str ) -> String
{
let mut response = String::new();
print!( "{} : ", request );
io::stdout().flush().ok();
io::stdin().read_line( &mut response ).ok();
response.trim().to_string()
}
//
| true |
8da48c10275ece85117cbfd624f9464b112b805d | Rust | Lawliet-Chan/phala-pruntime | /vendor/hmac-drbg/src/lib.rs | UTF-8 | 4,363 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | #![no_std]
extern crate hmac;
extern crate generic_array;
use hmac::digest::{Input, BlockInput, FixedOutput, Reset};
use generic_array::{ArrayLength, GenericArray};
use hmac::{Mac, Hmac};
use hmac::crypto_mac::MacResult;
pub struct HmacDRBG<D>
where D: Input + BlockInput + FixedOutput + Default + Reset + Clone,
... | true |
7728c9066cd51501b65c069366bbb295283a8991 | Rust | sciyoshi/euler | /src/problem123.rs | UTF-8 | 735 | 2.703125 | 3 | [] | no_license | use primal::Sieve;
use num::{FromPrimitive, ToPrimitive, BigInt, BigUint, Integer};
use mod_pow::ModPow;
pub fn solve() -> u64 {
let sieve = Sieve::new(1_000_000_000);
for (p, n) in sieve.primes_from(3).zip(2..) {
let p1: BigInt = FromPrimitive::from_usize(p + 1).unwrap();
let p2: BigInt = FromPrimitive::from_u... | true |
1c69c861d5acd8cbd448b18c520d3eb0752af767 | Rust | stuglaser/rustmat | /src/qr.rs | UTF-8 | 2,558 | 2.96875 | 3 | [
"MIT"
] | permissive | use base::{MatBase, MatBaseMut, Mat};
use householder::reflector_to_e1;
// QR Decomposition
//
// TODO: We can optimize space usage by storing Q implicitly in the
// lower-tri part of R
//
// See: http://www.cs.cornell.edu/~bindel/class/cs6210-f09/lec18.pdf
pub struct QR {
Q: Mat,
R: Mat,
}
impl QR {
pub... | true |
117531cc2125567abaf2eff4db05f20392f6088d | Rust | nymtech/nym | /sdk/rust/nym-sdk/examples/builder_with_storage.rs | UTF-8 | 1,398 | 2.859375 | 3 | [
"CC0-1.0",
"Apache-2.0"
] | permissive | use nym_sdk::mixnet;
use nym_sdk::mixnet::MixnetMessageSender;
use std::path::PathBuf;
#[tokio::main]
async fn main() {
nym_bin_common::logging::setup_logging();
// Specify some config options
let config_dir = PathBuf::from("/tmp/mixnet-client");
let storage_paths = mixnet::StoragePaths::new_from_dir(... | true |
e4fa40de8c9be5181c37d0521804c4e284fa39f0 | Rust | adatechschool/GildedRose-Gwen-Adriel | /src/gildedrose/mod.rs | UTF-8 | 1,537 | 3.125 | 3 | [] | no_license | use std::string;
use std::vec;
pub struct Item {
pub name: string::String,
pub sell_in: i32,
pub quality: i32
}
impl Item {
pub fn new(name: String, sell_in: i32, quality: i32) -> Item {
Item {name: name, sell_in: sell_in, quality: quality}
}
}
pub struct GildedRose {
pub items: vec::... | true |
94a6ec862a405f0f498f5ef446202a85c2c91d38 | Rust | GramYang/RustTest | /src/basic/control_flow.rs | UTF-8 | 9,400 | 3.875 | 4 | [] | no_license |
//循环
#[allow(dead_code, irrefutable_let_patterns)]
pub fn cf1() {
//while
let mut i = 0;
while i < 3 {
print!("hello ");
i = i + 1;
}
let mut x = vec![1, 2, 3];
while let Some(y) = x.pop() {
print!("{} ", y);
}
while let _ = 5 {
println!("Irrefutable patt... | true |
ce6d77a0de7e41bb4afbec043d7c2241e9beb54d | Rust | pearzl/leetcode_rust | /src/answer/q0187_repeated_dna_sequences.rs | UTF-8 | 1,260 | 3.328125 | 3 | [] | no_license | // q0187_repeated_dna_sequences
struct Solution;
use std::collections::HashMap;
impl Solution {
pub fn find_repeated_dna_sequences(s: String) -> Vec<String> {
let l = s.len();
if l <= 10 {
return vec![];
}
let mut map = HashMap::new();
for i in 0..=l - 10 {
... | true |
cd11183ba6c2738cafd056f16b1afed4cf30a95c | Rust | jjpe/stringify | /src/styles.rs | UTF-8 | 3,078 | 3.21875 | 3 | [] | no_license | use crate::error::{StringifyError, StringifyResult};
use crate::newline::Newline;
use std::collections::BTreeMap;
use std::ops;
#[macro_export]
macro_rules! styles {
(
$($key:expr => $value:expr),*
) => {{
use std::collections::BTreeMap;
#[allow(unused_mut)] let mut btmap = BTreeMap::ne... | true |
b50e6d02a7b24c0a451e35cf57d3a2de27ca76d4 | Rust | qtumproject/qx86-rs | /benches/qx86_benchmark.rs | UTF-8 | 4,704 | 2.671875 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate criterion;
extern crate qx86;
extern crate tempfile;
use qx86::vm::*;
use criterion::Criterion;
pub const CODE_MEM:u32 = 0x10000;
pub const DATA_MEM:u32 = 0x80000000;
pub const OOG_GAS_LIMIT:u64 = 10000;
#[cfg(test)]
#[derive(Default)]
pub struct TestHypervisor{
pushed_values: Vec<u32... | true |
6e53c9c51edd837440bfc8cb7a9b73ba49d701c6 | Rust | antoyo/relm | /relm-examples/examples/7gui/6_circle_drawer/src/gui/win.rs | UTF-8 | 2,290 | 2.65625 | 3 | [
"MIT"
] | permissive | use crate::gui::circle_drawing::{CircleDrawing, CircleDrawingMsg};
use crate::model::{CircleGroup, History};
use gtk::prelude::*;
use gtk::Orientation;
use relm::{Relm, Widget};
use relm_derive::{widget, Msg};
#[derive(Msg)]
pub enum WinMsg {
/// Undo message sent from the undo button.
Undo,
/// Redo mess... | true |
09ed6a5237bb959a5adba8a59d755c90dbadc2c8 | Rust | gwafotapa/blockchain | /tests/transaction.rs | UTF-8 | 2,190 | 2.78125 | 3 | [] | no_license | use rand::seq::SliceRandom;
use rand::Rng;
use blockchain::transaction::{Transaction, TransactionInput, TransactionOutput};
pub mod common;
#[test]
fn transaction_input_ser_deser() {
let transaction_input = common::random_transaction_input(None, None);
let transaction_input2 = TransactionInput::deserialize(t... | true |
cdfb62f38e706d67b36ebeec16013fb6ba815eb8 | Rust | mtrp12/fp-core.rs | /fp-examples/src/contracts_example.rs | UTF-8 | 382 | 3.421875 | 3 | [
"MIT"
] | permissive | #[test]
fn contracts_example() {
let contract = |x: &i32| -> bool { x > &10 };
let add_one = |x: &i32| -> Result<i32, String> {
if contract(x) {
return Ok(x + 1);
}
Err("Cannot add one".to_string())
};
let expected = 12;
match add_one(&11) {
Ok(x) => ass... | true |
dda2b1234c6c3339d428da37b8aed39eafe943af | Rust | Kreedzt/LearningRust | /17.3.oo-design-patterns/src/main.rs | UTF-8 | 671 | 3.0625 | 3 | [] | no_license | use oo_design_patterns::{Post};
fn main() {
// 状态模式测试: 开始
// let mut post = Post::new();
// post.add_text("I ate a salad for lunch today");
// assert_eq!("", post.content());
// post.request_review();
// assert_eq!("", post.content());
// post.approve();
// assert_eq!("I ate a salad ... | true |
b1eece3630347d0ea377c74a21398d291f5874ea | Rust | JohnGinger/aoc | /2017/rust-split-up/3/src/main.rs | UTF-8 | 1,772 | 3.28125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
extern crate aoc_util;
#[derive(PartialEq, Eq, Hash, Debug)]
struct Coord(i32, i32);
fn main() {
let target_number: i32 = aoc_util::get_input(3).parse().unwrap();
println!("Target is {}", target_number);
let mut x = 0;
let mut y = 0;
let mut level = 0;
let mut co... | true |
ea26c55e85fe4ee00b773cc926f757781efdcef3 | Rust | Twinklebear/ispc-rs | /examples/ddvol/src/tfn.rs | UTF-8 | 2,201 | 2.71875 | 3 | [
"MIT"
] | permissive | use crate::ddvol;
use crate::empty_handle;
use crate::vec3::Vec3f;
use crate::ISPCHandle;
/// A transfer function used to map values of the volume to colors
pub struct TransferFunction {
ispc_handle: ISPCHandle,
}
impl TransferFunction {
/// Create a default grayscale transferfunction which maps values from b... | true |
9e8c8af159d609f560ff0676e9784941a841b27b | Rust | luca-barbieri/rust-analyzer | /crates/ra_project_model/src/cargo_workspace.rs | UTF-8 | 10,035 | 2.625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! FIXME: write short doc here
use std::{
ops,
path::{Path, PathBuf},
};
use anyhow::{Context, Result};
use cargo_metadata::{BuildScript, CargoOpt, Message, MetadataCommand, PackageId};
use ra_arena::{Arena, Idx};
use ra_cargo_watch::run_cargo;
use ra_db::Edition;
use rustc_hash::FxHashMap;
use serde::Deseri... | true |
47048258b7b187d5f125f6cdf8f80e52e8a2d6fe | Rust | aga7hokakological/Ares | /src/decoders/CrackObject.rs | UTF-8 | 1,143 | 3.625 | 4 | [
"MIT"
] | permissive | ///! This module contains CrackSuccess and CrackFailure
///
/// Every cracker returns this object which
/// Either indicates success or failure among other things.
struct CrackObject{
/// If our checkers return success, we change this bool to True
success: bool,
/// Encrypted text is the text _bef... | true |
702af138d57407489ea9dc18597080a2555b48d5 | Rust | brson/rustTracks | /api.rs | UTF-8 | 6,523 | 2.75 | 3 | [
"MIT"
] | permissive | use extra::json;
use extra::serialize::Decodable;
fn maybe_extract_from_json_object<T: Decodable<json::Decoder>>(
obj: &json::Object, id: &~str) -> Option<T> {
let found = match obj.find(id) {
Some(s) => s.clone(),
None => return None,
};
let mut decoder = json::Decoder::new(found);... | true |
3831a114cac3b56fd03877e9576223a9ff8eaade | Rust | curlywurlycraig/rust-learning | /mutex/src/main.rs | UTF-8 | 322 | 3.1875 | 3 | [] | no_license | use std::sync::{Mutex, Arc};
use std::thread;
fn main() {
let a = Arc::new(Mutex::new(1));
for i in 1..10 {
let a_clone = Arc::clone(&a);
std::thread::spawn(move || {
let mut num = a_clone.lock().unwrap();
*num += 1;
});
}
println!("Value is {:?}", a);
... | true |
8aa7d0ccc0415cbb1c5eb172fb33fe4253271f1c | Rust | LFalch/telda | /src/cpu/mod.rs | UTF-8 | 6,690 | 2.71875 | 3 | [] | no_license | use crate::{
isa::OP_HANDLERS,
mem::{Memory, IO_MAPPING_CUTOFF},
U4,
};
mod register_type;
pub use self::register_type::*;
pub struct Cpu {
pub registers: Registers,
}
impl Cpu {
pub fn new(pc: u16) -> Self {
Cpu {
registers: Registers::new(pc),
}
}
pub fn run... | true |
4f59a4413b4125490b71b835221998d81d185562 | Rust | StardustDL/Algorithms-in-Rust | /src/ds/fenwick_tree.rs | UTF-8 | 3,089 | 3.765625 | 4 | [
"Apache-2.0"
] | permissive | use std::ops::{Add, Sub};
// Fenwick tree for point added and prefix sum
pub struct FenwickTree<T>
where
T: Copy + Add<Output = T> + Sub<Output = T>,
{
inner: Vec<<T as Add>::Output>,
zero: T,
}
impl<T> FenwickTree<T>
where
T: Copy + Add<Output = T> + Sub<Output = T>,
{
/// Creates an empty Fenwic... | true |
5bffd8c0089f8fb22a7e9d49d3554046e1c74fb2 | Rust | Serbis/trs | /src/runtime/ssh_thread_safe.rs | UTF-8 | 595 | 2.703125 | 3 | [] | no_license | //! Thread safe wrappers around ssh2 types
use ssh2::{Session, Channel};
pub struct ThreadSafeChannel<'a> {
pub channel: Channel<'a>
}
unsafe impl <'a> Send for ThreadSafeChannel<'a> {}
unsafe impl <'a> Sync for ThreadSafeChannel<'a> {}
impl <'a> Clone for ThreadSafeChannel<'a> {
fn clone(&self) -> Self {
... | true |
e07f3cb446dbe650210227c9e7510e637b50a3ff | Rust | thomas9911/timeseries | /examples/sqlite_example.rs | UTF-8 | 1,605 | 3.25 | 3 | [] | no_license | use timeseries;
use timeseries::{BtreeMapTrait, SqliteConfig, Table};
fn new_table_data() -> Table<u16, i32> {
let headers = vec![
String::from("p10"),
String::from("data"),
String::from("twentyfive"),
String::from("squares"),
];
// let indexes = vec![1, 2, 3, ...];
// ... | true |
4ca28867d93758e7cf44040481e83ebe23812e69 | Rust | safrannn/leetcode_rust | /src/_0532_kdiff_pairs_in_an_array.rs | UTF-8 | 1,142 | 3.515625 | 4 | [] | no_license | struct Solution;
use std::collections::HashMap;
impl Solution {
pub fn find_pairs(nums: Vec<i32>, k: i32) -> i32 {
if k < 0 {
return 0;
}
if nums.len() < 2 {
return 0;
}
let mut h_map: HashMap<i32, bool> = HashMap::new();
for v in nums {
... | true |
6bbc6d984c2468d8fa40753ed75f408f921fb8d1 | Rust | voelklmichael/varidor | /src/lib.rs | UTF-8 | 2,682 | 2.875 | 3 | [] | no_license | #[macro_use]
extern crate lazy_static;
extern crate num_traits;
mod board_square;
use self::board_square::*;
mod javascript_interaction;
pub use self::javascript_interaction::*;
//mod game_logic;
//pub use self::game_logic::*;
use std::sync::Mutex;
type BoardType = SquareBoard5;
const BOARDSIZE: usize = BoardType::... | true |
630a11233a978388a89bfe742ad30937ba953330 | Rust | badrobotics/example_projects | /queue_test/src/main.rs | UTF-8 | 3,556 | 2.53125 | 3 | [] | no_license | #![no_std]
#![no_main]
extern crate atomic_queue;
use core::fmt::Write;
use rust_tm4c::tm4c_peripherals::get_peripherals;
use rust_tm4c::gpio;
use rust_tm4c::system_control;
use rust_tm4c::uart;
use rust_tm4c::timer;
use rust_tm4c::interrupt;
use atomic_queue::AtomicQueue;
const CPU_FREQ: u32 = 120_000_000;
const... | true |
d899374ad4807d8d47068f851624bb57d9918457 | Rust | moonmile/gyakubiki-rust | /ch02/grm055/src/main.rs | UTF-8 | 459 | 3.84375 | 4 | [] | no_license | struct Point {
x: i32,
y: i32,
}
struct Person {
name: String,
age: i32,
}
impl Person {
fn to_string(&self) -> String {
format!("{} ({})", self.name, self.age )
}
}
fn func( pt : &Point ) -> String {
format!("x:{} y:{}", pt.x, pt.y )
}
fn main() {
let pt = Point { x:10, y:20... | true |
4962a11e229017ff2e375be5379dda0679fb5077 | Rust | SteadBytes/study | /rust-in-action/ch05/ch5-q/src/lib.rs | UTF-8 | 2,595 | 4.0625 | 4 | [] | no_license | //! # Q7 Number Format
//!
//! This crate provides an implementation of the [Q7 number format](https://en.wikipedia.org/wiki/Q_(number_format))
//! intended as a storage and data transfer type only - `Q7` values do not
//! direcly support any arithmetic operations.
//!
//! `Qm.n` notation:
//! - `Q` = Q number format d... | true |
5f65f25d8a34518e0674da095983264c7803fb83 | Rust | MrYakobo/nap | /src/lib.rs | UTF-8 | 866 | 3.140625 | 3 | [
"Unlicense"
] | permissive | macro_rules! map(
{ $($key:expr => $value:expr),+ } => {
{
let mut m = ::std::collections::HashMap::new();
$(
m.insert($key, $value);
)+
m
}
};
);
mod main;
#[cfg(test)]
mod tests {
use crate::main;
#[test]
fn parse_... | true |
5bc981a65e8c6d43062b4fa7b5eedd9b864f88ca | Rust | SuperSamus/prime | /examples/simple_generator.rs | UTF-8 | 455 | 3.359375 | 3 | [
"MIT"
] | permissive | use prime::generator::*;
use std::io;
fn main() {
// Asking for the number the user wants to arrive to.
println!("Write the number you want to arrive to:");
let mut max = String::new();
io::stdin()
.read_line(&mut max)
.expect("Error reading input!");
let max: u64 = max.trim().parse... | true |
c98592bc3c6b5982041b3328f1576dcb17e1f009 | Rust | SSMKittel/AdventOfCode | /2019/day04/src/main.rs | UTF-8 | 1,587 | 3.5 | 4 | [] | no_license | fn main() {
let min = 372037u32;
let max = 905157u32;
let data = permute_increasing(6, min, max);
let mut data_simple = data.to_vec();
data_simple.retain(has_doubles);
println!("Count with doubles {}", data_simple.len());
let mut data_exact = data.to_vec();
data_exact.retain(has_doubl... | true |
d0bd4818eec3888b214713e0a8f0e0e7ef4b973d | Rust | Vengarioth/tinypath | /src/token.rs | UTF-8 | 1,159 | 3.125 | 3 | [
"MIT"
] | permissive | use logos::Logos;
use super::{Segment, PathError};
#[derive(Debug, Logos)]
pub enum Token {
#[regex(r"[\\/]+")]
Separator,
#[regex("[^\"\\\\/\\*\\?<>\\|]+")]
Segment,
#[regex(r"\.")]
Dot,
#[regex(r"\.\.")]
DotDot,
#[error]
Error,
}
impl Token {
pub fn from_str(path: &st... | true |
f77ddd716e5deedc7c1c7c530d50633a482685e9 | Rust | qingshi163/leetcode_rust | /src/lc49.rs | UTF-8 | 807 | 3.3125 | 3 | [
"MIT"
] | permissive |
use std::collections::HashMap;
#[allow(dead_code)]
fn group_anagrams(strs: Vec<String>) -> Vec<Vec<String>> {
let mut map = HashMap::<Vec<u8>,Vec<String>>::new();
for s in &strs {
let mut key = s.bytes().collect::<Vec<u8>>();
key.sort_unstable();
map.entry(key).and_modify(|val| val.push... | true |
77c8c19dc8419e7ebc9400533a684f30f033d957 | Rust | Mittsuyama/learn-rust-by-examples | /10.modle/10.2.super_and_self/super_and_self.rs | UTF-8 | 838 | 3.15625 | 3 | [] | no_license | #[allow(dead_code)]
fn function() {
println!("The outest!");
}
mod my_mod {
pub fn function() {
println!("Outer mod!");
}
pub mod innter_mod {
pub fn function() {
println!("Inner mod!");
}
// 使用 self 和 super 访问自身、父模块,消除歧义,减少路径硬编码
pub fn call_function... | true |
3efb473f895d478274da19881af8ef355fdeba11 | Rust | SylphieBot/minnie | /minnie_model/src/gateway.rs | UTF-8 | 30,966 | 2.734375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Types related to gateway connections.
use crate::event::*;
use crate::serde::*;
use crate::types::*;
use crate::user::*;
pub use minnie_errors::*;
use std::fmt;
use std::marker::PhantomData;
use std::time::{SystemTime, Duration};
/// The presence the bot should be using.
#[serde_with::skip_serializing_none]
#[der... | true |
25a7eafb2a8bd32031e2d053791c132d56f9a63d | Rust | Korede-TA/yew | /src/html/scope.rs | UTF-8 | 9,685 | 2.90625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use super::*;
use crate::scheduler::{scheduler, Runnable, Shared};
use crate::virtual_dom::{VDiff, VNode};
use std::cell::RefCell;
use std::fmt;
use std::rc::Rc;
use stdweb::web::Element;
/// Updates for a `Component` instance. Used by scope sender.
pub(crate) enum ComponentUpdate<COMP: Component> {
/// Wraps mess... | true |
0d3caf9f11f3c5eaf74a61af793eb6af62cf606c | Rust | akrisrn/leet-code-rust | /src/solution/easy/p0101_symmetric_tree.rs | UTF-8 | 3,859 | 3.875 | 4 | [] | no_license | use std::cell::RefCell;
use std::rc::Rc;
use crate::Solution;
/// https://leetcode.com/problems/symmetric-tree/
///
/// Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
/// For example, this binary tree `[1, 2, 2, 3, 4, 4, 3]` is symmetric:
///
/// > 1
/// > / \
//... | true |
012a0160bf49940f1adc2df4c306db2ee08cb3b1 | Rust | jakehamilton/nebulet | /src/arch/x64/memory/cache.rs | UTF-8 | 737 | 2.765625 | 3 | [
"MIT"
] | permissive | /// Caches deallocated frames
use x86_64::structures::paging::PhysFrame;
use alloc::vec::Vec;
use super::FrameAllocator;
pub struct FrameCache<T: FrameAllocator> {
inner: T,
freed: Vec<PhysFrame>
}
impl<T: FrameAllocator> FrameCache<T> {
pub fn new(inner: T) -> FrameCache<T> {
FrameC... | true |
b0373c07368afccabad2b8489c8c7352f3787abd | Rust | rust-git/rsgit | /core/src/path/path_mode.rs | UTF-8 | 12,270 | 3.515625 | 4 | [
"Apache-2.0"
] | permissive | use std::cmp::{self, Ordering};
use crate::path::FileMode;
/// Represents the tuple of git path (an uninterpreted sequence of bytes,
/// not necessarily UTF-8) and git file mode. Used for sorting trees of objects.
#[derive(Debug, Eq, PartialEq)]
pub struct PathMode<'a> {
pub path: &'a [u8],
pub mode: FileMode... | true |
b499d13d0f6ecd7ab0b1e3193f37e74ac254805e | Rust | pklazy/lpc54628-rust | /src/syscon/flashcfg.rs | UTF-8 | 24,255 | 2.625 | 3 | [] | no_license | #[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::FLASHCFG {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R,... | true |
73597f2d9916fb32dde1bd468ed1ccedaa042af5 | Rust | twetzel59/spaceshooter | /src/background.rs | UTF-8 | 607 | 2.75 | 3 | [
"MIT"
] | permissive | use sfml::graphics::{Drawable, RenderStates, RenderTarget, Sprite};
use resources::Resources;
pub struct Background<'s> {
sprite: Sprite<'s>,
}
impl<'s> Background<'s> {
pub fn new(res: &'s Resources) -> Background<'s> {
Background {
sprite: Sprite::with_texture(res.background()),
... | true |
5dfdc9232998456b276c95ae1768f1bd7e1cdc35 | Rust | keithnoguchi/books-rs | /async-std/src/client.rs | UTF-8 | 4,219 | 3.25 | 3 | [] | no_license | //! Implementing a [Chat Client]
//!
//! # Examples
//!
//! ```no_run
//! use async_std::io;
//! use async_std::task;
//! use async_std_book::Client;
//!
//! type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
//!
//! fn main() -> Result<(), Error> {
//! let addr = std::env::args()
//! .nth(1)
... | true |
f0fe560985965ecdf69686042f6dec3b73478fc6 | Rust | kmeisthax/retrogram | /src/analysis/requisite.rs | UTF-8 | 13,959 | 3.375 | 3 | [] | no_license | //! Requisite list type
use crate::arch::Architecture;
use crate::maths::Popcount;
use crate::memory::Memory;
use crate::reg::{State, Symbolic};
use num::{One, Zero};
use std::collections::HashSet;
use std::convert::TryInto;
use std::hash::{Hash, Hasher};
pub type RequisiteSet<AR> = HashSet<Requisite<AR>>;
/// Indic... | true |
2e9281295117ae9ff44cbf7f1967ebd1a4df2f07 | Rust | Cypher1/oak | /oak_client/src/interceptors/mod.rs | UTF-8 | 2,096 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | //
// Copyright 2020 The Project Oak 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 o... | true |
05719183b8d924d9f5a4aaf186e5ebbf645625b6 | Rust | nevenoomo/ethshuffle-rs | /src/bin/devdeploy.rs | UTF-8 | 2,396 | 2.578125 | 3 | [] | no_license | use tokio2::runtime::Runtime;
use std::error::Error;
use clap::{App, Arg};
use std::path::Path;
use ethshuffle_rs::funccall::devdeploy;
use hex::FromHex;
fn main() -> Result<(), Box<dyn Error>> {
let matches = App::new("EthShuffle Contract Deployment")
.version(env!("CARGO_PKG_VERSION"))
.about("It... | true |
f3eda9d4b4aff575eeb984c5259ee1fea2e7fe2e | Rust | ricky26/chunked | /packages/chunked/src/system.rs | UTF-8 | 5,733 | 3.03125 | 3 | [
"MIT"
] | permissive | //! Composable ECS systems.
use std::cmp::Ord;
use std::fmt::Debug;
use std::fmt::Display;
use async_trait::async_trait;
use futures::{FutureExt, StreamExt};
use futures::future::BoxFuture;
use futures::stream::FuturesUnordered;
/// A token which represents a system in a `SystemSet`.
///
/// These tokens are not un... | true |
546b2250f5df95d5815425e8e5de7ba7dbbf6f13 | Rust | koute/rtps-rs | /src/messages/nack_frag.rs | UTF-8 | 2,836 | 3.0625 | 3 | [
"Apache-2.0"
] | permissive | use crate::messages::fragment_number_set::FragmentNumberSet_t;
use crate::structure::count::Count_t;
use crate::structure::entity_id::EntityId_t;
use crate::structure::sequence_number::SequenceNumber_t;
use speedy::{Readable, Writable};
/// The NackFrag Submessage is used to communicate the state of a Reader to a
/// ... | true |
7d6e2b5738c423f00eae7a1a4ca5725298042823 | Rust | myddrin/advent_code_2020 | /rust/day_06/main.rs | UTF-8 | 2,835 | 3.5 | 4 | [] | no_license | use std::{io, env};
use std::fs::File;
use std::io::{BufReader, BufRead};
use std::collections::HashMap;
#[derive(Debug, Clone)]
struct Group {
size: usize,
answers: HashMap<char, usize>, // question => nb answers
}
impl Group {
fn read(path: &str) -> io::Result<Vec<Group>> {
let file = File::ope... | true |
3d0247769f85edf3a4253ef15fb3960ea9f0a9eb | Rust | lightdiscord/jekyll-berlin-clock | /src/lib.rs | UTF-8 | 2,107 | 3.765625 | 4 | [] | no_license | use std::fmt::{self, Display};
pub struct Instant {
hours: u8,
minutes: u8,
seconds: u8
}
impl Instant {
pub fn new(hours: u8, minutes: u8, seconds: u8) -> Self {
assert!(hours < 24);
assert!(minutes < 60);
assert!(seconds < 60);
Instant {
hours,
... | true |
68a24c61b47a2b3fb3c1c894c86f968176271275 | Rust | unrealhoang/tokyo-rs | /server/src/actors/client_ws_actor.rs | UTF-8 | 3,083 | 2.59375 | 3 | [] | no_license | use crate::{
actors::GameActor,
models::messages::{ClientStop, PlayerGameCommand},
AppState,
};
use actix::{Actor, ActorContext, Addr, AsyncContext, Handler, StreamHandler};
use actix_web::ws::{self, CloseCode, CloseReason};
use ratelimit_meter::{DirectRateLimiter, GCRA};
use tokyo::models::ServerToClient;
... | true |
484eb71fc210491b994e6feba9807a024b608b4a | Rust | mistodon/chessjam | /src/data.rs | UTF-8 | 1,539 | 2.53125 | 3 | [] | no_license | use okmath::*;
use glium::texture::SrgbTexture2d;
use graphics::Mesh;
pub struct RenderCommand<'a> {
pub mesh: &'a Mesh,
pub color: Vec4<f32>,
pub mvp_matrix: Mat4<f32>,
pub colormap: &'a SrgbTexture2d,
pub texture_scale: Vec3<f32>,
pub texture_offset: Vec3<f32>,
}
pub struct UiRenderCommand<... | true |
48a0ade41a99cbe1e9168bba9aaebb54249373bd | Rust | jameysharp/c2rust | /cross-checks/rust-checks/config/src/scopes.rs | UTF-8 | 12,825 | 2.953125 | 3 | [
"BSD-3-Clause"
] | permissive | use std::collections::HashMap;
use std::rc::Rc;
#[derive(Debug, Clone)]
pub struct InheritedConfig {
// Whether cross-checks are enabled overall
pub enabled: bool,
// Function-specific overrides
pub entry: super::XCheckType,
pub exit: super::XCheckType,
pub all_args: super::XCheckType,
pub... | true |
3171a7ab810f45c164a6393aa93bac0469ed76e1 | Rust | xyxyxyxyxyxy/iotedge | /test/rust-test-util/test-result-reporting-client/src/client.rs | UTF-8 | 2,214 | 2.546875 | 3 | [
"MIT"
] | permissive | use std::{iter::FromIterator, vec};
use chrono::{DateTime, Utc};
use enumset::EnumSet;
use hyper::{body, client::HttpConnector, Body, Client, Request};
use tracing::info;
use crate::{
models::{message_result::MessageTestResult, test_result_dto::TestOperationResultDto},
ReportResultError, TestType,
};
const C... | true |
beeef5cc9021708e095aab990d6815f4b071eab2 | Rust | nsmryan/gasworks | /src/csv.rs | UTF-8 | 1,539 | 2.59375 | 3 | [] | no_license |
#[allow(unused_imports)]
use std::collections::HashSet;
#[allow(unused_imports)]
use std::collections::HashMap;
#[allow(unused_imports)]
use std::collections::BTreeMap;
extern crate csv;
use std::fs::File;
use std::io::Write;
use types::*;
use layout::*;
use loclayout::*;
use value::*;
use packet::*;
pub fn value... | true |
4ef8db114dfb33b7cb194ff09ef13b55669f6024 | Rust | adamnemecek/redo | /src/checkpoint.rs | UTF-8 | 12,242 | 3.1875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::{Command, Entry, History, Queue, Record, Result, Signal, Timeline};
use alloc::collections::VecDeque;
use alloc::vec::Vec;
/// A checkpoint wrapper.
///
/// Wraps a record or history and gives it checkpoint functionality.
/// This allows the record or history to cancel all changes made since creating the ch... | true |
b672cbd4aca5b08bf15c540afc9c09ab75ef0836 | Rust | statusfailed/tinyrenderer-rust | /src/wavefront.rs | UTF-8 | 1,576 | 3.296875 | 3 | [] | no_license | use nalgebra::{Vector3};
use std::fs::{File};
use std::io::{BufRead, BufReader};
fn vector3_from_line(tokens: Vec<&str>) -> Vector3<f64> {
Vector3::from_iterator(tokens.iter().map(|a| a.parse().unwrap()))
}
// https://en.wikipedia.org/wiki/Wavefront_.obj_file#Face_elements
pub struct Model {
pub vertices: Vec<Vec... | true |
79def54c70cac69fb5950b44753842b1a27c7745 | Rust | mayoko/ray-tracing | /rust/src/utils.rs | UTF-8 | 305 | 3.109375 | 3 | [] | no_license | pub const INFINITY: f32 = 1000000000.0;
pub const PI: f32 = 3.1415926535897932385;
pub fn degrees_to_radians(degrees: f32) -> f32 {
degrees * PI / 180.0
}
pub fn clamp(x: f32, min: f32, max: f32) -> f32 {
if x < min {
return min;
} else if x > max {
return max;
}
x
} | true |
f151076cd1f4310ed89ba1937f46ec41d2f7cd79 | Rust | mitchmindtree/json_io | /src/lib.rs | UTF-8 | 7,644 | 3.375 | 3 | [] | no_license | //!
//! Functions for simplifying the process of serializing types to JSON files.
//!
//! Supports both rustc-serialize (by default) and serde via the `--features="serde_serialization"
//! --no-default-features` flags.
//!
#[cfg(feature="rustc-serialize")]
#[cfg(not(feature="serde_serialization"))]
pub use rustc_ser... | true |
2cc6729b7474d5c345741c8519e21e0e3a02c502 | Rust | uber/piranha | /src/df/analysis.rs | UTF-8 | 4,637 | 3.03125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla"
] | permissive | /*
Copyright (c) 2023 Uber Technologies, Inc.
<p>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
<p>http://www.apache.org/licenses/LICENSE-2.0
<p>Unless required by applicable law or agreed to... | true |
e3a217384ada8c66f5eebc9e2dfc7f815d9f9b95 | Rust | Kogia-sima/gkquad-rs | /gkquad/benches/single.rs | UTF-8 | 1,162 | 2.75 | 3 | [
"MIT"
] | permissive | extern crate gkquad;
use smbench::*;
use std::f64::consts::PI;
use std::f64::{INFINITY, NEG_INFINITY};
use gkquad::single::Integrator;
use gkquad::Tolerance;
pub fn simple(b: &mut Bencher) {
let mut integrator = Integrator::new(|x: f64| x * x);
b.iter(|| {
let range = black_box(0.0..1.0);
let... | true |
dfcd8682226ffbafca4383010462ac0d4195fdfd | Rust | Aplet123/kctf-pow | /src/main.rs | UTF-8 | 2,160 | 3.125 | 3 | [
"BSD-3-Clause"
] | permissive | use kctf_pow::KctfPow;
fn gen_usage(name: &str) -> String {
format!(
"Could not parse arguments
Usage:
To solve a challenge: {0} solve <challenge>
To check a challenge: {0} check <challenge>
To randomly generate a challenge: {0} gen <difficulty>
To chain generation with checking: {0} ask <d... | true |
bcac6a11240088fa7f07a217781477b682f90104 | Rust | franleplant/graphql_rust_parser | /src/main.rs | UTF-8 | 2,330 | 3.21875 | 3 | [] | no_license | #[macro_use]
extern crate lazy_static;
use regex::Regex;
lazy_static! {
static ref RULES: Vec<(&'static str, &'static str)> = {
return vec![
("ID", r"^[[:alpha:]]\w*"),
("NUM", r"^(\d+|\d+.\d+)"),
("IF", r"^if"),
];
};
}
#[derive(Debug)]
struct Token<'a> {
... | true |
90c2a8f4ee3c5c2708b7b67f6905e4643129af4d | Rust | Rust-Mikrocontroller-Praktikum-2017/guiframework | /src/demo/mod.rs | UTF-8 | 2,747 | 2.765625 | 3 | [] | no_license | use collections::boxed::Box;
use layout::HorizontalLayout;
use layout::VerticalLayout;
use layout::MoveBox;
use forms::form::Form;
use forms::button::Button;
use forms::label::Label;
use util::bounding_box::BoundingBox;
use util::sizes;
use application::view::View;
fn bb(x: i32, y:i32, width: i32, height: i32) -> Bou... | true |
34662cc68394b0305ab96fab9c610c51b5984a7b | Rust | VV-Org/SpeechRecognitionPOC | /src/data_viz/mod.rs | UTF-8 | 1,203 | 2.734375 | 3 | [
"MIT"
] | permissive | use nalgebra::{Dynamic, VectorN};
use plotters::prelude::*;
use std::error::Error;
pub fn plot_2d(
path: &str,
title: &str,
legend: &str,
x: &VectorN<f64, Dynamic>,
y: &VectorN<f64, Dynamic>,
) -> Result<(), Box<dyn Error>> {
let root = BitMapBackend::new(path, (640, 480)).into_drawing_area();
... | true |
d821a6af519d242af864720f3ff3d9df740b0aec | Rust | aaronriekenberg/rust-doh-proxy | /src/doh/request_key.rs | UTF-8 | 1,276 | 2.578125 | 3 | [
"MIT"
] | permissive | use std::convert::TryFrom;
use trust_dns_proto::op::Message;
use trust_dns_proto::rr::dns_class::DNSClass;
use trust_dns_proto::rr::record_type::RecordType;
#[derive(Clone, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)]
struct RequestQueryKey {
name: String,
query_type: RecordType,
query_class: DNSClass,
}... | true |
3bd7d4e5c7e409eec537ca5d69911fd61a83c1eb | Rust | adrianisuru/perf-event-open-sys | /src/lib.rs | UTF-8 | 4,184 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Direct, unsafe bindings for Linux [`perf_event_open`][man] and friends.
//!
//! Linux's `perf_event_open` system call provides access to the processor's
//! performance measurement counters (things like instructions retired, cache
//! misses, and so on), kernel counters (context switches, page faults), and
//! many... | true |
087bb4228b3be30fa06babd1faa07b1f48a9461f | Rust | iSasuke7/kamasutra | /src/util.rs | UTF-8 | 3,490 | 3 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::borrow::Cow;
use failure::Error;
use memchr::Memchr2;
use serenity::client::Context;
use serenity::framework::standard::{Args as SArgs, Command, CommandError};
use serenity::model::channel::Message;
pub struct CmdFn<F>(pub F);
impl<F: Sync + Send + 'static + Fn(&mut Context, &Message, Args) -> Result<(), Err... | true |
deda5e3118ffd4e6f04881ce077c0755851abc70 | Rust | arj101/plane-bot | /src/command_parser.rs | UTF-8 | 7,236 | 2.671875 | 3 | [] | no_license | mod search;
mod add_command;
mod delete_command;
mod eval_command;
mod help_command;
mod random_commands;
mod run_command;
use super::*;
use std::thread;
pub fn parse(msg: &serenity::model::channel::Message, ctx: &serenity::client::Context) {
let mut cmd_found = true;
let command = match msg
.conten... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.