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
18222bb85e912e35d195e4e8b4717bf98873a177
Rust
hamadakafu/kyopro
/src/bin/typical90_70.rs
UTF-8
923
2.703125
3
[]
no_license
#![allow(clippy::comparison_chain)] #![allow(clippy::collapsible_if)] use std::cmp::Reverse; use std::cmp::{max, min}; use std::collections::{BTreeSet, HashMap, HashSet}; use std::fmt::Debug; use itertools::Itertools; use whiteread::parse_line; const ten97: usize = 1000_000_007; /// 2の逆元 mod ten97.割りたいときに使う const in...
true
dae9078bcc3643a674a511118e135507cd15c0fd
Rust
buzztaiki/rust-evdev-uinput-example
/examples/key-mapper-libevdev.rs
UTF-8
3,164
2.6875
3
[ "MIT" ]
permissive
use evdev_rs::enums::{EventCode, EventType, EV_KEY}; use evdev_rs::{uinput, Device, DeviceWrapper, GrabMode, InputEvent, ReadFlag, UninitDevice}; use nix::{ioctl_read_buf, libc}; use std::collections::HashMap; use std::fs::File; use std::os::unix::prelude::AsRawFd; use std::{env, io, process}; // see /usr/include/linu...
true
22891f2748a33747176292105d2197066e97099b
Rust
vspecky/chipper8
/src/main.rs
UTF-8
1,479
2.9375
3
[ "MIT" ]
permissive
mod chip8; mod gui; //mod disassembler; //use disassembler::Disassembler; use std::vec::Vec; use std::fs::{self, File}; use std::io::prelude::*; use std::time::Duration; const WIN_WIDTH: u32 = 64; const WIN_HEIGHT: u32 = 32; const PIXEL_SIZE: u32 = 15; fn main() { let args: Vec<String> = std::env::args().collect(...
true
6ff4373150571b2134b3acff4ecb9185172eace8
Rust
sak96/Advent2020
/src/day07/mod.rs
UTF-8
2,185
3.125
3
[]
no_license
use std::{collections::{HashSet, hash_map::RandomState}, io::BufRead}; use std::collections::HashMap; pub fn run<'a>(reader: Box<dyn BufRead + 'a>) { let mut hm = HashMap::new(); let mut hm1 = HashMap::new(); for input in reader.lines() { let line = input.unwrap(); // dotted black bags con...
true
429d6eab97b85bc5310c8131be707cc25eb9ac1e
Rust
kdnk-sandbox/rust_introduction
/src/ch07_ownership/examples/toy_vec_01.rs
UTF-8
236
2.890625
3
[]
no_license
use ch07_ownership::ToyVec; fn main() { let mut v = ToyVec::<String>::new(); v.push("Java Finch".to_string()); v.push("Budgeringar".to_string()); let e = v.get(1); assert_eq!(e, Some(&"Budgeringar".to_string())); }
true
8de73b7e2e306bb52dbdfbb0a3cc67fc6491bdd1
Rust
kahgeh/learn-rust
/traitobject/src/monomorphy.rs
UTF-8
239
2.75
3
[]
no_license
use super::draw::Draw; pub struct Screen<T: Draw> { pub components: Vec<T>, } impl<T> Screen<T> where T: Draw { pub fn run(&self){ for component in self.components.iter() { component.draw(); } } }
true
7a09c8533ddf099990ff8c3fe2b256c9830f5bdb
Rust
Canadadry/rTUI
/src/view.rs
UTF-8
4,382
3.15625
3
[]
no_license
use color; use color_table; use screen; const LEFT_BORDER_SIZE:usize = 1; const RIGHT_BORDER_SIZE:usize = 1; const TOP_BORDER_SIZE:usize = 1; const BOTTOM_BORDER_SIZE:usize = 1; enum Command { Write{ x:usize, y:usize, content:String }, Stream{ content:String }, Color { bg:color::Color, fg:colo...
true
4120b6f302849e141fcea22400d19ec39ebf224b
Rust
BigCatAccount/raze
/src/speaker.rs
UTF-8
2,812
2.765625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/* * This module implements a simple mono speaker with low-pass filter. * The basic algorithm is copied from the one in MAME but the code is much simpler. */ const FILTER_LENGTH : usize = 64; const RATE_MULTIPLIER : i32 = 4; const AUDIO_SAMPLE : i32 = 168 / RATE_MULTIPLIER; pub struct Speaker { unfiltered: [i32...
true
30edd801ae26582445142ec5d3bd52ac1fc3f5d9
Rust
gwy15/leetcode
/src/1439.有序矩阵中的第-k-个最小数组和.rs
UTF-8
2,403
3
3
[]
no_license
/* * @lc app=leetcode.cn id=1439 lang=rust * * [1439] 有序矩阵中的第 k 个最小数组和 */ struct Solution; // @lc code=start use std::iter::FromIterator; impl Solution { fn merge(previous_sum: Vec<i32>, row: &[i32], k: usize) -> Vec<i32> { // merge sum use std::cmp::Reverse; use std::collections::Binary...
true
ca3fd4e8c01f3014a83e8f4f3b14d85f6c2ed585
Rust
gcarq/comprs
/src/encodings/bwt.rs
UTF-8
5,839
3.0625
3
[ "BSD-2-Clause" ]
permissive
use std::cmp::Ordering; use std::ops::Index; use rayon::iter::{ IndexedParallelIterator, IntoParallelIterator, IntoParallelRefIterator, ParallelIterator, }; use rayon::prelude::ParallelSliceMut; const CHUNK_SIZE: u32 = 1024 * 1024; pub fn apply(data: &[u8]) -> Vec<u8> { // Create chunks and encode them l...
true
8e854df941e967f2c21e1c56585d2b346941e2d5
Rust
varkor/chalk
/src/solve/infer/instantiate.rs
UTF-8
5,702
3.125
3
[ "BSD-3-Clause", "bzip2-1.0.6", "LicenseRef-scancode-other-permissive", "NCSA", "MIT", "ISC", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "Unlicense" ]
permissive
use fallible::*; use fold::*; use std::fmt::Debug; use super::*; impl InferenceTable { /// Create a instance of `arg` where each variable is replaced with /// a fresh inference variable of suitable kind. fn instantiate<U, T>(&mut self, universes: U, arg: &T) -> T::Result where T: Fold + Debug,...
true
3e5bb6d8ee91ca2bf9974de5d39b05b46e1413b3
Rust
haiaty/neverstoplearning-rust
/src/error_handling.rs
UTF-8
1,364
3.453125
3
[]
no_license
/** https://doc.rust-lang.org/book/ch09-00-error-handling.html */ // wITHOUT PANIC BUT USING RESULT // return a Result from the function // which contains OK in case of success and Err in case of failure. // // These cases can either be explicitly handled via match or implicitly with unwrap. Implicit handling will...
true
c4beace40d98783ffe1abeca207d520043326c60
Rust
iwillspeak/conrod
/examples/custom_widget.rs
UTF-8
20,496
2.984375
3
[ "MIT" ]
permissive
//! //! //! A demonstration of designing a custom, third-party widget. //! //! In this case, we'll design a simple circular button. //! //! All of the custom widget design will occur within the `circular_button` module. //! //! We'll *use* our fancy circular button in the `main` function (below the circular_button mod...
true
19b8362bd8ff1236b662358c9bc06037b46020a1
Rust
sanisoclem/game-server-rs
/src/game_state.rs
UTF-8
887
3.140625
3
[ "MIT" ]
permissive
use std::net::SocketAddr; pub trait WorldBounds { fn normalize_location(self: &Self, loc: &mut Location); } pub enum PlayerState { Idle, } pub struct Location { pub x: i32, pub y: i32, } pub struct PlayerInfo { pub uid: i32, pub location: Location, pub rot_z: f32, pub speed: f32, ...
true
fd0e193c9a21682268945449538e0a4634f5aa38
Rust
sn2234/file_monitor
/src/processor.rs
UTF-8
9,511
2.796875
3
[ "Unlicense" ]
permissive
use std::fs; use std::path::{Path, PathBuf}; use std::error::Error; use std::{thread, time}; use std::process::{Command, Output}; use chrono::{DateTime, Local}; use crate::locations::{Location, Locations}; pub fn processLocations(locations : Locations) -> bool { if !verifyLocations(&locations) { ...
true
3fe67626599f309b939fc54ac525b4d2d086ed75
Rust
tianenchen/apex
/src/common.rs
UTF-8
2,666
2.921875
3
[]
no_license
use std::{io,error,fmt}; use serde::{Serialize, Deserialize}; use futures::channel; pub type Result<T> = std::result::Result<T,Error>; #[derive(Debug)] pub enum Error{ Io(io::Error), AsyncIo(async_std::io::Error), Send(channel::mpsc::SendError), Serialize(bincode::Error), // FindNewerLeader, } ...
true
831b2e496a5858f141fba7d3139624068b811b85
Rust
creikey/hawaiian-pronunciation
/src/main.rs
UTF-8
1,840
3.4375
3
[ "MIT" ]
permissive
use std::io; use std::io::prelude::*; const ENTER_HAWAIIAN_WORD: &str = "Enter a hawaiian word to pronounce ==> "; const INVALID_CHARACTER: &str = " is not a valid hawaiian character"; const PRONUNCIATION: &str = " is pronounced "; const ENTER_ANOTHER_WORD: &str = "Do you want to enter another word? Y/YES/N/NO ==> "; ...
true
89c611f4c53a5eb91b68878294165d02366b071e
Rust
rs-ipfs/rust-ipfs
/http/src/v0/root_files/tar_helper.rs
UTF-8
11,004
2.734375
3
[ "Apache-2.0", "CC-BY-4.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
///! Tar helper is internal to `/get` implementation. It uses some private parts of the `tar-rs` ///! crate to provide a `BytesMut` writing implementation instead of one using `std::io` interfaces. ///! ///! Code was originally taken and modified from the dependency version of `tar-rs`. The most ///! important copied p...
true
deadd094992e803d72adad18630c6f30bf375820
Rust
Leonqn/relegram
/src/responses/raw/shipping_address.rs
UTF-8
228
2.734375
3
[ "MIT" ]
permissive
#[derive(Deserialize, Debug, Clone)] pub struct ShippingAddress { pub country_code: String, pub state: String, pub city: String, pub street_line1: String, pub street_line2: String, pub post_code: String }
true
974dd701db447afc01ff34b3ff7f4890ecb87b50
Rust
molvin/RustSmallGame
/src/game/tetromino.rs
UTF-8
3,923
2.875
3
[]
no_license
use crate::utility::{ Point }; use std::cmp; use ggez::graphics::Color; use crate::game::Board; #[derive(Debug, Clone)] pub struct Tetromino { pub position: Point, pub points: [Point; 4], rotation_center: (f32, f32), pub color: Color } impl Tetromino { pub fn i() -> Tetromino { Tet...
true
904c5e4c639023b5901d1c6e301678da71678295
Rust
image-rs/image-tiff
/src/lib.rs
UTF-8
1,021
2.875
3
[ "MIT" ]
permissive
//! Decoding and Encoding of TIFF Images //! //! TIFF (Tagged Image File Format) is a versatile image format that supports //! lossless and lossy compression. //! //! # Related Links //! * <https://web.archive.org/web/20210108073850/https://www.adobe.io/open/standards/TIFF.html> - The TIFF specification extern crate j...
true
6b092a8dc02ef8b33ccd5558746bae6a89a0c81d
Rust
emoon/liquid-rust
/src/interpreter/output.rs
UTF-8
2,352
2.921875
3
[ "MIT" ]
permissive
use std::fmt; use itertools; use error::{Error, Result, ResultLiquidChainExt, ResultLiquidExt}; use value::Value; use super::Argument; use super::Context; use super::Renderable; #[derive(Clone, Debug, PartialEq)] pub struct FilterPrototype { name: String, arguments: Vec<Argument>, } impl FilterPrototype { ...
true
1472ffbdebe82e5c5c47f8803557e02c98268093
Rust
seanpianka/slack-blocks-rs
/src/lib.rs
UTF-8
5,157
2.890625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! This crate brings Slack's terrific [Block Kit 🔗] to //! the Rust ecosystem. //! //! Inside, you'll find models for all of Slack's Layout Blocks, //! Block Elements, and Composition Objects. Each structure has Slack's API //! documentation copied in-place so you don't have to leave your editor to //! remember the d...
true
1467510ed1b844e2e1df0d1ea1edc8f0ac551272
Rust
birarvin/rksuid
/tests/sorting.rs
UTF-8
798
2.828125
3
[ "MIT" ]
permissive
extern crate rksuid; #[cfg(test)] mod tests { use ::rksuid::rksuid; use ::rksuid::rksuid::Ksuid; // Sorting tests #[test] fn gt_lt() { let first = rksuid::new(Some(100), None); let second = rksuid::new(Some(500), None); let third = rksuid::new(Some(12321312), None); ...
true
26c0f6b865605f73a562063d3bf0339d9ac91848
Rust
yin939/Exercism
/rust/pig-latin/src/lib.rs
UTF-8
1,524
3.421875
3
[]
no_license
pub fn translate(input: &str) -> String { let mut rel = String::new(); for s in input.split_whitespace() { rel.push_str(helper(s).as_str()); rel.push(' '); } rel.trim_end().to_string() } fn helper(input: &str) -> String { if input.len() == 2 && input.chars().nth(1).unwrap().eq(&'y'...
true
3e922bbd7f3455e2bfdc25427b5f13ec2ad20f93
Rust
ericsink/blog
/gn/src/main.rs
UTF-8
24,237
2.71875
3
[ "Apache-2.0" ]
permissive
use mybatch::System; use mybatch::GetIter; use mybatch::AsBase; use mybatch::AsInterface; use mybatch::CloneHandle; use System::Collections::Generic::Dictionary_2 as Dictionary; use System::Collections::Generic::List_1 as List; use System::Collections::Generic::KeyValuePair_2 as KeyValuePair; use System::Collections::...
true
505f387680847eba703b66d00f5c6817dbac8879
Rust
MeirKriheli/rusmux
/src/project_config/error.rs
UTF-8
415
2.796875
3
[ "MIT" ]
permissive
//! Project config parsing error. use std::{error::Error, fmt::Display}; /// The project config parsing error, wrapping the de-serialization error. #[derive(Debug)] pub struct ProjectParseError(pub String); impl Error for ProjectParseError {} impl Display for ProjectParseError { fn fmt(&self, f: &mut std::fmt::F...
true
7e7bf7fea55719d473d6d7ac092b347ebd1bd33e
Rust
iCodeIN/tacview
/src/lib.rs
UTF-8
3,383
3.15625
3
[]
no_license
mod record; use std::io::{BufRead, BufReader, Lines, Read}; use std::str::FromStr; use record::Record; pub struct TacviewParser<R> { lines: Lines<BufReader<R>>, } impl<R> TacviewParser<R> { pub fn new(rd: R) -> Result<Self, ParseError> where R: Read, { let mut lines = BufReader::new(...
true
fcf54316edc24285ad6cd2129839aa5adb1f6d6d
Rust
rbartlensky/Lua-interpreter
/luavm/src/lib/instructions/upvals.rs
UTF-8
834
2.75
3
[]
no_license
use errors::LuaError; use luacompiler::bytecode::instructions::{first_arg, second_arg, third_arg}; use Vm; /// Up(1) = R(2)[R(3)] pub fn get_up_attr(vm: &mut Vm, instr: u32) -> Result<(), LuaError> { let val = { let arg2 = second_arg(instr) as usize; let from = vm.stack_frames[vm.curr_frame].closur...
true
2eab92aa0279d36b74a9ece678d4bea52764a7f0
Rust
phamlequang/turtle
/src/util/mod.rs
UTF-8
2,898
3.03125
3
[ "MIT" ]
permissive
#[cfg(test)] mod test; use std::env; use std::io; use std::path::{Path, MAIN_SEPARATOR}; use super::config::Shortcut; const TILDE: &str = "~"; pub fn home_directory() -> String { if let Some(pb) = dirs::home_dir() { if let Some(dir) = pb.to_str() { return String::from(dir); } } ...
true
ed4b7f56e5ff78bf78f0c49eae95020c9396ebe6
Rust
rossmacarthur/rephrase
/spoofer/src/vec.rs
UTF-8
689
3.578125
4
[ "Apache-2.0", "MIT" ]
permissive
//! A tiny Vec implementation backed by a mutable reference to a slice. use core::str; pub struct Vec<'s, T> { inner: &'s mut [T], len: usize, } impl<'s, T> Vec<'s, T> { pub fn new(inner: &'s mut [T]) -> Self { Self { inner, len: 0 } } pub fn push(&mut self, value: T) { assert!(s...
true
f49e7579a177903d11261b5b211da93399768405
Rust
zachlatta/rust-by-example
/0123-formatting.rs
UTF-8
605
3.53125
4
[]
no_license
use std::fmt; #[derive(Debug)] struct Color { r: u8, g: u8, b: u8, } impl fmt::Display for Color { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "RGB ({r}, {g}, {b}) 0x{r:02X}{g:02X}{b:02X}", r = self.r, g = self.g, ...
true
a51056f7127bf2c46d576c04d804d5f060fe67b3
Rust
pvmsikrsna/dyon
/src/intrinsics/functions.rs
UTF-8
5,265
2.625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::sync::Arc; use std::collections::HashMap; use super::standard; use Lt; use Module; use Prelude; use Variable; /// Lists all functions available in a module. pub fn list_functions(module: &Module) -> Vec<Variable> { let mut functions = vec![]; let name: Arc<String> = Arc::new("name".into()); let a...
true
cbfead277bfb7623eec4e383daa6324b66b6aec2
Rust
incker2/nakadion
/src/nakadi/publisher.rs
UTF-8
8,142
2.875
3
[ "MIT", "Apache-2.0" ]
permissive
//! Publish events to Nakadi use std::io::Read; use std::sync::Arc; use std::time::Duration; use backoff::{Error as BackoffError, ExponentialBackoff, Operation}; use reqwest::header::{HeaderMap, CONTENT_TYPE}; use reqwest::StatusCode; use reqwest::blocking::{Client as HttpClient, Response}; use serde::Serialize; use s...
true
3e8fd178f888fac274e9376613dddcaae16419da
Rust
lcdsmao/leetcode-rust
/problem/src/solution/p074_search_a_2d_matrix.rs
UTF-8
1,648
3.734375
4
[ "MIT" ]
permissive
pub struct Solution {} impl Solution { pub fn search_matrix(matrix: Vec<Vec<i32>>, target: i32) -> bool { let m = matrix.len(); let n = matrix.first().unwrap().len(); let mut top: i32 = 0; let mut bottom: i32 = m as i32 - 1; let mut vmid: i32 = m as i32; while top <...
true
2111b00d8525db1f3189b225a060e6a78dbe088b
Rust
ZephroC/rust-tracer
/src/buffer.rs
UTF-8
1,158
3.1875
3
[]
no_license
use std::convert::TryFrom; use crate::Resolution; use std::sync::RwLock; pub struct FrameBuffer { res: Resolution, front_buffer: RwLock<Vec<u8>>, rear_buffer: RwLock<Vec<u8>>, swap: bool, } impl FrameBuffer { pub fn new(res: Resolution) -> FrameBuffer { let byte_stride = 4; let pix...
true
d1f97e13c1dd652bb702cea3a6dd98f15aead8ce
Rust
vklein52/dist_fs
/src/filesystem.rs
UTF-8
13,591
2.671875
3
[]
no_license
use async_std; use async_std::io::ReadExt; use async_std::stream::StreamExt; use async_std::task::spawn; use crate::{BoxedError, BoxedErrorResult}; use crate::component_manager::*; use crate::constants; use crate::easyhash::{EasyHash, Hex}; use crate::globals; use crate::heartbeat; use crate::operation::*; use serde::{...
true
f498279f6f36cda1962512bf0a7f9202e7e3b07e
Rust
grantgumina/qs3
/src/main.rs
UTF-8
4,231
2.984375
3
[]
no_license
extern crate clap; extern crate rusoto_core; extern crate rusoto_s3; use std::fs::File; use std::io::Read; use std::vec::Vec; use if_chain::if_chain; use clap::{Arg, ArgMatches, App, SubCommand}; use rusoto_core::{Region}; use rusoto_s3::{S3Client, S3, Bucket, PutObjectRequest}; fn import(matches: &ArgMatches) { ...
true
c3d14de4849586803a5c5be691b45c79e0c34b50
Rust
piotr-cla/ockam
/implementations/rust/ockam/ockam_ffi/src/error.rs
UTF-8
1,536
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use ockam_core::Error; use std::os::raw::c_char; #[repr(C)] #[derive(Debug, PartialEq)] /// Ffi error pub struct FfiOckamError { code: i32, domain: *const c_char, } impl FfiOckamError { /// Create new error pub fn new(code: i32, domain: &'static str) -> Self { Self { code, ...
true
946c4a0868d9bb5885273a1fc9518454dd7425a8
Rust
NathanMcMillan54/C-secure
/build.rs
UTF-8
321
2.609375
3
[]
no_license
use std::{fs, io, path::Path}; const USER: &str = "user/"; fn user_dir() { if Path::new(USER).exists() { println!("user/ already exists"); } else { fs::create_dir(USER).expect("Error: user/ already exists"); fs::File::create("user/lastLogin.txt"); } } fn main() { user_dir(); }...
true
46cc38121f08639222f01733627ec052f6af150d
Rust
danreeves/rust-tests
/src/generics.rs
UTF-8
1,121
3.921875
4
[]
no_license
use std::any::{Any, TypeId}; use std::cmp::PartialOrd; fn same_type<T1: ?Sized + Any, T2: ?Sized + Any>(_a: &T1, _b: &T2) -> bool { TypeId::of::<T1>() == TypeId::of::<T2>() } #[test] fn generics() { // it takes types that have the PartialOrd and Copy traits fn largest<T: PartialOrd + Copy>(list: &[T]) -> ...
true
2ce6fcb1b59108a796ee7e23e3cb88beb0db0989
Rust
jporch/advent-of-code-2020-rust
/day1-1/src/main.rs
UTF-8
725
3.078125
3
[ "MIT" ]
permissive
use std::fs; use std::convert::TryInto; fn main() { let mut vals: Vec<i32> = Vec::new(); let contents = fs::read_to_string("src/input.txt") .expect("Something went wrong reading the file"); let tokens: Vec<&str> = contents.split("\n").collect(); for t in &tokens { vals.push(t.parse::<i...
true
16a8d079679d808fb7a60cd19964ef7134036a96
Rust
fits/try_samples
/rust/sample/trait_sample.rs
UTF-8
324
3.5625
4
[]
no_license
fn main() { let d = Data { name: "data", value: 4 }; println!("{}", d.name); println!("{}", d.times()); } struct Data { name: &'static str, value: i32 } trait Sample { fn sample(&self) -> i32; fn times(&self) -> i32 { self.sample() * 2 } } impl Sample for Data { fn sample(&self) -> i32 { self.value ...
true
a58429d0192400b0398aa08c373a6557918cd3a1
Rust
lianhuiwang/tokamak
/src/parser/lib.rs
UTF-8
3,557
2.953125
3
[ "Apache-2.0" ]
permissive
#![feature(convert)] #[macro_use] extern crate regex; extern crate common; extern crate plan; pub mod parser; pub mod lexer; #[test] fn test_tokenize() { use lexer::Token::*; let tokens = lexer::tokenize("1+-1."); assert_eq!(vec![Integer(1), Plus, Minus, Float(1.)], tokens); let tokens = lexer::tokenize("(1...
true
42cfb304afb36ffcf5ecf8f8c33f37a59009fafb
Rust
kino-ma/makra
/compile/src/codegen/aarch64/native.rs
UTF-8
9,421
2.8125
3
[]
no_license
#![allow(unused)] use crate::err::{Error::*, Result}; use alloc::fmt::Debug; use core::convert::TryInto; use super::reg; use super::Code; pub enum Condition { Equal, NotEqual, GreaterThan, LessThan, GtOrEqual, LtOrEqual, CarrySet, CarryClear, Negative, Positive, Always, ...
true
3a80ec9adb0e06df692dc76fe8229f59a6f71b77
Rust
udoprog/asteroids-amethyst
/src/resources.rs
UTF-8
2,887
2.90625
3
[ "Apache-2.0", "MIT" ]
permissive
use amethyst::{ ecs::{prelude::Entity, World}, renderer::SpriteRender, }; use crate::{components::Bounded, textures::SpriteSheet}; pub struct Ships { pub sprite_sheet: SpriteSheet, } impl Ships { pub fn initialize(world: &mut World) { let sprite_sheet = SpriteSheet::from_path(world, "texture/...
true
bbf2053f41ccc2998e46e58bb7b03f95bfaf7ec8
Rust
alexpana/rustracer
/src/config.rs
UTF-8
2,968
2.96875
3
[]
no_license
extern crate clap; use clap::{Arg, App, ArgMatches}; #[derive(Clone)] pub struct Config { pub thread_count: usize, pub chunk_count: usize, pub sample_count: usize, pub scene: String, pub output_image: String, pub output_size: (usize, usize), } impl Config { pub fn get_app<'a>() -> App<'a,...
true
8260bdd848984dcba7cf1eca9cfe560420c2643a
Rust
tailhook/nginx-config
/tests/errors.rs
UTF-8
1,046
2.515625
3
[ "MIT", "Apache-2.0" ]
permissive
extern crate nginx_config; extern crate regex; #[macro_use] extern crate pretty_assertions; use std::io::Read; use std::fs::File; use nginx_config::parse_main; fn test_error(filename: &str) { let mut buf = String::with_capacity(1024); let path = format!("tests/errors/{}.txt", filename); let mut f = File...
true
e1611cce2aebc6b8cedb923b2a93ad84e6882751
Rust
colin353/largetable
/benches/network.rs
UTF-8
1,446
2.671875
3
[]
no_license
/* network.rs This code tries to connect to a docker instance and checks the time required to perform queries. */ #![feature(test)] extern crate test; extern crate largeclient; extern crate rand; // This function generates a 25 character long ASCII-printable string. fn random_string() -> String { (0....
true
d735a78b2e522097f4f2d6ff15c60e6cbf17e154
Rust
pimdh/gpu-monitor
/src/cli_table.rs
UTF-8
1,170
2.796875
3
[]
no_license
use prettytable::Table; use prettytable::row::Row; use prettytable::cell::Cell; use fetch::{GpuRecord, HostResult}; fn gpu_record_row(r: &GpuRecord) -> Row { Row::new(vec![ Cell::new(&format!("{}", r.index)), Cell::new(&format!("{:.2}", r.total_memory / 1000.0)), Cell::new(&format!("{:.2}"...
true
de88d8a4a440af3533e56858429caee990ab20d3
Rust
Medeah/SPO
/l2/binary.rs
UTF-8
1,044
3.796875
4
[ "MIT" ]
permissive
fn main() { let a = [1,4,7,9,12,56,89,143,394,1946]; let middle = &a; println!("{}", binary_search_rec(middle, 12, 0 ,9)); println!("{}", binary_search_loop(middle, 12)); } fn binary_search_rec(a: &[i32], value: i32, low: usize , high: usize) -> i32 { println!("{}{}", low, high); if high < ...
true
fce1838b1a830724d203e85c3f2a16313a9cbe48
Rust
andreysobol/schnorrust
/src/secp256k1.rs
UTF-8
791
2.78125
3
[]
no_license
extern crate num_bigint; use num_bigint::{BigInt}; pub struct Secp256k1Params{ pub p: BigInt, pub n: BigInt, pub Gx: BigInt, pub Gy: BigInt, } pub fn secp256k1_params() -> Secp256k1Params{ let p: BigInt = BigInt::parse_bytes(b"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F", 16)....
true
49ff8aaf38c31fba3a6aafa9c680ae04c28beb9e
Rust
edunham/cobalt.rs
/src/cobalt.rs
UTF-8
6,650
2.96875
3
[]
no_license
use crossbeam; use std::sync::Arc; use std::fs::{self, File}; use std::io::{self, Read}; use std::path::Path; use std::collections::HashMap; use std::ffi::OsStr; use liquid::Value; use walkdir::WalkDir; use document::Document; pub fn build(source: &Path, dest: &Path, layout_str: &str, posts_str: &str) -> io::Result<(...
true
24cd33acef43ddf58e517c063e3737f6929a2f74
Rust
InterestingBrainPoops/learning
/Chess/src/main.rs
UTF-8
341
2.796875
3
[]
no_license
mod board; fn main() { println!("Hello, world!"); let pieces: Vec<board::Piece> = vec![]; let mut test = board::Board { pieces, turn: board::Color::Black, }; let fen = String::from("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"); test.from_fen(&fen); println!("{:#...
true
7263f4058d475017b4055fd8112d368ce436ab13
Rust
david68cu/rust-in-motion-videos
/unit4/module8-lifetime-elision/02-34-third-rule-applies/src/main.rs
UTF-8
414
3.390625
3
[ "Apache-2.0", "MIT" ]
permissive
use std::collections::HashMap; struct Config { version: usize, settings: HashMap<String, String>, } impl Config { // The lifetime elision rules mean the compiler interprets this signature as if we had written: // fn get_value<'a, 'b>(&'a self, key: &'b str) -> &'a str { fn get_value(&self, key: &s...
true
07bec6ca2b5060566cd3031970bb28e50db9f7ae
Rust
mathiasmagnusson/beetle
/judge/src/worker_pool.rs
UTF-8
1,894
3.375
3
[]
no_license
use std::{ io, sync::{mpsc, Arc, Mutex}, thread, }; enum Message { Job(Job), Stop, } type Job = Box<dyn FnOnce() + Send + 'static>; pub struct WorkerPool { sender: mpsc::Sender<Message>, workers: Vec<Worker>, } impl WorkerPool { pub fn new(workers: usize) -> Self { let (sende...
true
f12a53dc0a0b1f6f78cf4a7a03647ce69da06b98
Rust
vstepchik/p2pc
/frontend/src/components/nickname_input.rs
UTF-8
2,481
3.203125
3
[ "MIT" ]
permissive
use web_sys::HtmlInputElement as InputElement; use yew::prelude::*; pub struct NicknameInput { link: ComponentLink<Self>, value: String, input_ref: NodeRef, on_set: Callback<String>, } pub enum Msg { Nope, UpdateValue(String), SetNickname, } #[derive(Properties, PartialEq, Clone)] pub str...
true
263eebc825ac651f8688e446f14641f45cdff8a1
Rust
hazer-hazer/alpha
/llvm/src/types.rs
UTF-8
6,627
3.0625
3
[]
no_license
use llvm_sys::core; use llvm_sys::prelude::*; pub use llvm_sys::LLVMTypeKind as TypeKind; use crate::context::Context; use crate::values::Value; #[derive(Debug, PartialEq, Eq)] #[repr(u32)] pub enum AddressSpace { Generic = 0, Global = 1, Shared = 3, Const = 4, Local = 5, /// NVVM Internal ...
true
f846ca7141219de4711c48405c30590886de78ae
Rust
Xan0C/raytracing_the_next_week
/src/renderer.rs
UTF-8
1,934
2.8125
3
[ "MIT" ]
permissive
use crate::scene::Scene; use crate::ray::Ray; use crate::camera::Camera; use crate::vec::Vec3; use crate::hitable::Hitable; use lodepng::RGB; use rand::distributions::Uniform; use rand::prelude::*; use rayon::prelude::*; fn color_ray(r: &Ray, scene: &Scene, depth: u32) -> Vec3 { let hit = scene.bvh.hi...
true
c6dde046398dfe201125140428faa491f2e04f9a
Rust
swfsql/onemut
/src/prepared.rs
UTF-8
3,891
2.6875
3
[]
no_license
use super::{target, Apply, Chain, ConsumedToken, PartialApply, Take, TakeOwned, Token}; use std::marker::PhantomData; /// Holds a single scoped modification into a copy of `T`. /// The copy receives the modification lazily, and at the late stage /// of `Prepared::apply`, the original value `T` is replaced by the /// m...
true
29e4a0aa513330953659413478bf1fb5ee5e659b
Rust
tokio-rs/tracing
/tracing-appender/src/sync.rs
UTF-8
2,396
3.1875
3
[ "MIT" ]
permissive
//! Abstracts over sync primitive implementations. //! //! Optionally, we allow the Rust standard library's `RwLock` to be replaced //! with the `parking_lot` crate's implementation. This may provide improved //! performance in some cases. However, the `parking_lot` dependency is an //! opt-in feature flag. Because `pa...
true
33b4f0a67b7ce71fbccba7fa8fe3a5e88be54634
Rust
vickenty/steroids
/src/ship.rs
UTF-8
3,748
2.609375
3
[]
no_license
use three; use nphysics3d; use ncollide; use Ent; use Entity; use Registry; use bullet::Bullet; pub struct Ship { entity: Entity, hitpoints: u32, pitch: f32, yaw: f32, roll: f32, fire_delay: u32, } impl Ship { pub fn new( window: &mut three::Window, world: &mut nphysics3...
true
ae4e8a248293b2e4d75191f92aee23962f7e8c7d
Rust
GavinRay97/reaper-rs
/main/high/src/main_task_middleware.rs
UTF-8
6,530
2.609375
3
[ "MIT" ]
permissive
use crossbeam_channel::{Receiver, Sender}; use crate::{Reaper, DEFAULT_MAIN_THREAD_TASK_BULK_SIZE}; use futures::channel::oneshot; use std::time::{Duration, SystemTime}; pub struct TaskSupport { sender: Sender<MainThreadTask>, } // TODO-medium Is this correct? It was already like that when TaskSupport was a part...
true
ba6624701ca0af40e0aabc6b73008def6bf1d2ff
Rust
mt-caret/mizu
/mizu-crypto/src/double_ratchet.rs
UTF-8
17,063
2.578125
3
[]
no_license
use crate::error::CryptoError; use crate::keys::{ ChainKey, MessageKey, PrekeyKeyPair, PrekeyPublicKey, RatchetKeyPair, RatchetPublicKey, RootKey, }; use crate::x3dh::{X3DHSecretKey, X3DHAD}; use aes_gcm::aead::{generic_array::GenericArray, Aead, NewAead, Payload}; use aes_gcm::Aes256Gcm; use rand::{CryptoRng, RngC...
true
02133dc7c5ae3dea7907fb78e02d061bfdd6b2ac
Rust
sseritan/ss_leetcode
/0304_2DSubsum/src/main.rs
UTF-8
2,042
3.765625
4
[]
no_license
struct NumMatrix { row_sums: Vec<Vec<i32>>, } /** * `&self` means the method takes an immutable reference. * If you need a mutable reference, change it to `&mut self` instead. */ impl NumMatrix { // Only store cummulative for rows // O(N^2) memory and O(N^2) initialize time fn new(matrix: Vec<Vec<...
true
55070f886ba4c40dbb0af97eab47995d075a73b9
Rust
kacejot/procedural-landscape
/src/diamond_square.rs
UTF-8
2,849
2.9375
3
[]
no_license
use std::iter::Sum; use num::{Float, FromPrimitive}; use rand::{ distributions::{DistIter, Distribution, Uniform}, Rng, }; use crate::{height_map::HeightMap, map::Grid}; type DiamondSquareRandomizer<R> = DistIter<Uniform<f32>, R, f32>; pub struct DiamondSquare<R> { rng: DiamondSquareRandomizer<R>, s...
true
1eb08590ca5657341fecfbd2942dabb7b3af549d
Rust
mluluz/lighthouse
/beacon_node/db/src/stores/macros.rs
UTF-8
3,339
2.671875
3
[ "Apache-2.0" ]
permissive
macro_rules! impl_crud_for_store { ($store: ident, $db_column: expr) => { impl<T: ClientDB> $store<T> { pub fn put(&self, hash: &Hash256, ssz: &[u8]) -> Result<(), DBError> { self.db.put($db_column, hash.as_bytes(), ssz) } pub fn get(&self, hash: &Hash256...
true
337b74778da6f0da7041eadd0266125d3f77e9f9
Rust
jakubbaron/advent_of_code
/2015/day-17/src/main.rs
UTF-8
2,613
3.25
3
[]
no_license
use std::collections::HashMap; use std::io::{self}; fn main() -> io::Result<()> { let files_results = vec![ ("test.txt", 25, 4, 2, 3), // 2 is from part 1, min number of bottles ("input.txt", 150, 654, 4, 57), // 4 is from part 1, min number of bottles ]; for (f, capacity, result_1, no...
true
abee9910732ffc1ca8dd9d3954a9bf8133a12c82
Rust
fossabot/stronghold.rs
/engine/runtime/old_fork/src/zone_macos.rs
UTF-8
1,074
2.625
3
[ "Apache-2.0" ]
permissive
// Copyright 2020-2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 #[derive(PartialEq, Debug)] pub enum Error { UnexpectedExitCode { exit_code: libc::c_int }, Signal { signo: libc::c_int }, } impl Error { fn unexpected_exit_code(exit_code: libc::c_int) -> crate::Error { Self::UnexpectedEx...
true
351eb85f6819de02513fd87dff08f2d75a66cfa6
Rust
Qanora/haybale
/src/layout.rs
UTF-8
6,644
3.265625
3
[ "MIT" ]
permissive
//! Functions related to the in-memory layout of data types. use crate::backend::*; use crate::error::*; use crate::project::Project; use llvm_ir::types::{Type, FPType}; use std::sync::{Arc, RwLock}; /// our convention is that pointers are 64 bits pub const POINTER_SIZE_BITS: usize = 64; /// Get the size of the `Typ...
true
dfae3e123d3b04415123bf3b58cba3d12e1b6acd
Rust
K-C-DaCosta/sandboxed_collections
/src/collections/linked_list.rs
UTF-8
12,886
3.578125
4
[]
no_license
use std::ops::*; /// # Description /// A LinkedList with option Nodes /// # Cons /// The underlying memory is an array of pointers. Indirection performance penalties will apply /// # Pros /// 'T' can be pretty much anything. #[allow(dead_code)] pub type LinkedList<T> = DoublyLinkedList<OptionNode<T>>; /// The underly...
true
9973909c9c5ec7fb5aea6b633616d966e1bb5856
Rust
liuzhenhzong/tfs
/src/io/header.rs
UTF-8
19,439
3.40625
3
[ "MIT" ]
permissive
//! Disk header parsing. //! //! The disk header provides information on how to read a TFS disk. This module parses and //! interprets the disk header so it is meaningful to the programmer. /// The size of the disk header. /// /// This should be a multiple of the cluster size. const DISK_HEADER_SIZE: usize = 4096; ///...
true
d77f57054844bb1e8fb41cc281976f381b771251
Rust
Kowalevskaja/nalgebra
/src/geometry/similarity_construction.rs
UTF-8
7,980
2.578125
3
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
#[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; use num::One; use rand::{Rng, Rand}; use alga::general::Real; use alga::linear::Rotation as AlgaRotation; use core::ColumnVector; use core::dimension::{DimName, U1, U2, U3, U4}; use core::allocator::{OwnedAllocator, Allocator}; use core::storage::OwnedS...
true
7f11a7f83a6a0e0fed39215be0be66436265e85f
Rust
soros1321/graph-node
/core/src/schema/provider.rs
UTF-8
7,027
2.625
3
[ "MIT", "Apache-2.0" ]
permissive
use futures::prelude::*; use futures::sync::mpsc::{channel, Receiver, Sender}; use slog::Logger; use std::collections::HashMap; use tokio_core::reactor::Handle; use graph::components::schema::{SchemaProvider as SchemaProviderTrait, SchemaProviderEvent}; use graph::components::subgraph::SchemaEvent; use graph::componen...
true
78d941827d58df89bfe2ba8edc1b686328915e38
Rust
evaporei/design-patterns
/behavioral/null_object/rust/src/lib.rs
UTF-8
1,103
3.234375
3
[]
no_license
pub trait AbstractCustomer { fn is_nil(&self) -> bool; fn get_name(&self) -> &str; } pub struct RealCustomer<'a> { name: &'a str, } impl<'a> RealCustomer<'a> { pub fn new(name: &'a str) -> Self { RealCustomer { name } } } impl<'a> AbstractCustomer for RealCustomer<'a> { fn is_nil(&sel...
true
7695092f0c6ea48df2c48a0339e096cb5d9daff2
Rust
GothenburgBitFactory/taskwarrior
/taskchampion/sync-server/src/storage/mod.rs
UTF-8
2,873
2.9375
3
[ "MIT" ]
permissive
use chrono::{DateTime, Utc}; use uuid::Uuid; #[cfg(debug_assertions)] mod inmemory; #[cfg(debug_assertions)] pub use inmemory::InMemoryStorage; mod sqlite; pub use self::sqlite::SqliteStorage; #[derive(Clone, PartialEq, Eq, Debug)] pub struct Client { /// The latest version for this client (may be the nil versi...
true
83cb1dc7e97295a0f363ff3213cb7b5d66f2cbf6
Rust
epli2/socketio-rust-emitter
/src/lib.rs
UTF-8
7,777
2.890625
3
[ "MIT" ]
permissive
#[macro_use] extern crate serde_derive; use redis::Commands; use rmp_serde::Serializer; use serde::Serialize; use std::collections::HashMap; #[derive(Debug, Clone)] pub struct Emitter { redis: redis::Client, prefix: String, nsp: String, channel: String, rooms: Vec<String>, flags: HashMap<Strin...
true
0e759fdc67e7ace34a553e69bc7acb6520844cf0
Rust
euclio/msgpack-rust
/rmp-serde/tests/common/mod.rs
UTF-8
956
2.71875
3
[]
no_license
use std::io::Cursor; use serde::Deserialize; use rmp_serde::Deserializer; mod de; mod se; #[test] fn pass_deserializer_get_ref() { let buf = [0xc0]; let cur = Cursor::new(&buf[..]); let mut de = Deserializer::new(cur); assert_eq!((), Deserialize::deserialize(&mut de).ok().unwrap()); assert_eq!...
true
4325c258b76b14754247e68723c8770a0c99b1c5
Rust
J-F-Liu/geom3d
/src/utils/point.rs
UTF-8
1,579
3.296875
3
[ "MIT" ]
permissive
use crate::utils::Tolerance; use crate::{Float, Point2}; pub trait Point { fn distance_to_line_segment(&self, a: Self, b: Self) -> Float; fn is_inside_triangle(&self, a: Self, b: Self, c: Self) -> bool; } impl Point for Point2 { fn distance_to_line_segment(&self, a: Point2, b: Point2) -> Float { l...
true
e64102f0426107b2f71ccc2e00eccdebc7f54512
Rust
Jules-Bertholet/esolangs-rs
/crates/brainfuck-common/src/lib.rs
UTF-8
1,308
2.875
3
[ "MIT" ]
permissive
use proc_macro2::TokenStream; use quote::ToTokens; mod ast; #[must_use] pub fn brainfuck2(item: TokenStream) -> TokenStream { let item_str: &str = &item.to_string(); let bytes = item_str.as_bytes(); brainfuck_from_bytes(bytes) } #[must_use] fn brainfuck_from_bytes(bytes: &[u8]) -> TokenStream { let m...
true
e6fb78eac1b918011f12fc35665b3e40f4b593f3
Rust
benruijl/cuba
/examples/vegas.rs
UTF-8
871
2.625
3
[ "MIT" ]
permissive
extern crate cuba; use cuba::{CubaIntegrator, CubaVerbosity}; #[derive(Debug)] struct UserData { f1: f64, f2: f64, } #[inline(always)] fn integrand( x: &[f64], f: &mut [f64], user_data: &mut UserData, nvec: usize, _core: i32, _weight: &[f64], _iter: usize, ) -> Result<(), &'static ...
true
3d52636f798a168148c3ab37dc51549f4d093eaa
Rust
nedjs/path-manager
/utils/util.rs
UTF-8
1,639
3.390625
3
[ "MIT" ]
permissive
use std; use std::io::prelude::*; /// prompts for user input and returns value into Option result pub fn prompt(question: &String, default: &String) -> Option<String> { print!("{}", question); std::io::stdout().flush().ok(); let mut buff = String::new(); std::io::stdin().read_line(&mut buff).expect("Did not ente...
true
518f3a7b0c16e43211c3171e3a8c6e58395fcbfb
Rust
divinerapier/weaver
/weaver/src/error/mod.rs
UTF-8
3,427
2.890625
3
[ "Apache-2.0" ]
permissive
use std::{path::PathBuf, sync::mpsc}; use thiserror::Error; pub use directory_error::DirectoryError; pub use master_error::MasterError; pub use storage_error::StorageError; mod directory_error; mod master_error; mod storage_error; pub enum Error { Master(String), Storage(String), Directory(String), ...
true
6c5ff06a1387cdcae58cf5010fe7164610620443
Rust
benjaminbollen/rust-utp
/tests/stream.rs
UTF-8
2,553
2.71875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
extern crate utp; use std::old_io::test::next_test_ip4; use std::thread; use utp::UtpStream; macro_rules! iotry { ($e:expr) => (match $e { Ok(e) => e, Err(e) => panic!("{}", e) }) } #[test] fn test_stream_open_and_close() { let server_addr = next_test_ip4(); let mut server = iotry!(UtpStream::bind(server...
true
e887663090cd11e4c985295e691a2ea3345a77f7
Rust
1aguna/arrow2
/src/io/parquet/read/nested_utils.rs
UTF-8
6,784
2.546875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::sync::Arc; use parquet2::schema::{types::ParquetType, Repetition}; use crate::{ array::{Array, ListArray}, bitmap::{Bitmap, MutableBitmap}, buffer::{Buffer, MutableBuffer}, datatypes::DataType, error::{ArrowError, Result}, }; /// trait describing deserialized repetition and definition le...
true
75e4e4566d43a818d26dfcba410b669561e57abb
Rust
DoctorAlpaca/rust-sfml
/src/window/mouse.rs
UTF-8
2,838
3
3
[ "Zlib" ]
permissive
/* * Rust-SFML - Copyright (c) 2013 Letang Jeremy. * * The original software, SFML library, is provided by Laurent Gomila. * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from * the use of this software. * * Permission...
true
93c2286d979b9032b90214d9e92573cb4c3950ad
Rust
simon-auch/projecteuler
/src/bin/problem_0035.rs
UTF-8
774
2.90625
3
[]
no_license
use projecteuler::digits; use projecteuler::helper; use projecteuler::primes; fn main() { helper::check_bench(|| { solve(1_000_000); }); assert_eq!(solve(1_000_000), 55); dbg!(solve(1_000_000)); } fn solve(n: usize) -> usize { let primes = primes::sieve_bool(n); primes .iter() ...
true
1c7f4b6e4922ddbfca1be3339764dcda60bb90b2
Rust
dmvict/RustPractice
/practice/2_HelloWorldWithVars.rs
UTF-8
195
3.265625
3
[]
no_license
fn main() { let learn = "Learn"; let together = "Together"; let pro = "Pro"; println!( "Hello, {}-{}-{}!", learn, together, pro ); // print : Hello, Learn-Together-Pro! }
true
86fbf6f476c175a32fde1ba85229c136925ebc57
Rust
fujita/afxdp-rs
/src/bufpool.rs
UTF-8
2,618
3.046875
3
[ "Apache-2.0" ]
permissive
use std::cmp::min; use std::sync::{Arc, Mutex}; use crate::buf::Buf; use crate::mmaparea::MmapArea; /// BufPool stores Bufs. It can be used in a single thread or wrapped in a Mutex to provide a buffer pool to multiple /// threads. pub struct BufPool<'a, T: std::default::Default + std::marker::Copy> { _area: Arc<M...
true
61d602d060cd4c30f15836a1c63869b213981add
Rust
EricGz/cita-gossip
/src/msg.rs
UTF-8
3,379
2.953125
3
[ "MIT", "ISC", "Apache-2.0" ]
permissive
//The module defines data structures, //which declares message types, //and encapsulates logical operations. // // // // use::storage::Node; //The four structure are used for message transmission. pub struct Short_msg{ src:Node, des:Node, data:String, flag:bool, } pub struct List_msg{...
true
c6771e1eabb427d0ca2530a54b1e5b46843550ea
Rust
djanekovic/AOC
/day_7/src/main.rs
UTF-8
2,268
3.328125
3
[]
no_license
use std::io::{self, Read}; use std::collections::HashMap; use std::collections::VecDeque; #[derive(Debug)] struct Bag { number: u64, color: String, } fn bfs(tree: &HashMap<String, Vec<Bag>>, start: &str, end: &str) -> bool { if start == end { return false } let mut q: VecDeque<&str> = Vec...
true
0aff1abc7ad7e9275683d54c8a4f536cfb4ced6a
Rust
mnts26/aws-sdk-rust
/sdk/clouddirectory/src/model.rs
UTF-8
385,349
2.640625
3
[ "Apache-2.0" ]
permissive
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. /// <p>A typed link facet attribute update.</p> #[non_exhaustive] #[derive(std::clone::Clone, std::cmp::PartialEq)] pub struct TypedLinkFacetAttributeUpdate { /// <p>The attribute to update.</p> pub attribute: std::option::Option<c...
true
2fb74414349d561800e6611ee6a3abd790805949
Rust
pmizio/rusty-chat
/frontend/src/components/login.rs
UTF-8
2,463
3.078125
3
[]
no_license
use serde::Serialize; use yew::prelude::*; use yew::services::ConsoleService; use yew::Properties; #[derive(Serialize)] struct LoginPayload { #[serde(rename = "type")] type_: String, name: String, } impl LoginPayload { fn new(name: String) -> Self { Self { type_: "Login".to_string(...
true
93415e67380658abbc79efb9ac3dc2d1b9d81f7e
Rust
isgasho/reason
/src/state/filter.rs
UTF-8
3,681
3.46875
3
[ "MIT" ]
permissive
use crate::error::Fallacy; use crate::filter::PaperFilter; pub enum FilterInst { /// cd something /// Add a new filter joined with AND. Add(PaperFilter), /// cd . /// Changes nothing, but `cd -` takes this into account. Here, /// cd .. /// Remove the most recent non-empty filter. Pa...
true
6526c47b4c9b544204616df076e172e5eab810bd
Rust
gonzaemon111/rust_grammer
/array.rs
UTF-8
482
3.890625
4
[]
no_license
fn main() { let a: [isize;3] = [1, 2 , 3]; // `&配列` でスライスが作れる。 let b: &[isize] = &a; // スライスをフォーマットするにはプレースホルダが`{:?}`になる。 println!("{:?}", b); // => [1, 2, 3] for elm in b { println!("{}", elm); } // => 1 // 2 // 3 // あるいは`(スライス/配列)[インデックス]`で要素にアクセスできる。 print...
true
c7d623e8fec8751d1d84dd93ca9677a5aa95b88d
Rust
ialhamad/rust-exercism
/sum-of-multiples/src/lib.rs
UTF-8
349
3
3
[]
no_license
pub fn sum_of_multiples(limit: u32, factors: &[u32]) -> u32 { let mut multiples: Vec<u32> = Vec::new(); for n in factors { if n > &0 { for i in (*n..limit).step_by(*n as usize) { multiples.push(i) } } } multiples.sort(); multiples.dedup(); ...
true
1c9f7d1f4c2d54dc656bb0006f9db01470c1d294
Rust
allonsy/advent2017
/day23/main2.rs
UTF-8
737
3.53125
4
[ "MIT" ]
permissive
/* Note: After reducing the input code, it is determined that the code asks for the number of composites values between 106500 and 123500 inclusive */ fn main() { print_composite(); } fn print_composite() { let mut num_composite = 0; let mut start = 106500; while start <= 123500 { if !is_prim...
true
f6bf1c53fcd18ebf33c1c80cc40f904e2b25894a
Rust
EFanZh/LeetCode
/src/problem_0003_longest_substring_without_repeating_characters/mod.rs
UTF-8
553
3.15625
3
[]
no_license
pub mod sliding_window; pub mod sliding_window_2; pub mod sliding_window_3; pub trait Solution { fn length_of_longest_substring(s: String) -> i32; } #[cfg(test)] mod tests { use super::Solution; pub fn run<S: Solution>() { let test_cases = [ ("abcabcbb", 3), ("bbbbb", 1), ...
true
905c9b1bfe97c749b6a0569cd692a5946285b6c0
Rust
SuperiorJT/twilight
/model/src/guild/audit_log/optional_entry_info.rs
UTF-8
6,033
2.6875
3
[ "ISC" ]
permissive
use crate::id::{ChannelId, GenericId, MessageId}; use serde::{Deserialize, Serialize}; /// Additional information for certain [`AuditLogEventType`]s. /// /// [`AuditLogEventType`]: super::AuditLogEventType #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct AuditLogOptionalEntryInfo { /...
true
f49f24961a682683abe077f453f812c9f82ec352
Rust
markhakansson/simple-rustc
/src/type_checker.rs
UTF-8
10,945
3.25
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::ast::*; use crate::context::*; use crate::parser::*; pub type TypeRes<T> = Result<T, TypeErr>; #[derive(Debug, Clone, PartialEq, Eq)] pub struct TypeErr(pub String); /// Type checks any expression. fn tc_expr( expr: Expr, fn_list: &mut Functions, fn_context: &mut ContextStack<Type>, ) -> TypeR...
true