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
67db1ad90d48f8f1e3c29a387bb236325f30a752
Rust
jbertovic/pricefetch
/pricefetchlib/src/datastamp.rs
UTF-8
2,004
2.90625
3
[]
no_license
use crate::calc::*; use chrono::DateTime; use chrono::Utc; use serde::{Serialize, Serializer}; use std::fmt; pub const DATA_HEADER: &str = "period start,symbol,price,change %,min,max,30d avg"; /// DataStamp creates the data model in memory to keep track, store /// and move in memory the streamed data #[derive(Clone,...
true
d6d746ef056b87aecbcfbdd27b827c5772dbd766
Rust
ia7ck/competitive-programming
/AtCoder/abc265/src/bin/d/main.rs
UTF-8
633
2.671875
3
[]
no_license
use proconio::input; fn main() { input! { n: usize, p: u64, q: u64, r: u64, a: [u64; n], }; let mut cum = vec![0; n + 1]; for i in 0..n { cum[i + 1] = cum[i] + a[i]; } for w in 1..=n { let s = cum[w]; if s >= r && cum.binary_sear...
true
3df48ada4ac32b66b9427e3d28ebd2f7d87f6d90
Rust
aclysma/async-dispatcher
/src/required_resources.rs
UTF-8
1,003
3.296875
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use shred::ResourceId; use std::marker::PhantomData; // This is a helper that determines the reads/writes required for a system. I would have preferred // not to need this structure at all, but many of the shred types require lifetimes that just // don't play nicely with tasks. This gets rid of those lifetimes. #[deri...
true
54870b9a5da2b27e797f275d33d5416dc84d3b44
Rust
radonc0de/aoc20
/day_3/src/main.rs
UTF-8
1,508
3.359375
3
[]
no_license
use std::fs; fn main() { //turns puzzle input into vector of &str let input = fs::read_to_string("input") .expect("Failed to read 'input'"); let map = input.lines().collect::<Vec<&str>>(); println!("{}", (solver(&map, 1, 1) * solver(&map, 3, 1) * solver(&map, 5, 1) * solver(&map, 7, 1) * ...
true
fc9c556ec96952c3c8b491487e1906c487d6218e
Rust
Temdog007/rust-curves
/src/curve.rs
UTF-8
1,892
2.84375
3
[]
no_license
use nalgebra::*; use num_traits::*; pub fn get_points<'a, N: CurveScalar, C: Curve<N>>( curve: &'a C, divisions: usize, ) -> impl Iterator<Item = Vector3<N>> + 'a { assert!(divisions > 0); let n = N::from_usize(divisions).unwrap(); (0..divisions).map(move |i| { let t = N::from_usize(i).unwr...
true
0ae84c2b6fe7186aaa8e5cde775f1e7f262a33cb
Rust
usmank/loxi
/src/ast.rs
UTF-8
2,390
4.09375
4
[]
no_license
use std::fmt; pub enum Expression<T> { Literal(LiteralValue), Unary { operator: T, right: Box<Expression<T>>, }, Binary { operator: T, left: Box<Expression<T>>, right: Box<Expression<T>>, }, Ternary { operator: T, left: Box<Expression<T>>,...
true
c8b0d1399789d6a623952881dd349e505a593182
Rust
offscale/cargo-make
/src/logger.rs
UTF-8
1,969
3.09375
3
[ "LicenseRef-scancode-free-unknown", "Apache-2.0" ]
permissive
//! # log //! //! Initializes the global logger. //! #[cfg(test)] #[path = "./logger_test.rs"] mod logger_test; use fern; use log::{Level, LevelFilter}; use std::env; use std::io::stdout; #[cfg(test)] fn exit(code: i32) { panic!(code); } #[cfg(not(test))] use std::process::exit; #[derive(Debug, PartialEq)] ///...
true
9061aab34dfd741d921505ac826edf99a42bc9f0
Rust
CheezeCake/AoC-2019
/day07/day07.rs
UTF-8
5,632
2.984375
3
[ "MIT" ]
permissive
use std::collections::VecDeque; use std::i32; use std::io; struct Permutations { permutation: Vec<i32>, done: bool, } impl Permutations { fn new(start: i32, end: i32) -> Self { assert!(start <= end); Self { permutation: (start..=end).collect(), done: false, ...
true
7827af4fc8479469c4d01066ba6ffcb6a229907b
Rust
katyo/uctl-rs
/ufix/src/cast_fixed.rs
UTF-8
1,825
3.09375
3
[ "MIT" ]
permissive
use crate::{Cast, Digits, Exponent, Fix, Mantissa, Radix}; macro_rules! cast_from { ($type: ty) => { impl<R, B, E> Cast<$type> for Fix<R, B, E> where R: Radix<B>, B: Digits, E: Exponent, $type: Cast<Mantissa<R, B>>, Mantissa<R, B>: Cast<$t...
true
13e9f8e261940061a27c96b44ea383a748cb9445
Rust
Bukkaraya/AOC-2020
/ch-8/src/main.rs
UTF-8
2,673
3.3125
3
[]
no_license
use std::{ fs::File, io::{prelude::*, BufReader}, path::Path }; use std::collections::HashSet; fn lines_from_file(filename: impl AsRef<Path>) -> Vec<String> { let file = File::open(filename).expect("No such file"); let buf = BufReader::new(file); buf.lines() .map(|l| l.expect("Could no...
true
47d339aef85b1ebdf1be114d38f737e4e8be7b7c
Rust
tonytaylor/rust-katas
/character-count/main.rs
UTF-8
796
3.625
4
[]
no_license
use std::io; fn get_input(prompt: &str) -> String { println!("{}", prompt); let mut input = String::new(); match io::stdin().read_line(&mut input) { Ok(n) => { if n < 2 { get_input("please enter at least one character") } else { input.trim().t...
true
dbdc5f07e7336ce3044727e8679cee9828507542
Rust
isgasho/rasen
/rasen-dsl/codegen/functions.rs
UTF-8
3,388
2.765625
3
[ "MIT" ]
permissive
//! Fn trait implementations use codegen::operations::match_values; use proc_macro2::{Ident, Span, TokenStream}; static TRAITS: [(&str, &str, Option<&str>); 3] = [ ("FnOnce", "call_once", None), ("FnMut", "call_mut", Some("&mut")), ("Fn", "call", Some("&")), ]; pub fn impl_fn() -> Vec<TokenStream> { ...
true
e50a65d9c80c22c1b636783a6dd4a431848dd5dd
Rust
alex-dukhno/rust-tdd-katas
/old-katas-iteration-01/test/inc_dec_numbers_kata/day_1.rs
UTF-8
807
2.9375
3
[ "MIT" ]
permissive
pub use tdd_kata::inc_dec_numbers_kata::day_1::Checker; pub use tdd_kata::inc_dec_numbers_kata::day_1::NumberType::{Neither, Inc, Dec}; pub use expectest::prelude::be_equal_to; describe! inc_dec_tests { before_each { let checker = Checker::new(); } it "should be neither increasing nor decrising ...
true
a29d5f9c10421c4c4c65c862867889f455884c0e
Rust
roninro/fmconv
/src/format.rs
UTF-8
3,892
3
3
[]
no_license
#![allow(dead_code)] use std::str::FromStr; use serde_yaml::Value as YamlValue; use toml::Value as TomlValue; use crate::errors; #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum Format { Toml, Yaml, } impl Format { pub fn from_delim(d: &str) -> Result<Self, errors::Error> { match d { ...
true
ec91b276f779393222f2cbbde6add3c4360c6de9
Rust
leshow/exercism
/hackerrank/src/largest_triangle_area.rs
UTF-8
886
3.46875
3
[]
no_license
// 812. Largest Triangle Area // Easy // You have a list of points in the plane. Return the area of the largest // triangle that can be formed by any 3 of the points. // Example: // Input: points = [[0,0],[0,1],[1,0],[0,2],[2,0]] // Output: 2 // Explanation: // The five points are show in the figure below. The red tr...
true
98b09594f22125d56b7f2be009e174600f4c820a
Rust
Winnaries/rl-practices
/windy-gridworld/src/main.rs
UTF-8
6,649
3.328125
3
[]
no_license
use rand::distributions::{Distribution, Standard}; use rand::Rng; use std::ops::Add; #[derive(Eq, PartialEq, Clone, Copy, Debug)] struct Position { x: i32, y: i32, } impl Add<Position> for Position { type Output = Position; fn add(self, rhs: Position) -> Self::Output { Position { ...
true
a71b2e98f23f314771909f3b0d268c9d91dbba88
Rust
YangJeffrey/learning-rust
/book/chapter-3-5.rs
UTF-8
1,256
4.53125
5
[]
no_license
fn main() { //if else statement let number = 3; if number < 5 { println!("condition was true"); } else { println!("condition was false"); } // if else if let anothernumber = 6; if anothernumber % 4 == 0 { println!("number is divisible by 4"); } else if anoth...
true
a43ec6d758a4b0c4c91f9c882e2bbc3322ec2ecf
Rust
krepa098/stl2thumbnail_rs
/stl2thumbnail_rs/src/rasterbackend.rs
UTF-8
11,491
2.875
3
[]
no_license
use crate::aabb::*; use crate::mesh::*; use crate::picture::*; use crate::zbuffer::*; use std::f32::consts::PI; use std::time::{Duration, Instant}; #[derive(Debug)] pub struct RenderOptions { pub view_pos: Vec3, pub light_pos: Vec3, pub light_color: Vec3, pub ambient_color: Vec3, pub model_color: ...
true
f8314fb2ddf5ebb902ea3eb5c1cc66a9f1a2df01
Rust
chilikk/adventofcode
/2022/6.rs
UTF-8
751
3.328125
3
[]
no_license
fn main() { let mut line: String = String::new(); match std::io::stdin().read_line(&mut line) { Ok(_) => print_marker(line), Err(_) => (), } } fn print_marker(line: String) { println!("{}", get_marker(&line, 4)); println!("{}", get_marker(&line, 14)); } fn get_marker(line: &String,...
true
86f7c051f11c77ea41ee4c11d079112d6bb4c034
Rust
obs145628/calc-ir-wasm
/cl-wasm/src/wasmgen.rs
UTF-8
3,882
2.625
3
[ "MIT" ]
permissive
use binaryen::*; use crate::ir; struct CodeGen { exprs: Vec<Expr>, max_local: Option<usize>, module: Module, } impl CodeGen { pub fn new() -> Self { CodeGen { exprs: vec![], max_local: None, module: Module::new(), } } pub fn begin(&mut self...
true
b0850871e6157fbd4b8ecc69e0d4173f83164204
Rust
jbduncan/rust-book
/minigrep/src/lib.rs
UTF-8
4,819
3.734375
4
[]
no_license
//! # Minigrep //! //! `minigrep` is a very small, very minimalist grep-like tool. //! //! See `run` for an example of how to run this library as a command-line tool. use std::error::Error; use std::{env, fs}; pub struct Config { pub query: String, pub filename: String, pub case_sensitive: bool, } impl C...
true
4de14080dfb1b9f7d12a5c405acb67a0750bc68d
Rust
miquels/webdav-handler-rs
/src/lib.rs
UTF-8
6,541
2.953125
3
[ "Apache-2.0" ]
permissive
#![doc(html_root_url = "https://docs.rs/webdav-handler/0.2.0")] //! ## Generic async HTTP/Webdav handler //! //! [`Webdav`] (RFC4918) is defined as //! HTTP (GET/HEAD/PUT/DELETE) plus a bunch of extension methods (PROPFIND, etc). //! These extension methods are used to manage collections (like unix directories), //! ge...
true
ece688a84da80a8753bc0c40856082414640cdec
Rust
local-minimum/advent-of-code-2020
/day12/src/main.rs
UTF-8
4,720
3.40625
3
[]
no_license
use std::fs; fn load_demo() -> String { r#"F10 N3 F7 R90 F11"#.to_string() } fn load_data() -> String { fs::read_to_string("./input.txt").unwrap() } fn parse_instruction(instruction: &str) -> Option<(char, i64)> { match instruction.get(..1) { Some(ch_str) => { let ch: char = ch_str.ch...
true
cbf3be0799c41090080f4dc38eb8f04e25c339f6
Rust
zargony/advent-of-code-2019
/src/input.rs
UTF-8
2,638
3.171875
3
[]
no_license
//! Advent of Code 2019: puzzle input reading use crate::intcode::{Memory, Value}; use async_std::fs::File; use async_std::io::{self, BufReader}; use async_std::path::PathBuf; use async_std::prelude::*; use futures_util::future::ready; use futures_util::stream::TryStreamExt; use std::error; use std::str::FromStr; ///...
true
76091017168661acd1e9a5e4572fb867363020d5
Rust
fewensa/rtdlib
/src/types/chat_administrator.rs
UTF-8
2,239
3.03125
3
[ "MIT" ]
permissive
use crate::types::*; use crate::errors::*; use uuid::Uuid; /// Contains information about a chat administrator #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct ChatAdministrator { #[doc(hidden)] #[serde(rename(serialize = "@type", deserialize = "@type"))] td_name: String, #[doc(hidden)] ...
true
e5c9b9fa1b10baa9717cfd6ab0646775e5bd3cf7
Rust
luckyuro/rsKata
/src/katas/are_they_the_same.rs
UTF-8
683
2.984375
3
[]
no_license
//6kyu //kata_URL: // https://www.codewars.com/kata/are-they-the-same/train/rust #[allow(dead_code)] pub fn comp(a: Vec<i64>, b: Vec<i64>) -> bool { let mut new_a:Vec<i64> = a .into_iter() .map(|x| x*x) .collect(); new_a.sort(); let mut new_b = b; new_b.sort(); ne...
true
d1f574f3766edc1af95b4af96c41ebb0738446e2
Rust
oneshadab/trebek
/src/builtins/io.rs
UTF-8
1,091
2.984375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::to_runtime_result; use crate::{ misc::RuntimeResult, runtime::Runtime, types::{builtin::Builtin, t_object::TObject}, }; use std::io::{BufRead, Write}; pub fn get_builtins() -> Vec<Builtin> { vec![Builtin::new("scan", scan), Builtin::new("print", print)] } fn scan(ctx: &mut Runtime, args: Ve...
true
03894f29f9d9ebe1609dfa2e2599f8612507add9
Rust
nimr0d/projecteuler-rs
/src/bin/p2.rs
UTF-8
192
2.765625
3
[]
no_license
extern crate euler; fn main() { let N = 4000000; let mut f = (0, 1); let mut sum = 0; while f.0 <= N { sum += f.0; f = (f.0 + 2 * f.1, 2 * f.0 + 3 * f.1); } println!("{}", sum); }
true
2881b25b10ea9f5f9653b331239d61e4209e8649
Rust
bevyengine/bevy
/examples/app/logs.rs
UTF-8
1,304
3.234375
3
[ "Apache-2.0", "MIT", "Zlib", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive" ]
permissive
//! This example illustrates how to use logs in bevy. use bevy::prelude::*; fn main() { App::new() .add_plugins(DefaultPlugins.set(bevy::log::LogPlugin { // Uncomment this to override the default log settings: // level: bevy::log::Level::TRACE, // filter: "wgpu=warn,bev...
true
07edd18cd8803b92c4749405eccf025b6973fa92
Rust
natashad/ToyBrowserEngine
/rust_browser/src/html_parser.rs
UTF-8
3,170
3.296875
3
[]
no_license
use dom; pub fn parse(input : String) -> dom::Node { let mut nodes = Parser {pos : 0, input: input}.parse_node_sequence(); if nodes.len() == 1 { nodes.remove(0) } else { dom::element("html".to_string(), dom::AttrMap::new(), nodes) } } struct Parser { input: String, pos: usize }...
true
d7690f83429a2c3fa2a456e19d6e88974a2e7228
Rust
Limegrass/luffy
/luffy_gitea/src/lib.rs
UTF-8
2,183
2.53125
3
[ "MIT" ]
permissive
// https://github.com/go-gitea/gitea/blob/master/modules/notification/webhook/webhook.go pub mod payloads; pub mod structs; use luffy_core::Service; use payloads::*; use serde::{Deserialize, Serialize}; use std::convert::TryInto; use thiserror::Error; #[derive(Debug, Deserialize, Serialize)] pub enum HookEvent { ...
true
59871bf678a3b4d65c244b2858cf8a2ade43fbe5
Rust
jonnyom/Exercism-exercises
/rust/leap/src/lib.rs
UTF-8
248
2.875
3
[]
no_license
pub fn is_leap_year(year: u64) -> bool { let divisible_by_four = year % 4 == 0; let divisible_by_100 = year % 100 == 0; let divisible_by_400 = year % 400 == 0; return divisible_by_four && (!divisible_by_100 || divisible_by_400); }
true
d72ac1d44d9025293273eb3ac05918e9f96a0ad4
Rust
shaneutt/riak-rust-client
/src/yokozuna.rs
UTF-8
7,205
2.78125
3
[ "MIT" ]
permissive
/// Riak Search integrates Apache Solr for indexing and querying Riak KV /// /// For more information: https://docs.basho.com/riak/kv/latest/developing/usage/search/ use errors::RiakErr; use protobuf::{Message, RepeatedField}; use rpb::riak_yokozuna::{RpbYokozunaIndex, RpbYokozunaIndexPutReq}; use rpb::riak_search::{R...
true
d98c29c3677cfdd0bf691f01869a649d40ff499a
Rust
barzilouik/flowbetween
/ui/src/session/event.rs
UTF-8
309
2.53125
3
[ "Apache-2.0" ]
permissive
use super::super::control::*; /// /// Possible events that can be sent to the UI /// #[derive(Clone, PartialEq, Serialize, Deserialize, Debug)] pub enum UiEvent { /// Performs the specified action Action(Vec<String>, String, ActionParameter), /// Sends a tick to all the controllers Tick }
true
98d4fe227f8516af6262061c1af3a7c83ab865b1
Rust
itang/tests
/test-rusts/test-arrays-slices/src/main.rs
UTF-8
1,964
4.0625
4
[]
no_license
// // An array is a collection of objects of the same type T, stored in contiguous memory. Arrays are created using brackets [], // and their size, which is konow at compile time, is part of their signature [T; size]. // // Slices are similar to arrays, but their size is not known at compile time. Instend, a slice is a...
true
e4f35394dd6db6b95491af170290111d32c6e1de
Rust
ystreet/titleformat-rs
/src/functions/num/min.rs
UTF-8
1,147
3.140625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use functions::num::to_int; use types::Error; use types::Error::*; use std; /* $min(a,b, ...) * find the maximum of a, b, c, ... */ pub fn min(args : Vec<String>) -> Result<String, Error> { if args.len() < 2 { return Err(InvalidNativeFunctionArgs(String::from("min"), args.len())); } Ok(args.iter...
true
f8ea8f7cb989d8fb24674e6e40d42babe666507a
Rust
jlmcmchl/tba_api_v3
/src/frc_district/mod.rs
UTF-8
2,272
2.9375
3
[]
no_license
use Api; use serde_json::Value; use ModelType; use std::collections::HashMap; pub trait District { fn district_events(&mut self, district_key: &str, model_type: Option<ModelType>) -> Value; fn district_rankings(&mut self, district_key: &str) -> Value; fn district_teams(&mut self, district_key: &str, model_...
true
8ffa322496719fca3176555d1ad86441ea3b776f
Rust
masonium/aoc2017
/src/day24.rs
UTF-8
2,124
3.015625
3
[]
no_license
use prelude::*; type Piece = (usize, usize); type PieceMap = HashMap<usize, HashSet<Piece>>; fn remove_piece(m: &mut PieceMap, piece: Piece, port: usize) -> usize { m.get_mut(&piece.0).unwrap().remove(&piece); m.get_mut(&piece.1).unwrap().remove(&piece); piece.1 + piece.0 - port } fn insert_piece(m: &mut...
true
3d565e25703685f7f344791063b5b06453628852
Rust
Nemo157/cbor-diag-rs
/src/encode/diag.rs
UTF-8
15,901
3.015625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use half::f16; use std::fmt::Write; use super::Encoding; use crate::{ByteString, DataItem, FloatWidth, IntegerWidth, Simple, Tag, TextString}; #[derive(Copy, Clone, PartialEq, Eq)] pub(crate) enum Layout { Pretty, Compact, } pub(crate) struct Context<'a> { output: &'a mut String, layout: Layout, ...
true
c84fcae5f6a8682ab978bb554246edc1d6f0a300
Rust
patiences/rusty-bites
/mir-bites/struct_creation.rs
UTF-8
668
2.59375
3
[]
no_license
struct Point { x: i32, y: i32 } fn main() { let a = Point{ x: 4, y: 5}; } // MIR /* fn main() -> () { let mut _0: (); // return pointer scope 1 { let _1: Point; // "a" in scope 1 at <anon>:7:9: 7:10 } bb0: { StorageLive(_1); ...
true
fcc219b06a2e405a2fcec54b034e3bf4fe8102d0
Rust
exonum/exonum
/components/merkledb/tests/work/mod.rs
UTF-8
5,659
2.890625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Operations on indexes shared between `backup` and `migration` tests. use proptest::{ collection::vec, option, prop_assert_eq, prop_oneof, sample, strategy, strategy::Strategy, test_runner::TestCaseResult, }; use std::collections::BTreeMap; use exonum_merkledb::{ access::{Access, AccessExt, RawAccessM...
true
2e8923a079f5cd1c14fb1e1d76ce7b484f17f6fe
Rust
nushell/nushell
/crates/nu-protocol/src/value/stream.rs
UTF-8
8,015
3.203125
3
[ "MIT" ]
permissive
use crate::*; use std::{ fmt::Debug, sync::{atomic::AtomicBool, Arc}, }; pub struct RawStream { pub stream: Box<dyn Iterator<Item = Result<Vec<u8>, ShellError>> + Send + 'static>, pub leftover: Vec<u8>, pub ctrlc: Option<Arc<AtomicBool>>, pub is_binary: bool, pub span: Span, pub known_s...
true
a8c90e79a3e4e52617ff9d3e81d0851d13b44354
Rust
doanamo/Raytracer-2020
/src/render/setup.rs
UTF-8
1,747
3.25
3
[ "MIT" ]
permissive
use std::path::Path; use std::fs::OpenOptions; use std::io::{ BufWriter, BufReader }; use serde::{ Serialize, Deserialize }; use super::parameters::Parameters; use super::scene::Scene; #[derive(Debug)] pub enum Error { OpeningFile, CreatingFile, Serializing, Deserializing, } #[derive(Default, Serializ...
true
b91924af448167c1b170796c43d09cd921d86b2e
Rust
AntonGepting/tmux-interface-rs
/src/commands/windows_and_panes/move_window.rs
UTF-8
4,664
3.28125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use crate::commands::constants::*; use crate::TmuxCommand; use std::borrow::Cow; /// This is similar to link-window, except the window at `src-window` is moved to `dst-window` /// /// # Manual /// /// tmux ^3.2: /// ```text /// move-window [-abrdk] [-s src-window] [-t dst-window] /// (alias: movew) /// ``` /// /// tmu...
true
811b16a044362de7e9ca8f16d16bbb77c421877e
Rust
garrettpauls/AdventOfCode2018
/day19/src/ops.rs
UTF-8
3,759
3.09375
3
[ "Unlicense" ]
permissive
use std::collections::HashMap; pub type Reg = i64; pub type Param = usize; pub trait Operation { fn name(&self) -> &'static str; fn exec(&self, registers: &mut Vec<Reg>); } pub fn load_operations() -> HashMap<&'static str, &'static Fn(&mut Vec<Reg>, Param, Param, Param)> { let mut m: HashMap<&'static str...
true
4485dd1e10b0d598e6fd8a8cdf7dda277a412a15
Rust
scottschroeder/storyestimate
/src/webapp/errors.rs
UTF-8
1,668
2.828125
3
[]
no_license
use errors::*; use rocket; use rocket::Catcher; use rocket::http::Status; use rocket::request::Request; use rocket::response::{Responder, Response}; use serde_json; use std::io::Cursor; use std::result; impl<'r> Responder<'r> for Error { fn respond(self) -> result::Result<Response<'r>, Status> { info!(...
true
592aee037c859a8e5b48c0adbf1d22797254e2c2
Rust
julianandrews/adventofcode
/2019/rust/src/bin/day17.rs
UTF-8
12,758
3.015625
3
[]
no_license
extern crate aoc; use aoc::direction::Direction; use aoc::intcode::{RegisterValue, VM}; use aoc::point::Point2D; use std::collections::HashSet; use std::convert::TryFrom; use std::fmt; use std::str::FromStr; use aoc::aoc_error::AOCError; type Result<T> = ::std::result::Result<T, Box<dyn std::error::Error>>; type Poi...
true
85654ccb638174cfe6db08f7c4ff8fad62c6e38f
Rust
kazcw/guerrilla
/src/lib.rs
UTF-8
7,770
2.53125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![no_std] #[cfg(windows)] extern crate winapi; #[cfg(any(macos, unix))] extern crate libc; #[cfg(test)] #[macro_use] extern crate std; #[cfg(test)] extern crate chrono; #[cfg(windows)] unsafe fn copy_to_protected_address(dst: *mut u8, src: &[u8]) { use winapi::shared::minwindef::DWORD; use winapi::um::mem...
true
6009cc6fb71e081600003bf029e2a854c9f84c65
Rust
wasm-network/quicksilver
/src/graphics/view.rs
UTF-8
2,408
3.453125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use crate::geom::{Vector, Rectangle, Transform}; #[derive(Clone, Copy, Debug)] ///A view into the world, used as a camera and a viewport pub struct View { pub(crate) normalize: Transform, pub(crate) opengl: Transform } impl View { ///Create a new view that looks at a given area pub fn new(world: Recta...
true
6c65ae5e800baf77d95de0b4a1f3df9fa4e64b86
Rust
pimox/proxmox
/proxmox/src/tools/parse.rs
UTF-8
349
3.25
3
[]
no_license
//! Some parsing utilities. use anyhow::{bail, Error}; /// Parse a hexadecimal digit into a byte. #[inline] pub fn hex_nibble(c: u8) -> Result<u8, Error> { Ok(match c { b'0'..=b'9' => c - b'0', b'a'..=b'f' => c - b'a' + 0xa, b'A'..=b'F' => c - b'A' + 0xa, _ => bail!("not a hex digi...
true
4a2b56967edfa20e84a5d6623c70c3ab1a495ed3
Rust
Aurenos/rustache
/src/bin/main.rs
UTF-8
1,338
2.890625
3
[]
no_license
// #![allow(unused_imports)] // #![allow(unused_variables)] use std::collections::HashMap; use std::net::{TcpListener, TcpStream}; use std::str::FromStr; use rustache::buf_tcpstream::BufTcpStream; use rustache::command::{Cmd, CmdError}; fn main() { let listener = TcpListener::bind("127.0.0.1:8888").unwrap(); ...
true
a24fdd344a347257261b520715d0e09ddf16890d
Rust
bouncenow/advent-of-code-2018-rust
/src/ch5.rs
UTF-8
2,346
3.21875
3
[]
no_license
use std::mem; use std::collections::HashSet; use rayon::prelude::*; use crate::common::read_file; pub fn ch5() { let polymers = read_file("ch5.txt"); polymers.trim(); test_polymers_removal(&polymers); react_on_string(polymers); } fn test_polymers_removal(polymers: &str) { println!("min length a...
true
816adb435d902530bd76d637058c8f2bc648fef1
Rust
sikkatech/arkworks-threshold-decryption
/src/key_generation.rs
UTF-8
1,762
2.59375
3
[ "Apache-2.0", "MIT" ]
permissive
use ark_ec::{AffineCurve, PairingEngine, ProjectiveCurve}; use ark_ff::{Field, PrimeField, UniformRand, Zero}; use ark_poly::{ univariate::DensePolynomial, Polynomial, UVPolynomial, }; use crate::*; use rand_core::RngCore; pub fn generate_keys<P: ThresholdEncryptionParameters, R: RngCore> ( threshold: usize, ...
true
f7ee6798475566849050a0fb8f122a4e12a20aa8
Rust
gnmerritt/nphysics
/src/integration/euler.rs
UTF-8
2,472
3.0625
3
[ "BSD-2-Clause" ]
permissive
//! Euler integration functions. use na; use alga::general::Real; use math::{Point, Vector, Orientation, Rotation, Translation, Isometry}; /// Explicit Euler integrator. pub fn explicit_integrate<N: Real>(dt: N, p: &Isometry<N>, c: &Point<N>, lv:...
true
c0d5dd8ab53d7d920520dfdf0baa506622910c2d
Rust
rfdonnelly/advent-of-code
/2021/src/d16.rs
UTF-8
5,429
2.734375
3
[]
no_license
use crate::input; #[cfg(feature = "nom")] mod d16_nom; #[cfg(feature = "nom")] use d16_nom::*; #[cfg(feature = "bitvec")] mod d16_bitvec; #[cfg(feature = "bitvec")] use d16_bitvec::*; const DAY: usize = 16; pub fn run() -> String { let input = input(DAY); let mut output = String::new(); let time = std::...
true
9ddb3fc3ba38ff7adc90e0988c90e33de51933c3
Rust
charleschege/LiteSession
/src/lib.rs
UTF-8
7,252
2.890625
3
[ "Apache-2.0" ]
permissive
#![forbid(unsafe_code)] #![deny(missing_docs)] //! #### LiteSession //! //! Create Session Tokens that are Resilient to Misuse and Highjacking //! //! This library is inspired by research [A Secure Cookie Protocol](https://github.com/charleschege/LiteSession/blob/master/Research%20Documents/cookie.pdf) paper by Liu et...
true
ac79da5f0fb798d1eb5e609123ed51028a5dd380
Rust
vpetrigo/tinyrenderer
/tinyrenderer/src/line.rs
UTF-8
3,547
3
3
[]
no_license
use crate::point::Point; #[derive(Copy, Clone, Debug)] pub(crate) struct MajorMinor<T> { major: T, minor: T, } impl<T> MajorMinor<T> { fn new(major: T, minor: T) -> Self { MajorMinor { major, minor } } } #[derive(Copy, Clone, Debug)] pub(crate) struct SlopeParameters { is_steep: bool, ...
true
8b6a25dc77a141520dc27182f2b24284581281d9
Rust
CraftSpider/rust-jni
/src/types/native_method.rs
UTF-8
1,740
2.953125
3
[]
no_license
//! //! Module containing a struct and methods related to the RegisterNatives functionality //! use crate::{ffi, JavaType}; use std::ffi::{c_void, CString}; /// /// A struct representing a single native method. Contains the name of the method, the signature /// of the method, and the pointer to the actual Rust functi...
true
bd9e21623d7d7436bcfa0b9e40fe8f18747bda16
Rust
iwillspeak/ullage
/src/syntax/tree/expression.rs
UTF-8
18,075
3.78125
4
[ "MIT" ]
permissive
//! Syntax Expression //! //! A syntax expression represents the value of a given node in the //! syntax tree. use super::super::text::{Ident, SourceText, Span, DUMMY_SPAN}; use super::super::SyntaxNode; use super::operators::{InfixOp, PrefixOp}; use super::token::{Token, TokenKind}; use super::types::TypeAnno; use su...
true
585f6a9da8d241959ebbac77b5bd9b8c192e5fe8
Rust
shivaanshag/general-perceivers
/gperc/fastlibs/src/lib.rs
UTF-8
1,155
2.90625
3
[ "MIT" ]
permissive
use pyo3::prelude::*; use std::io::prelude::*; use std::fs; use std::os::unix::prelude::FileExt; /// Formats the sum of two numbers as string. #[pyfunction] fn sum_as_string(a: usize, b: usize) -> PyResult<String> { Ok((a + b).to_string()) } // take an array of i64 and return sum #[pyfunction] fn sum_array(a: Ve...
true
6dfe3ac42113cbef012330002d908c188c7f835f
Rust
vi/tokio-stdin-stdout
/examples/line-by-line.rs
UTF-8
2,105
2.96875
3
[]
no_license
extern crate tokio_stdin_stdout; extern crate tokio; extern crate tokio_io; extern crate tokio_codec; use tokio::prelude::future::ok; use tokio::prelude::{Future, Stream}; use tokio_codec::{FramedRead, FramedWrite, LinesCodec}; fn async_op(input: String) -> Box<Future<Item = String, Error = ()> + Send> { Box::new(o...
true
c02847879accc497274776246c9399f9296dad54
Rust
sebastiencs/rustorrent
/src/bencode/de.rs
UTF-8
10,197
2.53125
3
[]
no_license
use serde::{ de::{DeserializeSeed, MapAccess, SeqAccess, Visitor}, forward_to_deserialize_any, }; use serde::Deserialize; use std::{cell::Cell, fmt}; #[derive(Debug, PartialEq)] pub enum DeserializeError { UnexpectedEOF, WrongCharacter(u8), End, InfoHashMissing, TooDeep, NoFile, E...
true
bbc08bd5089ea508840fa32cf54407f85104aceb
Rust
neivv/whack
/src/insertion_sort.rs
UTF-8
3,594
3.59375
4
[ "MIT", "Apache-2.0" ]
permissive
//! Insertion sort. //! //! Obviously inefficient for large slices, but cuts several kilobytes of useless sorting code //! from binary size and this library is 99% of time sorting slices with less than 5 entries. //! //! Code taken from Rust stdlib (src/liballoc/slice.rs). //! Copyright them w/ the usual Apache2/MIT li...
true
a54e33ad1079e8ff0d37079e4682b28fec7619bf
Rust
agmcleod/adventofcode-2016
/21/src/utils.rs
UTF-8
770
3.1875
3
[]
no_license
pub fn rotate_vec_right(data: &mut Vec<u8>) { let copy = data.clone(); for (i, v) in copy.iter().enumerate() { let index = if i == data.len() - 1 { 0 } else { i + 1 }; data[index] = *v; } } pub fn rotate_vec_left(data: &mut Vec<u8>) { let copy = d...
true
ccfefe1234cca95a6e96c74c5b9563e62576d228
Rust
eseraygun/rust-honestintervals
/src/intervalset/def.rs
UTF-8
658
3.15625
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use interval::Interval; /// Interval set parsing error enum. #[derive(Debug)] pub enum ParseIntervalSetError { /// The first character of the strict is anything other than `'{'`. MissingOpeningBraces, /// The first character of the strict is anything other than `'}'`. MissingClosingBraces, /// Ther...
true
2d56667305c4007abc01a58b20646f56682bdcd6
Rust
awsomearvinder/waybar_battery_indicator
/src/bin/battery/mod.rs
UTF-8
4,926
2.8125
3
[ "MIT" ]
permissive
use waybar_server_logic::WayBarJsonObj; const ARRAY_SIZE :usize= 100; //TODO, make it work for more then just one battery. new() parameter? const FILE_PATH :&str= "/sys/class/power_supply/BAT0/"; ///This struct represents A battery. pub struct Battery{ capacity : u8, charge_now : u32, charge_full : u32, ...
true
e0e8fbe574f22ca283c759a90fd6ea899d6b4755
Rust
hypernova1/rust-tutorial
/10. 제네릭, 트레잇, 라이프타임/01. generic/src/main.rs
UTF-8
1,985
4.125
4
[]
no_license
/* 제네릭 데이터 타입 */ /* 이름과 시그니처만 다른 두 함수들 - 타입만 다르고 내부 구현은 똑같다. */ fn largest_i32(list: &[i32]) -> i32 { let mut largest = list[0]; for &item in list.iter() { if item > largest { largest = item; } } largest } fn largest_char(list: &[char]) -> char { let mut l...
true
72a2b4fb60cffcc72cefb9484ea8634785cee1a4
Rust
martsklav/boiler
/src/crypto.rs
UTF-8
2,747
3.140625
3
[]
no_license
use std::io::Cursor; use openssl::pkey::PKey; use openssl::symm::{Crypter, Cipher, Mode}; use rand::Rng; use rand::os::OsRng; fn generate_data(bytes: usize) -> Vec<u8> { let mut session_key = vec![0u8; bytes]; // TODO: Allow rng to be created only once let mut rng = OsRng::new().unwrap(); rng.fill_byt...
true
7c8271bdc3f3bb00851edd5ead39eda9525eeeb2
Rust
gitpicard/atom
/tests/scan_tests.rs
UTF-8
6,817
3.171875
3
[ "MIT" ]
permissive
extern crate atom; use atom::error::*; use atom::scan::*; fn verify_token(actual: &Token, expected: &Token, ignore_pos: bool) { assert_eq!(actual.token_type(), expected.token_type()); assert_eq!(actual.token_data(), expected.token_data()); assert_eq!(actual.source_name(), expected.source_name()); if !...
true
1f39b6e40bc474913f9e5045937576316fbcc7f8
Rust
SProst/hdf5-rs
/hdf5-types/src/h5type.rs
UTF-8
10,840
2.796875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use std::mem; use libc::{size_t, c_void}; use array::{Array, VarLenArray}; use string::{FixedAscii, FixedUnicode, VarLenAscii, VarLenUnicode}; #[repr(C)] struct hvl_t { len: size_t, p: *mut c_void, } #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] pub enum IntSize { U1 = 1, U2 = 2, U4 = 4, U8 ...
true
380e4225947d2a9728be2eb502ac1278cf55283a
Rust
AaronShah2/SGDA_Game_Jam_Proj
/src/states/pause.rs
UTF-8
4,418
2.703125
3
[]
no_license
use crate::{ resources::{prefabs::UiPrefabRegistry, Paused, QuitToMenu, ResourceRegistry}, states::OptionsState, utils::delete_hierarchy, }; use amethyst::{ ecs::Entity, input::{self, VirtualKeyCode}, prelude::*, ui::{UiEvent, UiEventType, UiFinder}, }; const PAUSE_ID: &str = "pause"; const...
true
79aa7a3e67127c3ffe5b8d44ce82b18d49cff4bd
Rust
emctague/comma
/src/lib.rs
UTF-8
2,975
4.03125
4
[]
no_license
//! `comma` parses command-line-style strings. See [`parse_command`] for details. use std::iter::Peekable; use std::str::Chars; fn parse_escape(ch: char, chars: &mut Peekable<Chars>) -> Option<char> { Some(match ch { '\\' => match chars.next()? { 'n' => '\n', 'r' => '\r', ...
true
3e42385105639aa4d4fb5aac619af4891aec599a
Rust
tikhono/CryptoHackPals
/pals/set2/_12_byte_at_a_time_ecb_decryption_simple/src/lib.rs
UTF-8
2,257
2.8125
3
[]
no_license
#[macro_use] extern crate lazy_static; use ascii::IntoAsciiString; use openssl::symm::{encrypt, Cipher}; use std::io; use std::io::Write; use std::sync::RwLock; lazy_static! { static ref KEY: RwLock<[u8; 16]> = RwLock::new([0u8; 16]); } pub fn get_cipher_text(plaintext: String) -> String { let cipher = Ciphe...
true
561079ebe0b8b5c05aa4700a57cb6f15598e291a
Rust
tari/warcdedupe
/warcio/src/header/fieldkind.rs
UTF-8
8,949
2.890625
3
[ "BSD-3-Clause" ]
permissive
use uncased::UncasedStr; use crate::FieldName; /// Standardized values for [field names](FieldName). #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum FieldKind { /// `WARC-Record-ID`: a globally unique identifier for a record. /// /// This field is mandatory and must be present in a standards-complia...
true
f4602f85a15a17b8a9296708f31ae9dc47fdc9db
Rust
local-group/acitx-simple-http-server
/actix-shs-cli/src/args.rs
UTF-8
8,560
2.5625
3
[ "MIT" ]
permissive
use clap; use std::fs; use std::net::IpAddr; use std::path::PathBuf; use std::env; use std::error::Error; use std::str::FromStr; #[derive(Debug)] pub struct Args { pub root: PathBuf, pub index: bool, pub upload: bool, pub sort: bool, pub cache: bool, pub range: bool, pub cert: Option<Strin...
true
bf59bd0cb963f420119e68714d995c62fb9e5adf
Rust
emergent/rust-atc-solution
/abc126/b.rs
UTF-8
860
3.421875
3
[]
no_license
fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() } #[allo...
true
dff8ed5e5864bc235ecfa623504b5b4d6d868360
Rust
chriscoomber/pinboard
/src/lib.rs
UTF-8
4,463
3.53125
4
[ "MIT" ]
permissive
#![warn(missing_docs)] //! A `Pinboard` is a shared, mutable, eventually consistent, lock-free data-structure. This //! allows multiple threads to communicate in a decoupled way by publishing data to the pinboard //! which other threads can then read in an eventually consistent way. //! //! This is not a silver bulle...
true
effd63d177c46e18175002b2c602b028f35842d8
Rust
zyxw59/subway_map.rs-old
/src/stop.rs
UTF-8
3,079
2.84375
3
[ "MIT" ]
permissive
use std::cmp::Ordering; use std::error::Error; use std::io::prelude::*; use errors; use ast::{LabelPos, Variables}; use math::{Line, Point}; use route::Segment; #[derive(Clone, Debug)] pub enum Stop { Line(Segment, Line, LabelPos, String), Segment(Segment, Segment, LabelPos, LabelPos, String), } impl Stop {...
true
a8788452baf2857d84ae29a1a5bec36c5d12c471
Rust
NeoLegends/FoSAP
/H13-first-longest-match/src/lib.rs
UTF-8
3,645
3.5
4
[]
no_license
//! An excersise regarding the evaluation of multiple regexes at the same time. use std::char as ch; use std::collections::HashSet; mod dfa; pub use dfa::*; /// Simulates the DFA from the exercise with the given RegEx / Token /// combo and some input string. pub fn simulate(reg_exs: &[(&str, &str)], input: &str) ->...
true
aa289654cc4409d3399d5f26f36be753eb6a8aa0
Rust
mendelt/clicker
/src/main.rs
UTF-8
993
2.75
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
mod deploy; mod manifest; mod manifest_toml; use crate::deploy::deploy; use crate::manifest_toml::parse_manifest_file; use clap::App; use clap::Arg; use clap::ArgMatches; use failure::Error; use std::path::Path; fn main() -> Result<(), Error> { let matches = App::new("Clicker: File and directory templater") ...
true
3fea4e19e42afb66b449b098a96dc3efee7e1484
Rust
haze/dawn
/command-parser/src/parser.rs
UTF-8
7,535
3.75
4
[ "ISC" ]
permissive
use crate::{Arguments, Config}; /// Indicator that a command was used. #[derive(Clone, Debug)] pub struct Command<'a> { /// A lazy iterator of command arguments. Refer to its documentation on /// how to use it. pub arguments: Arguments<'a>, /// The name of the command that was called. pub name: &'a...
true
736f6c81fc7e02652c62ac360f85ac5fb9f1a9f9
Rust
prisma/prisma-engines
/quaint/src/tests/types/mssql/bigdecimal.rs
UTF-8
5,184
2.59375
3
[ "Apache-2.0" ]
permissive
use super::*; use crate::bigdecimal::BigDecimal; use std::str::FromStr; #[cfg(feature = "bigdecimal")] test_type!(numeric( mssql, "numeric(10,2)", Value::Numeric(None), Value::numeric(BigDecimal::from_str("3.14")?) )); test_type!(numeric_10_2( mssql, "numeric(10,2)", ( Value::numer...
true
7eae1f275b5531e1f30080167bd64acec23476eb
Rust
ParkinWu/search_tree
/src/main.rs
UTF-8
6,786
3.078125
3
[ "MIT" ]
permissive
use std::ptr::null_mut; use std::mem; use std::marker::PhantomData; use std::fmt::{ Debug, Formatter}; type Link<T> = Option<Box<Node<T>>>; #[derive(Debug)] struct Raw<T> { ptr: *const Node<T>, } impl<T> Raw<T> { fn none() -> Self { Raw { ptr: null_mut() } } fn some(ptr: &mut Node<T>) -> Self ...
true
07198d6848ee9f951d79818ba27d4aac6873a42f
Rust
tolumide-ng/coding-challenge
/data_structures/src/queues_stacks/valid_parentheses.rs
UTF-8
2,164
3.515625
4
[]
no_license
pub fn is_valid(s: String) -> bool { let all_str: Vec<&str> = s.split("").collect(); let mut stack = vec![]; if s.len() > 0 && s.len() % 2 == 0 { for x in all_str { if x.len() > 0 { if *&["}", "]", ")"].contains(&x) && stack.is_empty() { return false;...
true
937740755ee5ed5ed850778bac0f1a7679d341a0
Rust
wear/jiraify
/src/main.rs
UTF-8
2,416
2.5625
3
[]
no_license
mod credential; mod issue_controller; pub use crate::credential::{BaseAuthCredential}; pub use crate::issue_controller::JiraIssue; extern crate clap; use clap::{Arg, App}; use std::io; fn main() { const JIRACONFIG: &str = "jira-conf"; const GITHUBCONFIG: &str = "github-conf"; let mut jira_config: BaseA...
true
7df3f48c1af44dc8cbf4627d459b29cbee363bdb
Rust
kohbis/leetcode
/algorithms/1984.minimum-difference-between-highest-and-lowest-of-k-scores/solution.rs
UTF-8
345
3.125
3
[]
no_license
use std::cmp::min; impl Solution { pub fn minimum_difference(nums: Vec<i32>, k: i32) -> i32 { let k = k as usize; let mut nums = nums; nums.sort_unstable(); let mut res = i32::MAX; for i in (k - 1)..nums.len() { res = min(res, nums[i] - nums[i - k + 1]); ...
true
8f87ef21ad61072d774b351e21e7cc840c564438
Rust
coilhq/interledger-relay
/crates/interledger-relay/src/services/from_peer.rs
UTF-8
6,294
2.640625
3
[ "Apache-2.0" ]
permissive
use std::collections::HashSet; use std::sync::Arc; use futures::future::{Either, Ready, err}; use log::error; use crate::{AuthToken, Relation, Service}; use crate::{RequestFromPeer, RequestWithHeaders}; /// Use the incoming `Authorization` header to tag requests with their peer's /// address. #[derive(Clone, Debug)]...
true
388fadec3804f725471f3e24596693553e039c8e
Rust
psyomn/wasteland
/src/static_data.rs
UTF-8
556
2.796875
3
[]
no_license
/* Static literals that are true in ALL environments of the game. * Apart from literals, you can add functions in here that would facilitate your mortal life. * For example you can have functions for printing out using println! macro different tidbits * of the story. If you plan to use another library such as ncurse...
true
e5468d05fb2d2f3a451c20ac636f6e3e66bb2b53
Rust
cafeclimber/GadgetNES
/src/nes.rs
UTF-8
2,059
2.5625
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::time::Duration; use super::cart::Cartridge; use super::cpu::Cpu; use super::interconnect::Interconnect; use super::screen::Screen; use super::sdl2::event::Event; use super::sdl2::keyboard::Keycode; use super::sdl2::Sdl; pub const KILOBYTE: usize = 1024; // Fields are public f...
true
d5e5ed612cd930080d077c485ab8901c4ae87e57
Rust
camallo/k8s-client-rs
/src/kubeconfig.rs
UTF-8
4,177
2.578125
3
[]
no_license
//! Types and helpers for `kubeconfig` parsing. use std::{env, path}; use super::errors::*; /// Configuration to build a Kubernetes client. #[derive(Debug, Serialize, Deserialize)] pub struct KubeConfig { pub kind: Option<String>, #[serde(rename = "apiVersion")] pub api_version: Option<String>, pub pr...
true
81c2f0c04b5d5b08857106dd1f478314ec10c0c1
Rust
Vawheter/clink_mpc
/src/gadgets/merkletree/cbmt_constraints.rs
UTF-8
8,804
2.5625
3
[ "Apache-2.0", "MIT" ]
permissive
//! Complete Binary Merkle Tree Proof gadgets. use math::PrimeField; use scheme::r1cs::Variable; use scheme::r1cs::{ConstraintSystem, SynthesisError}; use crate::Vec; use super::super::abstract_hash::{AbstractHash, AbstractHashOutput}; use super::cbmt::TreeIndex; pub struct MerkleProofGadget<I: TreeIndex, F: PrimeF...
true
94c3fa6901d2eb90004c4a0befd1c737475328e7
Rust
bbatha/advent2017
/day6/src/main.rs
UTF-8
1,087
3.109375
3
[]
no_license
use std::str::FromStr; fn redistribute(state: &mut [u8]) { let (mut i, bank) = state.iter() .cloned() .enumerate() .max_by_key(|&(i, val)| (val, -(i as isize))) // use index to break ties .unwrap(); state[i] = 0; for _ in (0..bank).rev() { if i < state.len() - 1 { ...
true
22642b5cc847678c791422c0aa0f168b1d968d3e
Rust
darkskygit/creak
/src/decoder/mp3.rs
UTF-8
4,524
2.75
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::*; use minimp3::{Decoder as Mp3Reader, Error as Mp3Error, Frame}; pub struct Mp3Decoder<R> { reader: Mp3Reader<R>, first_frame: Frame, sample_rate: u32, channels: usize, } impl<R: Read> Mp3Decoder<R> { #[inline] pub fn open<P: AsRef<Path>>(path: P) -> Result<Mp3Decoder<File>, Decode...
true
6d78a9e3114e11264854fbe42da88c3fc97d65c5
Rust
HichuYamichu/advent
/src/solutions/y2020/day07.rs
UTF-8
2,284
3.328125
3
[]
no_license
use std::collections::HashMap; type Rule = String; pub fn a(input: String) -> String { let mut rules: HashMap<Rule, Vec<Rule>> = HashMap::new(); let lines = input .lines() .map(|l| l.replace(" bags", "").replace(" bag", "").replace(".", "")); for l in lines { let mut parts = l.spl...
true
cb91c9bc3341a618f0823ed0385b23eca6691f04
Rust
wladwm/surge-ping
/examples/simple.rs
UTF-8
1,863
2.703125
3
[ "MIT" ]
permissive
#[macro_use] extern crate log; extern crate pretty_env_logger; use std::time::Duration; use structopt::StructOpt; use surge_ping::Pinger; #[derive(StructOpt, Debug)] #[structopt(name = "surge-ping")] struct Opt { #[structopt(short = "h", long)] host: String, /// Wait wait milliseconds between sending ea...
true
136773805eae16f37b129994ab995222f9e5f18c
Rust
Kirottu/weather-statusbar
/src/main.rs
UTF-8
2,724
2.890625
3
[]
no_license
use clap::{App, Arg}; use serde_json::Value; #[tokio::main] async fn main() { let matches = App::new("weather-statusbar") .about("Weather info for use in a statusbar") .arg( Arg::with_name("amount") .short("n") .long("amount") .help("Set t...
true
dc629a9e04b108a1b6b3b7131f3e57e7c3bf0177
Rust
rachlmac/sos-kernel
/alloc/src/bump_ptr.rs
UTF-8
1,519
2.765625
3
[ "MIT", "Apache-2.0" ]
permissive
// // SOS: the Stupid Operating System // by Eliza Weisman (hi@hawkweisman.me) // // Copyright (c) 2015-2017 Eliza Weisman // Released under the terms of the MIT license. See `LICENSE` in the root // directory of this repository for more information. // use memory::{Addr, PAddr}; use super::{Address, Allocator, A...
true
8c9f03d1f73c38ab8849e8e8da5c56be63a629bc
Rust
gregoryquick/rust_graphics
/src/render/buffer.rs
UTF-8
3,200
2.90625
3
[]
no_license
use crate::state; use wgpu::util::{BufferInitDescriptor, DeviceExt}; pub const U32_SIZE: wgpu::BufferAddress = std::mem::size_of::<u32>() as wgpu::BufferAddress; #[derive(Copy, Clone)] pub struct Vertex { #[allow(dead_code)] pub position: cgmath::Vector4<f32>, } unsafe impl bytemuck::Pod for Vertex {} unsaf...
true
b78988f833ed94281ccee957df64283677b3c32e
Rust
zer0x64/nsec-2021-nestadia
/nestadia-gui/src/main.rs
UTF-8
1,622
2.5625
3
[ "Apache-2.0", "MIT" ]
permissive
use std::error::Error; use std::path::PathBuf; use structopt::StructOpt; #[cfg(feature = "debugger")] use iced::{Application, Settings}; use nestadia_core::Emulator; mod rgb_value_table; mod sdl_window; #[cfg(feature = "debugger")] mod debugger_window; const NES_WIDTH: u32 = 256; const NES_HEIGHT: u32 = 240; pub(...
true
5488ef60b48c8657c3e642151d474dd16058c257
Rust
troublescooter/statrs
/src/distribution/negative_binomial.rs
UTF-8
14,381
3.3125
3
[ "MIT" ]
permissive
use crate::distribution::{self, poisson, Discrete, Univariate}; use crate::function::{beta, gamma}; use crate::statistics::*; use crate::{Result, StatsError}; use rand::distributions::Distribution; use rand::Rng; use std::f64; /// Implements the /// [NegativeBinomial](http://en.wikipedia.org/wiki/Negative_binomial_dis...
true