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
cd7af93dc23a295a4ad0e15c2f066933a3b74182
Rust
rodrigocfd/winsafe
/src/gui/native_controls/list_view_items.rs
UTF-8
8,409
3.078125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::co; use crate::decl::*; use crate::gui::{*, spec::*}; use crate::msg::*; use crate::prelude::*; /// Exposes item methods of a [`ListView`](crate::gui::ListView) control. /// /// You cannot directly instantiate this object, it is created internally by the /// control. pub struct ListViewItems<'a> {...
true
0b88b7d0fd0337b5635238a9c35cbc31bd99001a
Rust
fultonm/leetcodes
/rust/shuffle_an_array/src/main.rs
UTF-8
1,240
3.859375
4
[]
no_license
use rand::Rng; fn main() { let my_vec = vec![1, 2, 3, 4, 5]; println!("Running array shuffle with {:?}", my_vec); let obj = Solution::new(my_vec); let ret_2: Vec<i32> = obj.shuffle(); println!("Shuffled: {:?}", ret_2); let ret_1: Vec<i32> = obj.reset(); println!("Reset: {:?}", ret_1); } st...
true
17a9f4c61b94bb0e409422fa51add1d51d6484b4
Rust
youssefhabri/zero2-rs
/z2-menu/src/lib.rs
UTF-8
3,923
2.6875
3
[]
no_license
#[macro_use] extern crate log; use serenity::model::id::UserId; use serenity::model::prelude::{Reaction, ReactionType}; use serenity::prelude::Context; use crate::types::PaginationContainer; pub mod anilist; pub mod giphy; pub mod urban; pub mod reactions; pub mod types; pub mod utils; pub async fn handle_reaction...
true
25e78d3910e74b2c23487f3850bed746148b4b2f
Rust
pwnorbitals/MultimediaSignalProcessingClass
/Order-Dithered Block-Truncation-Coding/src/main.rs
UTF-8
7,465
2.921875
3
[]
no_license
use structopt::StructOpt; use image::GenericImageView; use std::string::String; use img_quality; use std::fmt; mod arrays; #[derive(StructOpt, Debug)] #[structopt(name = "basic")] struct Opt { #[structopt(name = "FILE")] file: String } #[derive(Clone, Debug)] struct VecBlock { width : usize, height : u...
true
274476c8294dd220c798c8593caa0c2297c6ba6a
Rust
k0pernicus/Rust_training
/add_for_all.rs
UTF-8
308
3.265625
3
[]
no_license
use std::env; fn add(x: &i32, y: &i32) -> i32 { *x + *y } fn main() { let table: Vec<i32> = vec![1,2,3,4,5]; let args: Vec<_> = env::args().collect(); let ref arg = args[1].parse::<i32>().unwrap(); for acc in &table{ println!("{} + {} = {}", acc, arg, add(&acc, &arg)); } }
true
3a67408faddfe84718b4ea09897a20cda09ddce0
Rust
erochest/intelligent-design
/small-pieces/src/environment/tests.rs
UTF-8
5,629
3.265625
3
[]
no_license
fn random_str() -> String { let value: [u8; 32] = rand::random(); let value = String::from_utf8_lossy(&value).to_string(); value } mod eval { use super::super::*; use super::*; use spectral::prelude::*; fn evaluates_to_self(value: Value) { let value = SharedValue::new(value); ...
true
a62923953b65c432225192209d460c7db4ca894e
Rust
happydpc/ray-tracing-gallery
/shaders/ray-tracing/src/pbr.rs
UTF-8
1,731
3.25
3
[]
no_license
use spirv_std::glam::Vec3; use spirv_std::num_traits::Float; struct BaseParams { view: Vec3, normal: Vec3, light: Vec3, halfway: Vec3, roughness: f32, } fn clamp(value: f32, min: f32, max: f32) -> f32 { value.min(max).max(min) } fn clamp_dot(a: Vec3, b: Vec3) -> f32 { clamp(a.dot(b), 0.0,...
true
c355913360a2304c6a408ae407c9bc54e4075f82
Rust
liufuyang/adventofcode-2020
/examples/day1/main.rs
UTF-8
1,466
2.984375
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::fs::File; use std::io::{self, BufRead, BufReader}; fn main() -> io::Result<()> { let file = File::open("./examples/day1/input_example.txt")?; let mut map = HashMap::new(); for line in BufReader::new(file).lines() { let num = line.unwrap_or("0".into()).parse:...
true
74b92a9ec2c6ea5e12d104e1cbbfcc9725cd1d1e
Rust
doytsujin/ipchannel
/src/generic/sender/mod.rs
UTF-8
598
2.625
3
[]
no_license
use std::{io::Write, marker::PhantomData}; #[cfg(test)] mod tests; pub struct Sender<I, T> { inner: I, _phantom: PhantomData<fn(T)>, } impl<I, T> Sender<I, T> { pub fn new(inner: I) -> Self { Self { inner, _phantom: PhantomData, } } } impl<I, T> crate::Sender<...
true
1cd6ee73e892e4cb0c9ecbe575c60cadd17a3b91
Rust
eaon/rotating-buffer
/src/lib.rs
UTF-8
4,975
3.578125
4
[]
no_license
#![no_std] /*! # Rotating Buffer … is a small helper data structure that allows a stack-allocated buffer to be reused while keeping data that couldn't be handled immediately. ## Example ```rust use rotating_buffer::*; let mut buf = RotatingBuffer::<u8, 4>::new(); buf.get_append_only().copy_from_slice(&[1, 2, 3, 4]...
true
392654c016c5a24fd780886bb4c180b6e590db09
Rust
eopb/noughts_and_crosses
/src/tests/won.rs
UTF-8
9,376
2.734375
3
[]
no_license
use GameBoard; use TileStatus; use Winner; impl GameBoard { pub fn has_someone_won(self) -> Winner { match cross(self) { Winner::Nought | Winner::Cross => Winner::Cross, Winner::None => nought(self), } } } fn nought(game_board: GameBoard) -> Winner { match nought_fi...
true
d6cfa5bf5ccf91c57efe0fe9e52c9264d4f24529
Rust
aneeshdurg/signalapps
/signal-apps-server/src/signalcli.rs
UTF-8
3,080
2.65625
3
[]
no_license
use std::io::Result; use std::str; use std::sync::Arc; use std::process; use async_process::{Child, Command, Stdio}; use async_trait::async_trait; use futures_lite::{io::BufReader, prelude::*}; use tokio::sync::mpsc; use crate::comm::{Control, Receiver, Sender}; static SIGNALCLI_PATH: &str = "../signal-cli/build...
true
31e3103b67d701c44544c4975e860ecb51182928
Rust
mass10/actix-web-app-example-1
/src/main.rs
UTF-8
892
2.765625
3
[]
no_license
//! //! //! use actix_web::{get, web, App, HttpServer, Responder}; mod application; mod db; #[get("/{id}/{name}/index.html")] async fn index(web::Path((id, name)): web::Path<(u32, String)>) -> impl Responder { format!("Hello {}! id:{}", name, id) } // #[get("/dashboard/")] // async fn index(web::Path()) -> impl Re...
true
3c1e400e3f02a5f60dc15c5c8db3249ba50798b8
Rust
Veykril/blend2d-rs
/src/gradient.rs
UTF-8
19,652
2.953125
3
[ "MIT", "Apache-2.0", "CC-BY-4.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Linear, Radial and Conical Gradients. use std::borrow::Borrow; use std::marker::PhantomData; use std::ops::{self, RangeBounds}; use std::{fmt, mem, ptr, slice}; use ffi::BLGradientValue::*; use crate::error::{expect_mem_err, OutOfMemory}; use crate::matrix::{Matrix2D, Matrix2DOp, MatrixTransform}; use crate::uti...
true
f51395bb802bf33e2c3eb2381020afc2d65bc7d4
Rust
fossabot/ckb-vm
/src/instructions/m.rs
UTF-8
9,550
3.09375
3
[ "MIT" ]
permissive
use super::super::machine::Machine; use super::super::memory::Memory; use super::super::Error; use super::register::Register; use super::utils::{funct3, funct7, opcode, rd, rs1, rs2, update_register}; use super::{Execute, Instruction as GenericInstruction, Instruction::M}; #[derive(Debug)] pub enum RtypeInstruction { ...
true
a23fa45ca8b54df3fb8d3e7c89374e793d467eb9
Rust
Twinklebear/ispc-rs
/examples/custom_tasksys/src/main.rs
UTF-8
3,626
3
3
[ "MIT" ]
permissive
#[macro_use] extern crate ispc; extern crate libc; use std::alloc::{alloc, dealloc, Layout}; use std::sync::Arc; use ispc::exec::TaskSystem; use ispc::task::ISPCTaskFn; ispc_module!(custom_tasksys); /// This task system implements a very simple serial execution of tasks /// where we run them immediately on launch #...
true
f43cb4f9ee9c4952b933589d7768d0b75fab9ebf
Rust
emad7105/rust-playground
/rust_try/src/async/async_select_join_all.rs
UTF-8
6,448
2.9375
3
[]
no_license
use anyhow::{Result, Ok, anyhow}; use futures::future::{BoxFuture, join_all, select_all, select_ok, try_join_all}; use futures::FutureExt; use tokio::time::{sleep, Duration}; use async_recursion::async_recursion; /// Source code online: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018 /// StackOverf...
true
eba0f0438dc63263f2164f53c7fe1bd29372c5c9
Rust
TrionProg/pz5
/src/geometry_type.rs
UTF-8
714
3.703125
4
[]
no_license
#[derive(Copy,Clone,PartialEq)] pub enum GeometryType{ Points, Lines, Triangles, } impl GeometryType{ pub fn from_vertices_count(vertices_count:usize) -> Result<GeometryType,String>{ match vertices_count{ 1 => Ok(GeometryType::Points), 2 => Ok(GeometryType::Lines), ...
true
62d55fc63a8af469fb837eb7ce7f60dd006d387e
Rust
iexus/advent_of_code_2020
/src/days/day_5.rs
UTF-8
1,463
3.8125
4
[]
no_license
pub fn call(puzzle_input: String) { let mut highest_seat_id = 0; let mut lowest_seat_id = 60; let mut sum_of_seats: u32 = 0; puzzle_input.lines().for_each(|pass| { let seat_id = shift_bits_for_chars(pass.chars()); if seat_id > highest_seat_id { highest_seat_id = seat_id; ...
true
7e93d5c964f1f283e6afd4f85be9401685c12079
Rust
Luro02/stable-vec
/examples/compact.rs
UTF-8
760
3.046875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use stable_vec::StableVec; fn main() { let mut sv = StableVec::new(); sv.push('a'); let b = sv.push('b'); let c = sv.push('c'); sv.push('d'); sv.push('e'); let f = sv.push('f'); sv.push('g'); sv.remove(b); sv.remove(c); sv.remove(f); println!("--- before compact():")...
true
53cfccaa32406963d772b15022ed2c47179ad20b
Rust
cakebaker/synth
/core/src/schema/content/mod.rs
UTF-8
17,789
2.84375
3
[ "Apache-2.0" ]
permissive
//! # Rules of the land //! //! - New variants added to the `Content` enum need to be of the form //! `$variant:ident(${variant}Content)`. //! - `${variant}Content` has to be exported by a submodule of this. //! - The submodule must use `super::prelude::*` to use external //! imports. //! - Other content nodes must...
true
bcb9c96264c4e09972cd0592ba6816befac6e42f
Rust
MihirLuthra/bit_fiddler
/src/bit_fiddle_macros/is_set.rs
UTF-8
4,973
3.703125
4
[]
no_license
/// Macro for checking if single, multiple or range of bits are set. /// It accepts multiple patterns for different use cases. /// It doesn't do any overflow or underflow checks. Behaviour on passing /// invalid args is undefined. /// /// A common thing in these patterns is `rev`. /// All patterns support this. Putting...
true
d37908964c8a71c72677eef5a1529b1e0e133a1a
Rust
emad7105/rust-playground
/rust_try/src/passbyref.rs
UTF-8
471
3.453125
3
[]
no_license
struct Person{ name: String, age: u16 } pub fn run(){ let emad = Person {name: "emad".to_string(), age: 32}; print_person_byref(&emad); print_person_byref(&emad); print_person_noref(emad); // print_person_noref(emad); // Error: not pass by ref } fn print_person_byref(p: &Person) { ...
true
4339e26f35c5d6e13a8143953687251b7ffb9eda
Rust
reneeichhorn/moonwave
/crates/moonwave_core/macros/tests/basic.rs
UTF-8
574
2.9375
3
[]
no_license
#![feature(arbitrary_self_types)] use moonwave_core_macro::*; #[actor] struct MyTestActor { number: usize, } #[actor] impl MyTestActor { #[actor_tick(real)] fn tick(&mut self) { self.number += 2; } #[actor_tick(timer(1s))] fn tick_every_second(&mut self) { self.number += 1; } #[actor_spawn]...
true
f09cfc6ccabdd65986bd317e2ae22a72b425eace
Rust
AKrill91/advent-of-code
/src/2020/day04.rs
UTF-8
10,070
3.265625
3
[]
no_license
use std::collections::HashMap; use regex::Regex; const VALID_ECL: [&str; 7] = [ "amb", "blu", "brn", "gry", "grn", "hzl", "oth" ]; pub fn run_a(input: &Vec<String>) -> i64 { let passports = Passport::multiple_from(input); passports.iter() .filter(|p| p.is_valid_basic()) ...
true
5422e189246249f7a5e7a83d02b730d3969ffbde
Rust
vangroan/stackbt
/automata_impl/src/automata_combinators.rs
UTF-8
9,845
3.4375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
//! //! It sometimes happens that you have an automaton on hand that acts //! somewhat, but not exactly, like you want it to, or it works like you want //! it to but has the wrong type. In those cases, you can use a wrapper //! instead of writing a whole new automaton. //! use automaton::{Automaton, FiniteStateAut...
true
c76818fa7863912a39c773bf7b317e905963386b
Rust
ugocloud/rust-drawing
/drawing/src/primitive.rs
UTF-8
3,454
2.953125
3
[ "MIT", "Zlib", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::color::*; use crate::units::*; #[derive(Debug)] pub enum Primitive { Line { color: Color, thickness: PixelThickness, start_point: PixelPoint, end_point: PixelPoint, }, Rectangle { color: Color, rect: PixelRect, }, Image { resource...
true
127e548ceb06af82c4071edd1abec99acc367436
Rust
rusticata/asn1-rs
/src/asn1_types/tagged/builder.rs
UTF-8
3,150
3.328125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::{Error, Explicit, Implicit, TaggedParser}; use crate::{Class, FromBer, FromDer, ParseResult, Tag}; use core::marker::PhantomData; /// A builder for parsing tagged values (`IMPLICIT` or `EXPLICIT`) /// /// # Examples /// /// ``` /// use asn1_rs::{Class, Tag, TaggedParserBuilder}; /// /// let parser = TaggedP...
true
3dc10698ea01e6562e006aaddeda5ed07b427a6b
Rust
MamadouSDiallo/advent_of_code_2020
/src/day_15/day15.rs
UTF-8
1,088
3.515625
4
[]
no_license
pub fn elves_numbers_game(max_steps: usize, numbers: &mut Vec<usize>) -> usize { let mut new_number = 0; let mut step = numbers.len() + 1; while step <= max_steps { let last_spoken = numbers[numbers.len() - 1]; let mut new = true; for (k, &v) in numbers.iter().rev().enumerate() { ...
true
1907ec43dea2208f665a751448a2aba65fbe7c5e
Rust
SuperiorJT/twilight
/model/src/channel/webhook/mod.rs
UTF-8
8,590
3.109375
3
[ "ISC" ]
permissive
mod channel; mod guild; mod kind; pub use self::{channel::WebhookChannel, guild::WebhookGuild, kind::WebhookType}; use crate::{ id::{ApplicationId, ChannelId, GuildId, WebhookId}, user::User, }; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub stru...
true
46bd83068be6b2cb12028ac8f06781c982958174
Rust
itome/nine-cc
/src/token.rs
UTF-8
7,844
3.90625
4
[]
no_license
#[derive(Debug, Clone)] pub struct Token { pub number: Option<i64>, pub operator: Option<String>, pub ident: Option<String>, } impl PartialEq for Token { fn eq(&self, other: &Self) -> bool { self.number == other.number && self.operator == other.operator } } impl Token { fn operator(op:...
true
764ce72ebac6704a7575b40c1741c7307b7131d2
Rust
cgspeck/the-rust-programming-language
/ch08/vectors/src/main.rs
UTF-8
718
3.875
4
[]
no_license
#[derive(Debug)] enum SpreadsheetCell { Int(i32), Float(f64), Text(String), } fn main() { let mut v = vec![1, 2, 3]; let third = &v[2]; println!("The third value is {}", third); match v.get(3) { Some(_third) => println!("there's a value at index 3"), _ => println!("no val...
true
0136d356f33c5ae644df8c68d751b15a472fc51b
Rust
oddstr13/ublox-cellular-rs
/ublox-cellular/src/services/data/socket/meta.rs
UTF-8
407
2.640625
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use super::SocketHandle; /// Network socket metadata. /// /// This includes things that only external (to the socket, that is) code /// is interested in, but which are more conveniently stored inside the socket itself. #[derive(Debug, Default)] pub struct Meta { /// Handle of this socket within its enclosing `Sock...
true
4133bb761a520870ac177c741918483a9f89e058
Rust
bookinstock/rust_example
/src/bin/generic.rs
UTF-8
11,604
3.46875
3
[]
no_license
/* # generic - function - struct - impl - trait - trait bound - empty bound - multi bound - where - newtype - associated item - q1 存在问题 - q2 关联类型 ## ps - use std::marker::PhantomData; ??? */ use std::fmt::Debug; fn f<T: Debug>(a: T) { println!("hello, {:?}", a); } #[derive(Debug)] struct...
true
f2028d333dc7ec11ee9f4447693c5085eead4d6e
Rust
jedahan/rust-skia
/skia-safe/src/core/sampling_options.rs
UTF-8
2,934
2.859375
3
[ "MIT" ]
permissive
use crate::prelude::*; use skia_bindings::{SkCubicResampler, SkFilterOptions, SkSamplingOptions}; pub use skia_bindings::SkSamplingMode as SamplingMode; pub use skia_bindings::SkMipmapMode as MipmapMode; /// Specify B and C (each between 0...1) to create a shader that applies the corresponding /// cubic reconstructi...
true
882518caf81d6a84b366a2f2e8d33deb10053e5e
Rust
flight-rs/flight
/src/vr.rs
UTF-8
18,273
2.578125
3
[ "MIT" ]
permissive
use nalgebra::{self as na, Similarity3, Transform3, Matrix4, Vector3, Point3, Vector2, Point2, Isometry3, Quaternion, Translation3, Unit}; use webvr::*; use draw::EyeParams; use fnv::FnvHashMap; use gfx::{Rect}; use ::NativeRepr; const VEL_SMOOTHING: f64 = 1e-90; /// Provides access to VR hardware. pub struct VrConte...
true
1b2dce5c50d03748fc5dd5fdde29437f7984178a
Rust
tykim-gaia3d/hey_listen
/src/rc/mod.rs
UTF-8
4,974
3.40625
3
[ "ISC" ]
permissive
use std::hash::Hash; /// Contains the blocking dispatcher. pub mod dispatcher; /// Puts the blocking dispatcher in scope. pub use dispatcher::Dispatcher; /// Every event-receiver needs to implement this trait /// in order to receive dispatched events. /// `T` being the type you use for events, e.g. an `Enum`. pub tr...
true
acc4380f0f7cf60629fa5affa3116c4fd988cc18
Rust
dennisss/dacha
/pkg/rpc/src/metadata.rs
UTF-8
5,559
2.890625
3
[ "Apache-2.0" ]
permissive
use std::collections::HashMap; use std::iter::Iterator; use common::bytes::Bytes; use common::errors::*; use parsing::ascii::AsciiString; // Comma separation pattern used for splitting received metadata values. regexp!(COMMA_SEPARATOR => "(?: \t)*,(?: \t)"); #[derive(Debug, Default, Clone)] pub struct Metadata { ...
true
c3c683f95195d60d0d12538e1636dc6a5b6cb887
Rust
jswrenn/nalgebra
/tests/linalg/qr.rs
UTF-8
3,025
2.59375
3
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
#![cfg(feature = "arbitrary")] use na::{DMatrix, DVector, Matrix3x5, Matrix4, Matrix4x3, Matrix5x3, Vector4}; use std::cmp; quickcheck! { fn qr(m: DMatrix<f64>) -> bool { let qr = m.clone().qr(); let q = qr.q(); let r = qr.r(); relative_eq!(m, &q * r, epsilon = 1.0e-7) && ...
true
dd3c08717238e29f1dffdaae447b9d33637b09b8
Rust
project-serum/solana
/download-utils/src/lib.rs
UTF-8
6,928
2.609375
3
[ "Apache-2.0" ]
permissive
use console::Emoji; use indicatif::{ProgressBar, ProgressStyle}; use log::*; use solana_runtime::{bank_forks::CompressionType, snapshot_utils}; use solana_sdk::clock::Slot; use solana_sdk::hash::Hash; use std::fs::{self, File}; use std::io; use std::io::Read; use std::net::SocketAddr; use std::path::{Path, PathBuf}; us...
true
25993b83c8eec4cfc1ed63c2f1409afab7c1a233
Rust
g-w1/CafeBot
/src/tools/help.rs
UTF-8
4,226
2.90625
3
[ "MIT" ]
permissive
// Simple help command. use crate::admin::admin_test::is_admin; use serenity::{ framework::standard::{macros::command, Args, CommandResult}, model::prelude::*, prelude::*, }; #[command] async fn help(ctx: &Context, msg: &Message, args: Args) -> CommandResult { // build the message let footer = "Caf...
true
f6060901efad3b9a20841d07829e84c880310cd0
Rust
onetonfoot/file_server
/src/main.rs
UTF-8
714
2.875
3
[]
no_license
#![deny(warnings)] use std::path::PathBuf; use std::env::current_dir; use structopt::StructOpt; #[derive(Debug, StructOpt)] #[structopt(name = "example", about = "An example of StructOpt usage.")] struct Opt { #[structopt(short = "p", long = "port", default_value = "7777")] port: u16, #[structopt(parse(fr...
true
62de2ebc83b841c2ec92acae6a3e71902cf3e2a8
Rust
nyctef/ray-tracer-challenge-rust
/src/rtc/shapes.rs
UTF-8
802
2.734375
3
[ "MIT" ]
permissive
use crate::*; mod sphere; pub use self::sphere::*; mod plane; pub use self::plane::*; pub trait Shape: std::fmt::Debug { // transformation matrix for world space -> Shape's local object space fn world_to_object(&self) -> Matrix4; fn material(&self) -> &PhongMaterial; fn local_normal_at(&self, point: T...
true
0c8c9094e164d5d093f22504dac42a845b6da88b
Rust
wine-app/wine-server
/src/graphql/review.rs
UTF-8
341
2.53125
3
[]
no_license
use crate::models::Review as DbReview; #[derive(Debug, juniper::GraphQLObject)] pub struct Review { pub user_id: i32, pub wine_id:i32, pub liked: bool, } impl From<DbReview> for Review { fn from(item: DbReview) -> Review { Review { user_id: item.user_id, wine_id: item.wine_id, liked: ite...
true
4d9b039a25c897e701861d434e95a03f9fee939c
Rust
l1h3r/did_url
/tests/parse.rs
UTF-8
3,834
2.5625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use did_url::DID; #[test] #[rustfmt::skip] fn test_parse_valid_method() { assert!(DID::parse("did:method:identifier").is_ok()); assert!(DID::parse("did:000:identifier").is_ok()); assert!(DID::parse("did:m:identifier").is_ok()); } #[test] #[rustfmt::skip] fn test_parse_invalid_method() { assert!(DID::parse("di...
true
0c8ade43215ea36178d19949c5b5628f83952ca8
Rust
MMKubicki/Advent-of-Code-2020
/day10/src/main.rs
UTF-8
3,788
3.5625
4
[ "Apache-2.0", "MIT" ]
permissive
use itertools::Itertools; use std::collections::HashMap; use std::{fs, num}; fn main() -> anyhow::Result<()> { let options = common::simple_cli::Opts::get(); let content = fs::read_to_string(options.input)?; let mut joltages = parse_input(&content)?; joltages.push(0); // Voltage of outlet joltage...
true
1f3cf13c4247f89b8ad0bb7650583073be8afaa4
Rust
gotham-rs/gotham
/gotham/src/tls/test.rs
UTF-8
12,339
2.640625
3
[ "MIT", "Apache-2.0" ]
permissive
//! Contains helpers for Gotham applications to use during testing. //! //! See the [`TestServer`] and [`AsyncTestServer`] types for example usage. use std::convert::TryFrom; use std::future::Future; use std::io; use std::net::SocketAddr; use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll}; use std::...
true
12a3b313795a29e7cfd007fc8db546bba49c7a90
Rust
oxidecomputer/hubtools
/hubtools/src/archive_builder.rs
UTF-8
5,651
2.703125
3
[]
no_license
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. use crate::header; use crate::Error; use crate::RawHubrisImage; use crate::CABOOSE_MAGIC; use std::io; use std::io::...
true
b31200243706ad5c6aa9da505a9621d9f9a6cbfc
Rust
krsmanian1972/ferries
/src/models/observations.rs
UTF-8
2,178
2.9375
3
[]
no_license
use crate::commons::chassis::ValidationError; use crate::commons::util; use crate::schema::observations; use chrono::NaiveDateTime; #[derive(Queryable, Debug, Identifiable)] pub struct Observation { pub id: String, pub enrollment_id: String, pub description: Option<String>, pub created_at: NaiveDateTi...
true
afdb24b38872fc0f072e69428deb93f8de994f8d
Rust
mauromeli/taller
/ahorcado/src/main.rs
UTF-8
2,079
3.4375
3
[]
no_license
use std::io::{stdin,stdout,Write}; /* fn main() { println!("Bienvenido al ahorcado de FIUBA!"); let mut intentos = 5; let palabra = "ahorcado"; let palabraEscondida = "________"; let mut letras = Vec::new(); println!("La palabra hasta el momento es: {}", palabraEscondida); let letra = lee...
true
7ca2e080cedcc0a4ecb94d6358bb680616527533
Rust
ryanpbrewster/rust-project-euler
/src/util/triangle.rs
UTF-8
2,264
3.609375
4
[]
no_license
// Represents a full lower-right triangle // E.g.: // 1 // 2 3 // 4 5 6 // 7 8 9 10 use std::fs::File; use std::io::Read; use std::ops::Index; use std::ops::IndexMut; use std::str::FromStr; #[derive(Debug)] pub struct Triangle<T> { contents: Vec<T>, } impl<T> Triangle<T> { pub fn new(contents: Vec<T>...
true
8adff7e1b408aad325b8671d7b85e87d3959e278
Rust
ibraheemdev/gql-client-rs
/tests/queries.rs
UTF-8
1,117
2.984375
3
[ "MIT" ]
permissive
mod structs; use crate::structs::{inputs::SinglePostVariables, AllPosts, SinglePost}; use gql_client::Client; use std::collections::HashMap; // Initialize endpoint const ENDPOINT: &'static str = "https://graphqlzero.almansi.me/api"; #[tokio::test] pub async fn fetches_one_post() { let client = Client::new(ENDPOINT...
true
1bf6ce6d4618d164fb70e5a46f3d056f78cb4c39
Rust
inflation/raytracer
/src/hittable_list.rs
UTF-8
1,766
3.015625
3
[]
no_license
use crate::prelude::*; use rand::Rng; use std::sync::Arc; #[derive(Debug)] pub struct HittableList { pub objects: Vec<Arc<dyn Hittable>>, } impl HittableList { pub fn new() -> Self { Self { objects: Vec::new(), } } pub fn add(&mut self, object: Arc<dyn Hittable>) { ...
true
3877c347d5b968fc32d0f48c80af33d4030da461
Rust
VaranTavers/rust_drone_follow
/src/filters/memory_filter.rs
UTF-8
2,514
2.921875
3
[]
no_license
use crate::traits::{Filter}; use crate::models::geometric_point::GeometricPoint; use crate::utils::marker_drawer::MarkerDrawer; use crate::utils::opencv_custom::get_blue; /// Same as NoFilter, but retains last known position of the hat. pub struct MemoryFilter { frames_unknown: usize, max_frames_unknown: usi...
true
ec78a2de326b669b763a7d2428a98c49556451c5
Rust
GabrielDertoni/lambda-lang
/src/compiler.rs
UTF-8
7,719
2.78125
3
[]
no_license
use std::collections::{ HashMap, HashSet, VecDeque }; use std::rc::Rc; use crate::span::Span; use crate::parser; use crate::parser::{ Result, Parser }; use crate::parser::ast; use crate::parser::error::Error; use crate::interpreter::{ Expr, Executable, Macro }; pub fn compile_program(s: &str) -> Result<Executable> { ...
true
a95e8c40535fcb4dc5fc3341f6fa477939e87cbe
Rust
pathbox/learning-rust
/rust-by-example/example_zh/mod_example/src/main.rs
UTF-8
1,827
3.1875
3
[]
no_license
use crate::sound1::instrument; use std::collections::HashMap; use std::io::Result as IoResult; // 重命名 use std::{cmp::Ordering, io}; // use std::cmp::Ordering; use std::io; mod sound; fn main() { let mut v = plant::Vegetable::new("squash", 10); v.name = String::from("butternut squash"); println!("{} are de...
true
d7fdb8f1ba53f927d84729e929615ed43a5129ac
Rust
oziee/tract
/hir/src/ops/nn/layer_max.rs
UTF-8
8,205
2.53125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::infer::*; use crate::internal::*; #[derive(Debug, Clone, new, Default, Hash)] pub struct LayerHardmax { axis: isize, } tract_linalg::impl_dyn_hash!(LayerHardmax); impl LayerHardmax { fn eval_t<D: Datum + tract_num_traits::Float + tract_num_traits::FromPrimitive>( &self, input: Arc<...
true
302e07bec4d827427f448e5bb5d298360c1f23eb
Rust
BuoyantIO/byte-channel-rs
/src/sync/mod.rs
UTF-8
1,273
2.765625
3
[]
no_license
use std::sync::{Arc, Mutex, Weak}; use buffer::ChannelBuffer; use window::Window; mod chunk; mod receiver; mod sender; mod window; pub use self::chunk::Chunk; pub use self::sender::ByteSender; pub use self::receiver::ByteReceiver; pub use self::window::WindowAdvertiser; /// Creates an asynchronous channel for trans...
true
4e94de3ea424d8e4f7935f84a5fa841cfb155a47
Rust
MuhannadAlrusayni/savory
/design-system/src/lib.rs
UTF-8
30,663
2.828125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use palette::{Hsla, LinSrgb, LinSrgba}; use savory::prelude::{DeclarativeConfig, Env}; use savory_elements::prelude::*; use savory_style::{ calc::calc, text::LineHeight, unit::{px, sec, Length}, values as val, Color, St, Style, }; use std::rc::Rc; pub struct SavoryDS { default_theme: Theme, dar...
true
c8ee170923c4bb6b6d1f0549bad7bb1b16653c13
Rust
Mibblez/aedat-file-reader-rs
/src/aedat_conversions/csv.rs
UTF-8
2,500
2.96875
3
[ "MIT" ]
permissive
use std::{fs::File, io::Write}; use crate::{ aedat_data::{CameraParameters, Event}, cli_configs::{CoordMode, CsvConfig}, }; fn format_polarity(polarity: bool) -> String { format!("{},", if polarity { "1" } else { "-1" }) } fn config_csv_header(config: &CsvConfig) -> String { let mut header_tmp = Stri...
true
2fb2503a2f4af53219cb8623dfacc07bad085347
Rust
fbenkstein/advent-of-code
/dima/src/day18.rs
UTF-8
5,434
3.359375
3
[]
no_license
use std::fmt::{self, Write}; use std::mem; #[derive(Clone, Copy, PartialEq, Eq)] enum Acre { Open, Trees, Lumberyard, } impl From<char> for Acre { fn from(c: char) -> Acre { match c { '.' => Acre::Open, '|' => Acre::Trees, '#' => Acre::Lumberyard, ...
true
89773bb6e6fdf740240f0a812219181c6395a1de
Rust
bluss/aeon
/vm/src/immix/histogram.rs
UTF-8
3,788
3.828125
4
[]
no_license
//! Histograms for marked and available lines. //! //! A Histogram is used to track the distribution of marked and available lines //! across Immix blocks. Each bin represents the number of holes with the values //! representing the number of marked lines. pub struct Histogram { values: Vec<usize>, } /// Iterator...
true
ffd5372bab46cd7f55e8534f160d2ee1960acfff
Rust
colemickens/kanshi
/src/backend.rs
UTF-8
1,954
2.65625
3
[ "MIT" ]
permissive
extern crate edid; use std::error::Error; use std::fmt; use std::fs::{File, read_dir}; use std::io::prelude::*; #[derive(Debug)] pub struct ConnectedOutput { pub name: String, pub edid: edid::EDID, } impl ConnectedOutput { pub fn vendor(&self) -> String { self.edid.header.vendor[..].iter().collect::<String>() ...
true
6ed1767600d668f5826993814a95ce99859acdfa
Rust
DavidJFelix/Solitaire-Unity
/Assets/Plugins/SolitaireLib/src/test.rs
UTF-8
705
3.21875
3
[ "Apache-2.0" ]
permissive
use super::*; #[test] fn it_works() { assert_eq!(2 + 2, 4); } #[test] fn standard_deck_has_52_cards() { let deck = create_standard_deck(); assert_eq!(deck.len(), 52); } #[test] fn standard_deck_has_unique_cards() { let mut deck = create_standard_deck(); deck.sort(); deck.dedup(); assert_e...
true
88e701122c323682bff1bf3d53710924b4792e1c
Rust
Perceval62/rust-http-server
/src/config.rs
UTF-8
3,960
3.234375
3
[ "MIT" ]
permissive
use serde::Deserialize; use serde::Serialize; use std::net::SocketAddr; use std::fs::File; use std::io::Read; use std::io::Write; use std::path::Path; use crate::microservice::Microservice; #[derive(Serialize, Deserialize)] struct Pref { ip: String, port: u16, num_threads_max: u16, root_path: St...
true
1966ea6ab265400d4a3c29f8e31ca9a194c0e046
Rust
NiceneNerd/byml-rust
/src/lib.rs
UTF-8
17,042
3.0625
3
[ "MIT", "Apache-2.0" ]
permissive
#![feature(seek_convenience)] //! A simple to use library for reading, writing, and converting Nintendo binary YAML (BYML) files in //! Rust. Supports BYML versions 2-4, (v2 used in *The Legend of Zelda: Breath of the Wild*). Can //! convert from BYML to readable, editable YAML and back. //! //! Sample usage: //! //! `...
true
fe76bbe6c6f7c6724e0001350cfc881b535a829d
Rust
AndrewTweddle/CodingExercises
/AdventOfCode/aoc2021/src/bin/day3_problem1.rs
UTF-8
814
3.125
3
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader}; const BIT_COUNT: usize = 12; fn main() { let input_file = File::open("data/day3_input").unwrap(); let br = BufReader::new(input_file); let bytes: Vec<u32> = br .lines() .map(|ln| u32::from_str_radix(ln.unwrap().as_str(), 2).unwrap()) ...
true
1a6b26f725574005d14769e2a9cf7bfdbdc5f5fa
Rust
haraldmaida/advent-of-code-2018
/src/day02/mod.rs
UTF-8
5,071
3.515625
4
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! # Day 2: Inventory Management System //! //! You stop falling through time, catch your breath, and check the screen on //! the device. "Destination reached. Current Year: 1518. Current Location: //! North Pole Utility Closet 83N10." You made it! Now, to find those anomalies. //! //! Outside the utility closet, you ...
true
7ea8a2b77faceeebe8b9d218b18bea950e658f9f
Rust
Noah-Kennedy/data_structures
/src/lists/mod.rs
UTF-8
562
3.15625
3
[]
no_license
pub mod linked_list; pub trait List<'a, E> { fn insert(&mut self, element: E, index: u64) -> bool; fn get(&self, index: u64) -> Option<E>; fn set(&mut self, index: u64, new_value: E) -> bool; fn remove(&mut self, index: u64) -> bool; fn size(&self) -> u64; } pub trait Stack<'a, E> { fn push(&m...
true
9734285d9a9eed5274896a65c5b8a0e560529f3b
Rust
reitermarkus/cargo-eval
/src/templates.rs
UTF-8
6,270
3.09375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
/*! This module contains code related to template support. */ use crate::app; use crate::error::{Blame, MainError, Result, ResultExt}; use regex::Regex; use std::borrow::Cow; use std::collections::HashMap; use std::fs; use std::path::PathBuf; lazy_static! { static ref RE_SUB: Regex = Regex::new(r#"#\{([A-Za-z_][A-...
true
fde7114529aad563eef7c2c704aab3f65eec6699
Rust
vtavernier/glsl-lang
/lang-util/src/file_id.rs
UTF-8
2,014
3.390625
3
[ "BSD-3-Clause", "Vim" ]
permissive
//! File identifier definition /// Unique file identifier #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(rserde::Serialize, rserde::Deserialize))] #[cfg_attr(feature = "serde", serde(crate = "rserde"))] pub struct FileId(u32); const MAX_VALUE: u32 = 0x7FFFFFFF...
true
563d7fe2843752898aa1441ec9d90aeb4be296ed
Rust
tuxmark5/north
/lang_mir/src/layout.rs
UTF-8
845
3.109375
3
[]
no_license
use { std::cmp }; //////////////////////////////////////////////////////////////////////////////////////////////// #[derive(Clone, Copy)] pub struct Layout { pub size: usize, pub alignment: usize, } impl Layout { pub fn new(size: usize, alignment: usize) -> Self { Self { size, alignment } } pub fn m...
true
9852f8884780edf82195af315d99ce800f5d4fdd
Rust
dctucker/audio-cat
/src/main.rs
UTF-8
1,646
2.828125
3
[]
no_license
extern crate hound; use std::i16; use std::env; use std::cmp::{min,max}; fn block_char(i:i8, inv:i8) -> String { if i <= 0 { if inv == 1 { return String::from("\u{2588}"); } else { return String::from(" "); } } let mut bytes = String::from("\u{2580}").into_bytes(); let base = bytes[2]; bytes[2] = bas...
true
53b869262d7dd2acfb2b4f7f9a7afdc1a35ae011
Rust
alibaba/GraphScope
/interactive_engine/executor/engine/pegasus/common/benches/queue.rs
UTF-8
1,454
2.78125
3
[ "Apache-2.0", "LicenseRef-scancode-proprietary-license", "FSFAP", "BSD-3-Clause-Clear", "GPL-1.0-or-later", "BSD-2-Clause-Views", "Bitstream-Vera", "MPL-2.0", "LicenseRef-scancode-warranty-disclaimer", "OFL-1.1", "BSD-3-Clause", "APAFML", "0BSD", "LicenseRef-scancode-free-unknown", "CC-B...
permissive
#![feature(test)] extern crate test; use std::collections::{LinkedList, VecDeque}; use std::time::Duration; use crossbeam_queue::ArrayQueue; use test::Bencher; #[derive(Copy, Clone)] struct FlatPtr(u64, u64); #[bench] fn write_vec_deque(b: &mut Bencher) { let mut queue = VecDeque::new(); b.iter(|| queue.push...
true
62fd9ffe9c2889a20f445d879b6d269520b274a3
Rust
nadrees/RustyRosalind
/src/nucleotides/dna.rs
UTF-8
1,071
3.265625
3
[ "Unlicense" ]
permissive
use super::{Complementable, Nucleotide}; #[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub enum DNA { A, C, G, T, } impl Nucleotide for DNA {} impl TryFrom<char> for DNA { type Error = char; fn try_from(c: char) -> Result<DNA, Self::Error> { match c { ...
true
1b5f67319025b3746488492bc4c618202aa4cd3a
Rust
johnfercher/rust-web-example
/src/handlers/mod.rs
UTF-8
2,642
2.6875
3
[ "Apache-2.0" ]
permissive
use super::AppState; use actix_web::{error, Error, HttpRequest, HttpResponse, Json, Path, Responder}; use failure::Fail; use crate::domain::models; use crate::clients::insults; #[derive(Fail, Debug)] pub enum AnalyzerError { #[fail(display = "External Service Error")] ExternalServiceError, #[fail(display =...
true
592033239eabd550eb80460507b5eb84c387fd6e
Rust
ia7ck/competitive-programming
/AtCoder/abc271/src/bin/c/main.rs
UTF-8
732
2.640625
3
[]
no_license
use proconio::input; fn main() { input! { n: usize, a: [usize; n], }; let mut ok = 0; let mut ng = a.len() + 1; while ng - ok > 1 { let mid = (ok + ng) / 2; let mut b = vec![false; mid + 1]; b[0] = true; let mut r = 0; for &x in &a { ...
true
66d2ad61107223ece86c77b0486efc8f495b6745
Rust
apoorv-agrawal91/gitsha
/src/main.rs
UTF-8
5,620
2.859375
3
[]
no_license
#![feature(slice_patterns)] use std::error::Error; use std::env; use std::fs; use std::fs::File; use std::io::Read; use std::io::Write; extern crate clap; use clap::{App, Arg, SubCommand}; extern crate github_rs; extern crate serde_json; use github_rs::StatusCode; use github_rs::client::{Executor, Github}; use serde...
true
f39c0fc2bdccaaadb3b21b3db91c1f94d4a69645
Rust
liigo/logic-rs
/src/variable.rs
UTF-8
11,423
3.234375
3
[]
no_license
use std::collections::HashMap; use std::collections::hash_map::Entry; use utils::split_lr; /// 变量定义(声明) #[derive(Default, Debug)] pub struct VarDef { pub name: String, /// i8,u8,i16,u16,i32,u32,f64,f64,str,hex pub typ: String, /// 'a..z' or 'a...z' pub range: String, /// default value if not b...
true
c12908e16f786a0e82bc079d9bda96f0ca24e549
Rust
thepowersgang/rust_os
/Usermode/loader/bin/src/load/mod.rs
UTF-8
1,385
2.703125
3
[ "BSD-2-Clause" ]
permissive
// Tifflin OS - Userland loader // - By John Hodge (thePowersGang) // // load/mod.rs // - Executable loading module use std::io::{Read}; pub struct Segment { pub load_addr: usize, pub file_addr: u64, pub file_size: usize, pub mem_size: usize, pub protection: SegmentProt, } #[derive(Debug)] pub enum SegmentProt { ...
true
5ebd7572a1759a583a1b8db4702c6169d86c54e0
Rust
stewart/advent-2018
/rust/09/src/main.rs
UTF-8
1,055
3
3
[]
no_license
#![allow(dead_code, unused_imports, unused_variables)] use std::collections::VecDeque; const PLAYERS: usize = 455; const LAST_SCORE: usize = 7122300; fn main() { println!("Part 01: {}", score(455, 71223)); println!("Part 02: {}", score(455, 7122300)); } fn part1(input: &str) -> usize { 0 } fn part2(inp...
true
213e414578cbd9eaeeacb06e5e62aef76b959de7
Rust
rhysforyou/fever-ray
/src/scene/light.rs
UTF-8
1,631
3.5
4
[]
no_license
use crate::color::Color; use crate::point::Point3; use crate::vector::Vector3; #[derive(Serialize, Deserialize, Debug)] pub struct DirectionalLight { pub direction: Vector3, pub color: Color, pub intensity: f32, } #[derive(Serialize, Deserialize, Debug)] pub struct AmbientLight { pub color: Color, pub inten...
true
f37e18abb451ea1be7e6ecfc54a525bc44e495b6
Rust
novoselov-ab/adventofcode-2020-rust
/src/bin/20.rs
UTF-8
7,952
3.125
3
[ "MIT" ]
permissive
use std::fs; #[derive(Debug, Clone, Default)] struct Tile { id: i64, arr: [Vec<Vec<char>>; 8], cached_borders: [[i32; 4]; 8], // N, E, S, W orientation: usize, selected: bool, } const W: usize = 10; fn rotated_cw(src: &Vec<Vec<char>>) -> Vec<Vec<char>> { let size = src.len(); let mut dst:...
true
d47a973b8e08af1ac3499a1cc48cf40be079630d
Rust
HVHO/rust-study
/prog/practice-1/4-1.rs
UTF-8
438
2.84375
3
[]
no_license
use std::io::prelude::*; use std::net::TcpListener; use std::net::TcpStream; fn main () -> std::io::Result<()> { let listener = TcpListener::bind("127.0.0.1:7893")?; for stream in listener.incoming() { println!("Connect Established!"); let mut stream = stream?; let mut buf = [0; 512...
true
4e77c86de7ef79263e6223a886334ef6fba9b840
Rust
tnowacki/libra
/language/move-ir-compiler/src/unit_tests/function_tests.rs
UTF-8
1,246
2.734375
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::unit_tests::testutils::compile_module_string; fn generate_function(name: &str, num_formals: usize, num_locals: usize) -> String { let mut code = format!("public {}(", name); code.reserve(30 * (num_formals + num_loca...
true
962ddb933d06712d8b162cbd686791067fda907d
Rust
minghu6/rust-minghu6
/coll_heap/src/lib.rs
UTF-8
5,501
2.578125
3
[]
no_license
#![feature(is_sorted)] #![feature(macro_metavar_expr)] pub mod fib; pub mod dary; use std::{collections::BinaryHeap, cmp::Reverse}; /// Test heap push/pop #[cfg(test)] macro_rules! test_heap { ($heap:expr, $endian:ident) => { test_heap!($heap, $endian, push:push, pop:pop); }; ($heap:expr, $end...
true
3e798c41f89cff4eed66890d01dac657829f1b95
Rust
Dmitri9149/Machine_translation_model
/src/bin/targets_to_source_sentences.rs
UTF-8
4,692
2.640625
3
[]
no_license
// take data from tokens_generator (sentencesAsIndicesDynamics) which are in // the form of sentence -> (token_indices) like [1,56,390] where the nubers are // indices for initial and newly generated tokens // tokens here are totally generated from vocabulaty of words, from characters // the data are transformed to t...
true
5f299ed4a81e8141d5b773e77086b729dc844b64
Rust
andrewjlm/rustrenderer
/src/geo.rs
UTF-8
10,797
3.59375
4
[]
no_license
use std::fmt; use std::ops::{Add, Sub, Mul}; use num::ToPrimitive; use image::{Image, Color}; pub trait VecNum: Add + Sub + Mul + Sized + ToPrimitive + Copy {} // Apparently it's considered bad to do this but I don't know how to avoid... impl VecNum for f64 {} impl VecNum for i32 {} #[derive(Copy, Clone, Debug)] pub...
true
e7452a23339171935c3e419ac6e82bb061d32773
Rust
wagnerf42/rayon
/rayon-core/src/tasks_logs/common_types.rs
UTF-8
1,122
3.125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Types which are common between rayon and rayon-logs. /// unique subgraph identifier pub type SubGraphId = usize; /// unique task identifier pub type TaskId = usize; /// at which time (in nanoseconds) does the event happen pub type TimeStamp = u64; /// All types of raw events we can log. /// It is generic because ...
true
a6bac01d61117c0d537faf600d039589ce61c276
Rust
7sDream/amiya
/examples/hello.rs
UTF-8
466
2.78125
3
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause-Clear" ]
permissive
// m is a macro to let you easily write middleware use closure like Javascript's arrow function // it can also convert a async fn to a middleware use the `m!(async_func_name)` syntax. use amiya::m; fn main() { // Only this stmt is Amiya related code, it sets response to some hello world texts let app = amiya::...
true
57f9f86f4acd6732114282e04cdc166f60c636cf
Rust
extrawurst/gitui
/asyncgit/src/sync/commit_filter.rs
UTF-8
4,018
2.625
3
[ "MIT" ]
permissive
use super::{commit_files::get_commit_diff, CommitId}; use crate::error::Result; use bitflags::bitflags; use fuzzy_matcher::FuzzyMatcher; use git2::{Diff, Repository}; use std::sync::Arc; /// pub type SharedCommitFilterFn = Arc< Box<dyn Fn(&Repository, &CommitId) -> Result<bool> + Send + Sync>, >; /// pub fn diff_con...
true
b8e896259ae97bf952c44e06db4a73f687a7e60d
Rust
tweber12/rulac
/src/skeleton/mod.rs
UTF-8
2,740
2.640625
3
[]
no_license
pub mod colored; pub mod uncolored; use crate::skeleton::uncolored::InternalId; use crate::ufo::PdgCode; use std::collections::{HashMap, HashSet}; use std::hash::Hash; #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct External { pub pdg_code: PdgCode, pub id: InternalId, pub particle: usize, ...
true
ebdb1cc4c5e5d76080af5f4265fc21f0de334bcb
Rust
COLDTURNIP/raphanus_leetcode
/rust/src/p452.rs
UTF-8
3,343
3.515625
4
[]
no_license
/* Problem 452. Minimum Number of Arrows to Burst Balloons ======================================================= https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/ There are some spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordina...
true
9ad99ddebebb87c40e10f1a47992f7f196dc6acb
Rust
nicholastmosher/stm32f103xx
/src/dac.rs
UTF-8
66,621
2.765625
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
# ! [ doc = "Digital to analog converter" ] use core::ops::Deref; use cortex_m::peripheral::Peripheral; use vcell::VolatileCell; # [ doc = "Digital to analog converter" ] pub const DAC: Peripheral<DAC> = unsafe { Peripheral::new(1073771520) }; # [ doc = r" Register block" ] # [ repr ( C ) ] pub struct RegisterBlock ...
true
6cfac3921cea2296458f6ed96c0cf2835c5feb31
Rust
rofrol/ProjectEulerRust
/src/prob0014.rs
UTF-8
727
2.640625
3
[]
no_license
#![crate_id = "prob0014"] #![crate_id = "prob0014"] #![crate_type = "rlib"] #![crate_type = "rlib"] extern crate collections; extern crate num; use collections::HashMap; use num::Integer; pub static EXPECTED_ANSWER: &'static str = "837799"; fn get_len(map: &mut HashMap<uint, uint>, n: uint) -> uint { match map....
true
d1a2da1e4ebf182a21743dff12afd04ee0cc86da
Rust
filmor/eir
/eir/src/env.rs
UTF-8
1,224
2.578125
3
[]
no_license
use cranelift_entity::{ EntityRef, PrimaryMap, entity_impl }; use super::FunctionIdent; #[derive(Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] pub struct ClosureEnv(u32); entity_impl!(ClosureEnv, "lambda_env"); impl ClosureEnv { pub fn from_num(num: usize) -> ClosureEnv { ClosureEnv::new(num) ...
true
27626833922a1ff32667d3123c828285d2ab5ffa
Rust
ThomWright/rusty_circuit
/src/solver/test_static_circuits.rs
UTF-8
10,176
2.640625
3
[ "MIT" ]
permissive
use solver::tests::create_planner; use solver::tests::run_loop_iteration; use test::Bencher; #[test] fn resistor_voltagesource() { use specs::Gate; use elements::Nodes; use elements::CalculatedCurrent; use elements::resistor; use elements::voltage_source; // Set up world let mut planner...
true
0d321d1dbc77e3d7a25c2c47b14ec5f735a7567e
Rust
suryatmodulus/clock
/src/vclock.rs
UTF-8
5,053
3.34375
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::collections::HashSet; #[derive(Default)] pub struct VectorClock { vector: HashMap<String, i64>, // TODO(kavi): Add support mutex for thread-safe? } impl VectorClock { pub fn new() -> VectorClock { VectorClock { vector: HashMap::new(), } ...
true
f04e910b4b18c1b567d295838577fc7cccbd2617
Rust
voxjar/elastiql
/src/aggregation/types/range.rs
UTF-8
5,457
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
//! Range aggregation types. use serde::{Deserialize, Serialize}; use crate::search::Script; #[cfg(feature = "graphql")] use crate::search::ScriptInput; /// A [*multi-bucket*] value source based aggregation that enables the user to /// define a set of ranges - each representing a bucket. During the aggregation /// ...
true
bc60896fa06c7c1bb4a35f47df421610ac6e4b75
Rust
PoiScript/sqlx
/sqlx-core/src/row.rs
UTF-8
5,458
3.0625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Contains the Row and FromRow traits. use crate::database::{Database, HasRawValue, HasRow}; use crate::decode::Decode; use crate::types::Type; pub trait ColumnIndex<DB> where DB: Database, DB: for<'c> HasRow<'c, Database = DB>, { fn resolve<'c>(self, row: &<DB as HasRow<'c>>::Row) -> crate::Result<usiz...
true