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
5ab79eec293e3378992447d0991a70f60cef0382
Rust
yuulive/eu
/src/lib.rs
UTF-8
17,722
2.53125
3
[]
no_license
#![feature(proc_macro_diagnostic)] extern crate proc_macro; use proc_macro::TokenStream; use proc_macro2; use quote::quote; use syn; use syn::spanned::Spanned; /// Turns function into partially applicable functions. #[proc_macro_attribute] pub fn part_app(attr: TokenStream, item: TokenStream) -> TokenStream { let ...
true
9d506be6d534eb1aac814f60e52cb1f6c6f6cca3
Rust
dairyisscary/for-your-reference-part-2
/src/main.rs
UTF-8
3,132
3.765625
4
[]
no_license
#[derive(Debug)] enum Error { UnexpectedEndOfInput, NotANumberChar(char), NotASymbolChar(char), NumberParseError(std::num::ParseIntError), } struct MinusExpression { left: i64, right: i64, } enum Symbol { Plus, Minus, } enum ParseTree { PlusExpr(i64, i64), MinusExpr(MinusExpre...
true
d28846fecf27e52c8e2454e72b5f8dfc49f91825
Rust
wako057/rust-tutorial
/chapter-05/struct_definition/src/main.rs
UTF-8
2,283
3.546875
4
[]
no_license
struct User { username: String, email: String, sign_in_count: u64, active: bool, } struct Color(i32, i32, i32); struct Point(i32, i32, i32); fn main() { let user1 = User { email: String::from("someone@example.com"), username: String::from("someusername123"), active: false, ...
true
bb984b11ddc58526fed05862fe18cd3d3de6e228
Rust
MDoerner/AdventOfCode2020
/Rust/adventOfCode2020/src/input.rs
UTF-8
886
3.046875
3
[]
no_license
use std::{path::Path, path::PathBuf}; use std::fs; pub struct PuzzleConfiguration { pub day: i32, pub part: i32 } pub fn puzzle_input(config: &PuzzleConfiguration) -> Option<String>{ let path: PathBuf = puzzle_file_path(&config); match fs::read_to_string(path){ Err(_) => None, ...
true
d4752100f7cf7ed6c070381b9a1cfabfd47a118a
Rust
boa-dev/boa
/boa_ast/src/function/mod.rs
UTF-8
6,004
3.296875
3
[ "MIT", "Unlicense" ]
permissive
//! Functions and classes nodes, as defined by the [spec]. //! //! [Functions][func] are mainly subprograms that can be called by external code to execute a sequence of //! statements (the *body* of the function). Javascript functions fall in several categories: //! //! - [`Function`]s. //! - [`ArrowFunction`]s. //! - ...
true
4224061d877433c6408b8b052eb2b7250c589cb2
Rust
gypsydave5/rust-book-exercises
/collections/src/main.rs
UTF-8
854
2.96875
3
[]
no_license
extern crate rand; mod vectors; mod strings; mod hashmaps; mod exercises; fn main() { use rand::prelude::*; vectors::accessing_elements(); vectors::iteration(); vectors::mutable_iteration(); strings::new_string_from_data(); strings::utf8_strings(); strings::updating_strings(); string...
true
14a3369b4ec0345539ebc03e046ba79fe74797e9
Rust
remysucre/fgh
/eqsat/src/analysis.rs
UTF-8
3,594
2.859375
3
[]
no_license
use egg::*; use std::collections::HashSet; use std::cmp::Ordering; use crate::lang::*; use crate::EGraph; #[derive(Default, Clone)] pub struct SemiringAnalysis; // Metadata for each class #[derive(Debug, PartialEq, Eq)] pub struct Data { // Set of free variables by their class ID pub free: HashSet<Symbol>, ...
true
89b09ff53ce90f894127e5f50f338f6f503cd0c9
Rust
P3GLEG/shellcode_loader
/src/main.rs
UTF-8
3,603
2.515625
3
[]
no_license
#![no_std] #![no_main] /// This is a shellcode loader Rust while also minimizing the size of the binary. In my tests the C /// version binary turned out to be 4k whilst on Mac with rust I got to 4.2k after running strip /// This can be optimized further. Conditional compiling for the static varibles would get you some ...
true
f2edaeca9c9b074334181ec84f76c99d5d623329
Rust
jungaretti/advent-of-code-2020
/src/day_04.rs
UTF-8
4,718
3.21875
3
[ "MIT" ]
permissive
use regex::Regex; use std::fs::File; use std::io::BufRead; use std::io::BufReader; const DATA_FILE_PATH: &str = "./data/day04.txt"; struct Passport { birth_year: Option<String>, issue_year: Option<String>, expiration_year: Option<String>, height: Option<String>, hair_color: Option<String>, eye...
true
7299a6fe675d2747927d62c89e4f2ff98708f5e2
Rust
ken0x0a/tonic-build-with-code-gen
/src/generate_code.rs
UTF-8
5,612
2.53125
3
[ "MIT" ]
permissive
use super::{Method, Service}; use crate::{generate_doc_comments, naive_snake_case, util}; use proc_macro2::TokenStream; use quote::{format_ident, quote}; /// Generate boilerplate code for gRPC server /// /// This takes some `Service` and will generate a `TokenStream` that contains /// a public module with the generate...
true
851b4c0412ebca15e4717fe54d05a9c6b6b1d831
Rust
mhk032/sequencer_lighting_linux
/src/animation/animation_custom_colors.rs
UTF-8
1,397
3.3125
3
[]
no_license
use crate::color::Color; #[derive(Debug)] pub struct AnimationCustomColors { pub colors: Vec<Color>, } impl AnimationCustomColors { pub fn set_colors_in_buffer(&self, buf: &mut Vec<u8>) { if self.colors.is_empty() { panic!("Colors are empty, this function shouldnt be called"); } ...
true
2d75539d8b6db72f163aad6f906e5f679e7a0a12
Rust
nesium/xcode-color-assets
/crates/swift-gen/src/renderers/renderer.rs
UTF-8
500
2.8125
3
[]
no_license
use super::super::AccessLevel; use super::data::RuleSet; pub struct RendererConfig { tab: String, pub access_level: AccessLevel, } impl RendererConfig { pub fn new(tab: &str, access_level: AccessLevel) -> Self { RendererConfig { tab: tab.to_owned(), access_level, } } pub fn indent(&self...
true
680a62061bf8e031562a02c5dc44202d29ea7aba
Rust
miam-miam100/Calculator
/src/app.rs
UTF-8
2,256
2.671875
3
[ "MIT" ]
permissive
use calculator::expression::{eval, Expression, Parser, Rule}; use calculator::types::{MathError, Token}; use eframe::egui::epaint::{color, Shadow}; use eframe::egui::{Align2, Frame, Window}; use eframe::{egui, epi}; pub struct CalcApp { input: String, prev_input: String, result: Result<Token, MathError>, }...
true
77b4d98a6f22e09934f646584e462cde264c2b6f
Rust
iBelieve/oxide
/kernel/src/arch/x86_64/io.rs
UTF-8
1,817
3.1875
3
[]
no_license
use core::marker::PhantomData; /***** TRAITS *****/ pub trait InOut { unsafe fn port_in(port: u16) -> Self; unsafe fn port_out(port: u16, value: Self); } impl InOut for u8 { unsafe fn port_in(port: u16) -> u8 { inb(port) } unsafe fn port_out(port: u16, value: u8) { outb(port, value); } } // impl InO...
true
4ce2418544363926d1352e01e07f51fe398e5387
Rust
tigleym/dwarf_seeks_fortune
/dsf_editor/src/systems/place_tiles.rs
UTF-8
2,668
2.59375
3
[ "BlueOak-1.0.0" ]
permissive
use crate::resources::{EditorData, TileEdit}; use amethyst::core::ecs::shrev::EventChannel; use amethyst::core::ecs::{Read, System, Write}; use amethyst::input::{InputEvent, StringBindings, VirtualKeyCode}; use dsf_core::components::Pos; use dsf_core::levels::{TileDefinition, TileDefinitions}; use dsf_core::resources::...
true
eb8cfa8fe980157c5efc0b4301171a423902c7cd
Rust
mcoffin/ioreg-proc
/zinc/build.rs
UTF-8
1,866
2.625
3
[]
no_license
use std::env; use std::fs; use std::io; use std::path::Path; fn get_platform() -> Option<String> { let features = env::vars().filter(|&(ref key, _)| key.starts_with("CARGO_FEATURE_MCU")); features.last().map(|(feature_var, _)| { feature_var .trim_left_matches("CARGO_FEATURE_MCU_") ...
true
49be8e25c9b7dc6d88a5582946db34772fa61954
Rust
sonos/tract
/examples/jupyter-keras-tract-tf2/src/main.rs
UTF-8
746
2.59375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use rand::*; use tract_onnx::prelude::*; fn main() -> TractResult<()> { let model = tract_onnx::onnx() // load the model .model_for_path("./example.onnx")? // optimize graph .into_optimized()? // make the model runnable and fix its inputs and outputs .into_runnable()?; // Generate some...
true
b9edba8560927bd52e12f3fd9adb5ccbaf512577
Rust
jTitor/leek2
/src/open-source/engine/modules/src/math/linear_algebra/mat4x4.rs
UTF-8
940
3.4375
3
[]
no_license
/*! Represents a 4x4 matrix and common matrix operations. */ pub trait ToIndex { fn to_index(self) -> usize; } /** Trait used to convert different matrix representations to a 1D float array for MatOps::from_floats(). #Expected Nontrivial Implementations ##Array of Arrays/Vectors ([[f32; 4]; 4], [Vec4; 4]) In thes...
true
8d8cc1c69a88b9a46c299b045fb7a7b82c4067c8
Rust
mcdonaldm1993/fibonacci-heap
/src/fibonacci_heap.rs
UTF-8
7,772
3.359375
3
[]
no_license
use std::collections::HashMap; use std::hash::Hash; use std::num::Float; use super::fibonacci_node::FibonacciNodeType; use super::fibonacci_node::FibNode; /// Struct that represents the [Fibonacci Heap](http://en.wikipedia.org/wiki/Fibonacci_heap) data structure. /// /// Algorithms for this are as seen in the [Introd...
true
d4e204c6522191132621ccd8bca2519bd10aa023
Rust
redox-os/ion
/src/lib/expansion/braces.rs
UTF-8
5,124
3.1875
3
[ "MIT" ]
permissive
use auto_enums::auto_enum; use permutate::Permutator; use smallvec::SmallVec; #[derive(Debug)] /// A token primitive for the `expand_braces` function. pub enum BraceToken { Normal(small::String), Expander, } #[auto_enum] pub fn expand<'a>( tokens: &'a [BraceToken], expanders: &'a [&'a [&'a str]], ) ->...
true
a55b035726c3e07575176818f43dde4031f79276
Rust
xosmig/xo_os
/libs/basics/src/sync/not_owning/spinlock.rs
UTF-8
656
2.578125
3
[ "MIT" ]
permissive
prelude!(); use ::core::sync::atomic::*; use super::Lock; pub struct SpinLock { current: AtomicUsize, next: AtomicUsize, } impl SpinLock { pub const fn new() -> Self { SpinLock { current: AtomicUsize::new(0), next: AtomicUsize::new(0), } } } impl Default for ...
true
a9b01f878501f94b2a4255da9c7c0cd9a0ca3787
Rust
rustyforks/moonlander
/src/gui/mod.rs
UTF-8
8,315
2.5625
3
[ "MIT" ]
permissive
mod header; use gtk::prelude::*; use gtk::Inhibit; use gtk::WidgetExt; use relm::{connect, init, Component, Relm, Widget}; use relm_derive::{widget, Msg}; use header::{Header, Msg as HeaderMsg}; use relm_moonrender::{Moonrender, Msg as MoonrenderMsg}; #[derive(Msg)] pub enum Msg { Quit, Goto(String), Go...
true
8328f8a7156e293b791e2e862975700d54b11600
Rust
a-r-n/wasm-rust
/src/wasm.rs
UTF-8
12,600
3.140625
3
[]
no_license
use std::collections::HashMap; use std::convert::TryFrom; use crate::error::Error; /// The allowable types for any real value in wasm (u8 and others are packed) #[derive(Copy, Clone, PartialEq)] pub enum PrimitiveType { I32, I64, F32, F64, } impl From<i32> for PrimitiveType { fn from(_: i32) -> P...
true
7179074ebae9647ac2cdde2bad83f09cee59c077
Rust
benferse/batgrep
/src/main.rs
UTF-8
4,285
3.796875
4
[ "MIT" ]
permissive
//! A small utility to parse search results from Ag and feed them //! into bat for pretty printing use std::env::args; use std::error::Error; use std::io::{self, Write}; use std::process::Command; /// Invokes bat, which is assumed to be in the runtime path fn run_bat(filepath: String, center: usize) -> Result<(), Box<...
true
752e24dde97756eba2a3f15f8ff19ae90c35c585
Rust
pgimalac/rustomaton
/src/parser.rs
UTF-8
3,983
3.21875
3
[ "MIT" ]
permissive
use crate::{parser::Token::*, regex::Operations}; use logos::Logos; use std::collections::{BTreeSet, VecDeque}; /// The token used by [`logos`](/logos/index.html`]). #[derive(Logos, Debug, PartialEq, Clone)] pub enum Token { #[end] End, #[error] Error, #[token = "|"] Union, #[token = "("...
true
9086befef163a71a3230ebab3e3ef6a84bf2c7b0
Rust
MadPsyentist/AdventOfCode2020
/src/day2.rs
UTF-8
2,463
3.375
3
[]
no_license
pub fn day(input: &str) { part1(input); part2(input); } pub fn part1(input: &str) { println!("Part 1: {} passwords meet their policy", input.lines().filter(|i| PasswordMeetsPolicy(PasswordAndPolicyFromLine(i))).count()); } pub fn part2(input: &str) { println!("part 2: {} passwords meet their ...
true
faf0b9635e1725ca2bfe554243ec9634140d1b50
Rust
Stannislav/Advent-of-Code
/2020/src/bin/16.rs
UTF-8
6,966
3.5
4
[ "MIT" ]
permissive
//! Solutions for day 16. extern crate regex; use regex::Regex; use std::collections::HashMap; use std::fs; /// A rule specifies two ranges: `(i, j, k, l)` => `i..=j` and `k..=l`. type Rule = (u32, u32, u32, u32); #[doc(hidden)] fn main() { // Parse the 3 blocks of the input: rules for ticket fields, my ticket, ...
true
e4cf19142fe85d850feab9c70fdb0198831fb66c
Rust
DevHyperCoder/alpc
/tests/test_numeric.rs
UTF-8
122
2.53125
3
[]
no_license
use alpc::parse; #[test] fn number_to_str() { assert_eq!(vec!("ONE ", "TWO ", "TREE "), parse("123".to_string())); }
true
1814eb801c2d6f68c6c36a225db0d3861b203edd
Rust
m-kann0/atcoder-rust
/examples/agc036_a.rs
UTF-8
1,980
3.671875
4
[]
no_license
use std::io::Read; fn main() { let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).unwrap(); let answer = solve(&buf); println!("{}", answer); } fn solve(input: &str) -> String { let mut iterator = input.split_whitespace(); let s: usize = iterator.next().unwrap().parse()....
true
3bce8bef7a1ac96076202b8585199253379d4261
Rust
IThawk/rust-project
/rust-master/src/test/run-pass/deriving/deriving-cmp-generic-struct.rs
UTF-8
872
3.640625
4
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// run-pass #[derive(PartialEq, Eq, PartialOrd, Ord)] struct S<T> { x: T, y: T } pub fn main() { let s1 = S {x: 1, y: 1}; let s2 = S {x: 1, y: 2}; // in order for both PartialOrd and Ord let ss = [s1, s2]; for (i, s1) in ss.iter().enumerate() { for (j, s2) in ss.iter().enumerate()...
true
09156dc43594d225b11ff2077888e4d93c8963cf
Rust
flip1995/comprakt
/compiler-lib/src/ast.rs
UTF-8
6,236
3.203125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::{asciifile::Spanned, strtab::Symbol}; use strum_macros::EnumDiscriminants; #[strum_discriminants(derive(Display))] #[derive(EnumDiscriminants, Debug, PartialEq, Eq)] pub enum AST<'t> { Empty, Program(Spanned<'t, Program<'t>>), } /// This is the top-level AST node. It stores all class declarations o...
true
5d0512f459f5fb7c8c24c6882fa9490dc86eaefe
Rust
iasoon/KeyboardOptimizer-LayoutGen-3000
/src/eval/ngram_eval/utils.rs
UTF-8
2,521
3.171875
3
[]
no_license
use cat::*; use eval::ngram_eval::types::*; /// A cursor over fixed-length subsequences of a given sequence. pub struct SubSeqs<'t, T: 't> { seq: &'t [T], idxs: Vec<usize>, } impl<'t, T: 't> SubSeqs<'t, T> { pub fn new(seq: &'t [T], len: usize) -> Self { SubSeqs { seq: seq, ...
true
fd33a0edf59bb39a39504896255b088bbd0d63b2
Rust
mkpankov/parse-rust
/src/main.rs
UTF-8
1,441
2.703125
3
[]
no_license
extern crate regex; use std::collections::BTreeMap; use std::io::BufRead; fn main() { let re = regex::Regex::new(concat!( r#""GET (?:https?://.+?/)?(.+?\.mp3)"#, r#" HTTP/1\.[01]" \d{3} (\d+)"#)).unwrap(); let stdin = std::io::stdin(); let locked_stdin = stdin.lock(); let mut stat: BTr...
true
f8d4b2a2429d82e03850d10d77723104dcf4cf21
Rust
davisvansant/otel_spec
/sdk/src/metrics/accumulator/aggregation.rs
UTF-8
1,042
2.75
3
[]
no_license
use super::Aggregator; pub struct Aggregation { pub result: Aggregator, } #[derive(Debug, PartialEq)] pub enum AggregationKind { // SomeAggregationKind, Sum, LastValue, Histogram, MinMaxSumCount, Exact, Sketch, } #[cfg(test)] mod tests { use super::*; #[test] fn aggregati...
true
fb1764a75ef3f2cdfdf55973ae5adc934f58fd89
Rust
bovee/RosalindRust
/src/bin/rosalind_RNA.rs
UTF-8
330
2.90625
3
[]
no_license
#![feature(io)] use std::io::ReadExt; use std::ascii::AsciiExt; fn main() { let stdin = std::io::stdin(); for chr in stdin.chars() { let chr = chr.ok().unwrap().to_ascii_uppercase(); let rna_chr = match chr { 'T' => 'U', _ => chr }; print!("{}", rna_chr);...
true
01bc26ac3d5a0b40d600fe7c13b4c9f16795cd5c
Rust
maxjoehnk/g13-rs
/src/device.rs
UTF-8
3,696
2.671875
3
[ "MIT" ]
permissive
use std::time::Duration; use rusb::{Context, Device, DeviceHandle, Direction, Recipient, request_type, RequestType}; use rusb::constants::*; use crate::consts::*; use crate::error::G13Error; use crate::flags::{Keys, ModeLeds}; pub struct G13 { handle: DeviceHandle<Context>, } impl G13 { pub(crate) fn new(de...
true
bb9ef72b50d73e8336f6b4903435417190bfb3ef
Rust
samscott89/serde_qs
/tests/test_serialize.rs
UTF-8
6,569
3.265625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[macro_use] extern crate serde_derive; extern crate serde_qs as qs; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] struct Address { city: String, street: String, postcode: String, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] struct QueryParams { id: u8, name: String, ...
true
364d315653557e90c0b2c814e3b15c642f7afe48
Rust
0nkery/rust-monkey
/src/parser.rs
UTF-8
33,777
3.625
4
[ "MIT" ]
permissive
use super::lexer::Lexer; use super::token::Token; use super::token::TokenType; use super::ast::Program; use super::ast::Statement; use super::ast::Expression; #[derive(PartialEq, PartialOrd)] enum Precedence { Lowest, Equals, LessGreater, Sum, Product, Prefix, Call, Index, } pub stru...
true
117a48048ed8c5ea183a6a898cd3d274889d14ca
Rust
mqudsi/sqlite-readers-writers
/src/main.rs
UTF-8
11,044
2.671875
3
[]
no_license
use random_fast_rng::{FastRng, Random}; use rusqlite::{params, Connection, DropBehavior}; use std::fs; use std::path::Path; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{mpsc, Arc, RwLock}; use std::thread; use std::time::{Duration, Instant}; const ITER_SECS: u64 = 5; const USE_RWLOCK: bool = false; c...
true
5c8487c3ffdc4c64bcb041db7182056cb8444a1d
Rust
thomvil/zetelverdeling-rs
/src/gelaagde_zetel_verdeler.rs
UTF-8
4,153
2.890625
3
[]
no_license
use super::*; #[derive(Debug)] pub struct GelaagdeZetelVerdeler<T, U> { pub(crate) kieskringen: HashMap<T, ZetelVerdeler<U>>, } impl<T, U> GelaagdeZetelVerdeler<T, U> { pub fn totaal_stemmen(&self) -> f32 { self.kieskringen .values() .map(|stemmen| stemmen.totaal_stemmen()) ...
true
6bc124dd5da851a83df80ae6c1f751fcee0b20cb
Rust
jcholder-thoughtworks/advent-of-code-2019
/02/intcode/src/lib.rs
UTF-8
2,381
3.765625
4
[]
no_license
pub type IntcodeProgram = Vec<i32>; pub type Pointer = usize; pub const OUTPUT: Pointer = 0; pub const NOUN: Pointer = 1; pub const VERB: Pointer = 2; pub fn parse_code(code: String) -> IntcodeProgram { let program = code.trim().split(','); program.map(|c| c.parse().unwrap()).collect() } pub fn execute_intco...
true
84a090879390cf24093f7f779cf0a0501efbc8c3
Rust
matklad/rust-analyzer
/crates/ide_completion/src/completions/record.rs
UTF-8
7,189
3.015625
3
[ "Apache-2.0", "MIT" ]
permissive
//! Complete fields in record literals and patterns. use ide_db::{helpers::FamousDefs, SymbolKind}; use syntax::ast::Expr; use crate::{ item::CompletionKind, patterns::ImmediateLocation, CompletionContext, CompletionItem, Completions, }; pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionCon...
true
a00aef86c842e0ed359c0df9b10c6d48eb128300
Rust
Farzy/rust-training
/src/myrand.rs
UTF-8
701
2.734375
3
[]
no_license
extern crate rand; extern crate rand_chacha; use rand::{Rng, SeedableRng}; use rand::seq::{SliceRandom}; pub fn main() { let mut rng = rand_chacha::ChaCha8Rng::seed_from_u64(10); for _ in 1..20 { println!("Random: i16: {} f32: {}", rng.gen::<i16>(), rng.gen::<f32>()); } for _ in 1..20 { ...
true
c50c88efad8c4409781ca6c80fb1ceded85a1949
Rust
andrew-d/rscrape
/src/fetchers.rs
UTF-8
1,805
3.3125
3
[]
no_license
use std::error; use std::io::Read; use hyper::method::Method; use hyper::client::{Client, IntoUrl}; /// Fetcher is the interface for things that can fetch a remote URL. pub trait Fetcher { /// Called once at the beginning of the scrape. fn prepare(&mut self) -> Result<(), Box<error::Error>> { Ok(()) ...
true
a01aff5eb14629a8e7c4a1591ec69566d386f3f3
Rust
dveeden/sysinfo
/src/unknown/disk.rs
UTF-8
642
2.578125
3
[ "MIT" ]
permissive
// // Sysinfo // // Copyright (c) 2017 Guillaume Gomez // use DiskExt; use DiskType; use std::ffi::OsStr; use std::path::Path; /// Struct containing a disk information. pub struct Disk {} impl DiskExt for Disk { fn get_type(&self) -> DiskType { unreachable!() } fn get_name(&self) -> &OsStr { ...
true
039f848993b3e7f226a9b7608c8a17ebbf0ebc91
Rust
exists-forall/nickel
/src/test_utils/expr.rs
UTF-8
5,408
2.796875
3
[]
no_license
use std::rc::Rc; use std::iter::repeat; use super::rc_str::rc_str; use expr::*; use types::*; pub fn unit(free_vars: usize, free_types: usize) -> Expr<Rc<String>> { Expr::from_content(ExprContent::Unit { free_vars, free_types, }) } pub fn var(usage: VarUsage, free_vars: usize, free_types: usi...
true
2b4faa703a1e96d34c39e9ce5e1ce843d6489160
Rust
geom3trik/tooro-editor
/src/ui/style.rs
UTF-8
11,308
2.546875
3
[ "MIT" ]
permissive
//! Style definitions for the different elements use iced::{button, checkbox, container, pick_list, slider, Background, Color, Vector}; /// Default window width pub const WINDOW_WIDTH: u32 = 1024; /// Default window height pub const WINDOW_HEIGHT: u32 = 655; /// Common element padding pub const SECTION_PADDING: u16...
true
368de44c7a44fe1133686177587e891eebfe3c0a
Rust
augustocdias/bail-out
/src/lib.rs
UTF-8
4,818
4.1875
4
[ "MIT" ]
permissive
//! This library is inspired in the `ensure` and `bail` macros from `anyhow`. The difference is that it is not tied to anyhow's types. //! Many libraries have their own error types and using the anyhow's `ensure` macro doesn't work because it returns an anyhow error. This library intends to work with any type. //! This...
true
59f592767e1f219ff9bf25bbfcff062427a50588
Rust
esqu1/too-many-ray-tracers
/src/main.rs
UTF-8
3,938
2.5625
3
[]
no_license
#![feature(mutex_unlock)] #![feature(trait_alias)] mod camera; mod color; mod object; mod ppm; mod rasterizer; mod vector; use camera::Camera; use color::Color; use object::*; use ppm::PPM; use rasterizer::Rasterizer; use std::sync::{Arc, Mutex}; use vector::{Vec3f, ORIGIN}; fn rasterize() { let aspect_ratio = 16...
true
bf71e13c776b8b91c9a2d2d07a42f8f7388adcbf
Rust
remysucre/differential-datalog
/lib/log.rs
UTF-8
2,623
2.609375
3
[ "MIT" ]
permissive
use std::sync; use std::collections; use std::ffi; type log_callback_t = Box<dyn Fn(log_log_level_t, &str) + Send + Sync>; lazy_static! { /* Logger configuration for each module consists of the maximal enabled * log level (messages above this level are ignored) and callback. */ static ref LOG_CONFIG...
true
20b6fdc75d1d5c4ca224bc0968521460b10b068d
Rust
kildevaeld/keyval-rs
/keyval/src/codec.rs
UTF-8
1,870
2.890625
3
[]
no_license
#[allow(unused_imports)] use crate::{Error, Raw, Value}; /// Base trait for values that can be encoded using serde pub trait Codec<T: serde::Serialize + serde::de::DeserializeOwned>: Value + AsRef<T> + AsMut<T> { /// Convert back into inner value fn into_inner(self) -> T; } #[macro_export] /// Define a co...
true
3de64094497322ef0ea43bddaa0ac633a5031ce0
Rust
0rvar/advent-of-code-2017
/day13/src/main.rs
UTF-8
2,195
3.25
3
[]
no_license
extern crate regex; use regex::Regex; use std::collections::HashMap; fn main() { let input = include_str!("input.txt").trim(); // let input = include_str!("alt_input.txt"); let mut range_by_depth: HashMap<usize, usize> = HashMap::new(); let mut max_depth = 0usize; for line in input.lines() { ...
true
934f9d60289645ae8ec7ebee6ca94fcb852da695
Rust
quietlychris/rust_c_arrays_ffi
/rust_arrays/src/test.rs
UTF-8
123
2.71875
3
[]
no_license
#[test] fn it_works() { assert_eq!(2 + 2, 4); } #[test] fn test_raf() { assert_eq!(4, crate::return_a_four()); }
true
71f0ce0dc07a6bf8032fe6749cd0753cc0155195
Rust
tensorbase/tensorbase
/crates/arrow/src/util/integration_util.rs
UTF-8
39,688
2.5625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-free-unknown" ]
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
4f1a4b5f5157f645ab60dde824e3d60c3fa3a999
Rust
CreateSomethingNew/WhyRust
/a6.rs
UTF-8
2,447
3.28125
3
[]
no_license
enum ExprC { NumC { n : u32 }, BoolC { b : bool }, StringC { s : String }, IfC { i : Box<ExprC>, t : Box<ExprC>, e : Box<ExprC> }, IdC { i : String }, LamC { params : Vec<String>, body : Box<ExprC> }, AppC { fun_def : Box<ExprC>, params: Vec<Box<ExprC>> } } enum ValueV { NumV { n : u32...
true
f8ae1abab539d879f1289a710967827ed6a6197d
Rust
bluss/bluss.github.io
/petgraph/src/visit.rs
UTF-8
22,239
3.015625
3
[ "Apache-2.0", "MIT" ]
permissive
//! Graph visitor algorithms. //! use fixedbitset::FixedBitSet; use std::collections::{ HashSet, VecDeque, }; use std::hash::Hash; use super::{ graphmap, graph, EdgeType, EdgeDirection, Graph, GraphMap, Incoming, Outgoing, }; use graph::{ IndexType, }; #[cfg(feature = "sta...
true
5e4438d1a4b5e6a38463fc8d6c70dbb690d13c9c
Rust
tyrchen/rust-training
/old-training-code/enum_test/src/address.rs
UTF-8
410
3.3125
3
[]
no_license
#[derive(Debug)] struct Ipv4Addr { value: String, } enum IpAddress { Ipv4(Ipv4Addr), Ipv6(String), } use IpAddress::{Ipv4, Ipv6}; pub fn run() { let ip = Ipv4(Ipv4Addr { value: String::from("127.0.0.1"), }); match ip { Ipv4(address) => println!("this is an ipv4: {:?}", address), Ipv6(address...
true
f30d518298ef5057e184f0426eaa1897166d44c7
Rust
superdump/building-blocks
/crates/building_blocks_mesh/src/quad.rs
UTF-8
5,903
3.125
3
[ "MIT" ]
permissive
use super::{PosNormMesh, PosNormTexMesh}; use building_blocks_core::{ axis::{Axis3Permutation, SignedAxis3}, prelude::*, }; /// A set of `Quad`s that share an orientation. pub struct QuadGroup<M> { /// The quads themselves. We rely on the group's metadata to interpret them. pub quads: Vec<(Quad, M)>, ...
true
dc8eee5de63dbcefaf9734012b67accb447e11fc
Rust
Wandalen/OxiSynth
/core/src/synth/soundfont/instrument.rs
UTF-8
3,546
2.75
3
[ "LGPL-2.1-only" ]
permissive
use std::rc::Rc; use super::generator::{self, Generator}; use super::modulator::Mod; use super::Sample; const GEN_SET : u32 = 1; #[derive(Clone)] pub struct Instrument { name : String, global_zone : Option<InstrumentZone>, zones : Vec<InstrumentZone>, } impl Instrument { pub fn import(sf2 : &soundfont::Soun...
true
e8104e6f1ffbfe52d59b8fb7c6ffb6c20ef605ef
Rust
Dentosal/rust_os
/src/multitasking/waitfor.rs
UTF-8
4,049
3
3
[ "MIT" ]
permissive
use alloc::vec::Vec; use core::sync::atomic::{AtomicU64, Ordering}; use hashbrown::HashSet; use crate::multitasking::ProcessId; use crate::time::BSPInstant; use super::queues::Queues; /// Instructions for scheduling a process #[derive(Debug, Clone, PartialEq)] pub enum WaitFor { /// Run again on the next free sl...
true
9f5cb600d325fdbe8e3c1554189f8001887a98ac
Rust
fizyk20/epidemic-sim
/src/simulation/params.rs
UTF-8
1,864
2.765625
3
[]
no_license
use serde_derive::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, Serialize, Deserialize)] pub struct Params { #[serde(default = "default_num_people")] pub num_people: usize, #[serde(default = "default_size")] pub size_x: f64, #[serde(default = "default_size")] pub size_y: f64, #[ser...
true
a0554c56eb96faba778b4c61a0c74a1f572ccd2d
Rust
nathantypanski/ncurses-rs
/build.rs
UTF-8
1,685
2.53125
3
[ "MIT" ]
permissive
extern crate gcc; extern crate pkg_config; use std::env; use std::fs::File; use std::io::Write; use std::path::Path; use std::process::Command; fn main() { check_chtype_size(); } fn check_chtype_size() { let out_dir = env::var("OUT_DIR").expect("cannot get OUT_DIR"); let src = format!("{}", Path::new(&ou...
true
686ba22ba330d9191b7932e2770189a97ffe7e9a
Rust
belltoy/mio
/src/sys/fuchsia/handles.rs
UTF-8
2,488
3.03125
3
[ "MIT" ]
permissive
use {io, poll, Evented, Ready, Poll, PollOpt, Token}; use magenta::HandleBase; use std::sync::Mutex; /// Wrapper for registering a `HandleBase` type with mio. #[derive(Debug)] pub struct EventedHandle<T> where T: HandleBase { /// The handle to be registered. handle: T, /// The current `Token` with which t...
true
66df62a3ab37aa3978edf752e8cec69dc1e82f0f
Rust
Wattyyy/LeetCode
/submissions/stone-game/solution.rs
UTF-8
482
2.84375
3
[ "MIT" ]
permissive
use std::cmp::max; impl Solution { pub fn stone_game(piles: Vec<i32>) -> bool { let n = piles.len(); let mut dp = vec![vec![0; n]; n]; for i in (0..n).rev() { for j in i..n { if i == j { dp[i][j] = piles[i]; } else { ...
true
32d57e7b6568bfa67d164c62b5f31c26081dedb7
Rust
TheoVanderkooy/rust-practice
/practice_problems/src/merge_lists.rs
UTF-8
9,721
3.40625
3
[]
no_license
use crate::list_node::*; // first recursive approach #[allow(dead_code)] pub fn merge_two_lists_rec(l1: Option<Box<ListNode>>, l2: Option<Box<ListNode>>) -> Option<Box<ListNode>> { if let ( Some(m1), Some(m2) ) = (&l1, &l2) { if m1.val < m2.val { Option::Some(Box::new(ListNode::cons(m1.val, mer...
true
3216ce2759d7b1089b7d1ff01207a6b13f212904
Rust
foxfriends/git-project
/src/commands/open/state/board/task.rs
UTF-8
2,136
2.6875
3
[]
no_license
use cursive::{Cursive, align::*, theme::*, traits::*, views::*, event, utils::markup::StyledString}; use super::State; use crate::model::*; pub fn card(state: State, task: &Task) -> impl View { let mut description_text = StyledString::styled(task.name(), Effect::Bold); if !task.name().ends_with(|ch: char| ch.i...
true
355d5219536e7db76ea8127463b00e5fb257d638
Rust
rbatis/rbatis
/rbdc-sqlite/src/types/bytes.rs
UTF-8
648
2.578125
3
[ "Apache-2.0" ]
permissive
use crate::decode::Decode; use crate::encode::{Encode, IsNull}; use crate::type_info::DataType; use crate::types::Type; use crate::{SqliteArgumentValue, SqliteTypeInfo, SqliteValue}; use rbdc::error::Error; impl Type for Vec<u8> { fn type_info(&self) -> SqliteTypeInfo { SqliteTypeInfo(DataType::Blob) }...
true
a95ece95e2000736d32077718f1245c7bd01bc8a
Rust
am1ko/sw-renderer
/src/rasterization.rs
UTF-8
4,191
3.125
3
[ "MIT" ]
permissive
use core::{Color, DisplayBuffer, Face, Renderable}; use na::{Vector2, Vector3}; /// Get barycentric coordinates for a point P with respect to a triangle ABC /// /// # Arguments /// /// * 'a' Vertex A of the triangle ABC /// * 'b' Vertex B of the triangle ABC /// * 'c' Vertex C of the triangle ABC /// * 'p' Point P for...
true
ebcf5b547c8506cb942bfd71a03bad5719b3d5ac
Rust
BruceBrown/d3
/d3-core/src/channel/connection.rs
UTF-8
711
2.75
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use super::*; /// The Connection provides a weak link between the sender and receiver. /// The value of which is dubious. It may provide some feedback mechanisms. /// It may also provide some insights into a live system to graph the data /// flow. #[derive(Default)] pub struct Connection { connection: Weak<Mutex<C...
true
770320b2fb945be6aa6425bc6d4dada830888256
Rust
Rexagon/raccoin
/blockchain/src/blockchain.rs
UTF-8
713
2.859375
3
[ "Apache-2.0" ]
permissive
use serde::Serialize; use std::iter::FromIterator; use crate::block::Block; #[derive(Debug, Serialize)] pub struct BlockChain { pub blocks: Vec<Block>, } impl BlockChain { pub fn new(genesis: Block) -> Self { BlockChain { blocks: vec![genesis], } } pub fn add_block(&mut s...
true
73e256d1ca1e6be7ea8dd099e864323794c4fec5
Rust
crazyrex/Hecate
/src/meta/mod.rs
UTF-8
3,148
2.796875
3
[ "MIT" ]
permissive
extern crate r2d2; extern crate r2d2_postgres; extern crate postgres; extern crate serde_json; extern crate std; extern crate rocket; #[derive(PartialEq, Debug)] pub enum MetaError { NotFound, ListError(String), GetError(String), SetError(String) } impl MetaError { pub fn to_string(&self) -> Strin...
true
ce61a678b26d8c460589afba644731effa11ebd3
Rust
goodcodedev/descr
/descr-gen/src/process/codegen_tosource.rs
UTF-8
4,116
2.828125
3
[ "MIT" ]
permissive
use lang_data::data::*; use lang_data::rule::*; use descr_common::util::*; use std::collections::HashMap; pub struct CodegenToSource<'a, 'd: 'a> { data: &'a LangData<'d> } struct AstRules<'a, 'd: 'a> { pub rules: HashMap<&'a str, Vec<&'a AstPartsRule<'d>>> } impl<'a, 'd: 'a> AstRules<'a, 'd> { pub fn inser...
true
966d425885224b3f7f83e783db320593f3dc7b76
Rust
universome/aladdin
/src/base/timers.rs
UTF-8
1,063
3.25
3
[]
no_license
use std::iter::Iterator; use std::time::{Duration, Instant}; use std::thread::sleep; pub struct Periodic { interval: u64, timestamp: Instant } impl Periodic { pub fn new(interval: u32) -> Periodic { Periodic { interval: interval as u64, timestamp: Instant::now() - Duration:...
true
3183226e0cfd512f382eb1f4703c8bc1a6de021a
Rust
JohnWall2016/xlsx-rs
/src/xlsx/zip.rs
UTF-8
1,519
2.703125
3
[]
no_license
use zip::read::{ZipArchive, ZipFile}; use std::fs::File; use std::path::Path; use std::io::{Read, Cursor, Result as IOResult}; use super::base::XlsxResult; pub struct Archive(ZipArchive<Cursor<Vec<u8>>>); impl Archive { pub fn new<P: AsRef<Path>>(path: P) -> XlsxResult<Self> { let data = File::open(path)...
true
8ff221e3ce477ba83dd48b5aead3ee37c6da1383
Rust
CaulyKan/leetcode
/找出数组中的幸运数/src/lib.rs
UTF-8
499
2.9375
3
[]
no_license
impl Solution { pub fn find_lucky(arr: Vec<i32>) -> i32 { let mut map = std::collections::HashMap::new(); for i in arr { if map.contains_key(&i) { *(map.get_mut(&i).unwrap()) += 1; } else { map.insert(i, 1); } } let...
true
d93956e3156d4b4275829952a6f5b961f37d0a27
Rust
stm32-rs/stm32h7xx-hal
/src/ethernet/eth.rs
UTF-8
27,911
2.578125
3
[ "BSD-3-Clause", "0BSD", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Ethernet PHY layer for the STM32H7 //! //! As well as this implementation, another notable implementation can //! be found as part of the [quartiq/stabilizer] project. The two //! implementations were developed independently, but both in the same //! year (2019) and they have many similarities. //! //! In particula...
true
c477f973d7958d57113c905c5036e202b5eb4f21
Rust
elasticrash/rust-renderer
/src/materials/material.rs
UTF-8
600
2.671875
3
[]
no_license
use crate::hittable::HitRecord; use crate::ray::Ray; use crate::vec3::Color; pub trait Material: MatClone { fn scatter( &self, _r_in: &Ray, rec: &HitRecord, attenuation: &mut Color, scattered: &mut Ray, ) -> bool; } pub trait MatClone { fn clone_box(&self) -> Box<dy...
true
f05a224cb2814d8cfad495f64a71063b483e9ba7
Rust
techtronics/MantaRay
/src/main.rs
UTF-8
7,378
2.53125
3
[]
no_license
#![feature(macro_rules)] extern crate cgmath; extern crate image; extern crate num; use cgmath::point::Point3; use std::io::File; // use image::GenericImage; // use std::sync::{Arc, Future, RWLock, TaskPool}; // use std::iter::count; // use std::cmp::min; use camera::OriginCamera; use light::{Light, LightSource}; us...
true
4ad57f30b063709f339da4c30d5de40d6aa26c7e
Rust
bauhaus93/dwarfs
/src/world/world_error.rs
UTF-8
1,183
2.890625
3
[]
no_license
use std::fmt; use std::error::Error; use std::io; use graphics::{ GraphicsError, mesh::MeshError }; #[derive(Debug)] pub enum WorldError { Graphics(GraphicsError), MeshCreation(MeshError) } impl From<GraphicsError> for WorldError { fn from(err: GraphicsError) -> Self { WorldError::Graphics(err) ...
true
9f97c781e55d23ad5c91ba2422a071d16d5d3109
Rust
content-authenticity-initiative/img-parts
/src/jpeg/entropy.rs
UTF-8
1,999
3.28125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use std::io::{Read, Result, Write}; use byteorder::{ReadBytesExt, WriteBytesExt}; use super::markers; #[derive(Clone, PartialEq)] pub struct Entropy { raw: Vec<u8>, } #[allow(clippy::len_without_is_empty)] impl Entropy { pub(crate) fn read(r: &mut dyn Read) -> Result<Entropy> { let mut raw = Vec::ne...
true
28d414328289645ec78dd3be20450f396eb79033
Rust
sugyan/leetcode
/problems/0055-jump-game/lib.rs
UTF-8
499
3.25
3
[]
no_license
pub struct Solution; impl Solution { pub fn can_jump(nums: Vec<i32>) -> bool { let mut n = 1; for i in (0..nums.len() - 1).rev() { n = if nums[i] < n { n + 1 } else { 1 }; } n == 1 } } #[cfg(test)] mod tests { use super::*; #[test] fn example_1() { ...
true
9cb50343fa7d8b4683d022a87b1941f71b6aa9e3
Rust
AE9RB/basic-rust-games
/hexapawn/src/main.rs
UTF-8
7,664
3.109375
3
[]
no_license
use std::collections::hash_map::Entry; use std::collections::HashMap; use std::fmt; use std::io; use std::io::Write; use std::ops::{Index, IndexMut}; extern crate rand; use rand::seq::SliceRandom; use rand::thread_rng; const MOTION: [[u8; 2]; 14] = [ [1, 4], [1, 5], [2, 4], [2, 5], [2, 6], [3,...
true
ed69dc53c6aab95cbcdca48fb9917fa78f55727a
Rust
wjzz/eval-in-rust
/src/eval/parsing.rs
UTF-8
6,052
3.703125
4
[]
no_license
pub mod token; use token::Token; #[derive(Debug, PartialEq, Eq)] pub enum BinOperator { Plus, Mult, } #[derive(Debug, PartialEq, Eq)] pub enum Expr { Number(u32), Var(String), BinOp(BinOperator, Box<Expr>, Box<Expr>), } #[derive(Debug, PartialEq, Eq)] pub enum Stm { EvalExpr(Box<Expr>), A...
true
3dc1a423269fee4b61a849cdcac29b69d1830c4e
Rust
tetcoin/tetsy-wasm-gc
/wasm-gc-api/src/error.rs
UTF-8
518
2.640625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use std::error; use std::fmt; use tetsy_wasm::elements::Error as TetsyWasmError; /// The error type for garbage collecting webassembly bytecode. #[derive(Debug)] pub struct Error(TetsyWasmError); impl error::Error for Error { fn description(&self) -> &str { "webassembly garbage collection failed" } } ...
true
93a3d4abdea57bd03abe7b13cf4d53432c8d10db
Rust
nvzqz/chance-rs
/src/rng/panic.rs
UTF-8
1,365
3.109375
3
[ "MIT", "Apache-2.0" ]
permissive
use core::fmt::Debug; use crate::prelude::*; /// A wrapper around a [`TryRng`](trait.TryRng.html) that implements /// [`Rng`](trait.Rng.html) via panicking if an error occurred. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(transparent)] pub struct PanickingRng<R: ?Sized>(pub R); ...
true
a07e21c9baeecbd4dc1bee915b40c846fe151ef5
Rust
marco-c/gecko-dev-wordified
/third_party/rust/rayon/src/slice/mergesort.rs
UTF-8
25,108
2.6875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
/ / ! Parallel merge sort . / / ! / / ! This implementation is copied verbatim from std : : slice : : sort and then parallelized . / / ! The only difference from the original is that the sequential mergesort returns / / ! MergesortResult and leaves descending arrays intact . use crate : : iter : : * ; use crate : : sli...
true
ed3c636781a812af694f1f2cf035defe8dd97def
Rust
PyrokinesisStudio/tetris
/src/controls.rs
UTF-8
926
3
3
[]
no_license
use glium::glutin::VirtualKeyCode; use glium::glutin::VirtualKeyCode::*; pub struct Controls; pub enum Action { RotateCW, RotateCCW, RotateStop, MoveLeft, MoveRight, MoveStop, TrySpawn, GameReset, } impl Controls { pub fn resolve_press(&self, key: VirtualKeyCode) -> Option<Action> { Some(...
true
cc29f971da65b9730507437485f044b768dadf42
Rust
simias/cdimage
/src/internal.rs
UTF-8
9,845
3.390625
3
[]
no_license
//! This module provides generic reusable structures to easily store and lookup a CD's structure in //! an image format implementation. //! //! Those are only useful for implementing a new image format backend. use std::cmp; use std::fmt; use std::path::PathBuf; use subchannel::AdrControl; use {Bcd, CdError, CdResult,...
true
3894501eda161054bd57e29fcebf926daaa0a36c
Rust
dfrankland/sfbart
/src/client/apis/version_information/version.rs
UTF-8
1,288
2.671875
3
[ "MIT" ]
permissive
use crate::client::constants::PUBLIC_KEY; use anyhow::Result; use reqwest; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Version { pub api_version: String, pub copyright: String, pub license: String, pub mes...
true
9125cce27ff6cde90a024651248d1f66c320a7c5
Rust
pepyakin/remarkable-oxide
/service/src/extendable_range.rs
UTF-8
2,288
3.59375
4
[ "MIT" ]
permissive
use futures::prelude::*; /// This stream is similar to a range iterator: for a range `[lhs..rhs]` it emits all numbers in /// sequence starting from `lhs` to `rhs`. /// /// The feature of this stream is that `rhs` can be moved forward. In fact, the `rhs` specified by /// the `rhs_stream`. Each time `rhs_stream` produc...
true
9c600633a01daa09197dc86ca9001843e9c77c31
Rust
PistonDevelopers/conrod
/conrod_core/src/ui.rs
UTF-8
65,301
2.78125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use color::Color; use cursor; use event; use fnv; use graph::{self, Graph}; use input; use position::{self, Align, Dimensions, Direction, Padding, Point, Position, Range, Rect, Scalar}; use render; use std; use std::sync::atomic::{self, AtomicUsize}; use text; use theme::Theme; use utils; use widget::{self, Widget}; /...
true
d14383111457cefa7b0ba6cd21f3b242a2afb459
Rust
katsyoshi/zatsu
/rust/atcoder/practice_contest/src/d.rs
UTF-8
702
3.203125
3
[]
no_license
fn read_line<T>() -> Vec<T> where T: std::str::FromStr, <T as std::str::FromStr>::Err : std::fmt::Debug { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect() } fn c<'a>(v: &'a Vec<i32>) -> bool { v.iter().filter(...
true
1040949077d225808c26ab31919ee8abdf15aa97
Rust
KuekenPartei/proofmarshal
/hoard/src/pile/mod.rs
UTF-8
1,418
2.5625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use crate::blob::Blob; use crate::load::{Load, LoadIn, LoadRefIn, MaybeValid}; use crate::ptr::{TryGet, AsZone}; use crate::owned::Take; pub use crate::offset::{Offset, OffsetMut, Error, SliceGetBlobError}; #[derive(Debug, Default)] pub struct Pile<B> { inner: B, } impl<B> Pile<B> { pub fn new(inner: B) -> S...
true
4088451acdb3ef90515cbdfce4b7406f9acc6cdd
Rust
EFanZh/LeetCode
/src/problem_1482_minimum_number_of_days_to_make_m_bouquets/binary_search_2.rs
UTF-8
2,524
3.125
3
[]
no_license
pub struct Solution; // ------------------------------------------------------ snip ------------------------------------------------------ // use std::num::NonZeroU32; impl Solution { fn min_max(values: &[i32]) -> (u32, u32) { let mut iter = values.iter().map(|&num| num as u32); let mut min = ite...
true
ab224e08a975dc405b295412af7b41bff149b9b1
Rust
cmyr/cargo-instruments
/src/instruments.rs
UTF-8
15,344
3.078125
3
[ "MIT" ]
permissive
//! interfacing with the `instruments` command line tool use std::fmt::Write; use std::fs; use std::path::{Path, PathBuf}; use std::process::{Command, Output}; use anyhow::{anyhow, Result}; use cargo::core::Workspace; use semver::Version; use crate::opt::AppConfig; /// Holds available templates. pub struct Template...
true
3bd77a117606eef9698f3148200954a60e726879
Rust
Tehforsch/amazingGrame
/src/render/draw.rs
UTF-8
727
2.53125
3
[]
no_license
use piston_window; use piston_window::ellipse::Ellipse; use piston_window::{Context, Transformed}; use piston_window::types::Color; use opengl_graphics::GlGraphics; use ::point::Point; pub fn circle(pos: Point, radius: f64, color: Color, context: Context, gl: &mut GlGraphics) { Ellipse { color: color,...
true
b2e308267ee7aa14375375edc45c9c8e8990dc6d
Rust
jgautier/monkey
/src/object.rs
UTF-8
7,348
3.21875
3
[]
no_license
use crate::code::Instructions; use crate::ast::BlockStatement; use crate::ast::Node; use std::rc::Rc; use std::collections::HashMap; use std::cell::RefCell; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum HashKey { Integer(i64), String(String), Boolean(bool) } impl HashKey { pub fn inspect(&self) -> Str...
true
7f0d7f44ad5bd61f9645b2acfe3cb1b24f7065a2
Rust
MoAlyousef/vial
/examples/filters.rs
UTF-8
1,442
3.046875
3
[ "MIT", "Apache-2.0" ]
permissive
use { std::sync::atomic::{AtomicUsize, Ordering}, vial::prelude::*, }; routes! { // `count` will run before all routes in this block #![filter(count)] GET "/" => |_| "Hey there!"; GET "/hits" => hits; // `count` will run again when /double is visited #[filter(count)] GET "/double"...
true
863623ff96d1cd69b973f9999f7a9e638b94ec4c
Rust
redmar/aoc2020
/day08/src/main.rs
UTF-8
3,262
3.203125
3
[]
no_license
#[derive(Debug, Copy, Clone)] enum Instruction { Nop(i32), Acc(i32), Jmp(i32), } #[derive(Debug, PartialEq)] enum Mode { Part1, Part2, } impl Instruction { fn parse_instruction(line: &str) -> Instruction { let mut itr = line.split(' '); let instruction = itr.next(); let...
true
07fe6be1903916041ffcb4271800f1a3e6011a7f
Rust
mast3rsoft/vdvault
/src/main.rs
UTF-8
3,271
3.171875
3
[]
no_license
use strsim::levenshtein; use std::fs::{read_dir, DirEntry}; use std::path::PathBuf; use regex::*; use std::process::*; use rustyline::Editor; use ansi_term::Color; fn find_dir(to_match: &str, media: &str) -> Option<DirEntry> { let media_folder = read_dir(media).expect("media"); let mut top_path = PathBuf::n...
true