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
0c7fed9d1650f87e494d3f1bdb13da097b0e0a9e
Rust
bitkis/ruspiro-loader
/src/loader.rs
UTF-8
8,340
2.546875
3
[ "MIT" ]
permissive
/*************************************************************************************************** * Copyright (c) 2019 by the authors * * Author: André Borrmann * License: Apache License 2.0 **************************************************************************************************/ //! # Bootloader //!...
true
e5c64405cbc2366ca35d52110dfce781024732dc
Rust
piscisaureus/v8rs
/src/local.rs
UTF-8
2,945
3.453125
3
[ "MIT" ]
permissive
use crate::value::Value; use std::marker::PhantomData; use std::ops::Deref; use std::ops::DerefMut; use std::ptr::NonNull; #[repr(C)] /// An object reference managed by the v8 garbage collector. /// /// All objects returned from v8 have to be tracked by the garbage /// collector so that it knows that the objects are s...
true
ae0cba62f627fa8c3a4e1fa5c95828f7dfeba486
Rust
CyberFlameGO/nushell
/crates/nu-command/src/commands/dataframe/shape.rs
UTF-8
1,296
2.78125
3
[ "MIT" ]
permissive
use crate::prelude::*; use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::{dataframe::NuDataFrame, Signature, TaggedDictBuilder}; pub struct DataFrame; impl WholeStreamCommand for DataFrame { fn name(&self) -> &str { "dataframe shape" } fn usage(&self) -> &str { ...
true
92ed887efb44ce128facb6799d9123b2839ffa15
Rust
ehorrent/KeyboardLightingParser
/rust/src/parser.rs
UTF-8
6,017
3.53125
4
[]
no_license
use regex::Regex; use std::collections::HashMap; use std::fmt; // ------------------------------------------------------------------------------------- // Public parser models #[derive(Clone, Copy)] pub enum Color { Green, Blue, Red, Yellow, Orange, } impl fmt::Display for Color { fn fmt(&self, f: &mut f...
true
2f318dade24cd6722f1ee4f5beef6e0ca538a30e
Rust
jinjagit/Rust
/objects2/src/main.rs
UTF-8
471
4.0625
4
[]
no_license
// How to change value in Struct instance using a function pub struct Value { value: i32, } impl Value { pub fn add(&mut self, x: i32) { self.value = self.value + x; } } fn main() { let mut a = Value { value: 0, }; change(&mut a); println!("a.value = {}", a.value); } //...
true
334d7270cece726d686a5d8d4694c16f17fcc88a
Rust
vedantprajapati/VDatabase
/Concurrent Database/main.rs
UTF-8
1,816
2.90625
3
[]
no_license
/* * main.rs * * Processes arguments and starts EasyDB server * * University of Toronto * 2019 */ mod schema; mod packet; mod server; mod database; use std::env; fn usage(prog: &String) { println!("usage: {} [-g] PORT [FILE=default.txt] [HOST=localhost]", prog); println!("\t-g: debug mode (more verbos...
true
d5d333c2c4414c589d949235f185bc26101210bf
Rust
LaplaceKorea/simulation
/simulation/src/deterministic/network/mod.rs
UTF-8
6,645
3
3
[ "MIT" ]
permissive
//! In memory network //! //! Servers can be registered with the network, allowing for new connections to //! be accepted or rejected depending on the current fault state of the network. //! //! The network can inject partitions between machines. use std::{io, net, sync}; pub(crate) mod fault; mod inner; mod listen; p...
true
dc94691e87a81c2214de0761bcd24958d19d0771
Rust
serde-rs/serde
/test_suite/tests/ui/with-variant/skip_de_tuple_field.rs
UTF-8
201
2.59375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use serde_derive::Deserialize; #[derive(Deserialize)] enum Enum { #[serde(deserialize_with = "deserialize_some_other_variant")] Tuple(#[serde(skip_deserializing)] String, u8), } fn main() {}
true
7ece5de2117ea96f31ef40feabc66fc552c697d0
Rust
nickolay/git-interactive-rebase-tool
/src/core/src/components/help/tests.rs
UTF-8
2,081
2.765625
3
[ "BSD-3-Clause", "GPL-3.0-only", "Apache-2.0", "BSD-2-Clause", "GPL-3.0-or-later", "LicenseRef-scancode-unknown-license-reference", "GPL-1.0-or-later" ]
permissive
use input::{KeyModifiers, MouseEvent, MouseEventKind, StandardEvent}; use rstest::rstest; use view::{assert_rendered_output, testutil::with_view_state}; use super::*; fn handle_event(help: &mut Help, event: Event) { let evt = help.read_event(event).unwrap_or(event); with_view_state(|context| help.handle_event(evt, ...
true
33d5fb60427bc9b7948408b5dbd4630c87557822
Rust
itbaiyang/rust-book
/src/iter_m/iter_test.rs
UTF-8
1,809
4.03125
4
[]
no_license
/** * 迭代器是惰性的 * 迭代器消费方法 next() collect() * 迭代器生成其他迭代器方法 map filter */ pub fn init() { // lazy_iter() let sum: u32 = Counter::new() .zip(Counter::new().skip(1)) .map(|(a, b)| a * b) .filter(|x| x % 3 == 0) .sum(); assert_eq!(18, sum); } #[test] fn lazy_iter() { ...
true
9f202d06a52168637f36c5fb170cdcc67494846b
Rust
Fayhen/rust-notes-and-examples
/operators/src/main.rs
UTF-8
2,239
3.765625
4
[]
no_license
use std::io; fn parse_input() -> f64 { let parsed_input: f64 = loop { let mut input = String::new(); println!("\nPlease enter a number:"); io::stdin() .read_line(&mut input) .expect("Failed to read. Please try again."); let _float: f64 = match input.trim()....
true
ffaaa7a6f7a526aa2537acbcb299ffafa1e5315b
Rust
ishanjain28/raytracing-in-a-weekend
/src/types/vec3.rs
UTF-8
3,901
3.265625
3
[]
no_license
use std::{ fmt::{Display, Formatter, Result as FmtResult}, ops::{Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Neg, Sub, SubAssign}, }; #[derive(Copy, Clone)] pub struct Vec3([f64; 3]); impl Vec3 { #[inline] pub const fn new(a: f64, b: f64, c: f64) -> Vec3 { Vec3([a, b, c]) ...
true
4ccee9f238f8bbe9592ec93925dca2f349e6c1b8
Rust
tramulns/benchmark-memory
/benchmark_arr_bounds_checks/src/lib.rs
UTF-8
2,495
2.921875
3
[]
no_license
#![feature(test)] #[allow(dead_code)] const KB: usize = 1024; #[allow(dead_code)] const MB: usize = KB * KB; #[allow(dead_code)] const N: usize = 16 * MB; #[cfg(test)] mod tests { use super::*; extern crate test; use rand::prelude::*; use test::Bencher; #[bench] fn bench_index_sum(b: &mut B...
true
a09c310b64cdada001f6b85f7b07c36f3f002a83
Rust
maroider/native-dialog-rs
/src/impl/mac/file.rs
UTF-8
2,249
2.8125
3
[ "MIT" ]
permissive
use crate::{Dialog, Error, OpenMultipleFile, OpenSingleDir, OpenSingleFile, Result}; use osascript::JavaScript; use serde::de::DeserializeOwned; use serde::Serialize; use std::path::PathBuf; impl Dialog for OpenSingleFile<'_> { type Output = Option<PathBuf>; fn show(self) -> Result<Self::Output> { cho...
true
a40c891a3cdadcbe627a2b31ee9ec8650602f900
Rust
rust9x/rust
/src/test/run-make-fulldeps/coverage/try_error_result.rs
UTF-8
577
2.5625
3
[ "MIT", "BSD-3-Clause", "Apache-2.0", "BSD-2-Clause", "LicenseRef-scancode-other-permissive", "NCSA" ]
permissive
#![allow(unused_assignments)] // expect-exit-status-1 fn call(return_error: bool) -> Result<(),()> { if return_error { Err(()) } else { Ok(()) } } fn main() -> Result<(),()> { let mut countdown = 10 ; for _ in 0..10 { countdown ...
true
3aa21366bb41cbd5a6e1e4952395a3df8f0224c9
Rust
Robbepop/cargo-tally
/src/error.rs
UTF-8
1,442
2.75
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use semver::ReqParseError; use std::fmt::{self, Display}; use std::io; pub enum Error { MissingJson, ParseSeries(String, ReqParseError), Io(io::Error), Json(serde_json::Error), Reqwest(reqwest::Error), Regex(regex::Error), NothingFound, } pub type Result<T> = std::result::Result<T, Error>...
true
d29105c641d36634e373ebe2a24badb0c5eaac1a
Rust
tensorbase/tensorbase
/crates/client/src/errors.rs
UTF-8
5,658
2.828125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-free-unknown" ]
permissive
use std::str::Utf8Error; use std::{borrow::Cow, io, result}; use thiserror::Error; use url::ParseError; use crate::types::SqlType; #[derive(Debug, Error, Clone, Eq, PartialEq)] #[error("{} {} {}", name, code, message)] pub struct Exception { pub name: String, pub code: u32, pub message: String, #[cfg...
true
f63606c59585c594b27151895f892ebbd81e8c85
Rust
fewensa/rtdlib
/src/types/message_position.rs
UTF-8
2,160
2.9375
3
[ "MIT" ]
permissive
use crate::types::*; use crate::errors::*; use uuid::Uuid; /// Contains information about a message in a specific position #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct MessagePosition { #[doc(hidden)] #[serde(rename(serialize = "@type", deserialize = "@type"))] td_name: String, #[doc...
true
3f065ce9dbe02bda2a65294c066ea162aaa8f648
Rust
willy610/tableclass
/src/bins/binchrisdate/ex_join_and_project.rs
UTF-8
4,918
2.609375
3
[]
no_license
use tableclass::explain::explain; use tableclass::table::{Table, TableRow}; use tableclass::table_folder::table_from::Params2FromCSV; use tableclass::table_folder::table_join::{Params2Join, PostProject}; //use tableclass::table_folder::table_select::Params2Select; //use tableclass::table_folder::table_limit::Params2Lim...
true
5457a4fc09072cd54fc6ddc6dae46fd4317d411c
Rust
mneumann/dla-rs
/src/lib.rs
UTF-8
9,326
3.0625
3
[ "MIT" ]
permissive
extern crate rand; extern crate image; use rand::Rng; use std::fs::File; use std::path::Path; use std::usize; use std::cmp; /// An aggregate particle attached to some other particle. #[derive(Copy, Clone)] struct Aggregate { /// Age (iteration number). If negative, aggregate does not exist. age: i32, ///...
true
ab0792f0c955fb5c0394c76ed05dca9a486553d1
Rust
akkypiko/Ruml
/src/typed_ast.rs
UTF-8
1,453
2.9375
3
[]
no_license
use id::*; use typing::*; #[derive(Debug)] pub enum TypedAst { Unit, Int(i64), Bool(bool), Var(Id, Type), Seq (Vec<TypedAst>, Type), Logical { lhs: Box<TypedAst>, op: Id, rhs: Box<TypedAst>, ty: Type }, BinaryOp { lhs: Box<TypedAst>, op: Id, rhs: Box<TypedAst>, ty: Type }, UnaryOp { o...
true
278be82133aedb5a5b21ecc64e42e79e40a8b5d0
Rust
prasmussen/orri
/backend/src/orri/site/http/edit_route.rs
UTF-8
9,820
2.640625
3
[ "MIT" ]
permissive
use actix_web::{web, HttpResponse}; use actix_session::Session; use crate::orri::app_state::AppState; use crate::orri::domain::{self, Domain}; use crate::orri::site::{self, Site, GetSiteError}; use crate::orri::slowhtml::html::Html; use crate::orri::slowhtml::html; use crate::orri::slowhtml::attributes as attrs; use cr...
true
9712ef769f794bc6d1955bae31763bb51ebee47f
Rust
iprs-dev/iprs
/src/ipfsd/thread.rs
UTF-8
2,984
2.921875
3
[ "MIT" ]
permissive
use crossbeam_channel::{self as cbm, select}; use log::{debug, error}; use std::thread; use crate::{util, Error, Result}; const MAX_CHANSIZE: usize = 16; pub enum Req { Fin, } pub enum Res { None, } /// Client handle to communicate with ipfs-daemon. pub struct Client { tx: cbm::Sender<(Req, Option<cbm...
true
c69895cd3ee4a5095ddaffb11c31bbe3c2133198
Rust
tomocy/rust-cookbook
/cents/src/main.rs
UTF-8
583
3.75
4
[]
no_license
fn main() {} enum Coin { Penny, Nickel, Dime, Quater, } impl Coin { fn value_in_cents(&self) -> u32 { match self { Coin::Penny => 1, Coin::Nickel => 5, Coin::Dime => 10, Coin::Quater => 25, } } } #[cfg(test)] mod tests { use ...
true
625cb147486724d5ae0a8d9dc932e91b6d0a2621
Rust
rylev/azure-functions-rs
/azure-functions-shared/src/codegen/bindings/table.rs
UTF-8
1,793
2.8125
3
[ "MIT" ]
permissive
use crate::codegen::Direction; use serde::{ser::SerializeMap, Serialize, Serializer}; use std::borrow::Cow; pub const TABLE_TYPE: &str = "table"; #[derive(Debug, Clone)] pub struct Table { pub name: Cow<'static, str>, pub direction: Direction, pub table_name: Cow<'static, str>, pub partition_key: Opti...
true
7bb635b41319b2aabb75eb0dbaaa050f37075ae4
Rust
dmhacker/dual-ec-drbg
/src/prng.rs
UTF-8
2,621
3.421875
3
[]
no_license
use crate::curve::Curve; use crate::point::{CurvePoint, Point}; use rug::{Assign, Integer}; use std::rc::Rc; pub struct DualECDRBG { pub curve: Curve, pub outsize: u32, pub outmask: Integer, pub p: Point, pub q: Point, state: Integer, } impl DualECDRBG { pub fn new(curve: &Curve, p: &Point...
true
b19fff1aaf361480713c35b72072f5c52703b165
Rust
cda-group/arcon
/arcon/src/stream/operator/function/map.rs
UTF-8
2,063
2.640625
3
[ "Apache-2.0" ]
permissive
use crate::{ data::{ArconElement, ArconNever, ArconType}, error::*, index::{ArconState, EmptyState}, stream::operator::{Operator, OperatorContext}, util::ArconFnBounds, }; use std::marker::PhantomData; pub struct Map<IN, OUT, F, S> where IN: ArconType, OUT: ArconType, F: Fn(IN, &mut S) ...
true
e54e47b107fe4efa7de86b0efc8be33a58a94006
Rust
saelay/libharu-rs
/examples/util/mod.rs
UTF-8
3,350
2.765625
3
[]
no_license
extern crate libharu; extern crate anyhow; use libharu::prelude::*;//{Document, PageDescriptionMode, PageDescTextCommon}; pub fn print_grid(doc: &Document, page: &PageDescriptionMode) -> anyhow::Result<()> { let height = page.height()?; let width = page.width()?; let font = doc.font("Helvetica", N...
true
ebeb0e4cb7e86c072af73e8be4123ba405781675
Rust
pixelistik/request_log_analyzer
/src/http_handler/tests/mock.rs
UTF-8
2,965
2.65625
3
[ "MIT" ]
permissive
use std::io::{self, Read, Write, Cursor}; use std::net::Shutdown; use std::time::Duration; use std::cell::Cell; use std::net::SocketAddr; use hyper::net::NetworkStream; // MockStream is copied from Hyper tests // https://github.com/hyperium/hyper/blob/0.10.x/src/mock.rs // MIT licensed, Copyright (c) 2014 Sean McArthu...
true
40e16266cc8c8dc6c442f6d67bc69188ffb9e4a2
Rust
Caelmyn/rs-job-mgr
/jenkins_ci/src/parameters.rs
UTF-8
1,526
3.296875
3
[]
no_license
use std::fs; use serde::{Deserialize, Serialize}; /* -- Key definition -- */ #[derive(Deserialize, Serialize, Default, Debug)] struct Parameter { name: String, value: String, } /* -- Key public implementation -- */ impl Parameter { fn new(key: &str, value: &str) -> Self { let mut ret = Self { ...
true
9b3784cc74e7dac7301a1690b4eed469921dffa3
Rust
Lyndon-Mackay/abl_formatter
/src/lib.rs
UTF-8
12,479
2.9375
3
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
extern crate pest; mod assign; mod expression; mod function; mod temp_table; use std::{ fs::File, io::{stdin, BufRead, BufReader}, }; use lazy_static::lazy_static; use regex::Regex; use assign::format_assign; use expression::{format_by_expression,format_accumulate,format_conditional_expression, format_datat...
true
cf6368ee19531c82cf8f6e1fe665d1e2793e4721
Rust
niuez/toptree-rust
/src/node.rs
UTF-8
15,310
2.734375
3
[]
no_license
use std::ptr::NonNull; use crate::parent_dir::*; use crate::link::*; //use crate::expose::*; pub trait Cluster: Clone { type V: Default + Copy + std::fmt::Debug; fn identity() -> Self; fn compress(left: Self, right: Self, a: Self::V, b: Self::V, c: Self::V) -> Self; fn rake(left: Self, right: Self, a: ...
true
38d82384a701acb2b96bca6a3e62e5a34e7cdf2f
Rust
euclidr/leetcode
/examples/p456.rs
UTF-8
2,429
3.359375
3
[]
no_license
struct Solution; impl Solution { pub fn find132pattern(mut nums: Vec<i32>) -> bool { use std::i32; if nums.len() < 3 { return false; } nums.reverse(); let mut stack = vec![]; let mut throwed = i32::MIN; for i in 0..nums.len() { while ...
true
88be731d9475c0d38ff05f85338ef1d4bb829bd7
Rust
scottpenn/oiler
/src/euler.rs
UTF-8
815
3.40625
3
[]
no_license
use rayon::prelude::*; pub fn euler_1(limit: u32) -> u32 { let mut sum = 0; for i in 1..limit { if i % 5 == 0 || i % 3 == 0 { sum += i; } } sum } pub fn euler_1_iter(limit: u32) -> u32 { (1..limit).filter(|i| i % 5 == 0 || i % 3 == 0).sum() } pub fn euler_1_loop(limit:...
true
89e1b9114c7a9d3232555e5c4fa510e82854ef25
Rust
jaroslaw-weber/rust-ox-ui
/src/button.rs
UTF-8
276
3.0625
3
[ "MIT" ]
permissive
#[derive(Debug, Serialize, Deserialize)] pub struct Button { id: i32, } //button component, have id (usually unique) for listeners impl Button { pub fn get_id(&self) -> i32 { self.id } pub fn new(id: i32) -> Button { Button { id: id } } }
true
ea645b529d7a4abae10ca0f9d19d9af8baff96a2
Rust
santhosh-r/Assorted
/Rust/Rust in Motion/unit1/structs/src/main.rs
UTF-8
3,543
4.21875
4
[]
no_license
// structs enum HockeyPosition { Wing // enum variants should be in CamelCase } struct HockeyPlayer { // by convention, struct and enum names should be in CamelCase name: String, // field names should be in snake_case number: u8, position: HockeyPosition, goals_ytd: u8 } // tuple structs struct T...
true
86a95ff0e36c47424a8ec2a3b1925f62d045eaf4
Rust
theidiotmachine/WA1
/wa1-generator/src/mem.rs
UTF-8
2,752
2.796875
3
[ "MIT", "CC0-1.0" ]
permissive
use std::collections::HashMap; use std::cmp; use wa1_types::{Member}; use wa1_ast::prelude::{TypeDecl, UserClassStorage}; use crate::wasm::{WasmValueType}; use crate::wasm_types::get_wasm_value_type; pub fn stupid_log2(x: u32) -> u32 { //I am ashamed to say I have no idea how to do this properly in Rust matc...
true
586b90207f818b449427271ad39e9f0dae844908
Rust
kingxsp/rust-postgres
/postgres/src/simple_query.rs
UTF-8
1,131
2.71875
3
[ "MIT" ]
permissive
use fallible_iterator::FallibleIterator; use futures::stream::{self, Stream}; use std::marker::PhantomData; use tokio_postgres::impls; use tokio_postgres::{Error, SimpleQueryMessage}; pub struct SimpleQuery<'a> { it: stream::Wait<impls::SimpleQuery>, _p: PhantomData<&'a mut ()>, } // no-op impl to extend borr...
true
c77c652faa3f45af54183b03f4e6de38c523d0eb
Rust
TrentonZero/rust-koans
/src/euler/euler002.rs
UTF-8
589
3.375
3
[ "MIT" ]
permissive
#[test] fn euler002() { let result = fibos() .take_while(|&x| x <= 4000000) .filter(|&x| x % 2 == 0) .fold(0, |acc, v| acc + v); println!("euler 002: {0}", result.to_string()); } // okay i confess I cribbed this. struct Fibos { curr: u32, next: u32, } impl Iterator for Fibos...
true
7db998caa70e49c7e93086ab0b248892836968fb
Rust
jqnatividad/qsv
/tests/test_sqlp.rs
UTF-8
27,571
2.96875
3
[ "MIT", "Unlicense" ]
permissive
use crate::workdir::Workdir; macro_rules! sqlp_test { ($name:ident, $fun:expr) => { mod $name { use std::process; use super::{make_rows, setup}; use crate::workdir::Workdir; #[test] fn headers() { let wrk = setup(stringify!($name...
true
3858470edfc1951740184275899b33fd15407112
Rust
birarvin/rksuid
/tests/new.rs
UTF-8
1,326
2.703125
3
[ "MIT" ]
permissive
#[cfg(test)] mod tests{ use rksuid::rksuid::{new, RngType, Ksuid, gen_epoch, gen_payload}; use chrono::prelude::*; use rand::distributions::Standard; use rand::prelude::*; use std::{thread, time}; use strum::IntoEnumIterator; use std::any::{Any, TypeId}; // Creation tests #[test] fn test_new() { let first = new(N...
true
7c2aac03353725e357a9e9dd2eb61532e865e4b4
Rust
21eleven/leetcode-solutions
/rust/0858_mirror_reflection/lcm.rs
UTF-8
1,365
3.078125
3
[]
no_license
/* 858. Mirror Reflection Medium There is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of the remaining corners, numbered 0, 1, and 2. The square room has walls of length p, and a laser ray from the southwest corner first meets the east wa...
true
6ceb4cbb8f45998ab5ba789df3fd3b39bdaba089
Rust
JoNil/aoc2020
/src/bin/12_b.rs
UTF-8
1,601
3.328125
3
[]
no_license
use aoc2020::{get_input, Vec2}; fn parse_instruction(line: &str) -> (char, i32) { let (ins, amount) = line.split_at(1); (ins.as_bytes()[0] as char, amount.parse().unwrap()) } fn evaluate_rules(input: &str) -> Vec2 { let mut wp = Vec2(10, 1); let mut pos = Vec2(0, 0); for (ins, amount) ...
true
7ad1713ea124a1b0cb52b1f0fa8b9e5a2710ab6c
Rust
donsbot/experiments-rust
/basics/src/bounds.rs
UTF-8
416
3.15625
3
[ "BSD-3-Clause" ]
permissive
use std::ops::{Add, Mul}; // num-generic dot product fn dot<N>(v1: &[N], v2: &[N]) -> N where N: Copy + Mul<Output = N> + Add<Output = N> + Default, { let mut total: N = N::default(); for i in 0..v1.len() { total = total + v1[i] * v2[i]; } total } pub fn main() { let a: &[f64] = &[1., ...
true
18c882f24c530221f5a60c48a72a389ef667de08
Rust
maximeborges/async-on-embedded
/async-embedded/src/unsync/waker_set.rs
UTF-8
4,264
2.96875
3
[ "MIT", "Apache-2.0" ]
permissive
// NOTE based on async-std v1.5.0 use core::{ cell::UnsafeCell, task::{Context, Waker}, }; // TODO replace with `heapless::Slab` but then we need to pick a fixed capacity // (equal to the maximum number of in-flight tasks) for the `Slab` use heapless::{i, Slab}; // NOTE this should only ever be used in "Thre...
true
d573969e61db8aca40282f55285d342cdc002dc0
Rust
marco-c/gecko-dev-wordified
/third_party/rust/anyhow/tests/test_chain.rs
UTF-8
2,579
2.859375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use anyhow : : { anyhow Chain Error } ; fn error ( ) - > Error { anyhow ! ( { 0 } ) . context ( 1 ) . context ( 2 ) . context ( 3 ) } # [ test ] fn test_iter ( ) { let e = error ( ) ; let mut chain = e . chain ( ) ; assert_eq ! ( " 3 " chain . next ( ) . unwrap ( ) . to_string ( ) ) ; assert_eq ! ( " 2 " chain . next (...
true
d8dfcf80594d50ffc8d5d5da9ce09b38bd3a0aaf
Rust
glium/glium
/examples/tessellation.rs
UTF-8
6,761
2.5625
3
[ "Apache-2.0" ]
permissive
#[macro_use] extern crate glium; use glium::index::PrimitiveType; use glium::{Display, Surface}; use glutin::surface::WindowSurface; use support::{ApplicationContext, State}; mod support; #[derive(Copy, Clone)] struct Vertex { position: [f32; 2], } implement_vertex!(Vertex, position); struct Application { p...
true
f0492f1709080c025a58000ce585d2e82339a0f5
Rust
enkejill/advent_of_code
/src/day6.rs
UTF-8
4,830
2.71875
3
[]
no_license
/* * Copyright (c) 2019 Jill Enke <jill.enke@gmail.com> * All rights reserved. * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitatio...
true
3fd88abb65b5b46312b73c74466670c83b78ca53
Rust
CodeLongAndProsper90/macchina
/src/read/kernel.rs
UTF-8
1,961
2.828125
3
[ "MIT" ]
permissive
use std::process::Command; /// Linux: Read kernel release using `sysctl -nb kernel.osrelease` #[cfg(target_os = "linux")] pub fn osrelease() -> String { let output = Command::new("sysctl") .args(&["-n", "-b", "kernel.osrelease"]) .output() .expect("ERROR: failed to fetch \"kernel.osrelease\...
true
66d5553399ecf12c1977f165e8500e10b19d268c
Rust
shadowmint/rust-pup
/crates/pup-core/src/context/global_env.rs
UTF-8
339
2.5625
3
[]
no_license
use crate::utils::path::display; use std::collections::HashMap; use std::path::Path; /// Generate a global injected env to use for everything pub fn build_global_env(root: &Path) -> HashMap<String, String> { let mut global_env = HashMap::new(); global_env.insert(format!("MANIFEST_HOME"), display(root)); re...
true
e5c029eb3e2d364d786dbd5f1e07480e525faa29
Rust
stefan-k/shepplogan-rs
/src/shape/ellipse.rs
UTF-8
10,626
2.953125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. use super::BoundingBox; /...
true
5304fe8a60246c3d2e82d3335a75353c0d50e895
Rust
stefanos1316/Rosetta_Code_Data_Set
/tasks/concurrent-computing/rust/concurrent-computing/src/main.rs
UTF-8
499
2.953125
3
[ "CC0-1.0" ]
permissive
extern crate rand; use std::thread; fn main() { for _i in 0..1000000 { for word in "Enjoy Rosetta Code".split_whitespace() { let local_word = word.to_owned(); let original_thread = std::thread::spawn(move || { thread::sleep(std::time::Duration::from_millis(1)); ...
true
edd3687308a1dd45b25d57dbf00e5539080c9f53
Rust
vksmgr/Learn_Rust_Programming
/out/production/algorithms/sorting.rs
UTF-8
2,941
3.5625
4
[]
no_license
pub fn insertion_sort(arr: &mut[i32]) ->&mut [i32]{ let mut i =0; let mut j =1; let arr_len = arr.len(); let mut key =0; for i in 1..arr_len{ key = arr[i]; j = i-1; while j>= 0 && key < arr[j] { arr[j+1] = arr[j]; j = j-1; } arr[j + 1] = ...
true
4d7a6a6c9eb210b5b6621f32cd1e83b3981a41da
Rust
doy/rbw
/src/api.rs
UTF-8
43,955
2.953125
3
[ "MIT" ]
permissive
// serde_repr generates some as conversions that we can't seem to silence from // here, unfortunately #![allow(clippy::as_conversions)] use crate::prelude::*; use crate::json::{ DeserializeJsonWithPath as _, DeserializeJsonWithPathAsync as _, }; use tokio::io::AsyncReadExt as _; #[derive( serde_repr::Serial...
true
eecb48084996276bf7afc122edb1ea202933134c
Rust
isgasho/glsl
/glsl/src/lib.rs
UTF-8
1,938
3.328125
3
[]
no_license
//! # GLSL compiler //! //! This crate is a GLSL450 compiler. It’s able to parse valid GLSL450 formatted source into an //! abstract syntax tree (AST). That AST can then be transformed into SPIR-V, your own format or //! even folded back to a raw GLSL [`String`] (think of a minifier, for instance). //! //! You’ll find ...
true
c6b3bda64fa5769a511d79c2960158e5ada2ec48
Rust
hhirtz/ellidri
/ellidri-tokens/src/mode.rs
UTF-8
13,554
3.125
3
[ "ISC", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Mode parsing and validation use std::str; /// User modes supported by ellidri. Advertised in welcome messages. pub const USER_MODES: &str = "aio"; /// Channel modes that have no parameters and are supported by ellidri. Advertised in welcome /// messages. pub const SIMPLE_CHAN_MODES: &str = "imnst"; /// Channe...
true
135ea88ec3b07d99d552445bebe1c87571aaea17
Rust
marhoily/chess_rust
/src/square88/ops.rs
UTF-8
1,652
3.296875
3
[]
no_license
use super::*; use std::ops::*; impl BitOr<Square88> for Square88 { type Output = Square88; fn bitor(self, rhs: Square88) -> Self::Output { Square88(self.0 | rhs.0) } } impl BitOrAssign<Square88> for Square88 { fn bitor_assign(&mut self, rhs: Square88) { self.0 |= rhs.0 } } impl BitA...
true
c2ff835ad4120ef11eca380b790491277a9d78ec
Rust
codec-abc/kas
/src/traits/utils.rs
UTF-8
865
2.828125
3
[ "Apache-2.0" ]
permissive
// 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 in the LICENSE-APACHE file or at: // https://www.apache.org/licenses/LICENSE-2.0 //! Utility traits //! //! Arguably this stuff belongs in a...
true
6090e39c2c89029503b6f1810e205bacf55329a6
Rust
kamadorueda/alejandra
/src/alejandra/src/rules/bin_op.rs
UTF-8
3,845
2.59375
3
[ "Unlicense" ]
permissive
pub(crate) fn rule( build_ctx: &crate::builder::BuildCtx, node: &rnix::SyntaxNode, ) -> std::collections::LinkedList<crate::builder::Step> { rule_with_configuration(build_ctx, node, "bin_op_and_or_default") } pub(crate) fn rule_with_configuration( build_ctx: &crate::builder::BuildCtx, node: &rnix::...
true
1263edd96e28e62d6592372939c1579ca4332ef9
Rust
artemshein/varuint
/src/varint.rs
UTF-8
5,097
3.21875
3
[ "MIT" ]
permissive
use crate::VarintSizeHint; use std::{ fmt, ops::{Deref, DerefMut}, }; pub trait VarintBaseType: Copy + Clone + PartialEq + PartialOrd + Eq + Ord + fmt::Debug + VarintSizeHint { } impl<T: Copy + Clone + PartialEq + PartialOrd + Eq + Ord + fmt::Debug + VarintSizeHint> VarintBaseType for T { } /// Variab...
true
19fc779a01da5c989fe24d2ed1c31c3e0496db91
Rust
jdmeyer3/adventofcode2020
/src/bin/day11.rs
UTF-8
10,612
3.46875
3
[]
no_license
use std::fmt; use std::fmt::Formatter; #[derive(Debug, PartialEq, Clone)] enum Seat { Empty, Occupied, Floor, OutOfBounds, } #[derive(Clone)] struct Seating { seats: Vec<Seat>, width: usize, } impl fmt::Display for Seating { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { l...
true
d97715d0972320da96912fa7a9bd0656d5f23c2b
Rust
IThawk/rust-project
/rust-master/src/test/ui/did_you_mean/issue-34337.rs
UTF-8
156
2.921875
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
fn get(key: &mut String) { } fn main() { let mut v: Vec<String> = Vec::new(); let ref mut key = v[0]; get(&mut key); //~ ERROR cannot borrow }
true
d1444299dd10040375dd7a4f1fda3ab29de55d71
Rust
diseraluca/stm32g4
/src/stm32g431/rtc.rs
UTF-8
13,763
2.9375
3
[]
no_license
///Register block #[repr(C)] pub struct RegisterBlock { ///0x00 - time register pub tr: TR, ///0x04 - date register pub dr: DR, ///0x08 - sub second register pub ssr: SSR, ///0x0c - initialization and status register pub icsr: ICSR, ///0x10 - prescaler register pub prer: PRER, ...
true
adca3a81e7d2e92519ef163b113a9e1abd4b59a4
Rust
wangds/puzzle-solver
/tests/hidato.rs
UTF-8
3,070
3.15625
3
[ "MIT" ]
permissive
//! Hidato. //! //! https://en.wikipedia.org/wiki/Hidato extern crate puzzle_solver; use puzzle_solver::{Puzzle,Solution,Val,VarToken}; const WIDTH: usize = 8; const HEIGHT: usize = 8; const NA: i32 = -1; type Board = [[i32; WIDTH]; HEIGHT]; fn make_hidato(board: &Board) -> (Puzzle, Vec<VarToken>) { let mut sys...
true
5c0d8ef034c8dcf498164f74fc9884fae1e14ee2
Rust
instrumentisto/cqrs-rs
/cqrs-codegen/src/lib.rs
UTF-8
11,815
2.921875
3
[ "Apache-2.0" ]
permissive
extern crate proc_macro; use proc_macro::TokenStream; #[cfg(all(not(feature = "watt"), feature = "no-watt"))] /// Imports proc macro from implementation crate as is. macro_rules! import { ($input:expr, $fn:ident) => { cqrs_codegen_impl::expand(syn::parse($input), cqrs_codegen_impl::$fn) }; } #[cfg(al...
true
8a9e1ee558a22191db5d321dc16a645574e5c6bd
Rust
TIboStans/Dramasim
/compiler/src/compilation_error.rs
UTF-8
3,496
3.09375
3
[]
no_license
use crate::Line; use mexprp::EvalError; use std::fmt::Formatter; #[derive(Debug)] pub enum CompilationError<'a> { MathEval(Line<'a>, EvalError), NegativeRegisters { line: Line<'a>, expr: &'a str, value: isize, }, NoOperand { line: Line<'a>, opcode: &'a str, }...
true
81e60f4d8a000e8902913afea2d626690a1bc75a
Rust
oshunter/fuchsia
/third_party/rust_crates/vendor/smol/src/timer.rs
UTF-8
3,477
3.640625
4
[ "BSD-3-Clause", "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Implementation of [`Timer`]. //! //! Timers are futures that fire at a predefined point in time. use std::fmt::Debug; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use std::time::{Duration, Instant}; use crate::reactor::Reactor; /// Fires at the chosen point in time. /// /// Timers ...
true
ea34a161822e8fcaadf7691ef2d9f98cdfe993da
Rust
luhuimao/morgan
/interface/src/syscall/mod.rs
UTF-8
960
2.546875
3
[ "Apache-2.0" ]
permissive
//! named accounts for synthesized data accounts for bank state, etc. //! use crate::pubkey::Pubkey; pub mod slot_hashes; /// "Sysca11111111111111111111111111111111111111" /// owner pubkey for syscall accounts const ID: [u8; 32] = [ 6, 167, 211, 138, 69, 216, 137, 185, 198, 189, 33, 204, 111, 12, 217, 220, 229,...
true
b8e824eb140e057534eccb7a1ad861c05adc2147
Rust
daithiocrualaoich/euler
/rs/004.rs
UTF-8
1,065
3.84375
4
[ "Apache-2.0" ]
permissive
/* * Largest palindrome product * ========================== * A palindromic number reads the same both ways. The largest palindrome made * from the product of two 2-digit numbers is 9009 = 91 x 99. * * Find the largest palindrome made from the product of two 3-digit numbers. */ trait NumberTheory { fn is_pa...
true
aae0c44a346d1164a04986ef49662ae058bb6699
Rust
rowlandz1/slink
/src/value.rs
UTF-8
12,437
3.1875
3
[]
no_license
/* value.rs * * Defines basic operations on SciVal objects. These operations should apply_to * more than one of the SciVal variants. Otherwise it should probably be in * internals.rs */ use core::ops; use core::cmp; use std::collections::HashMap; use crate::callable::Callable; use crate::error::{EvalError, EvalResult}...
true
39215c1d573cda2db23d6a438957f27e6697abbc
Rust
wiltonlazary/steamy
/vdf/src/entry/value.rs
UTF-8
509
3.359375
3
[]
no_license
use std::ops::Deref; use super::{Entry, Parse}; #[derive(Clone, PartialEq, Eq, Debug)] pub struct Value(String); impl From<String> for Value { fn from(value: String) -> Value { Value(value) } } impl Into<Entry> for Value { fn into(self) -> Entry { Entry::Value(self) } } impl Deref for Value { type Target =...
true
e48cd9765116c7388607d2c9fb66a6d2817499cc
Rust
akolybelnikov/Gatech_Graduate_Algorithms
/src/bin/euler_tour.rs
UTF-8
6,572
3.265625
3
[]
no_license
use rand::random; use rand::seq::SliceRandom; use std::collections::HashMap; use std::collections::HashSet; fn create_tour(mut nodes: &mut Vec<i32>) -> Vec<(i32, i32)> { let mut connected: Vec<i32> = vec![]; let mut tour = vec![]; let mut degree = HashMap::new(); // We start by connecting two random n...
true
fcbdf7c02f8a17c4cf6f1ee92b6a2cb1f95e92ed
Rust
rusticata/asn1-rs
/src/asn1_types/tagged/application.rs
UTF-8
1,548
3.171875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{Class, Explicit, Implicit, TaggedValue}; /// A helper object to parse `[APPLICATION n] EXPLICIT T` /// /// A helper object implementing [`FromBer`](crate::FromBer) and [`FromDer`](crate::FromDer), to /// parse explicit application-tagged values. /// /// # Examples /// /// To parse a `[APPLICATION 0] EXPLIC...
true
d8e5b798e40311c2daa5e328ad9ae40d76e6a3af
Rust
Commander-lol/mockery.rs
/src/main.rs
UTF-8
1,024
2.609375
3
[]
no_license
use failure::{Error, Fail}; use mockery::{cli, generation, generator, model}; fn main() { let args = cli::get_args_from_stdin(); match process_args(args) { Ok(_) => (), Err(e) => eprintln!("{}", e), } } /// Wrap a string in a failure compatible container until refactoring is complete #[derive(Debug, Fail)] enu...
true
07f8271d37f13cf4c856afb08dbae78ebd9c55ea
Rust
vangroan/rengine
/src/voxel/camera.rs
UTF-8
3,738
2.796875
3
[ "MIT" ]
permissive
//! Cast rays out of camera use crate::camera::{ActiveCamera, CameraProjection, CameraView}; use crate::option::lift2; use crate::res::DeviceDimensions; use crate::voxel::{voxel_raycast, VoxelRaycast}; use glutin::dpi::{PhysicalPosition, PhysicalSize}; use nalgebra::{Matrix4, Perspective3, Point3, Unit}; use specs::{R...
true
069c437a8036da62cb1f1961850a664d705c3483
Rust
wasmerio/wasmer-python
/packages/api/src/wasi.rs
UTF-8
14,159
2.734375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{ errors::to_py_err, import_object::ImportObject, module::Module, store::Store, wasmer_inner::wasmer_wasi, }; use pyo3::{ exceptions::{PyRuntimeError, PyValueError}, prelude::*, types::{PyDict, PyList}, }; use std::{path::PathBuf, slice}; #[derive(Copy, Clone)] #[repr(u8)] pub enum Versi...
true
2514685ed35aa9f4c0b86f2d9a1b682864930404
Rust
cxt90730/yigfs
/client/interval_tree/tests/tree_test.rs
UTF-8
11,793
3.375
3
[ "Apache-2.0" ]
permissive
use std::time::Instant; use interval_tree::tree::IntervalTree; use interval_tree::interval::Interval; #[test] fn test_interval_tree_basic_insert()->Result<(), String>{ let mut tree = IntervalTree::new(Interval::new(0,0)); let mut start = 0; let mut end = 10; loop{ let intr = Interval::new...
true
d7c7d3d5c7cd3508acdd8120141d39e51f06f0d3
Rust
alexandruradovici/harbour
/src/sleep.rs
UTF-8
1,539
3.171875
3
[ "Apache-2.0" ]
permissive
use super::command; use std::io; use std::{thread, time}; command! ("sleep", "Suspend execution for an interval of time", execute, (help = "the interval to suspend execution (default in seconds), optional suffixes are (s)econds, (m)inutes, (h)ours, (d)ays") interval: String ); fn parse_interval_str (interval_s:&s...
true
888802e495fdea90d785ad96803794ee53d8bce2
Rust
lemadane/rust-sandbox
/src/types.rs
UTF-8
180
2.703125
3
[]
no_license
pub fn run() { let is_active:bool = true; let is_greater: bool = 10 > 5; let a1 = 'a'; let smiley = '\u{1F600}'; println!("{:?}", (is_active, is_greater, a1, smiley)); }
true
34178b0a38ceae66f69521f6d86ff47375af9217
Rust
m1kit/buchberger
/src/field.rs
UTF-8
5,089
2.984375
3
[]
no_license
use num_traits::{One, Zero}; use ordered_float::NotNan; use std::cmp::Eq; use std::fmt; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}; pub trait Field: Copy + std::marker::Sized + Add<Output = Self> + AddAssign + Sub<Output = Self> + SubAssign + Mul<Out...
true
69b00e2d0fa298abc92f767b0b6ed8b6a74ff732
Rust
christophersarmiento/advent-of-code
/2020/day-02/src/main.rs
UTF-8
1,008
3.3125
3
[ "MIT" ]
permissive
use std::fs::File; use std::io::BufReader; use std::io::prelude::*; fn main() { let f = File::open("./src/input.txt").unwrap(); let reader = BufReader::new(f); let mut part_one_count = 0; let mut part_two_count = 0; for line in reader.lines(){ let line = line.unwrap(); let split:Vec<&str> = line.sp...
true
42b954adb234253484bf3a127fb63d9af498286b
Rust
gevorgyana/proof_of_concept_haskell_lexer
/src/regex.rs
UTF-8
4,485
3.046875
3
[]
no_license
use super::lexeme; use super::token; use std::collections::HashMap; use std::sync::Mutex; use std::any::TypeId; use once_cell::sync::OnceCell; use regex as regex_backend; use std::convert::TryInto; #[derive(Debug, PartialEq)] pub enum Error { NoMatch, DistantMatch, InvalidExpression, LexemeNotAllowed...
true
d1b3fbf4d4088e1d148817860aafae0a8b1061c2
Rust
zBaitu/rfmt
/tests/ir/attrs/attr.rs
UTF-8
669
2.71875
3
[]
no_license
#![allow(unused_variables)] #![crate_type = "lib"] fn main() { // General metadata applied to the enclosing module or crate. #![crate_type = "lib"] // A function marked as a unit test #[test] fn test_foo() { /* ... */ } // A conditionally-compiled module #[cfg(target_os = "linux")...
true
31babed6372ca5cd359bda374aa0eac65423dbe9
Rust
docknetwork/jsonrpc-proxy
/proxy/transports/src/ws.rs
UTF-8
4,850
2.734375
3
[]
no_license
//! WebSockets server for the proxy. use std::{ net::{SocketAddr, Ipv4Addr}, sync::Arc, }; use jsonrpc_ws_server as ws; use params::Param; use pubsub; use rpc; const CATEGORY: &str = "WebSockets Server"; const PREFIX: &str = "websockets"; /// Returns CLI configuration options for the WS server. pub fn param...
true
6f60e160b9f428e4daa80942642dc69e424c490b
Rust
pcsm/simulacrum
/simulacrum_mock/src/constraint/mod.rs
UTF-8
1,507
2.953125
3
[ "MIT" ]
permissive
pub mod result; pub mod stock; pub use self::result::*; /// A `Constraint` is a type that can be added to an `Expectation`. /// /// All `Constraint`s added to an `Expectation` must all pass in order for the /// `Expectation` to pass. pub trait Constraint<I> { /// This constraint has been called with the given par...
true
8ff2a08c9d74ffc364fdcfc55161fce461d3a4c8
Rust
Remy162/rust-labview-examples
/rust_labview_yaml/src/lib.rs
UTF-8
5,629
2.59375
3
[]
no_license
extern crate libc; extern crate yaml_rust; use libc::c_char; use std::ffi::{CStr, CString}; use std::fs; use yaml_rust::YamlLoader; #[cfg(test)] mod tests { use super::*; use std::ffi::CString; #[test] fn c_load_unload_no_panic() { let c_string_path = CString::new(String::from( "C...
true
5b81b13d6bce5f21e880040c25e2b86df87ad7fa
Rust
getreu/tp-note
/tpnote-lib/src/html.rs
UTF-8
23,178
2.8125
3
[ "MIT", "Apache-2.0" ]
permissive
//! Helper functions dealing with HTML conversion. use crate::config::LocalLinkKind; use crate::markup_language::MarkupLanguage; use parking_lot::RwLock; use parse_hyperlinks::parser::Link; use parse_hyperlinks_extras::iterator_html::HyperlinkInlineImage; use parse_hyperlinks_extras::parser::parse_html::take_link; use...
true
7ad5adda5305bc18e1ebc95008eae38272465aeb
Rust
bbannier/gtest-runner
/src/gtest/parse.rs
UTF-8
8,952
2.765625
3
[ "MIT" ]
permissive
use { crate::{ gtest, gtest::{Event, Status}, }, anyhow::{anyhow, Result}, console::strip_ansi_codes, }; #[cfg(test)] use { itertools::{join, Itertools}, std::iter::FromIterator, }; #[derive(Clone)] struct Test { case: String, log: Vec<String>, } pub struct Parser<T> {...
true
c8a0e1dd9e9af0611b2da8b8446624ef7c1a718c
Rust
etactica/red-heart
/src/svc_dis.rs
UTF-8
6,137
2.59375
3
[]
no_license
use crate::ble::{Characteristic, Service}; use stm32wb55::{ event::AttributeHandle, gatt::{ CharacteristicEvent, CharacteristicProperty, Commands as GattCommands, ServiceType, Uuid, }, }; /// Device Information Service... /// // Should these just be an enum? // Should these be directly Uuid16 type...
true
24aae41b7202e01d1d96265b8bc34793d76af67b
Rust
kdeberk/advent-of-code
/aoc2018/src/main.rs
UTF-8
1,416
2.640625
3
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader}; mod day1; mod day2; mod day3; mod day4; mod day5; mod day6; mod day7; mod day8; mod day9; mod day10; mod day11; mod day12; mod day13; mod day14; mod day15; mod day16; mod day17; mod day18; mod day19; mod day20; mod day21; mod day22; mod day23; mod day24; mod day25;...
true
e68f53fdd67d42d379aa4461f1dd5a7667194bbf
Rust
Sherlock-Holo/image_bed
/src/http/size_limit.rs
UTF-8
3,811
2.953125
3
[ "MIT" ]
permissive
use std::error::Error; use std::task::Context; use std::task::Poll; use bytes::{BufMut, BytesMut}; use futures_util::StreamExt; use hyper::{Body, Request, Response, StatusCode}; use hyper::service::Service; use slog::warn; use crate::http::ServiceResult; use crate::log::{self, LogContext}; #[derive(Debug)] pub struc...
true
cf4e7884a7581902b94fdac0f935259fc8f6a78f
Rust
ten3roberts/vulkan-sandbox
/src/vulkan/common_vertex.rs
UTF-8
1,406
2.515625
3
[]
no_license
use std::mem; use ash::vk; use ultraviolet::vec::*; use super::vertex::VertexDesc; #[repr(C)] pub struct CommonVertex { position: Vec3, color: Vec4, uv: Vec2, } impl CommonVertex { pub fn new(position: Vec3, color: Vec4, uv: Vec2) -> Self { Self { position, color, ...
true
c59d108383fabf57754e53761f0355226e3efe4a
Rust
cesare/rust-experiments
/src/sequence/mod.rs
UTF-8
545
3.4375
3
[]
no_license
use std::ops::AddAssign; pub struct ArithmeticProgression<T> { current: T, diff: T, } impl<T> ArithmeticProgression<T> { pub fn new(init: T, diff: T) -> ArithmeticProgression<T> { ArithmeticProgression { current: init, diff: diff, } } } impl<T> Iterator for Ari...
true
e844480d739d96e496790c17ec8c7affbb708190
Rust
apllodb/apllodb
/apllodb-storage-engine-interface/src/alter_table_action.rs
UTF-8
612
2.515625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use serde::{Deserialize, Serialize}; use crate::column::{column_definition::ColumnDefinition, column_name::ColumnName}; /// Actions to be done by ALTER TABLE statement. #[derive(Clone, Eq, PartialEq, Hash, Debug, Serialize, Deserialize)] pub enum AlterTableAction { /// ALTER TABLE {table_name} ADD COLUMN {column_...
true
590921cf3b5f51e499238776925d49d486fa4b5c
Rust
Nertsal/ludumdare49
/src/game/circle.rs
UTF-8
1,493
3.328125
3
[]
no_license
use super::*; pub struct Circle { pub position: Vec2<f32>, pub rotation: f32, pub radius: f32, pub color: Color<f32>, } impl Circle { pub fn new(position: Vec2<f32>, rotation: f32, radius: f32, color: Color<f32>) -> Self { Self { position, rotation, radi...
true
e020b5704cbee21093d6f242da41ba113ee444e3
Rust
mamcx/forbidden
/src/credentials.rs
UTF-8
1,752
3.453125
3
[ "MIT", "Apache-2.0" ]
permissive
//! A common set of Credentials used to associate a [crate::users] with an authentication provider. //! //! As explained in [13 best practices for user account, authentication, and password management, 2021 edition](https://cloud.google.com/blog/products/identity-security/account-authentication-and-password-management-...
true
dde7b3b15d154a273efc40490b8014789b6bca94
Rust
leptonyu/salak.rs
/src/source_toml.rs
UTF-8
2,284
2.765625
3
[ "MIT" ]
permissive
use toml::Value; use crate::{ source_raw::FileItem, Key, Property, PropertyError, PropertySource, Res, SubKey, SubKeys, }; #[derive(Debug)] pub(crate) struct Toml { item: FileItem, name: String, value: Value, } impl Toml { pub(crate) fn new(item: FileItem) -> Res<Self> { Ok(Toml { ...
true
b3338367fc7c37b3d62937bc24abb8e2d604f5b4
Rust
finos/perspective
/rust/perspective-viewer/src/rust/components/containers/select.rs
UTF-8
8,836
2.796875
3
[ "Apache-2.0" ]
permissive
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ // ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃ // ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃ // ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄...
true
e553fee7a4c673fee86c8640d879b6ff2361c1ab
Rust
EFanZh/LeetCode
/src/problem_0128_longest_consecutive_sequence/mod.rs
UTF-8
379
2.84375
3
[]
no_license
pub mod hash_set; pub trait Solution { fn longest_consecutive(nums: Vec<i32>) -> i32; } #[cfg(test)] mod tests { use super::Solution; pub fn run<S: Solution>() { let test_cases = [(&[100, 4, 200, 1, 3, 2] as &[_], 4)]; for (nums, expected) in test_cases { assert_eq!(S::longes...
true
53f2cde2081147acda0408a2292fcdfec53db334
Rust
silverweed/ecsde
/inle/inle_input/src/mouse/sfml.rs
UTF-8
1,927
3.265625
3
[]
no_license
use super::Mouse_Button; pub(super) use sfml::window::mouse::{Button, Wheel}; use sfml::window::Event; pub(super) fn get_mouse_btn(btn: Button) -> Option<Mouse_Button> { match btn { Button::Left => Some(Mouse_Button::Left), Button::Right => Some(Mouse_Button::Right), Button::Middle => Some(...
true