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
f8c305611dc91d448204e1ebec3d28be9b19aa9d
Rust
FluenTech/embedded-time
/tests/fraction.rs
UTF-8
2,515
3.421875
3
[ "MIT", "Apache-2.0" ]
permissive
use embedded_time::fraction::Fraction; use embedded_time::ConversionError; use test_case::test_case; #[test_case((6, 3) => Ok((2,1)) ; "Reduce the fraction if possible")] #[test_case((6, 0) => Err(ConversionError::DivByZero) ; "A denominator of 0 will fail")] fn new_reduce(fraction: (u32, u32)) -> Result<(u32, u32), C...
true
f43655f1df1e6b21315ccc0d580bad5dd175f1b1
Rust
hydro-project/hydroflow
/hydroflow/src/util/clear.rs
UTF-8
1,452
3.46875
3
[ "Apache-2.0" ]
permissive
//! Module for the [`Clear`] trait. use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque}; use std::ffi::OsString; /// A trait for abstracting over the `.clear()` method available in many /// collection types. pub trait Clear { /// Clears the collection without neccesarily...
true
448334018fcc07fb10984e0c6a7a309b97b23321
Rust
zRedShift/aoc-2018
/aoc02/src/main.rs
UTF-8
1,309
3.3125
3
[]
no_license
use std::collections::HashSet; use std::fs::File; use std::io::{Error, Read}; use std::path::Path; fn parse_input(path: &Path) -> Result<String, Error> { let mut s = String::new(); File::open(path)?.read_to_string(&mut s)?; Ok(s) } fn part_one(s: &str) -> i32 { let (mut two, mut three) = (0, 0); ...
true
689e0e76a43755de4820bd25cb04e94d8f66bd25
Rust
jarkkom/adventofcode-2020
/src/06/part1.rs
UTF-8
2,473
3.453125
3
[]
no_license
use std::collections::HashSet; use std::env; use std::fs::File; use std::io; use std::io::BufRead; use std::io::BufReader; use std::io::Read; use std::path::Path; fn open_input(filename: &str) -> io::Result<File> { let path = Path::new(filename); File::open(path) } fn read_input(reader: impl Read) -> Result<V...
true
831a53f79aa6d1d815fe40f06e6098d240358f98
Rust
XMPPwocky/rust-protobuf
/src/lib/clear.rs
UTF-8
194
2.953125
3
[ "BSD-2-Clause" ]
permissive
/// anything that can be cleared pub trait Clear { fn clear(&mut self) { fail!("TODO"); } } impl<T> Clear for Option<T> { fn clear(&mut self) { self.take(); } }
true
bc6fae7adda694504e1f78d22a9517564cdadc17
Rust
mich101mich/aoc-2018
/src/days/day_12.rs
UTF-8
2,700
3.015625
3
[]
no_license
use crate::utils::*; fn calc_score(state: &[bool], num_iter: usize, padding: usize) -> isize { state .iter() .enumerate() .map(|(i, b)| (i as isize - (num_iter * padding) as isize, b)) .filter(|(_, b)| **b) .map(|(i, _)| i) .sum::<isize>() } #[allow(unused)] pub fn ...
true
3a92ddb007a063f27f01ed1ef30b25580795878e
Rust
malleusinferni/forfeiture
/src/lib.rs
UTF-8
1,095
3
3
[]
no_license
extern crate rayon_core; use std::fmt::Debug; use std::hash::Hash; //use std::sync::Arc; #[derive(Copy, Clone, Debug)] pub struct Error; pub type Result<T, E=Error> = std::result::Result<T, E>; pub trait Id: 'static + Clone + Debug + Eq + Hash { type Target: Asset; fn load(self) -> Result<Self::Target>; } ...
true
ec669a859806cd2fd7855d16af22ed4568f28254
Rust
marony/raft-on-rust
/src/main.rs
UTF-8
2,446
2.84375
3
[]
no_license
use std::env; use std::{thread, time}; use std::sync::{Arc, RwLock}; #[macro_use] extern crate log; extern crate env_logger; extern crate bincode; extern crate rustc_serialize; mod raft; // RUST_BACKTRACE=1 RUST_LOG=raft_rust=debug cargo run 1000 0 127.0.0.1:8080 127.0.0.1:8081 127.0.0.1:8082 // ノード分のプロセスを起動する // 自分...
true
b75745294378080c48d3e307ad9152a6735a6759
Rust
cyh2020/rust-raytracer
/src/materials/metal.rs
UTF-8
1,085
3.046875
3
[ "MIT" ]
permissive
use structures::vec3::Vec3; use structures::ray::Ray; use objects::HitRecord; use super::Scatterable; use super::lambertian::point_in_unit_sphere; #[derive(Clone, Copy, Debug)] pub struct Metal { albedo: Vec3, fuzz: f64, } impl Metal { pub fn new(albedo: Vec3, fuzz: f64) -> Metal { ...
true
e12951de197c386e05bf04fbbf6cb4b623727cf4
Rust
jonlil/loopia-cli
/src/util.rs
UTF-8
1,209
2.6875
3
[]
no_license
use clap::Arg; pub fn format_argument<'a, 'b>() -> Arg<'a, 'b> { Arg::with_name("format") .long("format") .default_value("json") .takes_value(true) } pub fn id_argument<'a, 'b>() -> Arg<'a, 'b> { Arg::with_name("id") .long("id") .takes_value(true) .required(true...
true
a3e5ae19ae6fb97c2b15f20255267fa0752c5c41
Rust
FyroxEngine/Fyrox
/editor/src/command/mod.rs
UTF-8
4,323
2.515625
3
[ "MIT" ]
permissive
use crate::scene::commands::SceneContext; use std::fmt::Debug; pub mod panel; pub mod universal; #[macro_export] macro_rules! define_command_stack { ($command_trait:ident, $command_stack:ident, $context:ty) => { pub trait $command_trait: Debug + 'static { fn name(&mut self, context: &$context)...
true
accdcc8a2fbe178535b98b854ec20bd88791b1f8
Rust
Enet4/dicom-rs
/pixeldata/src/transform.rs
UTF-8
8,023
3.375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! Private module for pixel sample value transformation functions. use snafu::Snafu; /// Description of a modality rescale function, /// defined by a _rescale slope_ and _rescale intercept_. #[derive(Debug, Copy, Clone, PartialEq)] pub struct Rescale { /// the rescale slope pub slope: f64, /// the rescal...
true
2049f1ddbcb26c918ecb3d3582793eb6f857a1f1
Rust
pavel1269/advent-of-code
/2020/src/day04.rs
UTF-8
8,794
3.109375
3
[]
no_license
use std::collections::HashMap; pub fn get_solution_part1() -> i64 { let input = get_challenge_input(); let passports = parse_input(input); let result = filter_valid_passports_fields(passports).len(); return result as i64; } pub fn get_solution_part2() -> i64 { let input = get_challenge_input(); ...
true
3bda3a95e03c75925e8a7c9418854ddcad828e74
Rust
Jafagervik/TDT4195
/cg2/src/main.rs
UTF-8
17,332
2.8125
3
[]
no_license
extern crate nalgebra_glm as glm; use std::fs::File; use std::io::Read; use std::sync::{Arc, Mutex, RwLock}; use std::thread; use std::{mem, os::raw::c_void, ptr}; mod shader; mod util; use glutin::event::{ DeviceEvent, ElementState::{Pressed, Released}, Event, KeyboardInput, VirtualKeyCode::{self, *}...
true
3c3c1ff1be4182a4697f3bc044c7175d68d71752
Rust
atouchet/boa
/boa/src/syntax/parser/expression/primary/function_expression/mod.rs
UTF-8
3,089
3.03125
3
[ "Unlicense", "MIT" ]
permissive
//! Function expression parsing. //! //! More information: //! - [MDN documentation][mdn] //! - [ECMAScript specification][spec] //! //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function //! [spec]: https://tc39.es/ecma262/#prod-FunctionExpression #[cfg(test)] mod tests; us...
true
633993dd033360e12eba972af887113b35f8fc92
Rust
suomesta/rust_samples
/020_tuple/main.rs
UTF-8
102
2.625
3
[]
no_license
fn main() { let t:(bool, i32, f64) = (true, 5, 1.5); println!("{} {} {}", t.0, t.1, t.2); }
true
9ee06bc1e47c8d29189ac6b9ea43ee11a3f4bd54
Rust
sashaweiss/itree
/src/term.rs
UTF-8
2,253
2.8125
3
[ "MIT" ]
permissive
use std::io; use termion; use termion::clear::All; use termion::cursor::{Goto, Hide, Show}; use termion::event::Key; use termion::input::TermRead; use termion::raw::IntoRawMode; use termion::screen::{ToAlternateScreen, ToMainScreen}; use render::TreeRender; fn clear() { print!("{}", All); print!("{}", Goto(1...
true
6f4d84d9e741828d747451c92790c14ba75c48de
Rust
mesalock-linux/crates-io
/vendor/stdweb/src/webapi/html_elements/option.rs
UTF-8
1,646
3.15625
3
[ "Apache-2.0", "Unlicense", "BSD-3-Clause", "0BSD", "MIT", "CC-BY-SA-3.0" ]
permissive
use webapi::element::{Element, IElement}; use webapi::event_target::{EventTarget, IEventTarget}; use webapi::html_element::{HtmlElement, IHtmlElement}; use webapi::node::{INode, Node}; use webcore::try_from::TryInto; use webcore::value::Reference; /// The HTML `<option>` element is used to define an item contained in ...
true
a8382ac439f5c2721b7286aff93341cc26626924
Rust
MwlLj/rust-tools
/cmakelists_manager/cmake_depencies/src/parse/git_librarys.rs
UTF-8
2,784
2.71875
3
[]
no_license
/* ** parse format: ** git_lib { name = awnet_client, version = 0.2.1, platform = ${FILE_PREFIX}, extra = '' } */ use super::object; const keyword_name: &str = "name"; const keyword_version: &str = "version"; const keyword_subs: &str = "subs"; const keyword_enable: &str = "enable"; const keyword_include_enable: &str =...
true
c00e34cb1344ff499f7055511208ce169e1e11fc
Rust
qeedquan/challenges
/leetcode/reverse-bits.rs
UTF-8
575
3.609375
4
[ "MIT" ]
permissive
// Reverse bits of a given 32 bits unsigned integer. fn main() { println!("{:032b}", reverse_bits(0b00000010100101000001111010011100)); println!("{:032b}", reverse_bits(0b11111111111111111111111111111101)); } fn reverse_bits(x: u32) -> u32 { let mut v = x; v = ((v >> 1) & 0x55555555) | ((v & 0x5555555...
true
4244400be2a51df1e6b6b930a92763ae8fc88dbf
Rust
zesterer/pollster
/src/lib.rs
UTF-8
4,752
3.140625
3
[ "Apache-2.0", "MIT" ]
permissive
#![doc = include_str!("../README.md")] #![cfg_attr(docsrs, feature(doc_auto_cfg))] use std::{ future::Future, sync::{Arc, Condvar, Mutex}, task::{Context, Poll, Wake, Waker}, }; #[cfg(feature = "macro")] pub use pollster_macro::{main, test}; /// An extension trait that allows blocking on a future in suff...
true
7eda530002b5b905672db2e2b551a9f802c00d69
Rust
mcarton/strfmt
/src/lib.rs
UTF-8
1,276
2.875
3
[ "MIT" ]
permissive
//! strfmt crate use std::fmt; use std::fmt::Write; use std::collections::HashMap; use std::string::String; #[cfg(test)] mod tests; mod types; mod formatter; mod fmtstr; mod fmtf64; mod fmti64; pub use types::{Result, FmtError, Alignment, Sign}; pub use fmtstr::strfmt_map; pub use formatter::Formatter; /// rust-st...
true
5db5dec3d9df925caadd17e249c31619baddcc19
Rust
iqlusioninc/usbarmory.rs
/firmware/examples/examples/stack-overflow.rs
UTF-8
1,249
3.296875
3
[ "Apache-2.0", "MIT" ]
permissive
//! A program that produces a stack overflow //! //! There's stack overflow protection installed so this won't cause undefined //! behavior. Stack overflows will trigger a "data abort" (hardware) exception. //! //! Expected output (output may not match exactly due to optimization //! differences between compiler versio...
true
5d1f76e96c0b7ccaac036d4b667164a091db3adb
Rust
nickelc/modio-rs
/src/types/mods.rs
UTF-8
20,088
2.578125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::collections::HashMap; use std::fmt; use serde::de::{Deserializer, IgnoredAny, MapAccess, Visitor}; use serde::Deserialize; use url::Url; use super::files::File; use super::{deserialize_empty_object, DeserializeField, MissingField, TargetPlatform}; use super::{Logo, Status, User}; /// See the [Mod Object](ht...
true
15c09aa9a258cf97dc9f47be3b6157d9c3ac3ddb
Rust
psiphi75/psiphi75.github.io
/RustIntroduction-part-III/async-learn/src/thread.rs
UTF-8
320
3.078125
3
[]
no_license
use std::thread; use std::time::Duration; fn main() { let handle = thread::spawn(|| { println!("hi from the spawned thread!"); thread::sleep(Duration::from_millis(1)); println!("hi again from the spawned thread!"); }); // Wait for the thread to finish handle.join().unwrap(); }
true
9c46e05681a34e83cade2fd52700324514d9fed8
Rust
Axect/NMC2020
/chap1/Rust/src/bin/02_saxpy.rs
UTF-8
335
3.5625
4
[]
no_license
use std::ops::{Add, Mul}; fn main() { let x = vec![1,2,3]; let mut y = vec![4,5,6]; saxpy(2, &x, &mut y); println!("{:?}", y); } fn saxpy<T: Add<Output=T> + Mul<Output=T> + Copy>(a: T, x: &Vec<T>, y: &mut Vec<T>) { assert_eq!(x.len(), y.len()); for i in 0 .. y.len() { y[i] = y[i] + a *...
true
77dc96a39984325b2ff1d096d04006dba28e793e
Rust
mbrobbel/advent-of-code
/2019/day3/src/main.rs
UTF-8
4,338
3.640625
4
[ "Unlicense" ]
permissive
use std::{collections::HashSet, error::Error, io::Read, str::FromStr}; enum Direction { Right, Left, Down, Up, } struct Move { direction: Direction, distance: usize, } impl FromStr for Move { type Err = std::num::ParseIntError; fn from_str(s: &str) -> Result<Self, Self::Err> { ...
true
8b9736824b0bf9dca24c6d403e5419fe4da8c8e6
Rust
sile/succ
/src/bitwise/string.rs
UTF-8
8,521
2.921875
3
[ "MIT" ]
permissive
use std::mem; use std::fmt; use std::iter; use super::Bit; use super::Rank; use super::Index; use super::fixnum::Fixnum; use super::fixnum::FixnumLike; use super::ops; use super::ops::{RankBit, SelectZero, SelectOne, PredZero, PredOne, SuccZero, SuccOne}; #[derive(Debug, Clone)] pub struct BitString<N = u64> { fi...
true
a76ea54a5e54370dfc34407a96623a1dea3270e8
Rust
fspmarshall/tokio-util
/src/never.rs
UTF-8
2,120
3.46875
3
[]
no_license
use tokio::prelude::*; use std::{fmt,error}; /// I swear, this never happens. /// #[derive(Hash,Debug,Copy,Clone,PartialEq,Eq,PartialOrd,Ord)] pub enum Never { } /// Implement `From<Never>` against a locally defined type. /// /// This is especially helpful for dealing with APIs such as `Result<..,Never>` /// or `F...
true
7284bcdb4b15902a868a90340406649d1252861d
Rust
zmack/mogilefsd-rs
/src/tracker/threaded.rs
UTF-8
1,922
2.84375
3
[]
no_license
use std::io::{self, Write, BufRead, BufReader}; use std::net::{TcpListener, TcpStream, ToSocketAddrs}; use std::sync::Arc; use std::thread; #[allow(unused_imports)] use super::{Tracker, Request, Response}; pub struct ThreadedListener { listener: TcpListener, tracker: Arc<Tracker>, } impl ThreadedListener { ...
true
646df0147cbb0d74dde3d55e6da6b80018cebfef
Rust
gtgsantos/soldank
/gfx2d/src/context/pipeline.rs
UTF-8
2,864
2.5625
3
[ "MIT" ]
permissive
use super::*; // main rendering pipeline pub const VERT_SOURCE: &[u8] = b" #version 120 uniform mat3 transform; attribute vec2 in_pos; attribute vec2 in_texcoords; attribute vec4 in_color; varying vec2 texcoords; varying vec4 color; void main() { color = vec4(in_color.rgb * in...
true
cfa651ab278f2e5bc4ddc60246c230fcf662ed2f
Rust
tomtau/tendermint-rs
/tendermint/src/rpc/client.rs
UTF-8
5,988
2.65625
3
[ "Apache-2.0" ]
permissive
//! Tendermint RPC client use crate::{ abci::{self, Transaction}, block::Height, net, rpc::{self, endpoint::*, Error, Response}, Genesis, }; use hyper::header; use std::io::Read; /// Tendermint RPC client. /// /// Presently supports JSONRPC via HTTP. pub struct Client { /// Address of the RPC ...
true
3e7e227cdd6a453add7f572b70c2d360aa36c5a6
Rust
rodrimati1992/structural_crates
/structural/src/field/variant_field.rs
UTF-8
27,542
3.453125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
/// Provides shared access to an enum variant field. /// /// The `V` and `F` type parameters are expected to be [TStr](../struct.TStr.html). /// /// Every instance of "the `F` field"/"the `V` variant" in the docs mean /// "in the field/variant named by the `F`/`V` type parameter" /// /// # Safety /// /// `IsVariant<V>`...
true
feb68ce99bbedb350075b211172f49cb71436507
Rust
jonayerdi/aoc2018
/src/bin/day3p2.rs
UTF-8
4,497
3.0625
3
[]
no_license
use std::fs::File; use std::io::{self, Read}; use std::path::PathBuf; enum Cell { Empty, Claimed(usize), Overlap(Vec<usize>), } impl std::fmt::Display for Cell { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { Cell::Empty => write!(f, "."), ...
true
61f9831d0a2f1f38421388735532d0085aeacbf6
Rust
konamilk/atcoder-abc175
/src/bin/a.rs
UTF-8
337
2.890625
3
[]
no_license
use proconio::input; #[allow(unused_imports)] use proconio::marker::{Chars, Bytes}; fn main() { input! { s: String } let mut ans = 0; if s.contains("RRR") { ans = 3 } else if s.contains("RR"){ ans = 2 } else if s.contains("R"){ ans = 1 } printl...
true
d166e79fbc4a6be2e11e8468d3cea68054a66d1d
Rust
bytebuddha/xrl
/src/api/render.rs
UTF-8
438
2.59375
3
[ "MIT" ]
permissive
use crate::protocol::StyleDef; /// A Reference to a line in the line cache. #[derive(Debug, PartialEq)] pub struct LineRef<'a> { pub text: &'a str, pub styles: Vec<StyleDef>, pub cursor: &'a [u64], pub line_num: Option<u64>, } /// A Reference to a single character in a line in the line cache. #[derive...
true
b7b1350ba63c94e3ad771d792857838dc591fe57
Rust
BenoitZugmeyer/Exegesis
/src/bin/exegesis.rs
UTF-8
3,332
2.984375
3
[]
no_license
#![feature(question_mark)] extern crate clap; extern crate toml; extern crate exegesis; extern crate hyper; extern crate serde; use clap::{App, Arg}; use std::fs; use std::io; use std::io::{Read, Write}; use std::fmt::Write as FmtWrite; use std::path::Path; use std::process; use exegesis::{Website, HtmlFormatter, Rule...
true
dace57d7f49f2ff892e1340d030c5b2972cf0f0a
Rust
idunn-network/idunn-dht
/src/kbucket.rs
UTF-8
5,662
3.078125
3
[]
no_license
//this is warning is seriously annoying while trying to develop code #![allow(dead_code)] #![allow(unused_variables)] //use std::sync::Arc; use std::fmt; use std::rc::Rc; use std::cell::RefCell; use std::collections::BTreeMap; use nodeid::NodeId; const K: usize = 5; pub struct NodeInfo { nodeid: NodeId, pr...
true
b11aaf7b14b65a08085c7ee705f73dca8b9b9502
Rust
Noah2610/LD45-WorkingTitle
/src/systems/helpers.rs
UTF-8
3,417
2.546875
3
[ "MIT" ]
permissive
use std::ops::Deref; use amethyst::ecs::storage::{MaskedStorage, Storage}; use deathframe::components::solid::SolidTag as _; use super::system_prelude::*; use crate::level_manager::Level; use crate::savefile_data::SavefileData; use crate::solid_tag::SolidTag; // Copied from LD44 #[derive(Default, Clone, Debug)] pub ...
true
c697b7acdf1b2e3f82edcedd68b592bc9eddbe69
Rust
cartoon-raccoon/verdigris
/vdg-oxidizer/src/assembler/lexer.rs
UTF-8
16,833
3.21875
3
[ "MIT" ]
permissive
//! The lexical analyser for Verdigris assembly code. //! //! The Lexer struct only converts the raw assembly text into a token stream. //! This token stream is then passed down to the Parser struct, which then //! parses the tokens into discrete instructions. use std::iter::Peekable; use std::str::Chars; use std::fm...
true
13c04216553ac4fcf86b56ce28e2dddfd1a10034
Rust
Kerollmops/slice-group-by
/src/linear_str_group/linear_str_group_by_key.rs
UTF-8
4,156
3.109375
3
[ "MIT" ]
permissive
use std::mem; use super::{str_as_ptr, str_as_mut_ptr, str_from_raw_parts, str_from_raw_parts_mut}; macro_rules! str_group_by_key { (struct $name:ident, $elem:ty, $as_ptr:ident, $as_str:ident) => { impl<'a, F> $name<'a, F> { #[inline] pub fn as_str(&self) -> &str { se...
true
a0946601c737dee8461cd570d2fb11be1e4e698c
Rust
cgc/rnd
/ray-tracer-challenge/src/linalg/transformations.rs
UTF-8
2,451
3.046875
3
[]
no_license
use crate::matrices::*; use crate::tuples::*; pub const PI: f64 = std::f64::consts::PI; impl Matrix { pub fn translate(&self, x: f64, y: f64, z: f64) -> Matrix { translation(x, y, z) * *self } pub fn scale(&self, x: f64, y: f64, z: f64) -> Matrix { scaling(x, y, z) * *self } pub fn rotate_x(&self, rad: f6...
true
4df52eaa0103f2efc126b0393e747d378853663b
Rust
Xephobia/doinghisjob
/src/commands/ping.rs
UTF-8
1,158
2.515625
3
[ "Unlicense" ]
permissive
use anyhow::anyhow; use serenity::{ client::bridge::gateway::{ShardId, ShardManager}, framework::standard::{macros::command, CommandResult}, model::prelude::*, prelude::*, }; use std::sync::Arc; pub struct ShardManagerContainer; impl TypeMapKey for ShardManagerContainer { type Value = Arc<Mutex<Sh...
true
900bffafb9f01e70f3afbc3890f15c1cc3b1d822
Rust
loganyu/leetcode
/problems/258_add_digits.rs
UTF-8
786
3.484375
3
[]
no_license
/* Given an integer num, repeatedly add all its digits until the result has only one digit, and return it. Example 1: Input: num = 38 Output: 2 Explanation: The process is 38 --> 3 + 8 --> 11 11 --> 1 + 1 --> 2 Since 2 has only one digit, return it. Example 2: Input: num = 0 Output: 0 Constraints: 0 <= num <...
true
d1590d9dcb4d1bda07a3c9871c362b81a3915166
Rust
JPRoland/tetrs
/src/tetromino.rs
UTF-8
7,182
2.890625
3
[]
no_license
pub type Piece = Vec<Vec<u8>>; pub type States = Vec<Piece>; pub trait TetrominoGenerator { fn new() -> Tetromino; } pub struct Tetromino { pub states: States, pub x: isize, pub y: usize, pub current_state: u8, } pub struct TetrominoI; impl TetrominoGenerator for TetrominoI { fn new() -> Tet...
true
110c917a360dad3ad6407091193e1e4fc4c2aaee
Rust
mfkiwl/crochet
/examples/async.rs
UTF-8
1,541
2.9375
3
[ "Apache-2.0" ]
permissive
//! A very simple async example. use druid::{AppLauncher, PlatformError, Widget, WindowDesc}; use crochet::{AppHolder, Button, Column, Cx, DruidAppData, Label}; fn main() -> Result<(), PlatformError> { let main_window = WindowDesc::new(ui_builder); let data = Default::default(); AppLauncher::with_window(...
true
98f50df940022c543aa65eab04b4111b9a00b30a
Rust
euxcet/RuaDB
/src/rm/filesystem/utils/bitmap.rs
UTF-8
4,791
2.75
3
[]
no_license
const LEAF_BIT: i32 = 32; const MAX_INNER_NUM: usize = 67; const BIAS: u32 = 5; // pub const DE_BRUIJN: [i32; 32] = [0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9]; pub struct Bitmap { data: Vec<u32>, size: i32, root_bit: i32, roo...
true
40a03136737959fe35cff007dd3c8e7342d15729
Rust
yamagata-akita/rust_tutorial
/chapter_4/study/src/str.rs
UTF-8
4,693
3.921875
4
[]
no_license
fn main() { // 文字列スライス型(str型) // &strか&mut strと表記する // strリテラルはダブルクオートで囲み、型は &'static str // 'staticはライフタイム指定子と呼ばれる let s1 = "abc1"; // &'static str型 let s2 = "abc2"; assert!(s1 < s2); assert!(s1 != s2); let s3 = "文字列を複数行に渡って書くと 改行やスペースが入る"; let s4 = "行末にバックスラッシ...
true
6c11dbd1a51ac75c8f8120074c6f2a8b3382b94f
Rust
TyOverby/implicit-gpu
/util/buffer_view/src/main.rs
UTF-8
2,840
2.84375
3
[]
no_license
extern crate buffer_dump; extern crate gpu_interp; extern crate minifb; mod util; use minifb::{Key, Window, WindowOptions}; use std::fs::File; use std::io::BufReader; use util::*; enum Event { Up, Down, None, } fn down_event(window: &Window) -> bool { window.is_key_pressed(Key::Comma, minifb::KeyRep...
true
44508cbb197b6ffebd921a0d96ff9893a9721a41
Rust
pierrechevalier83/unicode_types
/src/generated/lao.rs
UTF-8
11,424
3.515625
4
[ "LicenseRef-scancode-unicode" ]
permissive
/// An enum to represent all characters in the Lao block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum Lao { /// \u{e81}: 'ກ' LetterKo, /// \u{e82}: 'ຂ' LetterKhoSung, /// \u{e84}: 'ຄ' LetterKhoTam, /// \u{e86}: 'ຆ' LetterPaliGha, /// \u{e87}: 'ງ' LetterNgo, /...
true
7a463b7284fdddf65e395b6ce16ae73baba58582
Rust
TtTRz/RustLib
/code/Singleton/Rc/src/main.rs
UTF-8
787
3.53125
4
[]
no_license
use std::cell::RefCell; use std::rc::Rc; struct Singleton { count: i32, } impl Singleton { fn new() -> Self { Singleton { count: 0 } } pub fn get_instance() -> Rc<RefCell<Singleton>> { static mut SINGLETON: Option<Rc<RefCell<Singleton>>> = None; unsafe { SINGLETON ...
true
8a5029e56e9523fb5c0972adf8598520f48dfcee
Rust
pierrechevalier83/unicode_types
/src/generated/rejang.rs
UTF-8
5,959
3.3125
3
[ "LicenseRef-scancode-unicode" ]
permissive
/// An enum to represent all characters in the Rejang block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum Rejang { /// \u{a930}: 'ꤰ' LetterKa, /// \u{a931}: 'ꤱ' LetterGa, /// \u{a932}: 'ꤲ' LetterNga, /// \u{a933}: 'ꤳ' LetterTa, /// \u{a934}: 'ꤴ' LetterDa, /// ...
true
2aaea1f390a67441cb6dc030ad0f0e6bdd78dc59
Rust
yanakad/kompact
/core/src/net/udp_state.rs
UTF-8
5,938
2.515625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::*; use crate::{ messaging::{NetMessage, SerialisedFrame}, net::buffer::{BufferChunk, DecodeBuffer}, }; use mio::net::UdpSocket; use network_thread::*; use std::{collections::VecDeque, io, net::SocketAddr}; const MAX_PACKET_SIZE: usize = 65536; pub(super) struct UdpState { logger: KompactLogger,...
true
5abbd6954f87891febb69315671cb8f5e8e1b700
Rust
bjrnmrtns/xp-game-engine
/rts/src/client/navigation.rs
UTF-8
13,436
2.796875
3
[]
no_license
use bevy::prelude::Vec2; use std::collections::VecDeque; #[derive(PartialEq, Eq)] pub struct Cell { pub x: usize, pub y: usize, } impl Cell { pub fn new(x: usize, y: usize) -> Self { Self { x, y } } } #[derive(Clone, Copy)] pub struct IVec2 { pub x: i32, pub y: i32, } impl IVec2 { ...
true
bf396e922acb8faf8d0196177010af3795439090
Rust
mchataigner/eureka
/src/file_handler.rs
UTF-8
2,596
3.0625
3
[ "MIT" ]
permissive
pub mod file_handler { use std::error::Error; use std::fs; use std::io; use std::io::ErrorKind; use std::io::{Read, Write}; use std::path; const CONFIG_REPO: &'static str = "repo_path"; const CONFIG_EDITOR: &'static str = "editor_path"; pub enum ConfigFile { Repo, E...
true
14cb7aa3a8d52999022c69a74aed227dfbf7301a
Rust
geniousli/point24
/src/algorithm/most_water.rs
UTF-8
664
3.203125
3
[]
no_license
pub struct Solution {} impl Solution { pub fn max_area(height: Vec<i32>) -> i32 { let mut i = 0; let mut j = height.len() - 1; let mut max_value = 0; while i < j { let min = Solution::min(height[i], height[j]); let value = (j - i) as i32 * min; if ...
true
7d1f60fd0c0b49b4578d496c580f6fe0feaad542
Rust
c0ka/grrs
/linked-lists/src/single_linked.rs
UTF-8
5,465
3.8125
4
[]
no_license
use std::mem; /// One-direction linked stack with a head attribute pointing to it's latest aka top node. pub struct List<T> { head: Link<T>, } /// Pointer to the next node or a None value. /// This is a Box type pointer, so it can be fixed length. type Link<T> = Option<Box<Node<T>>>; /// Node of stack, includin...
true
7c4aaa58a6a7573446992e6817e45035b667e03f
Rust
rydz/rocket_seek_stream
/src/multipart.rs
UTF-8
9,055
2.765625
3
[ "MIT" ]
permissive
#![allow(dead_code)] #![allow(unused_must_use)] use crate::ReadSeek; use rand; use rocket::futures::io::Cursor; use rocket::futures::AsyncWriteExt; use rocket::tokio::io::ReadBuf; use rocket::tokio::runtime::Handle; use rocket::{ futures::executor::block_on, tokio::io::{AsyncRead, AsyncSeek, AsyncSeekExt}, }; ...
true
43084e8fe0cfbb2ea42fbc99f54b4faf95840321
Rust
will14smith/rlox
/rlox-interpreter/src/expression.rs
UTF-8
11,029
3.09375
3
[]
no_license
use rlox_scanner::{ SourceToken, Token }; use rlox_parser::Expr; use crate::{ EvaluateResult, Interpreter, RuntimeError, RuntimeErrorDescription, Value, }; pub fn evaluate(interpreter: &mut Interpreter, expr: &Expr) -> EvaluateResult<Value> { match expr { Expr::Nil(_) => Ok(Value::Nil),...
true
c00acfb4e123285b96e10d7bcc653a0c167a80ba
Rust
memorysafety/sudo-rs
/test-framework/sudo-compliance-tests/src/sudo/sudoers/cmnd.rs
UTF-8
9,548
2.671875
3
[ "MIT", "Apache-2.0" ]
permissive
//! Test the Cmnd_Spec component of the user specification: <user> ALL=(ALL:ALL) <cmnd_spec> use pretty_assertions::assert_eq; use sudo_test::{Command, Env, TextFile}; use crate::{Result, USERNAME}; macro_rules! assert_snapshot { ($($tt:tt)*) => { insta::with_settings!({ filters => vec![(r"[[...
true
05a01ed60700edea042d0e36e01a167fef63c9a7
Rust
blck-snwmn/rust-parser-combinator
/src/lib.rs
UTF-8
851
3.046875
3
[]
no_license
pub mod parser; pub mod parser_result; pub use crate::parser::Parser; pub use crate::parser_result::ParseResult; pub fn match_string<'a>(patten: &str) -> Parser<'a, &str> { Parser { func: Box::new(move |input: &str| { if input.starts_with(patten) { ParseResult::success(patten) ...
true
31bb2ff3679b60ac2d4a5e81414809ec4874a28b
Rust
Sharko-21/rusty_browser
/src/parser.rs
UTF-8
4,689
2.890625
3
[]
no_license
use std::fs::File; use std::io::BufReader; use std::io::prelude::*; use std::rc::Rc; use std::collections::{HashMap}; use std::cell::{RefCell, Ref}; use std::cmp::Ordering; use std::ops::Add; use crate::dom; const LEX_TAG_OPENER: char = '<'; const LEX_TAG_CLOSER: char = '>'; const LEX_CLOS...
true
4f98555bfdb18a818d2cafac8eee6e655e04cd77
Rust
jlgerber/packybara
/src/io/packages_xml.rs
UTF-8
22,379
3.15625
3
[]
no_license
/******************************************************* * Copyright (C) 2019,2020 Jonathan Gerber <jlgerber@gmail.com> * * This file is part of packybara. * * packybara can not be copied and/or distributed without the express * permission of Jonathan Gerber ******************************************************...
true
fa7d18f7a33c04a04af1b4b446f120d53a8ef2ed
Rust
joseluis/papariki
/src/geometry.rs
UTF-8
1,280
2.84375
3
[]
no_license
use crate::mesh::Mesh; use crate::protos::vector_tile::mod_Tile::Feature; use nalgebra as na; use std::f32::consts::PI; #[derive(Debug, Clone)] pub struct LonLat(na::Point2<f32>); impl LonLat { pub fn new(lon: f32, lat: f32) -> Self { Self(na::Point2::new(lon, lat)) } } impl Feature { pub fn to_mesh(&self) -> M...
true
ac0ea2fd5f0036ed1175624aee9d7f7a697944e3
Rust
eonil/lldb.rs
/src/stringlist.rs
UTF-8
3,562
2.65625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.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 std::ffi::{CStr...
true
3f03028751dc02b5b4b31af7bd172b7d9014ef3b
Rust
Electron-libre/doser
/src/ingredient.rs
UTF-8
839
3.6875
4
[]
no_license
use num_rational::Ratio; #[derive(Debug)] pub struct Ingredient { pub label: String, pub quantity: Ratio<u32>, } impl Ingredient { pub fn scale(&self, mult: u32) -> Self { Self { label: self.label.clone(), quantity: self.quantity * mult, } } } impl std::fmt::Di...
true
134ad592f558005076ed5913cb715e0dfb52ba3e
Rust
UTMIST/oneshot-rs
/src/sample/mod.rs
UTF-8
1,344
2.9375
3
[ "MIT" ]
permissive
mod two; use rand::seq::SliceRandom; use std::fs; use std::io::Result; use std::path::PathBuf; use std::vec::Vec; /// Generate <num_pairs> pairs of character images. pub fn random_pairs(dataset: &str, num_pairs: usize) -> Result<Vec<(PathBuf, PathBuf)>> { let scripts = fs::read_dir(dataset)? .map(|res| re...
true
998fe726d848d14d44b14cb8f0d199f5566fc0d1
Rust
jakubdabek/jftt
/lab1/knuth_morris_pratt/src/knuth_morris_pratt.rs
UTF-8
2,175
3.09375
3
[]
no_license
use std::collections::BTreeMap; #[derive(Debug)] pub struct Matcher<'a> { alphabet: &'a[char], pattern: &'a[char], text: &'a[char], transitions: BTreeMap<usize, usize>, } pub struct MatcherIter<'a> { matcher: &'a Matcher<'a>, current_state: usize, current_index: usize, } fn make_transitio...
true
61b1bbd218cc64bc8d2cb83d35bb1fa845a3a020
Rust
alexsparrow/brainlift
/src/state.rs
UTF-8
765
3.21875
3
[]
no_license
pub struct BrainfuckState { pub mem: [u8; 1024], pub pos: usize, } impl BrainfuckState { pub fn new() -> Self { return BrainfuckState { mem: [0; 1024], pos: 0, }; } pub fn memory_dmp(&self) { for i in 0..1024 { if self.mem[i] > 0 { ...
true
ba834525d50344c065adbab30bb7096e3a8d3f7c
Rust
dorucioclea/IsengardContract
/mandos/src/storage_raw_check.rs
UTF-8
3,871
3.0625
3
[]
no_license
use super::*; use serde::{ de::{self, Deserializer, MapAccess, Visitor}, ser::{SerializeMap, Serializer}, Deserialize, Serialize, }; use std::{collections::BTreeMap, fmt}; pub enum CheckStorageRaw { Star, Equal(CheckStorageDetailsRaw), } pub struct CheckStorageDetailsRaw { pub storages: BTreeMa...
true
ef1bbe7efda4515dc0c2d9052edfa32b6c1d100e
Rust
archshift/accion
/src/builtins.rs
UTF-8
4,528
3.078125
3
[]
no_license
use std::collections::HashMap; use std::char; use std::convert::TryInto; use crate::mktype; use crate::types::{Type, TypeId, TypeStore, Purity, FnArgTypes}; use crate::values::{Value, ValList}; pub type BuiltinMap = HashMap<String, Builtin>; #[derive(Debug)] pub struct Builtin { pub name: String, pub ty: Typ...
true
75efdcf98ad24e9c5d5a9b9a64feb7e482d18b62
Rust
pchampin/sophia_rs
/api/src/ns/_namespace.rs
UTF-8
2,300
3.359375
3
[ "LicenseRef-scancode-cecill-b-en", "CECILL-B" ]
permissive
use super::*; #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] /// A custom namespace. /// /// The [`get`](Namespace::get) method can be used to create a new IRI by concatenating a suffix to this namespace's IRI. pub struct Namespace<T: Borrow<str>>(IriRef<T>); impl<T: Borrow<str>> Namespace<T> { ...
true
426b3cfe7cd5afdbc67c2ccd373fb5bf7ad4a475
Rust
cronosun/liquesco-rust
/schema/src/types/range.rs
UTF-8
8,753
2.75
3
[ "MIT", "Apache-2.0" ]
permissive
use liquesco_serialization::types::boolean::Bool; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; use std::convert::TryFrom; use liquesco_common::error::LqError; use liquesco_serialization::core::DeSerializer; use crate::context::CmpContext; use crate::context::ValidationContext; use crate::core::Type; u...
true
c73344b01db31955ed6eed47ede74597d9021927
Rust
jagtesh/uptop
/src/main.rs
UTF-8
390
2.546875
3
[]
no_license
use sysinfo::{ProcessExt, SystemExt}; fn format_process_list(pid: &i32, proc: &sysinfo::Process) -> String { return format!("{:6}\t{:<30}\t{:<10}", pid, proc.name(), proc.status()); } fn main() { let mut system = sysinfo::System::new(); system.refresh_all(); for (pid, proc) in system.get_process_lis...
true
7294b4f6ee6ad58dacd8979fb540da9f29344126
Rust
solana-grimes/solana
/src/counter.rs
UTF-8
2,277
3.359375
3
[ "Apache-2.0" ]
permissive
use std::sync::atomic::{AtomicUsize, Ordering}; use std::time::{Duration, SystemTime, UNIX_EPOCH}; pub struct Counter { pub name: &'static str, pub counts: AtomicUsize, pub nanos: AtomicUsize, pub times: AtomicUsize, pub lograte: usize, } macro_rules! create_counter { ($name:expr, $lograte:exp...
true
4f4f85533abeb60eccfb33de8608b5e3184da2fe
Rust
MarkMcCaskey/toy-engine
/src/job_manager/job_manager.rs
UTF-8
2,012
3.328125
3
[]
no_license
//! The system for taking tasks, breaking them up and executing them //! acts as a blackbox. Tasks are given with (possibly multidimensional) priority and the job manager //! does its best to schedule and execute theam //! The system will be able to either pass back messages requesting that other systems reduce the /...
true
50ae040eb122f8af5d144b9f5ef7ef9ac5d1bf33
Rust
jakmeier/paddlers-browser-game
/paddlers-frontend/src/net/graphql/response.rs
UTF-8
2,951
2.96875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Handling GraphQL response parsing. //! //! The hard work of parsing is done externally in the graphql_client crate. //! This module takes the parsed values, checks for errors and passes on the data to the next layer. //! use paddlers_shared_lib::prelude::PadlApiError; use crate::prelude::{PadlError, PadlErrorCode...
true
c71f8b9aa9b05b3af46e1420590d091d49f7a8d1
Rust
Lev-Stambler/firrtl-parser
/src/string.rs
UTF-8
5,430
2.65625
3
[]
no_license
use crate::{ IDStr, Info, Literal, Module, PrimOp, }; use nom::{ IResult, regexp::str::{ re_capture, re_find, }, bytes::complete::{ tag, take_while, is_not }, character::complete::{ space0, }, sequence::{ terminated, preceded, delimited, }, multi::{ separated_list0, }, combinator::...
true
1d903453298fb6e5ce22926756541ef23ffcabf3
Rust
xiangminwang/toggy
/src/config.rs
UTF-8
1,114
3
3
[ "MIT" ]
permissive
use std::str::FromStr; use ini::Ini; pub struct Config { pub hotkey: u32, pub lower_players: u8, pub upper_players: u8, } impl Config { pub fn new() -> Self { Config { hotkey: 192, lower_players: 1, upper_players: 8, } } pub fn reload(&mut s...
true
74d5c912534ecbe55ad8f2cce2436f61063fa609
Rust
janpauldahlke/fhir-rs
/src/model/ProductShelfLife.rs
UTF-8
8,003
3.015625
3
[ "MIT" ]
permissive
#![allow(unused_imports, non_camel_case_types)] use crate::model::CodeableConcept::CodeableConcept; use crate::model::Extension::Extension; use crate::model::Identifier::Identifier; use crate::model::Quantity::Quantity; use serde_json::json; use serde_json::value::Value; use std::borrow::Cow; /// The shelf-life and s...
true
60af8435f0cd9e2e33afe02507f70fc442d86ac6
Rust
jasonblog/note
/Rust/code/learn_rust/learn_box1/src/main.rs
UTF-8
958
3.09375
3
[]
no_license
//box适合用于如下场景: //(1)当有一个在编译时未知大小的类型,而又需要再确切大小的上下文中使用这个类型值的时候;(举例子:在一个list环境下,存放数据,但是每个元素的大小在编译时又不确定) //(2)当有大量数据并希望在确保数据不被拷贝的情况下转移所有权的时候; //(3)当希望拥有一个值并只关心它的类型是否实现了特定trait而不是其具体类型时。 //enum List { // Cons(i32, List), // Nil, //} enum List { Cons(i32, Box<List>), Nil, } //struct List { // int value; //...
true
7e6a88fb66551733a2bd1c5f5377ff1eac0554ff
Rust
shadowmint/rust-pup
/workers/pup-worker-pathtools/src/tools_env.rs
UTF-8
423
2.765625
3
[]
no_license
use pup_worker::errors::{PupWorkerError, PupWorkerErrorType}; use std::env; /// Get an env variable or return an error. pub fn get_env(name: &str) -> Result<String, PupWorkerError> { match env::var(name) { Ok(v) => Ok(v.to_string()), Err(_) => Err(PupWorkerError::with_message( PupWorker...
true
7ae789d818e652157d96dc4d3ce9f91185886209
Rust
Patrik-Stas/play_with_rust
/old_futures/src/static_mut_so_question_lazy_static.rs
UTF-8
1,836
3.4375
3
[]
no_license
use ::std::sync::RwLock; #[derive(Debug)] struct SomeData { id: u32 } #[derive(Debug)] struct SimpleFoo {} #[derive(Debug)] struct ComplexFoo { some_data: SomeData } trait GreetingTrait { fn hello(&self); } impl GreetingTrait for SimpleFoo { fn hello(&self) { println!("Hello, this is SimpleFoo"); ...
true
d47fe36bbe04b4595d061a26b4214ed17f57a658
Rust
wking/cincinnati
/vendor/actix-http/src/body/mod.rs
UTF-8
7,518
2.921875
3
[ "Apache-2.0", "MIT" ]
permissive
//! Traits and structures to aid consuming and writing HTTP payloads. #[allow(clippy::module_inception)] mod body; mod body_stream; mod message_body; mod response_body; mod size; mod sized_stream; pub use self::body::Body; pub use self::body_stream::BodyStream; pub use self::message_body::MessageBody; pub use self::r...
true
2b6b5d73ca6018c1987820a47fc9bae4d6edfe6e
Rust
MarvinKlemp/fs-totp-client
/src/command/command_handler.rs
UTF-8
1,433
3.046875
3
[]
no_license
use std::collections::HashMap; use super::{Command, Result}; use command::decrypt::DecryptCommand; use command::encrypt::EncryptCommand; pub struct CommandHandler { commands: Vec<Box<Command>> } impl CommandHandler { pub fn new() -> CommandHandler { let mut commands: Vec<Box<Command>> = Vec::new(); ...
true
95e0201bd2240182ba2b7b0ffbec782d46929c3b
Rust
bouk/rayray
/src/objects/triangle.rs
UTF-8
1,473
3.265625
3
[]
no_license
use vec3::Vec3; use {Material, Hit, Hittable, Ray, EPSILON}; pub struct Triangle { vertices: [Vec3; 3], material: Material, } impl Triangle { pub fn new(v0: Vec3, v1: Vec3, v2: Vec3, material: Material) -> Triangle { Triangle { vertices: [v0, v1, v2], material, } ...
true
aed766eb1f22284214ad6260f709681b548ebf85
Rust
scrblue/cribbage_server
/src/client.rs
UTF-8
13,743
2.90625
3
[]
no_license
extern crate cribbage; use serde::{Deserialize, Serialize}; use std::io::{Read, Write}; use std::net; use std::sync::mpsc; // Simply sends the message to the client and guarantees its arrival fn simple_notification( client_stream: &mut net::TcpStream, game_handler_transmitter: &mpsc::Sender<super::messages::Cl...
true
41307ddd188da08dd3645451f5bfa22119b1d334
Rust
Pr47/T10
/src/tyck/fusion.rs
UTF-8
12,534
2.53125
3
[ "WTFPL" ]
permissive
//! `fusion` 模块用于实现 Rust FFI 时所需要的“编译期”类型检查 use std::any::TypeId; use std::error::Error; use crate::tyck::{TypeCheckInfo, FFIAction}; use crate::tyck::base::StaticBase; use crate::void::Void; use crate::data::Value; pub type ExceptionSpec = Option<TypeId>; pub type Nullable = bool; /// ```compile_fail(E0477) /// # ...
true
d0ef2deaddfd765a563b08170435f5b68a71bfeb
Rust
fgiannesini/fizz-buzz-kata
/src/main.rs
UTF-8
887
3.765625
4
[]
no_license
fn main() { } fn fizzbuzz(value: i32) -> String { let mut result = "".to_string(); if value % 3 == 0 { result.push_str("fizz") } if value % 5 == 0 { result.push_str("buzz") } result } #[cfg(test)] mod tests { use crate::fizzbuzz; #[test] fn should_get_fizz_if_value...
true
74bbacff08891f63a76a0a4b6406fdb778d32214
Rust
shunjilin/gleam
/src/fs.rs
UTF-8
14,668
2.890625
3
[ "Swift-exception", "Apache-2.0" ]
permissive
use crate::error::{Error, FileIoAction, FileKind, GleamExpect}; use flate2::{write::GzEncoder, Compression}; use ignore::DirEntry; use std::{ ffi::OsStr, fmt::Debug, fs::File, io::{BufRead, BufReader, Write}, path::{Path, PathBuf}, }; #[derive(Debug, PartialEq, Clone)] pub struct OutputFile { p...
true
38fe6249e3d8ee4f7338220d505bdd571ce42fe6
Rust
dsherret/swc
/macros/enum_kind/src/lib.rs
UTF-8
3,533
2.75
3
[ "MIT", "Apache-2.0" ]
permissive
extern crate proc_macro; use syn; use swc_macros_common::prelude::*; mod expand; mod input; mod parse; mod util; /// # Attributes on enum /// ## functions /// `#[kind(functions(name = "return_type"))]` /// /// ```rust,ignore /// #[macro_use] /// extern crate enum_kind; /// /// /// You can split attributes if you wa...
true
b2ffdec6d10ab27f40c3f9e30c6662c82680cd1a
Rust
tere-shell/tere
/server/src/ipc/mod.rs
UTF-8
3,564
3.078125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Wrap a serde mechanism so that it can be used over UNIX domain sockets with ancillary data. //! Adds specific support for FD passing. //! //! This module uses nightly-only experimental APIs. //! It may need to be updated regularly to keep up. //! This still seems a better journey than 3rd party crates at a time whe...
true
e803b84f3061ec5dba5803671e2c69e2f7528b6e
Rust
gazliddon/pacdaddy
/server/src/messages/parse.rs
UTF-8
2,330
2.921875
3
[ "MIT" ]
permissive
use messages::{Message, Payload}; use errors::Errors; use json; use json::JsonValue; use v2; fn get_key<'a>(json : &'a JsonValue, key : &str) -> Result<&'a JsonValue, Errors> { let j = &json[key]; if j.is_null() { Err(Errors::Missing(key.to_string())) } else { Ok(j) } } fn to_u64(json...
true
d5b738520e2e0f990ab67f0df8e1928b33d84a55
Rust
tempbottle/rust-paillier-1
/src/coding/integral/mod.rs
UTF-8
4,626
3.03125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Integral code supporting both scalars and vectors. use super::*; pub mod scalar; pub mod vector; use std::ops::{Add, Shl, Shr, Rem}; use num_traits::One; use arithimpl::traits::ConvertFrom; use std::marker::PhantomData; /// Integral code for scalars and vectors. pub struct Code<I> { /// Number of componen...
true
80811a88490bbe12a249185a1dcf043adf9a29e5
Rust
m-242/shrtd
/src/routes/mod.rs
UTF-8
1,531
2.84375
3
[ "MIT" ]
permissive
use rocket::{get, response::Responder, routes, State}; use tokio::fs; use crate::types::{Record, RecordData}; mod file; mod paste; mod redirect; pub fn mounts() -> Vec<rocket::Route> { /*! Return the list of the application's exposed endpoints */ routes![file::create, paste::create, redirect::create, get] } ...
true
98780122a6f5f6ad7e6f42d3f66625f1f7504166
Rust
eupn/macrotest
/src/lib.rs
UTF-8
5,095
3.359375
3
[]
no_license
#![crate_type = "lib"] #![doc(html_root_url = "https://docs.rs/macrotest/1.0.9")] //! #### &emsp; Test harness for macro expansion. //! //! Similar to [trybuild], but allows you to write tests on how macros are expanded. //! //! *Minimal Supported Rust Version: 1.56* //! //! <br> //! //! # Macro expansion tests //! //...
true
278e6ad6803d8614a0483e3d6df073752b05cb95
Rust
yixxxichen/Rust-pair-programming
/wordcorrect/src/main.rs
UTF-8
11,714
3.40625
3
[]
no_license
<<<<<<< HEAD /* * word correction * * Reads text from the corpus text and * Count the frequency of each word, then correct the candidate word in input text, output with the most frequetly * used one * * Background * * The purpose of correct is to find possible corrections for misspelled words. It consists of two pha...
true
6e928c603031878568d2bdc5c867d55a99617ecb
Rust
danii/btree-slab-fork
/src/utils.rs
UTF-8
911
3.25
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::borrow::Borrow; use crate::generic::node::Keyed; /// Search in `sorted_slice` for the item with the nearest key smaller or equal to the given one. /// /// `sorted_slice` is assumed to be sorted. #[inline] pub fn binary_search_min<T: Keyed, Q: ?Sized>(sorted_slice: &[T], key: &Q) -> Option<usize> where T::Key:...
true
c92981640181cf49839e415371306949dc371e84
Rust
pavel1269/advent-of-code
/2022/src/day20/mod.rs
UTF-8
4,357
3.453125
3
[]
no_license
pub fn get_solution_part1() -> String { let input = get_input(); let result = calc_coordinates(input); return result.to_string(); } pub fn get_solution_part2() -> String { let input = get_input(); let result = calc_real_coordinates(input); return result.to_string(); } fn calc_real_coordinates(...
true
0bb10a5b9d734102e50752e6d212a6f9ea154ae2
Rust
markshevchenko/rust-learning
/20/macros/src/main.rs
UTF-8
667
3.125
3
[ "Unlicense" ]
permissive
#[cfg(test)] mod tests { macro_rules! assert_has_value { ($value: expr) => { match &$value { None => panic!("assertation failed: expression is None"), _ => (), } } } #[test] fn test_some() { assert_has_value!(Some(2)); ...
true