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
bd353a6715e727d703335222aabf2fb2d970e266
Rust
Torrencem/dynamics_census
/src/main.rs
UTF-8
19,404
2.859375
3
[]
no_license
#![allow(unused, dead_code)] use std::str::FromStr; use std::num::ParseIntError; extern crate anyhow; use anyhow::Error; use anyhow::Context; mod sigma_invariants; use sigma_invariants::*; extern crate polynomial; extern crate num_field_quad; use polynomial::*; use num_field_quad::*; use num_field_quad::mod_p::*; ...
true
e315bc7b355a9280d5853931970567ab208e9df5
Rust
japaric/compiler-builtins
/src/float/pow.rs
UTF-8
1,177
2.78125
3
[ "NCSA", "MIT" ]
permissive
macro_rules! pow { ($intrinsic:ident: $fty:ty, $ity:ident) => { /// Returns `a` raised to the power `b` #[cfg_attr(not(test), no_mangle)] pub extern "C" fn $intrinsic(a: $fty, b: $ity) -> $fty { let (mut a, mut b) = (a, b); let recip = b < 0; let mut r: $f...
true
c76411da34e9e4fdb92d54f82abedc6ad02c3d11
Rust
bagelboy/adventofcode
/2017/day01/src/main.rs
UTF-8
1,756
3.3125
3
[]
no_license
use std::fs::File; use std::io::Read; fn solve_captcha(input: &[char]) -> u32 { input.iter().enumerate().fold(0, |s, (i, j)| { if i < input.len() && input[i] == input[(i + 1) % input.len()] { s + j.to_digit(10).expect("this should be a number") } else { s } }) } ...
true
4257704a3350fb5ea5b76927a2db203dead0fd6b
Rust
jkristell/infrared
/src/protocol/rc5/encoder.rs
UTF-8
1,046
2.71875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{protocol::Rc5, sender::ProtocolEncoder}; //TODO: Check Overflow const fn calc_freq(mut f: u32) -> u32 { let mut div = 1_000_000; if f > 1000 { f /= 1000; div /= 1000; } (889 * f) / div } impl<const FREQ: u32> ProtocolEncoder<FREQ> for Rc5 { type EncoderData = [u32; 1]...
true
e659fcc05f17f1bc6f59bd3b80708d1faba86b5e
Rust
qingzhu521/paradfs
/src/utils/load_binary.rs
UTF-8
1,537
2.75
3
[]
no_license
use crate::structure::{Graph, AdjacentList}; use crate::common::io::*; use std::time::Instant; pub fn load_binary_graph(dir: String) -> Graph { println!("start to load binary graph"); let now = Instant::now(); let adj_path = fs::create_path(&vec![dir.as_str(), "adj"]); let rev_adj_path = fs::create_pat...
true
413efe8408887b85a3d7064d2e41a7ebb5d063a2
Rust
suryapandian/rust
/examples/05.Ownership/4.copy.rs
UTF-8
211
3.21875
3
[]
no_license
fn main() { let mut foo = 42; let f = &mut foo; let bar = *f; // get a copy of the owner's value *f = 13; // set the reference's owner's value println!("{}", bar); println!("{}", foo); }
true
56927c9523914ae467fb93286946830f6392fe6d
Rust
trustwallet/wallet-core
/codegen-v2/src/tests/mod.rs
UTF-8
4,484
2.625
3
[ "BSD-3-Clause", "LicenseRef-scancode-protobuf", "LGPL-2.1-only", "Swift-exception", "MIT", "BSL-1.0", "Apache-2.0" ]
permissive
// Copyright © 2017-2023 Trust Wallet. // // This file is part of Trust. The full Trust copyright notice, including // terms governing use, modification, and redistribution, is contained in the // file LICENSE at the root of the source code distribution tree. use crate::codegen::swift::{render_to_strings, RenderIntput...
true
0e3f99c0357cafeaf169025f87bdb67a1b60961e
Rust
crides/keebopt
/src/data.rs
UTF-8
3,419
2.859375
3
[ "MIT" ]
permissive
#![allow(dead_code)] use std::collections::BTreeMap; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; use nom::{ branch::alt, bytes::complete::tag, character::complete::{alpha1, char, digit1, none_of, one_of, u32}, combinator::{eof, map, opt, value}, multi::many0, sequ...
true
2763691d1bbf06993f713aaae13e014f72e82785
Rust
egorgrachev/Exercism
/rust/raindrops/src/lib.rs
UTF-8
391
3.140625
3
[]
no_license
pub fn raindrops(n: u32) -> String { let mut output = String::new(); let is_factor = |factor: u32| n % factor == 0; if is_factor(3) { output.push_str("Pling"); } if is_factor(5) { output.push_str("Plang"); } if is_factor(7) { output.push_str("Plong"); } if o...
true
a7e97d628819dc9e1469b6ce02c3c7beea43b339
Rust
leocavalcante/list-load
/src/lib.rs
UTF-8
669
2.6875
3
[ "MIT" ]
permissive
use std::error::Error; use s3::bucket::Bucket; use s3::credentials::Credentials; use s3::region::Region; pub type YouCanDoIt<T = ()> = Result<T, Box<dyn Error>>; pub fn bucket() -> YouCanDoIt<Bucket> { let bucket_name = std::env::var("S3_BUCKET")?; let s3_access_key = std::env::var("S3_ACCESS_KEY")?; let...
true
50cec877e6f3645917510f6b71ea77faae563c61
Rust
chaaz/adventofcode_2018
/day_06/src/part1.rs
UTF-8
2,590
3.140625
3
[]
no_license
use std::ops::RangeInclusive; use std::cmp::Ordering; pub fn run() { let content = include_str!("input.txt").trim().split("\n"); let points: Vec<_> = content.map(|line| Point::from_line(line)).collect(); let rect = Rect::min_bounds(&points); let mut total = vec![(0u32, false); points.len()]; // (area, infini...
true
c875da7f6b1e91afabe15623fa504c9b7a01c1de
Rust
DryDish/Rust
/main/src/main.rs
UTF-8
469
3.125
3
[]
no_license
use logger::{SIZE, init_logger, error, info, warn}; #[derive(Debug)] struct ObjectThing { name: String, age: u8 } fn main() { init_logger(); let thing = ObjectThing { name: "Peter".to_string(), age: 18 }; info!("Hello there"); info!("Hello", "there!"); warn!("Warning ...
true
87643c9c762af960a256df88e92daab697e6b95d
Rust
ticki/kernel
/kernel/scheme/pipe.rs
UTF-8
4,669
2.53125
3
[ "MIT" ]
permissive
use alloc::arc::{Arc, Weak}; use collections::{BTreeMap, VecDeque}; use core::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; use spin::{Mutex, Once, RwLock, RwLockReadGuard, RwLockWriteGuard}; use syscall::error::{Error, Result, EBADF, EPIPE}; use syscall::scheme::Scheme; /// Pipes list pub static PIPE_SCH...
true
099dd85e4752906625b19d691bc659db4b43da55
Rust
Earthmark/Korriban
/runtime/src/space.rs
UTF-8
635
3.015625
3
[ "MIT" ]
permissive
use crate::prop::PropSet; pub trait Element { fn update(&self, src: &PropSet, dest: &mut PropSet); } pub struct Space { props: PropSet, elements: Vec<Box<dyn Element>>, } impl Space { pub fn new() -> Self { Self { props: PropSet::new(), elements: Vec::new(), } ...
true
6bdbc948212ac88ebf9071ec289e827d9f2e0e3b
Rust
EFanZh/Introduction-to-Algorithms
/src/chapter_12_binary_search_trees/section_12_1_what_is_a_binary_search_tree/mod.rs
UTF-8
1,463
3.46875
3
[]
no_license
use crate::chapter_10_elementary_data_structures::section_10_4_representing_rooted_trees::SimpleBinaryTreeNode; pub mod exercises; // Inorder-Tree-Walk(x) // // 1 if x ≠ nil // 2 Inorder-Tree-Walk(x.left) // 3 print x.key // 4 Inorder-Tree-Walk(x.right) pub fn inorder_tree_walk<T, F: FnMut(&T)>(root:...
true
0af29edcbd179921ffd5f6a18515d4f4e6055d3b
Rust
hajifkd/nand2tetris
/10/jackc/src/parser.rs
UTF-8
29,983
2.859375
3
[]
no_license
use crate::lexer::{JackTokenizer, KeywordKind, SymbolKind, Token}; use crate::{escape_xml, JackcError}; use std::convert::TryFrom; pub trait Parse where Self: Sized, { fn parse<T: std::io::Read>(tokenizer: &mut JackTokenizer<T>) -> Result<Self, JackcError>; } #[derive(Debug)] pub struct Class { name: Stri...
true
06cffa8d1e54571f6ef3a9ab135544b169d36e3a
Rust
dtolnay/faketty
/tests/test.rs
UTF-8
622
2.65625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::fs::{self, File}; use std::io; use std::process::Command; #[test] fn test() -> io::Result<()> { let tempdir = scratch::path("faketty"); let stdout = tempdir.join("test-stdout"); let stderr = tempdir.join("test-stderr"); let status = Command::new(env!("CARGO_BIN_EXE_faketty")) .arg("te...
true
d04c7d910c4cdec9f62d3ccb34462cf376975b17
Rust
debragail/prisma-engines
/query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/nested_mutations/already_converted/nested_delete_inside_upsert.rs
UTF-8
13,155
2.734375
3
[ "Apache-2.0" ]
permissive
use query_engine_tests::*; #[test_suite] mod delete_inside_upsert { use query_engine_tests::{assert_error, run_query, run_query_json, DatamodelWithParams}; use query_test_macros::relation_link_test; // "a P1 to C1 relation " should "work through a nested mutation by id" // TODO:(dom): Not working on ...
true
139e06783a21e63693cd63fdb118f982303e1034
Rust
DutchJavaDev/Rust-Rock-Paper-Scissors
/src/main.rs
UTF-8
3,762
3.515625
4
[]
no_license
extern crate rand; use std::io; use rand::Rng; #[derive(Debug)] #[derive(PartialEq)] enum Winner { None, Robot, Draw, You } #[derive(Debug)] #[derive(PartialEq)] enum Choices { None, Rock, Paper, Scissors } macro_rules! writeln { () => { println!(); }; ($txt:expr...
true
31191ac7075c4f69fb04c88499105a51d9d5f338
Rust
nwtnni/photon
/src/integrator/light.rs
UTF-8
1,361
2.671875
3
[ "MIT" ]
permissive
use crate::prelude::*; use crate::geom; use crate::light::Light as _; use crate::math; use crate::scene; use crate::integrator; #[derive(Copy, Clone, Debug)] pub struct Light; impl<'scene> integrator::Integrator<'scene> for Light { fn shade(&self, scene: &scene::Scene<'scene>, ray: &math::Ray, hit: &geom::Hit<'sc...
true
e3061f761cb36078bcfe83683b2dd39bf252c8b0
Rust
tut-cc/ProjectEuler
/Problem018/rust/euler018.rs
UTF-8
896
2.984375
3
[]
no_license
use std::str::FromStr; use std::fmt::Debug; use std::cmp; fn convert_from_str<T: FromStr>(line: &str) -> Vec<T> where T::Err : Debug { line.split_whitespace().map(|x| x.parse::<T>().unwrap()).collect() } fn main() { let s = "75 95 64 17 47 82 18 35 87 10 20 04 82 47 65 19 01 23 75 03 34 88 02 77 73 07 63 67 99 65...
true
85505059681272416aa047121994c607bf79aa7e
Rust
briete/yukicoder
/no56/src/main.rs
UTF-8
348
2.78125
3
[]
no_license
fn getline() -> String{ let mut __ret=String::new(); std::io::stdin().read_line(&mut __ret).ok(); return __ret; } fn main() { let l = getline(); let lv: Vec<_> = l.trim().split(' ').collect(); let d: f64 = lv[0].parse().unwrap(); let p: f64 = lv[1].parse().unwrap(); println!("{}", (d + (d * p /...
true
35b9d615707635caad411b42df1d305b4997a308
Rust
awersching/wedder
/src/weather/weather_condition.rs
UTF-8
808
2.703125
3
[ "MIT" ]
permissive
use std::collections::HashMap; use serde::{Deserialize, Serialize}; use strum_macros::Display; use crate::config::Config; #[derive(Debug, Hash, Eq, PartialEq, Serialize, Deserialize, Display)] #[strum(serialize_all = "snake_case")] pub enum WeatherCondition { ClearSky, FewClouds, Clouds, ManyClouds, ...
true
38dccff8576af3e4f0ea499d92cee13c74d120d7
Rust
tarikeshaq/y86-lib
/src/executer/print.rs
UTF-8
4,486
2.640625
3
[ "MIT" ]
permissive
use super::instructions::{ICode, Instruction, Register}; use super::State; use lazy_static::lazy_static; use num_traits::FromPrimitive; use std::collections::HashMap; lazy_static! { static ref MAP: HashMap<u8, &'static str> = vec![ ((ICode::IHALT as u8) << 4, "halt"), ((ICode::INOP as u8) << 4, "no...
true
5f3ac359342d77e11bb70333f8c82e0534cd04d3
Rust
Reeywhaar/nut
/src/bucket/cursor_tests.rs
UTF-8
5,365
2.65625
3
[ "MIT" ]
permissive
use crate::db::tests::db_mock; #[test] fn seek_none() { let mut db = db_mock().build().unwrap(); let mut tx = db.begin_rw_tx().unwrap(); drop(tx.create_bucket(b"blub").unwrap()); let c = tx.cursor(); let item = c.seek(b"foo"); assert!(item.is_ok()); assert!(item.unwrap().is_none()); } #[te...
true
852e8273a09a2eb7114c9fc7b67062876f052fec
Rust
williamluke4/prisma-engine
/libs/sql-connection/src/mysql.rs
UTF-8
3,192
2.6875
3
[ "Apache-2.0" ]
permissive
use crate::{pooling::*, traits::{SqlConnection, SyncSqlConnection}}; use quaint::{ ast::*, connector::{self, ResultSet}, error::Error as QueryError, pool::{MysqlManager}, }; use std::convert::{TryInto}; use tokio::runtime::Runtime; use url::Url; /// A connection, or pool of connections, to a MySQL data...
true
eea8ba5d75541f5a56acf3dfb9edff2aabca006c
Rust
Mange/googleprojection-rs
/tests/integration_test.rs
UTF-8
201
2.546875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern crate googleprojection; #[test] fn it_works() { let pixel = googleprojection::from_ll_to_pixel(&(13.2, 55.9), 2).unwrap(); assert_eq!(pixel.0, 550.0); assert_eq!(pixel.1, 319.0); }
true
7d32e936f0291441dc5e2dbe5f56510737c93669
Rust
japaric-archived/linalg.rs
/src/ops/sub_assign/diag.rs
UTF-8
695
2.546875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use std::ops::Neg; use assign::SubAssign; use blas::Axpy; use onezero::One; use ops; use {DiagMut, Diag}; // Combinations: // // LHS: DiagMut // RHS: &T, T // // -> 2 implementations // Core implementations impl<'a, 'b, T> SubAssign<&'a T> for DiagMut<'b, T> where T: Axpy + Neg<Output=T> + One { fn sub_assign(&...
true
bb9927801d1cc0799ba396c831b50084c888eb02
Rust
jawline/klee-rust
/tests/simple.rs
UTF-8
816
3.078125
3
[ "Unlicense" ]
permissive
extern crate klee; #[test] fn basic_test() { let mut a : i32 = 0; klee::symbol(&mut a, "a"); assert_eq!(a, 56); } #[test] fn other_test() { let mut a : i32 = 0; let mut b : i32 = 0; klee::symbol(&mut a, "a"); klee::symbol(&mut b, "b"); if a == 50 && b == 50 { panic!("I should happen!"); } ...
true
eff061564b16e15bbfe022ef2b571ca6b942ef91
Rust
tbarrella/crypto-pure
/src/ghash.rs
UTF-8
6,715
2.90625
3
[ "Apache-2.0" ]
permissive
use byteorder::{BigEndian, ByteOrder as _}; pub(crate) fn ghash(key: &[u8; 16], data: &[u8], ciphertext: &[u8]) -> [u8; 16] { let mut tag = [0; 16]; let mut mac = GHash::new(key, data); mac.update(ciphertext); mac.write_tag(&mut tag); tag } const R0: u128 = 0xe1 << 120; struct GHash { functio...
true
ce7f75f0a67fb7ad04eb8e7b7f1b8dcc323905d3
Rust
Nessex/advent-of-code
/2020/aoc-2020d6p2/src/main.rs
UTF-8
1,104
3
3
[]
no_license
use std::io::{self, Read}; use std::collections::HashSet; use std::iter::FromIterator; fn main() -> io::Result<()> { let mut buffer = String::new(); let mut stdin = io::stdin(); stdin.read_to_string(&mut buffer)?; let mut total = 0; for group in buffer.split("\n\n") { let mut set: HashSe...
true
b58b9df40011e68c36b4fd4991634e1ef1e8440b
Rust
grodwar/Hello_rust
/src/basics/types_and_variables.rs
UTF-8
5,018
3.296875
3
[]
no_license
#![allow(dead_code)] //turns off the warning from the compiler //#![allow(unused_imports)] use std::mem; // this is how you import const MEANING_OF_LIFE:u8 = 42; // no fixed address (its gonna be replaced inline at compilation time) //have to declare the type by yourself // all caps by standard static Z:i32 = 123; sta...
true
6c7082213a04c9dfc941a587dc811ef39b1293bb
Rust
shelbyd/subsrch
/src/indices.rs
UTF-8
401
2.984375
3
[ "MIT" ]
permissive
use std::collections::*; pub type Indices = HashSet<usize>; pub trait SelectIndices { fn select_indices(self, indices: &Indices) -> Self; } impl<T> SelectIndices for Vec<T> { fn select_indices(self, indices: &Indices) -> Self { self.into_iter() .enumerate() .filter(|&(i, _)| i...
true
d18152b6671f982de45bf22764e4a1582a942bc1
Rust
avlo/rust-reference
/src/string_literal.rs
UTF-8
245
2.890625
3
[]
no_license
fn main() { let mut s = "string"; println!("{}", s); s = "another"; println!("{}", s); //let s1 = String::from("hello"); //let s2 = s1; //println!("{}", s2); let s1 = String::from("hello"); let s2 = s1; println!("{}, world!", s1); }
true
7d928a1ec6830a6071ca497d14d206674ed96943
Rust
Measter/rust_utils
/src/time/timespan.rs
UTF-8
18,903
3.265625
3
[]
no_license
use std::time::Duration; const NANOS_PER_MILLISECOND_F: f64 = 1_000_000.0; const NANOS_PER_SECOND_F: f64 = 1_000_000_000.0; const NANOS_PER_MILLISECOND: u32 = 1_000_000; const SECONDS_PER_MINUTE: u64 = 60; const SECONDS_PER_HOUR: u64 = SECONDS_PER_MINUTE * 60; const SECONDS_PER_DAY: u64 = SECONDS_PER_HOUR * 24; /// T...
true
fbbdb7a00b5ae00a915911053a22999960bd939a
Rust
wuggen/resolution
/src/fileparser.rs
UTF-8
5,955
2.796875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::cnf::*; use crate::resolution_graph::ResolutionGraph; use std::collections::HashMap; use std::fs::File; use std::io::prelude::*; use std::path::Path; #[derive(Debug)] pub enum FileParseError { IOError(std::io::Error), ParseError(String), } impl std::fmt::Display for FileParseError { fn fmt(&se...
true
988b90fddd48c4b9b529fff4a93c1439e79b1ebc
Rust
basiliqio/messy_json
/src/schema.rs
UTF-8
9,681
3.375
3
[ "MIT" ]
permissive
use std::ops::Deref; use super::*; /// ## Schema of a JSON Value /// /// This enum describes in broad strokes how a JSON should look like when deserialized. /// /// At deserialization, this enum will ensure that the JSON Value corresponds to this schema. #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub enum MessyJson...
true
23f3acd5cc06257b8225db84cfe4805b94973cf2
Rust
hml1006/amqp-proto
/src/method/base.rs
UTF-8
4,136
2.921875
3
[ "BSD-2-Clause" ]
permissive
use crate::class::Class; use crate::error::FrameDecodeErr; use crate::method::tx::TxMethod; use crate::method::connection::ConnectionMethod; use crate::method::channel::ChannelMethod; use crate::method::access::AccessMethod; use crate::method::exchange::ExchangeMethod; use crate::method::queue::QueueMethod; use crate::...
true
9695d72c0f737e8ff67b267fcbe3621fd9d0aa9f
Rust
AhmedArslan/d4-format
/d4/src/task/histogram.rs
UTF-8
2,021
2.984375
3
[ "MIT" ]
permissive
use super::{Task, TaskPartition}; use std::ops::Range; pub struct Histogram(String, u32, u32); pub struct Partition { range: (u32, u32), base: i32, histogram: Vec<u32>, below: u32, above: u32, } impl TaskPartition for Partition { type PartitionParam = Range<i32>; type ResultType = (u32, V...
true
8a0c82a91ed8074e700245524515013a1056a88d
Rust
hml1006/amqp-proto
/src/method/connection.rs
UTF-8
1,524
3.15625
3
[ "BSD-2-Clause" ]
permissive
use crate::method::base::MethodId; #[derive(Clone, Copy)] pub enum ConnectionMethod { Start, StartOk, Secure, SecureOk, Tune, TuneOk, Open, OpenOk, Close, CloseOk, Unknown, } impl MethodId for ConnectionMethod { fn method_id(&self) -> u16 { match self { ...
true
e37fef6c1f1eed32ddb95a1448e7fcb28865f280
Rust
indiv0/rnes
/src/cpu.rs
UTF-8
77,268
3.046875
3
[]
no_license
use mapper::{Mapper, NROM}; use memory::{Address, Memory, NESMemory}; use opcode::Opcode; use opcode::Opcode::*; use std::cmp::Ordering::{Equal, Greater, Less}; use util::{bit_get, bit_set, is_negative}; // Initialization values for the CPU registers. const CPU_STATUS_REGISTER_INITIAL_VALUE: u8 = 0x34; // 0x00111000 (...
true
c507d496af5f2d649a009cfe15c735ac48470830
Rust
secondfry/school21-rust-libft
/src/strlen.rs
UTF-8
634
3.796875
4
[ "MIT" ]
permissive
/// # strlen /// Returns str.len(). /// /// This function has no reason to exist. /// /// ## Example /// ``` /// assert_eq!(ft::strlen("abc"), 3); /// assert_eq!(ft::strlen("\0bc"), 3); /// ``` pub fn strlen(s: &str) -> usize { return s.len(); } /// # strlen_naive /// Returns amount of sumbols to first null-symbol i...
true
7bb46f2a42b130254f4afacf255b481849fe3932
Rust
0xbadcoffe/ctap-hid-fido2
/src/client_pin_response.rs
UTF-8
1,781
2.875
3
[ "MIT" ]
permissive
use crate::cose; use crate::util; use serde_cbor::Value; pub struct Pin { pub retries: i32, } pub fn parse_cbor_client_pin_get_pin_token(bytes: &[u8]) -> Result<Vec<u8>, String> { let cbor: Value = serde_cbor::from_slice(bytes).unwrap(); if let Value::Map(n) = cbor { // 最初の要素を取得 let (key,...
true
a5e1fe22083eadc45c8e3b27f5c7cb1d9573a81c
Rust
maheshambule/presto_rs
/src/parsing/parser.rs
UTF-8
132,662
2.90625
3
[]
no_license
use super::{parse_tree, visit_post_order, ParseTree}; use crate::lexing::{ predefined_names, predefined_names::PredefinedName as PN, Lexer, Token, TokenKind as TK, }; use crate::utils::{ position, position::Position, syntax_error, syntax_error::Message, syntax_error::SyntaxError, text_range, text_range::Tex...
true
ce16aa8230cfc4f75fbb19c1e227a256d3c076a9
Rust
fhars/libtock-rs
/examples/button_subscribe.rs
UTF-8
858
2.640625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
#![no_std] use core::fmt::Write; use libtock::buttons; use libtock::buttons::ButtonState; use libtock::console::Console; use libtock::timer; use libtock::timer::Duration; // FIXME: Hangs up when buttons are pressed rapidly - problem in console? fn main() { let mut console = Console::new(); let mut with_callb...
true
05bf558ab8029b8f45b4941386b8f3f480dea8cd
Rust
AlbinoGazelle/Learning-Rust
/slices/src/main.rs
UTF-8
1,480
4.21875
4
[ "MIT" ]
permissive
//function to get the first word in a string using slices fn first_word(s: &str) -> &str { let bytes = s.as_bytes(); for (i, &item) in bytes.iter().enumerate() { if item == b' ' { return &s[0..i]; } } &s[..] } fn main() { //Slices are a way to reference a sequence of ...
true
d22cf12220a96444813ef95859b1cb0b8f0238a1
Rust
melentyev/main
/rust_http_server/http/request.rs
UTF-8
5,787
3.015625
3
[]
no_license
use std::io::{TcpStream, BytesReader}; use std::collections::HashMap; use http::method::Method; use std::str::FromStr; use std::str::StrExt; use std::str::from_utf8; use std::str::from_utf8_unchecked; #[derive(Show)] pub struct Request { pub method: Method, pub http_minor : u32, pub http_major: u32, pub path: Stri...
true
5e437206eff26a55c2caa00a04ad989714840f6b
Rust
deuzu/adventofcode
/day1/src/step1.rs
UTF-8
946
3.453125
3
[]
no_license
use std::fs::File; use std::io; use std::io::Read; use std::path::Path; fn main() { let input = get_input().expect("Failed to open input file"); let lines = input.lines().into_iter(); let mut result: Option<u32> = None; for p1 in lines.clone() { for p2 in lines.clone() { let pair: ...
true
d88931ad4f0ad25388f9929a51e0b9c0eb267e9e
Rust
dcchut/serenity
/examples/12_timing_and_events/src/main.rs
UTF-8
9,695
3.046875
3
[ "ISC" ]
permissive
//! This example will showcase one way on how to extend Serenity with a //! time-scheduler and an event-trigger-system. //! We will create a remind-me command that will send a message after a //! a demanded amount of time. Once the message has been sent, the user can //! react to it, triggering an event to send another...
true
a3d7340d7687a176bdf374b64fe27d6667c2dd1c
Rust
maximumstock/Advent-of-Code-2019
/day_01/src/main.rs
UTF-8
1,982
2.859375
3
[]
no_license
fn main() { let input = vec![ 149579, 95962, 97899, 149552, 65085, 111896, 127591, 115128, 64630, 120430, 81173, 136775, 137806, 132042, 65902, 87894, 97174, 126829, 88716, 85284, 61178, 106423, 89821, 51123, 85350, 53905, 74259, 59710, 80358, 111938, 129027, 144036, 68717, 69382, 64163, 651...
true
a372bd072a3db7c657d91a0c01d0b6efc449184b
Rust
michalwa/cgol-rs
/src/utils.rs
UTF-8
480
3.640625
4
[]
no_license
use std::ops::RangeInclusive; pub trait RangeExt<T> { /// Constrains the value to be contained within the range fn clamp(&self, t: T) -> T where T: Clone + Ord; } impl<T> RangeExt<T> for RangeInclusive<T> { fn clamp(&self, t: T) -> T where T: Clone + Ord, { if &t < self...
true
d943db1d1ae0659c7251d85b7993389ff79d0eca
Rust
ckatsak/aoc2020
/day11/part2.rs
UTF-8
10,235
3.390625
3
[]
no_license
use std::convert::TryInto; use std::io::{BufRead, BufReader}; use std::path::Path; use anyhow::{anyhow, bail, Result}; #[derive(Clone, Debug, PartialEq)] enum Seat { Empty(usize, usize), Occupied(usize, usize), Floor, } impl std::convert::TryFrom<((usize, usize), char)> for Seat { type Error = String...
true
55b9d5c71e743cfdd343c78faf3414bf5d14ed25
Rust
madrury/rusty-rogue
/rogue/src/melee_combat_system.rs
UTF-8
7,979
2.9375
3
[]
no_license
use specs::prelude::*; use super::{ Map, Point, TileType, CombatStats, WantsToMeleeAttack, Name, WantsToTakeDamage, GameLog, Renderable, Position, AnimationRequestBuffer, AnimationRequest, Equipped, GrantsMeleeAttackBonus, StatusIsMeleeAttackBuffed, ElementalDamageKind, SpawnEntityWhenMeleeAttacked, Ent...
true
3207d986d26532431cbdf6f675917ac797c64920
Rust
JM4ier/oxidized
/src/commands/play/random_ai.rs
UTF-8
419
2.546875
3
[]
no_license
use super::*; use rand::prelude::*; use std::marker::*; #[derive(Default)] pub struct RandomPlayer<G> { _phantom: PhantomData<G>, } impl<G: PvpGame<usize> + Clone> AiPlayer<usize, G> for RandomPlayer<G> { fn make_move(&mut self, game: &G, player_id: usize) -> usize { let mut valid_moves = game.possibl...
true
a7f59cb003e22559cfebef194e0f0d12676e09f0
Rust
lo48576/datetime-string
/src/common/ymd8_hyphen.rs
UTF-8
50,477
3.078125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Date string in `%Y-%m-%d` (`YYYY-MM-DD`) format. //! //! This is also an RFC 3339 [`full-date`] string. //! //! [`full-date`]: https://tools.ietf.org/html/rfc3339#section-5.6 use core::{ convert::TryFrom, fmt, ops::{self, Range}, str, }; use crate::{ datetime::{is_leap_year, validate_ym0d, val...
true
f516fc53beaae3ae886475b213cc9f02447937cf
Rust
s32k-rust/s32k144.rs
/src/mcm/cpcr.rs
UTF-8
23,016
2.734375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::CPCR { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut ...
true
a540f98ec4812de10331df8b56a4642d9a28e50d
Rust
zhangjingqiang/os-ht-generator
/src/main.rs
UTF-8
1,824
2.6875
3
[ "MIT" ]
permissive
extern crate csv; use std::error::Error; use std::io; use std::process; use std::fs::File; const DOC: &str = r#" parameters: key_name: "user" image: "image" flavor: "flavor" security_groups: [ "default" ] volume_size: 100 volume_type: "SSD" vm_name: "vm" domain: "domain" az: "az" network: - ne...
true
37f0b10e33a45004759e1f784b72bbb3bed9e57e
Rust
astro/rust-lpc43xx
/src/mcpwm/inten_clr/mod.rs
UTF-8
8,852
2.609375
3
[ "Apache-2.0" ]
permissive
#[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::INTEN_CLR { #[doc = r" Writes to the register"] #[inline] pub fn write<F>(&self, f: F) where F: FnOnce(&mut W) -> &mut W, { let mut w = W::reset_value(); f(&mut w); self.register.s...
true
1d11dd0f65dbc05409c1f2256ba68575fce3d0e8
Rust
hacspec/hacspec
/lib/src/math_util/ct_util.rs
UTF-8
2,768
3.453125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::prelude::*; /// Conditional, constant-time swapping. /// Returns `(x, y)` if `c == 0` and `(y, x)` if `c == 1`. #[inline] #[cfg_attr(feature = "use_attributes", not_hacspec)] pub fn cswap_bit<T: Integer + Copy>(x: T, y: T, c: T) -> (T, T) { cswap(x, y, T::default().wrap_sub(c)) } /// Conditional, const...
true
7cc8d493470baaa52a47fdbaf20ccb302489412e
Rust
juggernaut0/aoc2019
/src/day20.rs
UTF-8
8,698
2.984375
3
[]
no_license
use std::collections::{HashMap, VecDeque}; pub fn run1(input: Vec<String>) -> u32 { let map = Map::from_input(input); pathfind(&map.chars, &map.outside_portals, &map.inside_portals) } pub fn run2(input: Vec<String>) -> u32 { let map = Map::from_input(input); pathfind2(&map.chars, &map.outside_portal...
true
ef2eca7a786fc403d4a89b0c9d44e6cd310ea96e
Rust
obeah/sheeit
/sheeit/tests/concurrency_test.rs
UTF-8
7,581
2.703125
3
[ "MIT" ]
permissive
mod util; use core::cmp; use prettytable; use prettytable::{Row, Table}; use rand; use rand::Rng; use sheeit::storage::Storage; use sheeit::storage::{Cell, CoreDocument, Value}; use std::sync::Arc; use std::thread; use std::time::{Duration, Instant}; use util::multi_value::MultiValue; use uuid::Uuid; #[test] fn te...
true
4238a19e0f097d5b0ae522d8bb30324da41ce1dc
Rust
semargal/num-to-words
/src/test_utils.rs
UTF-8
226
2.6875
3
[ "Apache-2.0" ]
permissive
use crate::types::*; pub struct InOut(pub Int, pub StaticStr); pub fn test_set(f: &dyn Fn(Int) -> Result<String>, data: &[InOut]) { for sample in data.iter() { assert_eq!(f(sample.0).unwrap(), sample.1); } }
true
2f7803eef306f205b04f04171bb6f30d39e124c1
Rust
PaigeDavid/CSIS616
/project1/src/main.rs
UTF-8
13,345
3.40625
3
[]
no_license
//! CSIS-616 - Program #3 //! //! Some parts were originally made by: Ralph W. Crosby PhD. //! Edited and added to by: Paige Peck //! //! //! Process a yaml format deterministic finite automaton producing //! - A textual representation of the internal state graph //! - A Graphviz `.dot` file representing the graph /...
true
d580d7d567ad69b5963db406b2af014ce3bb801c
Rust
qeedquan/challenges
/codegolf/rotate-cartesian-coordinates.rs
UTF-8
949
3.78125
4
[ "MIT" ]
permissive
/* Write a program rotates some Cartesian coordinates through an angle about the origin (0.0,0.0). The angle and coordinates will be read from a single line of stdin in the following format: angle x1,y1 x2,y2 x3,y3 ... eg. 3.14159265358979 1.0,0.0 0.0,1.0 1.0,1.0 0.0,0.0 The results should be printed to stdout i...
true
4fbc9ccf587fe4654f8fad05e165e8ab1b551a43
Rust
gleam-lang/gleam
/compiler-core/src/erlang/tests/strings.rs
UTF-8
1,837
3.421875
3
[ "Apache-2.0" ]
permissive
use crate::assert_erl; #[test] fn concat() { assert_erl!( r#" pub fn go(x, y) { x <> y } "#, ); } #[test] fn concat_3_variables() { assert_erl!( r#" pub fn go(x, y, z) { x <> y <> z } "#, ); } #[test] fn string_prefix() { assert_erl!( r#" pub fn go(x) { case x { ...
true
4630212c14e8e13e04c7355d8648ab75eb1e5f31
Rust
galenelias/AdventOfCode_2015
/src/Day24/mod.rs
UTF-8
2,581
3.15625
3
[]
no_license
use std::io::{self, BufRead}; use itertools::Itertools; fn check_splits(vals: &Vec<u32>, pos: usize, target: u32) -> (bool, Option<(usize, u64)>) { let mut sum : u32 = 0; let mut first_index = None; for i in 0..pos { sum += vals[i]; if sum == target { if first_index.is_none() { first_index = Some(i+1); ...
true
5fc9fe499cc6efd86b031744fc233573fbc5ee6b
Rust
jannes/fan2jian
/src/bin.rs
UTF-8
1,387
3.078125
3
[]
no_license
use std::{fs, io::Write, path::PathBuf}; use fan2jian::map_text; const HELP: &str = "\ fan2jian USAGE: app [INPUT_PATH] [OUTPUT_PATH] FLAGS: -h, --help Prints help information -r, --reverse Do reverse direction: 简体 to 繁体 ARGS: <INPUT_PATH>: path to input file <OUTPUT_PATH>: path to output...
true
3071b2cf57668eba4eb936b1f00a67dfbc8f6178
Rust
louiidev/smol-rs
/examples/camera_movement.rs
UTF-8
1,343
2.625
3
[]
no_license
use smol_rs::errors::SmolError; use smol_rs::math::Vector3; use smol_rs::{import_file, App, AppSettings, Color, Keycode, Transform}; extern crate smol_rs; fn main() -> Result<(), SmolError> { let mut app = App::new(AppSettings { target_fps: 144., ..Default::default() }); let t = app ...
true
bc99790fe5245a45cea43cc1f0b1bbed4051dd58
Rust
AssafAoc/aoc2020
/src/d5.rs
UTF-8
1,549
2.890625
3
[ "Unlicense" ]
permissive
use std::collections::BTreeSet; #[allow(dead_code)] const TEST: &str = r#"FBFBBFFRLR BFFFBBFRRR FFFBBBFRRR BBFFBBFRLL"#; // 357, 567, 119, 820 #[allow(dead_code)] pub fn run() { let input = super::get_input(5, ""); // let input = TEST.lines(); let mut seat_ids = BTreeSet::new(); for boarding_pass in...
true
b852cda2eb3b7916dd3c49f4a6513538c62332d0
Rust
erezny/rusted-cypher
/src/cypher/mod.rs
UTF-8
11,540
2.96875
3
[ "MIT" ]
permissive
//! Provides structs used to interact with the cypher transaction endpoint //! //! The types declared in this module, save for `Statement`, don't need to be instantiated //! directly, since they can be obtained from the `GraphClient`. //! //! # Examples //! //! ## Execute a single query //! ``` //! # use rusted_cypher:...
true
6d355db6745ac2b0d7be36a786672edb075249b7
Rust
fbenkstein/advent-of-code
/gabriel/day22/src/main.rs
UTF-8
7,494
3.03125
3
[]
no_license
use priority_queue::PriorityQueue; use revord::RevOrd; use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashSet, VecDeque}; use std::fmt; struct Cave { depth: usize, width: usize, height: usize, target_x: usize, target_y: usize, regions: Vec<usize>, } enum Region { Rocky, Wet, ...
true
8ccb6a616ebc6a105fb5c7d6340ad8823142325e
Rust
bto/wasm-gameboy
/wasm/src/cpu/opcode/dec_tests.rs
UTF-8
8,542
2.734375
3
[]
no_license
use super::*; #[macro_use] mod tests_macro; #[test] fn op_dec_r() { let mut cpu = CPU::new(); let opcode_base = 0b00_000_101; for i in [0b000, 0b001, 0b010, 0b011, 0b100, 0b101, 0b111].iter() { let opcode = opcode_base | (i << 3); // half carry let pc = cpu.registers.pc; ...
true
7621a3536407b217140ee6294a2d82f1ccbc37d4
Rust
quezlatch/Dining_Philosophers
/src/dining_philosophers/analysis.rs
UTF-8
5,846
3.28125
3
[]
no_license
use std::collections::HashMap; use std::sync::{Arc, Mutex}; use crate::dining_philosophers::philosopher::state_machine::State; use crate::dining_philosophers::philosopher::state_machine::State::Eating; fn calculate_percentage(history: &Vec<State>) -> f32 { let total: f32 = history.len() as f32; let no_of_thin...
true
4e4e5aaaa15fc4affce21d0958d3816ef892739d
Rust
freexploit/weebtk
/src/main.rs
UTF-8
1,513
3.140625
3
[]
no_license
use cstr::cstr; use qmetaobject::prelude::*; // The `QObject` custom derive macro allows to expose a class to Qt and QML #[derive(QObject, Default)] struct Greeter { // Specify the base class with the qt_base_class macro base: qt_base_class!(trait QObject), // Declare `name` as a property usable from Qt ...
true
ae7b95c7ae4ee95a5f05ff1c2cbc8bfbe05da5d1
Rust
FlyingDutchmanGames/lib_table_top
/src/common/deck/card/rank.rs
UTF-8
6,372
3.609375
4
[]
no_license
use serde_repr::*; /// The pips of a standard deck. Important note that the cards have `repr(u8)` and Ace is /// represented by 1 #[derive( Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Hash, Ord, Serialize_repr, Deserialize_repr, )] #[repr(u8)] pub enum Rank { Ace = 1, Two = 2, Three = 3, Four = ...
true
746e0082dedde11d2c63cd13517c473e54bf9cd3
Rust
sparky8251/maelstrom
/src/db/mod.rs
UTF-8
619
2.9375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
pub mod postgres; pub use postgres::PostgresStore; use async_trait::async_trait; use std::error::Error; /// A Storage Driver. /// /// This trait encapsulates a complete storage driver to a /// specific type of storage mechanism, e.g. Postgres, Kafka, etc. #[async_trait] pub trait Store: Clone + Sync + Send + Sized {...
true
1a496a75623ac9952bd713bc8a942f0768919194
Rust
nilsso/challenge-solutions
/exercism/rust/rectangles/src/lib.rs
UTF-8
1,830
3.1875
3
[]
no_license
#![feature(bool_to_option)] use std::iter::repeat; fn cartesian_product(m: usize, n: usize) -> impl Iterator<Item = (usize, usize)> { (0..m).flat_map(move |i| repeat(i).zip(0..n)) } fn combinations(n: usize) -> impl Iterator<Item = (usize, usize)> { (0..n.max(1) - 1).flat_map(move |i| repeat(i).zip(i + 1..n)...
true
03ef86f43404ce52bf262a4749e755367620de40
Rust
joaodelgado/advent-of-code-2019
/src/day02.rs
UTF-8
2,886
3.484375
3
[]
no_license
use super::Day; struct Computer { instructions: Vec<usize>, pc: usize, } impl Computer { fn new(instructions: Vec<usize>) -> Computer { Computer { pc: 0, instructions, } } fn init(&mut self, noun: usize, verb: usize) { self.instructions[1] = noun; ...
true
7ddb4f2445ad5311781fa8f54fdafefc73b491ca
Rust
mrmanne/advent-of-code-2020
/src/days/day23.rs
UTF-8
3,217
3.109375
3
[ "MIT" ]
permissive
use crate::puzzle::{io, File, Puzzle}; pub struct Day23; fn play(cups: &mut Vec<usize>, mut cur: usize, turns: usize) { let max = cups.len() - 1; for _ in 0..turns { let mut removals = vec![]; let mut next = cups[cur]; for _ in 0..3 { removals.push(next); next ...
true
1a13a85923c74fe6c94f6fc5f9dc7c9a602b4b0e
Rust
dragon1061/MoonZoon
/crates/zoon/src/web_storage.rs
UTF-8
7,244
3.046875
3
[ "MIT" ]
permissive
use crate::*; use once_cell::race::OnceBox; use web_sys::Storage; pub type Result<T> = std::result::Result<T, Error>; // ------ local_storage ------ pub fn local_storage() -> &'static LocalStorage { static LOCAL_STORAGE: OnceBox<SendWrapper<LocalStorage>> = OnceBox::new(); LOCAL_STORAGE.get_or_init(|| { ...
true
586e1e388eb2d1c4ba9e4a629c221bf33a7c1f27
Rust
ArturKovacs/emulsion
/subcrates/gelatin/src/misc.rs
UTF-8
8,477
3.21875
3
[ "MIT" ]
permissive
use cgmath::Vector2; use glium::glutin::dpi; use std::ops::{Add, AddAssign, Div, Mul, Sub}; /// Used to represent logical pixel coordinates and dimensions. /// /// This struct is distinct from `PhysicalVector` which represents /// physical pixel coordinates and dimensions to avoid /// confusion when dealing with scal...
true
837bb10fac90ad3ceb69a750e6044be367943a8b
Rust
EdShaw/rust-sdl2
/src/timer.rs
UTF-8
679
2.53125
3
[ "MIT" ]
permissive
pub mod ll { use std::libc::{uint32_t, uint64_t}; //SDL_timer.h externfn!(fn SDL_GetTicks() -> uint32_t) externfn!(fn SDL_GetPerformanceCounter() -> uint64_t) externfn!(fn SDL_GetPerformanceFrequency() -> uint64_t) externfn!(fn SDL_Delay(ms: uint32_t)) //TODO: Figure out what to do with th...
true
811a23a018aea0ed38e382a83c0932b28bc07637
Rust
neelakantankk/rust_book_vec_operations
/src/main.rs
UTF-8
2,316
3.5
4
[]
no_license
extern crate rand; use rand::Rng; use std::collections::HashMap; use std::cmp::Ordering; fn main() { let mut numbers: Vec<u32> = Vec::new(); println!("Populating Vector..."); const LOWER : u32 = 0; const UPPER : u32 = 50; for _i in 0..500 { let input : u32 = rand::thread_rng().g...
true
922e97f2a45cff1d36b3072078c17724591eff2c
Rust
darkedge/advent-of-code-2020
/day08/src/main.rs
UTF-8
6,762
3.671875
4
[]
no_license
use std::fs::File; use std::io::prelude::*; use std::io::BufReader; /* --- Day 8: Handheld Halting --- Your flight to the major airline hub reaches cruising altitude without incident. While you consider checking the in-flight menu for one of those drinks that come with a little umbrella, you are interrupted by the ki...
true
c0a82dfec335c489fd95293aa1c77e73934c31da
Rust
fredmorcos/attic
/Snippets/Rust/sdl-windows/src/main.rs
UTF-8
3,532
2.875
3
[ "Unlicense" ]
permissive
use derive_more::From; use log::trace; use sdl2::event::{Event, WindowEvent}; use sdl2::pixels::Color; use sdl2::render::WindowCanvas; use sdl2::video::WindowBuildError; use sdl2::VideoSubsystem; use std::collections::HashMap; use std::fmt::{self, Debug}; use std::process; use std::sync::mpsc; use thiserror::Error; #[...
true
651be25f76eee3fed7ca3947938d39036d488e0b
Rust
PrismaPhonic/Learn-Rust
/Chapter-13/workout-closures/src/main.rs
UTF-8
2,749
3.71875
4
[ "MIT" ]
permissive
use std::thread; use std::time::Duration; use std::collections::HashMap; use std::hash::Hash; // fn simulated_expensive_calculation(intensity: u32) -> u32 { // println!("calculating slowly..."); // thread::sleep(Duration::from_secs(2)); // intensity // } struct Cacher<T, V, Y> where T: Fn(V) -> Y, ...
true
d77a64c543f47ced8c63db9c130a40e359af0a13
Rust
uzairhasankhan/Rust-Based-Ludo-Game
/for_loop/src/main.rs
UTF-8
1,049
4.03125
4
[]
no_license
// // // //If the enum is C-like (as in your example), then you can create a static array of each of the variants and return an iterator of references to them: // use self::Direction::*; // use std::slice::Iter; // #[derive(Debug)] // pub enum Direction { // Forward, // Left, // Backward, // Right, ...
true
c1b0fc3ddb253421f8b1d90c3f10f1f80ccd25f7
Rust
yaspoon/adventOfCode2020
/day2_1/src/main.rs
UTF-8
2,336
3.484375
3
[]
no_license
use std::path::Path; use std::fs::File; use std::io::BufReader; use std::io::prelude::*; struct PasswordPolicy { min: usize, max: usize, character: char, password: String, } impl PasswordPolicy { fn new(line: String) -> PasswordPolicy { let parts: Vec<&str> = line.split(" ").collect(); ...
true
fab8e049a34ac91a7cc1561de5e9b097f355d1c5
Rust
bantic/project-euler
/problem9/problem9.rs
UTF-8
445
3.484375
3
[]
no_license
fn is_perfect(num: int) -> bool { let root = (num as f32).sqrt(); return root.fract() == 0f32; } fn main() { for a in range(100i, 500) { for b in range(100i, 500) { let prod = a*a + b*b; if is_perfect(prod) { let c = (prod as f32).sqrt() as int; if a+b+c ...
true
9306b169c542fc5e69371ee25550945e6e55db6e
Rust
jeffilluminati/sqtoy
/src/main.rs
UTF-8
7,773
2.515625
3
[ "MIT" ]
permissive
#![allow(dead_code)] #[macro_use] extern crate gfx; extern crate gfx_window_glutin; extern crate glutin; extern crate rand; extern crate image; use gfx::traits::FactoryExt; use gfx::Device; use gfx_window_glutin as gfx_glutin; pub type ColorFormat = gfx::format::Srgba8; pub type DepthFormat = gfx::format::DepthStenc...
true
a796f436a176cfed5be6a33943b5673a465dae21
Rust
tsoernes/ndarray
/src/doc/various_utils/mod.rs
UTF-8
3,461
4
4
[ "MIT", "Apache-2.0" ]
permissive
//! Various operations on `ndarray`s. //! //! # Sorting //! Sorting `ndarray`s can be achieved by using the //! [`sort` functions from the standard library][https://doc.rust-lang.org/stable/std/primitive.slice.html#method.sort_unstable]. //! As a basic example, here is how to sort an array of integers using `sort_unsta...
true
2a7d31ebd484eecc2288b9368ed34d78c0ca7a93
Rust
CrabBucket/AdventOfCode2020
/src/Day1.rs
UTF-8
790
3.25
3
[]
no_license
use std::{fs, path::Path, env}; pub fn findpairthenmult(input: u32) -> u32{ input * (2020u32 - input) } pub fn day1(){ // let path = env::current_dir().expect("error getting current dir").join("day1.txt"); // println!("{:?}", path); let inputs = fs::read_to_string("day1.txt").expect("couldn't find file"...
true
9900c1536870dc1d1725b8aacb8f7bc26ec125f5
Rust
frenicth/tock
/chips/nrf51/src/timer.rs
UTF-8
10,825
2.75
3
[ "Apache-2.0", "MIT" ]
permissive
//! The nRF51822 timer system operates off of the high frequency clock //! (HFCLK) and provides three timers from the clock. Timer0 is tied //! to the radio through some hard-coded peripheral linkages (e.g., there //! are dedicated PPI connections between Timer0's compare events and //! radio tasks, its capture tasks a...
true
3a353403f09e20dcc3ddb30ab314ed2a323d55bf
Rust
louisch/advent-of-code-2019
/rust/src/main.rs
UTF-8
969
3.53125
4
[]
no_license
fn meets_criteria(number: &u64) -> bool { let digits: Vec<u32> = number.to_string().chars().filter_map(|c| c.to_digit(10)).collect(); let mut digits_clone = digits.clone(); digits_clone.reverse(); let mut matching = None; loop { let maybe_digit = digits_clone.pop(); if let Some(digit...
true
7ce822adafcf2c09aea826f02aac77f899364b8f
Rust
payload/tot-up
/src/entry_data.rs
UTF-8
1,528
3.46875
3
[ "MIT" ]
permissive
use std::collections::HashMap; use internment::ArcIntern; /// trade higher runtime with lower peak memory usage pub type Term = ArcIntern<String>; /// An entry is a file or a directory. /// Data per entry is the map of used terms and their counts. #[derive(Clone, Debug, Default)] pub struct EntryData { path: Str...
true
76d03a7ca9dca54b3bd09f20ce6b379b1664325f
Rust
bouzuya/rust-atcoder
/cargo-atcoder/contests/abc192/src/bin/c.rs
UTF-8
585
2.84375
3
[]
no_license
use proconio::input; fn f(x: usize) -> usize { let mut g2 = x.to_string().chars().collect::<Vec<char>>(); g2.sort(); let mut g1 = g2.clone(); g1.reverse(); let g1 = g1.iter().collect::<String>().parse::<usize>().unwrap(); let g2 = g2 .iter() .collect::<String>() .trim_st...
true
8ad979e271d322fff373bcfc6414afed8aefb474
Rust
ruby-vietnam/hardcore-rule
/algorithms/solutions/week12/unrealhoang/lisp_intepreter.rs
UTF-8
6,412
3.390625
3
[]
no_license
use std::collections::HashMap; use std::fmt::Debug; #[derive(Debug, Clone)] enum Value { Integer(i64), // String(String), Symbol(String), List(Vec<Value>), } #[derive(Debug)] enum Bounded { Value(Value), Function(&'static Callable), Form(&'static Callable) } #[derive(Debug)] struct Contex...
true
22fb38f99ee044f9f1e445a2b05d59ab2bed6dca
Rust
singaraiona/rik
/src/kobjects.rs
UTF-8
12,785
2.515625
3
[]
no_license
use std::mem::size_of; use std::ptr::{read, copy_nonoverlapping}; use std::vec::Vec; #[derive(Debug)] pub enum KObject { Atom (KAtom), Vector (KVector), Dictionary (KDictionary), Table (KTable), KeyedTable (KKeyedTable), Function (KFunction), Error (KSymbol), Un...
true
c749c9f82c3a4acde35427e9104a52e4aff87e58
Rust
KevDev13/horcrux
/src/main.rs
UTF-8
3,237
3.265625
3
[ "MIT", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
// main.rs // Author: Kevin Garner, kevin@kgar.net // // Horcrux is an application that will split a file into // multiple shares using Shamir's Secret Sharing. This will // allow the separating of files across different locations // (i.e. cloud services, USB drives, etc) while still allowing // the loss of 1 or more s...
true
fb883c8c3df6f7edfd2c791eb244bde30b6ef27a
Rust
billsjchw/tigerc-rs
/src/util.rs
UTF-8
2,173
3.71875
4
[]
no_license
pub fn parse_integer_literal(literal: &str) -> i64 { let mut result = 0i64; for &c in literal.as_bytes() { result = result.wrapping_mul(10).wrapping_add((c - b'0') as i64); } result } pub fn parse_string_literal(literal: &str) -> String { let mut result = String::new(); let bytes = li...
true