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
ae97e9de39ce6d542f33a4b88acf7132be253c0d
Rust
Kevinbriceo567/FakemonRustBattleSimulator
/src/main.rs
UTF-8
17,627
2.71875
3
[]
no_license
use fltk::{ app, button::*, frame::*, group::*, input::*, menu::*, output::*, valuator::*, window::*, image::* }; use std::error::Error; use std::path::PathBuf; use std::collections::HashMap; use image::GenericImageView; use rand::seq::SliceRandom; use rand::prelude::*; use std:...
true
815472ba0567bd8ba1212d86acbde283f444641b
Rust
akamit91/rustkpi
/rust/rust-src-1.25.0/src/vendor/cargo_metadata/tests/selftest.rs
UTF-8
1,851
2.546875
3
[ "Apache-2.0", "BSD-3-Clause", "NCSA", "LicenseRef-scancode-other-permissive", "ISC", "BSD-2-Clause", "MIT" ]
permissive
extern crate cargo_metadata; extern crate semver; use std::path::Path; use semver::Version; #[test] fn metadata() { let metadata = cargo_metadata::metadata(None).unwrap(); assert_eq!(metadata.packages[0].name, "cargo_metadata"); assert_eq!(metadata.packages[0].targets.len(), 2); assert_eq!(metadata...
true
ecd60228dfd79cf037404650a8c12aa8c777dc9e
Rust
lqhuang/advent-of-code-2020
/src/bin/day10.rs
UTF-8
9,615
3.703125
4
[]
no_license
//! # --- Day 10: Adapter Array --- //! //! Patched into the aircraft's data port, you discover weather forecasts of a //! massive tropical storm. Before you can figure out whether it will impact //! your vacation plans, however, your device suddenly turns off! //! //! Its battery is dead. //! //! You'll need to plug i...
true
234cc2a5bc4e70b3dfe4342ee889b6befc328b6b
Rust
PeterW-LWL/mail
/internals/src/encoder/trace.rs
UTF-8
5,179
3.078125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
/// If it is a test build the EncodingBuffer will /// have an additional `pub trace` field, /// which will contain a Vector of `Token`s /// generated when writing to the string buffer. /// /// For example when calling `.write_utf8("hy")` /// following tokens will be added: /// `[NowUtf8, Text("hy")]` #[derive(Debug, Cl...
true
73e49506acf3b6bda3e5961191851bbb5929352c
Rust
wsf1990/arrow
/rust/datafusion/src/execution/filter.rs
UTF-8
7,370
2.515625
3
[ "Apache-2.0", "CC0-1.0", "MIT", "BSD-3-Clause", "BSL-1.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
true
4abe7bbe13f474e6db0dbe77d8c8f34b30329e4e
Rust
YorozuyaDev/compiler
/parser/expressions/hashmap.rs
UTF-8
3,348
3.453125
3
[ "MIT" ]
permissive
use crate::{ Error, Parser, Precedence, tokens::{ Signs, Token, Tokens, }, }; use std::collections::HashMap as HashMapSTD; use super::{ Expression, Expressions, parse_expression, }; #[derive(Debug, Clone, PartialEq)] pub struct HashMap { token: Token, items: HashMapSTD<String, Box<Exp...
true
7de0696b1d0e77f7895f4fcd29725d8ec824aeea
Rust
maximebedard/wizer
/src/instrument.rs
UTF-8
9,566
2.78125
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
//! The initial instrumentation pass. use crate::info::{Module, ModuleContext}; use crate::stack_ext::StackExt; use std::convert::TryFrom; use wasm_encoder::SectionId; /// Instrument the input Wasm so that it exports its memories and globals, /// allowing us to inspect their state after the module is instantiated and...
true
8d39936005da59bf79aedbc211b70372c9aa473e
Rust
iankronquist/rustyvisor
/hypervisor/src/vcpu.rs
UTF-8
704
2.609375
3
[ "MIT" ]
permissive
//! This module defines functions for working with VCpus. use crate::VCpu; use x86::bits64::segmentation::fs_deref; /// Get a reference to the current VCpu structure. /// The reference is static because the VCpu structure must outlive the /// hypervisor. /// Each CPU has data used to represent the guest stored in the ...
true
6c7a92c86898158c03ff9fcfbb8d7cc27abb7e79
Rust
tomc1998/rs-java-parser
/src/parser/identifiers.rs
UTF-8
2,560
3.390625
3
[]
no_license
//! Parsing for identifiers use super::*; use lexer::TokenType; /// A qualified identifier is just a node that contains a list of identifiers. /// The '.' separating the idents are stripped. pub fn parse_qualified_identifier(tokens: &mut TokenIter, src: &str) -> ParseRes { let mut children = vec![assert_term_with...
true
9f31a99751a562efdb32a5d2467de9d5656be258
Rust
athre0z/ctf-alien-cpu
/src/flag-logic.rs
UTF-8
2,439
2.90625
3
[ "MIT" ]
permissive
#![no_std] #[inline(always)] fn basic_checks(flag: &[u8]) -> bool { if flag.len() != 30 { return false } // '_' == '_' == '_' if flag[12] != flag[17] || flag[17] != flag[24] { return false } // 'l == 'l' if flag[20] != flag[19] { return false } // 'e' == '...
true
99d8067f0575017d122d67b68354c8a4b0e26016
Rust
rootulp/exercism
/rust/luhn/src/lib.rs
UTF-8
1,278
3.828125
4
[ "MIT" ]
permissive
/// Check a Luhn checksum. pub fn is_valid(input: &str) -> bool { let luhn = Luhn::new(input); match luhn { Ok(l) => l.is_valid(), Err(_) => false, } } struct Luhn { number: String, } impl Luhn { pub fn new(input: &str) -> Result<Self, &'static str> { let number = input.re...
true
ae400e49fcfd12ded57e80862d37de01eb08993b
Rust
akolybelnikov/makepad
/workshops/nov28_step1_wasm/src/lib.rs
UTF-8
919
3.203125
3
[ "MIT" ]
permissive
// take a vec and return its innards as a [ptr,len,cap] triplet ptr fn vec_to_js(vec: Vec<f32>) -> u32 { let vec = std::mem::ManuallyDrop::new(vec); let to_js = vec![ vec.as_ptr() as u32, vec.len() as u32, vec.capacity() as u32 ]; let to_js = std::mem::ManuallyDrop::new(to_js); ...
true
dec81da35b8cb8cdfcf2368e00352e9204b25bc8
Rust
CasualX/programming-problems-rs
/src/list, strings/4-odd-positions.rs
UTF-8
438
3.875
4
[]
no_license
// Write a function that returns the elements on odd positions in a list. fn main() { let values = [5, 2, 8, -5, -1]; let odds = odd_positions(&values); println!("Odd positions: {:?}", odds); } fn odd_positions<T: Copy>(list: &[T]) -> Vec<T> { let mut flip = false; list.iter().filter(|_| { // Flip flop skippi...
true
5787cccbaff3c41ae4372e72833702a0cbf0320b
Rust
TobiasDeBruijn/cf-linux
/src/install/file.rs
UTF-8
2,347
2.765625
3
[]
no_license
use std::path::{Path, PathBuf}; use indicatif::{ProgressBar, ProgressIterator}; use anyhow::Result; use std::fs; use std::io; use std::os::unix::fs::PermissionsExt; use tempfile::TempDir; pub fn copy<U: AsRef<Path>, V: AsRef<Path>>(from: U, to: V) -> Result<()> { let mut stack = vec![PathBuf::from(from.as_ref())];...
true
520cd3b4189867a6bbd98d85d3a9a83b9454d780
Rust
lamaboy2018/RNgl
/src/dataprocess/List.rs
UTF-8
1,829
4.03125
4
[]
no_license
use List::*; enum List<T> { // Cons: 包含一个元素和一个指向下一个节点的指针的元组结构 Cons(T, Box<List>), // Nil: 表示一个链表节点的末端 Nil, } impl List<T> { // 创建一个空链表 fn new() -> List { // `Nil` 是 `List`类型的。因为前面我们使用了 `use List::*;` // 所以不需要 List::Nil 这样使用 Nil } // 在前面加一个元素节点,...
true
fe92bb7be86091f1814f8c62a50423558f22e11a
Rust
agaviria/coyete
/backend/src/services/crypto.rs
UTF-8
2,317
3.1875
3
[ "Apache-2.0" ]
permissive
use argon2::{self, Config, ThreadMode, Variant, Version}; use errors::Error; // hash encodes plaintext with a salt vector slice. Returns encoded string or // fails with [argon2::Error](https://docs.rs/rust-argon2/0.3.0/argon2/enum.Error.html) pub fn hash(password: &str, salt: Vec<u8>) -> Result<String, Error> { /...
true
525d4c67b7d261265bc2d893aade233d5c347bd5
Rust
pokefreak627/coords
/src/main.rs
UTF-8
285
3.09375
3
[]
no_license
use rand::Rng; fn main() { let mut random_numbers = [(0, 0); 10]; let mut rng = rand::thread_rng(); for i in 0..10 { random_numbers[i].0 = rng.gen_range(1..=10); random_numbers[i].1 = rng.gen_range(1..=10); } println!("{:?}", random_numbers); }
true
156b03069ddbc25fb6256ba1a4f0923ff5d64d32
Rust
Kethku/Pando
/src/app_data.rs
UTF-8
2,213
2.75
3
[]
no_license
use druid::{Data, Point}; use druid::im::{HashMap as ImHashMap, HashSet as ImHashSet}; use serde::{Serialize, Deserialize}; use crate::widgets::{ canvas::{Positioned, CanvasData}, pin_board::PinBoardData, flow::{FlowData, FlowDependency}, todo::TodoItem, }; #[derive(Clone, Data, Debug, Serialize, Dese...
true
8e8d2ee4f50f9f43eca2092c561b82b38de0e9e1
Rust
bbqsrc/iref
/src/lib.rs
UTF-8
8,612
3.796875
4
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! This crates gives an implementation of //! [Internationalized Resource Identifiers (IRIs)](https://en.wikipedia.org/wiki/Internationalized_resource_identifier) and IRI references following //! [RFC 3987](https://tools.ietf.org/html/rfc3987) and //! [RFC 3986](https://tools.ietf.org/html/rfc3986) defined by the //! ...
true
8adc15037c48be7684e94ef9fdbd9907a875169c
Rust
rustcargo/rustlearn
/exercises/play-normal/src/rstype.rs
UTF-8
2,637
3.65625
4
[]
no_license
pub struct S<T> { m: T, } pub struct D<T, U>(S<(T, U)>); pub enum E { First(isize, f32), Second { m1: isize, m2: f32 }, Third(D<isize, f32>), None, } impl From<E> for String { fn from(e: E) -> Self { // The following "match" helps us in deconstructing an enum entry to its // b...
true
b4889724247fcf8332fa9261ca0f2a7d83708e86
Rust
c-liang/leetcode
/crates/data_structure/tree/serialize_and_deserialize_binary_tree/src/lib.rs
UTF-8
2,631
3.75
4
[ "MIT" ]
permissive
//! # 297. 二叉树的序列化与反序列化 //! https://leetcode-cn.com/problems/serialize-and-deserialize-binary-tree/ //! 序列化是将一个数据结构或者对象转换为连续的比特位的操作,进而可以将转换后的数据存储在一个文件或者内存中, //! 同时也可以通过网络传输到另一个计算机环境,采取相反方式重构得到原数据。 use std::cell::RefCell; use std::rc::Rc; mod dfs; mod dfs_mid; // Definition for a binary tree node. #[derive(Debug, Parti...
true
92ad8e887fec22c5a0aa1aafbb846a0cbfc948ed
Rust
boj/garbage
/other/rust/src/main.rs
UTF-8
7,551
3.03125
3
[]
no_license
// Optimized game implementation in Rust extern crate time; use std::time::Duration; use time::precise_time_ns; use std::ops::{Add, Sub, Mul}; use std::{thread}; const BLOCKS_PER_CHUNK: usize = 65535; const ENTITIES_PER_CHUNK: usize = 1000; const BLOCK_COUNT: usize = 256; const CHUNK_COUNT: usize = 100; fn main() {...
true
53aba7468ebecbac0653bf5c8c546f405384ff5a
Rust
xrei/prime-numbers-benchmark
/rust/main.rs
UTF-8
426
2.875
3
[]
no_license
mod primes; use std::time::{Instant}; fn main() { let start = Instant::now(); // primes::test(1000000); // this is very slow! // 45 sec for 1kk primes // primes::test_functional(10000000); // this is somewhat fast. // ~1 sec for 1kk primes // primes::test_functional_paralell(1000000); // 26 ms WHAT TA F...
true
4790bedd4b03dff18edfe707775eb2e0c385d48b
Rust
ysnrkdm/fulleffect
/src/mesh.rs
UTF-8
7,746
2.8125
3
[ "MIT" ]
permissive
use crate::aabb::Aabb; use crate::camera::Ray; use crate::config::INF; use crate::material::Material; use crate::math::det; use crate::rayintersectable::Intersectable; use crate::rayintersectable::Intersection; use crate::scene::Surface; use crate::vector::Vector2; use crate::vector::Vector3; trait IntersectWith<T> { ...
true
9a13eb988a11e129ddac9b8cb62d892777c2bcbc
Rust
abingham/spor
/src/anchor/context.rs
UTF-8
2,411
3.40625
3
[ "MIT" ]
permissive
use serde::{Deserialize, Serialize}; use std::cmp::max; use thiserror::Error; #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Context { before: String, offset: usize, topic: String, after: String, width: usize, } impl Context { pub fn new(before: &str, offset: usize, topic: &str, af...
true
003214e84cc340bd1414c1a1fdf8bf72c5f1b21c
Rust
tyjacobson/projects
/parser.rs
UTF-8
4,045
2.90625
3
[]
no_license
// // Author: Tyler Jacobson // // Email: tj545714@ohio.edu // // Name: parser.rs (ir) // // Date: April 14, 2019 // // Purpose: Will translate a program from GrumpyIR to equivalent GrumpyVM code. // // Notes: <Exp> -> <term> <exp'> $ // <prog> -> <fun_list> ...
true
cfd315e0a2b64a08947c5931f407e255053edaa9
Rust
Diamondlord/zero2prod
/tests/api/health_check.rs
UTF-8
935
2.828125
3
[]
no_license
use crate::helpers::spawn_app; // `actix_rt::test` is the testing equivalent of `actix_rt::main`. // It also spares you from having to specify the `#[test]` attribute. // You can inspect what code gets generated using // `cargo expand --test health_check` (<- name of the test file) #[actix_rt::test] async fn health_ch...
true
5043d290d9d25ab67e27c2f830d83059c3949b1e
Rust
196Ikuchil/nes_emulator
/src/nes/ppu/register/ppu_data.rs
UTF-8
2,550
3.234375
3
[ "MIT" ]
permissive
use super::super::super::types::{Data, Addr}; use super::super::super::Ram; use super::super::palette::*; use super::Mapper; #[derive(Debug)] pub struct PpuData { buf: Data, } // Data ($2007) // VRAM read/write data register. After access, the video memory address will increment by an amount determined by $2000:2. ...
true
e853a4d8d62b927828305553484dd92c55d58a06
Rust
Tomboyo/cliset-rs
/src/main.rs
UTF-8
3,712
3.453125
3
[]
no_license
mod options; use std::collections::BTreeSet; use itertools::Itertools; use crate::options::Operation::*; use crate::options::Options; fn main() { match Options::from_stdin().map(invoke) { Err(e) => println!("Error: {}", e), Ok(output) => println!("{}", output), } } fn invoke(options: Option...
true
166d1bf7a1f54bff732962c520afbde428e380e7
Rust
simonbrahan/rustbook
/threads/api/src/main.rs
UTF-8
512
3.640625
4
[]
no_license
use std::thread; use std::time::Duration; fn main() { let nums = [1, 4, 5, 8, 10]; let handle = thread::spawn(move || { for i in &nums { println!("Number {} from spawned thread", i); thread::sleep(Duration::from_millis(1)); } }); for i in 1..5 { println!...
true
23872b1aa58ef4deb414b13a733a47c58f775c59
Rust
markushedvall/chip8-rs
/chip8ui/src/pixel.rs
UTF-8
465
3.15625
3
[]
no_license
#[derive(Clone, Copy, Debug, Default)] pub struct Pixel { color: f32, } impl Pixel { pub fn update(&mut self, dt: f64) { if self.color > 0.0 { self.color -= dt as f32 * 8.0; if self.color < 0.0 { self.color = 0.0 } } } pub fn turn_on(...
true
0a737e0bd51a16538b9cbd5ce366de786445908d
Rust
Gijom/rs-tiled
/src/layers/tile/finite.rs
UTF-8
2,457
3.140625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use xml::attribute::OwnedAttribute; use crate::{ util::{get_attrs, map_wrapper, XmlEventResult}, LayerTile, LayerTileData, MapTilesetGid, Result, }; use super::util::parse_data_line; /// The raw data of a [`FiniteTileLayer`]. Does not include a reference to its parent [`Map`](crate::Map). #[derive(PartialEq,...
true
8a5459310421eb47e2a160603425826d7c144c95
Rust
KevinKelley/noobchain-rs
/src/txn.rs
UTF-8
6,044
3.078125
3
[]
no_license
use super::*; use crypto::{apply_sha256, apply_ECDSA_sig, verify_ECDSA_sig}; use chain::NoobChain; use wallet::Wallet; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Transaction { pub transaction_id: Vec<u8>, // this is also the hash of the transaction. pub sender: Key, // senders address/public ke...
true
abcf70cd0efc54903c203c4ac8324c3cbefce55f
Rust
dscorbett/rust-uax29
/uax29/src/breaks.rs
UTF-8
143,780
2.71875
3
[]
no_license
// NOTE: The following code was generated by "scripts/unicode.py", do not edit // directly #![allow(warnings)] pub trait FromChar { fn from_char(c: char) -> Self; } pub mod word_break { use std::slice::SliceExt; pub use self::Category::*; use std::result::Result::{Ok, Err}; #[allow(non_camel_case...
true
869a5351de9287708dd0783609bf79044534a4fc
Rust
TimmDay/learning_rust
/references/src/stacksize.rs
UTF-8
1,769
3.265625
3
[]
no_license
pub fn infinite_recursor(mut depth_recursion_counter: usize) { depth_recursion_counter += 1; //number of recursions * kb of array allocation (1) + approx consumed stack cap for println! println!("approximate stack size: {}", depth_recursion_counter + 708); let x = [0u8; 1000]; // ie allocate/consume...
true
47eaa45fd1433a25b6900bbae9d51eed1ffab5ec
Rust
oscourse-tsinghua/OS2018spring-projects-g15
/src/arch/x86_64/interrupts/trapframe.rs
UTF-8
1,404
2.734375
3
[ "MIT" ]
permissive
#[derive(Debug, Clone, Default)] pub struct TrapFrame { pub r15: usize, pub r14: usize, pub r13: usize, pub r12: usize, pub rbp: usize, pub rbx: usize, pub r11: usize, pub r10: usize, pub r9: usize, pub r8: usize, pub rsi: usize, pub rdi: usize, pub rdx: usize, ...
true
a10fef8952ff129f85f53b5fd4e4621723d3e9f6
Rust
alveraboquet/price-bridge
/src/tcp/tcp_data_writer.rs
UTF-8
1,428
2.796875
3
[]
no_license
use tokio::{ io::{AsyncWriteExt, WriteHalf}, net::{TcpStream} }; pub struct TcpContextWriter { tcp_stream: Option<WriteHalf<TcpStream>>, id: u128 } impl TcpContextWriter { pub fn new(tcp_stream: WriteHalf<TcpStream>, id: u128) -> TcpContextWriter { TcpContextWriter { tcp_stream...
true
121aba61be7272405260af92cec6af1daba72f62
Rust
eqv/fuzz_ui
/source_info/src/source_state.rs
UTF-8
2,664
2.875
3
[]
no_license
use std::collections::{HashSet}; use std::path::Path; use std::io::BufReader; use std::io::BufRead; use std::fs::File; use regex::Regex; use dump_srcmap::MappedFilename; use crate::newtypes::{SrcID, LineID, LineNum}; #[derive(Serialize)] pub struct SourceFileInfo{ pub base_name: String, pub path: String, ...
true
f5a59b7699fb4652792cf6e62210be8dc5433c66
Rust
liljencrantz/crush
/src/util/user_map.rs
UTF-8
4,761
2.5625
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::sync::Mutex; use std::os::raw::c_char; use lazy_static::lazy_static; use nix::unistd::{Uid, Gid, getuid}; use crate::lang::errors::{CrushResult, to_crush_error, error}; use std::ffi::CStr; use libc::gid_t; use std::path::PathBuf; use libc::{passwd, uid_t}; use crate::argument_e...
true
327a1aa7b2e1edba0fc065a20ea9c7a3afa19b20
Rust
jDomantas/plank
/plank-frontend/src/type_param_check.rs
UTF-8
7,952
2.71875
3
[ "MIT" ]
permissive
use ast::resolved::{Expr, Function, FunctionType, Program, Statement, Struct, Symbol, Type}; use plank_syntax::position::Spanned; use std::collections::HashMap; use CompileCtx; pub(crate) fn check_type_params(program: &mut Program, ctx: &mut CompileCtx) { let mut ctx = Context::new(ctx); ctx.check_program(prog...
true
45699858fea99da724058f1c5c9f70ecd34a0df4
Rust
ultracold273/leetcode-rs
/src/everyday/april/apr_28.rs
UTF-8
563
3.109375
3
[]
no_license
fn single_numbers(nums: Vec<i32>) -> Vec<i32> { let mut xor = nums.iter().fold(0, |a, b| a ^ b); let mut cnt = 0; while xor != 0 { if xor & 1 != 0 { break; } cnt += 1; xor = xor >> 1; } let mut arr0 = Vec::new(); let mut arr1 = Vec::new(); nums.ite...
true
43e653cd78967cdbcbe975605d9f1ad349c1b030
Rust
zyla/dbstuff
/table/src/datum.rs
UTF-8
4,690
3.140625
3
[]
no_license
// Clippy seems to have some bug triggered by derive(Arbitrary) #![allow(clippy::unit_arg)] use proptest_derive::Arbitrary; #[derive(Debug, PartialEq, Eq, Clone, Copy, Arbitrary)] pub enum Type { String, Int8, Bool, } #[derive(Debug, PartialEq, Eq, Clone, Copy, Arbitrary)] pub enum Nullability { Null...
true
898e902953275cabdbf1c8f8da42a12377035047
Rust
harmakhis971/Rust-Duplicati-Restore
/src/blockid.rs
UTF-8
5,330
2.75
3
[ "MIT" ]
permissive
use crate::database::DB; use base64; use serde::Deserialize; use serde_json; use std::fs; use std::fs::File; use std::io::prelude::*; use std::io::SeekFrom; use std::io::Write; use std::path::Path; #[derive(Debug)] pub enum FileType { File { hash: String, size: i64, time: String, }, ...
true
d8634bc4b6cfc431006867069e518eda074de3a7
Rust
csmoe/rustfmt
/src/string.rs
UTF-8
11,966
2.796875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // 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 ...
true
220811d45a33c1a2448f325994a3d7df42aeacb9
Rust
GaTechThomas/iced
/src/rust/iced-x86/src/block_enc/tests/misc.rs
UTF-8
8,404
2.53125
3
[ "MIT" ]
permissive
/* Copyright (C) 2018-2019 de4dot@gmail.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distr...
true
76ea23a52544086a6c51f93aee9077ceb4504f04
Rust
utilForever/BOJ
/Rust/1504 - Specific Shortest Path.rs
UTF-8
2,969
3.046875
3
[ "MIT" ]
permissive
use io::Write; use std::{collections::BinaryHeap, io, str}; pub struct UnsafeScanner<R> { reader: R, buf_str: Vec<u8>, buf_iter: str::SplitAsciiWhitespace<'static>, } impl<R: io::BufRead> UnsafeScanner<R> { pub fn new(reader: R) -> Self { Self { reader, buf_str: vec![],...
true
077b237266b1b83155f55053c4597de5272e7ca1
Rust
thvdveld/drone-svd
/src/register.rs
UTF-8
7,849
2.703125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{deserialize_int, deserialize_int_opt, field::Field, Access, DimGroup}; use anyhow::Result; use serde::{Deserialize, Deserializer}; use std::{fs::File, io::Write}; #[serde(rename_all = "camelCase")] #[derive(Clone, Debug, Deserialize)] pub enum RegisterTree { Register(Register), Cluster(Cluster), } ...
true
9ecc77287894149c84eb36598f2f597101768789
Rust
FlyingCowMooMoo/rust-game-roguelike
/src/components.rs
UTF-8
1,421
2.59375
3
[]
no_license
use rltk::{FontCharType, Point, RGB}; use specs::prelude::*; use specs_derive::*; #[derive(Component)] pub struct Position { pub x: i32, pub y: i32, } #[derive(Component)] pub struct Renderable { pub glyph: FontCharType, pub foreground: RGB, pub background: RGB, } #[derive(Component, Debug)] pub ...
true
bc4dc4543b80d6453a80bedbf6b96aacaadb571e
Rust
drklee3/mempool
/src/model/transaction.rs
UTF-8
1,946
3.296875
3
[]
no_license
use std::collections::HashMap; use std::convert::TryFrom; use std::fmt; use super::Fee; use crate::error::Error; #[derive(Clone, Debug)] pub struct Transaction { pub tx_hash: String, pub gas: u64, pub fee_per_gas: f64, pub signature: String, } impl Transaction { pub fn fee(&self) -> Fee { ...
true
3d0ca8b415ce245ebf1a88680ccdb8383041bf4c
Rust
rovangju/vacuum-robot-simulator
/src/simulation/sensor/laserscanner.rs
UTF-8
1,484
3.015625
3
[]
no_license
use std::cmp::Ordering; use geometry::{Line, Point, Pose, Ray, Target}; use math::{Angle, Scalar, PI}; use sensor::laserscanner::{Measurement, Scan}; pub struct LaserScanner { pub num_columns: u32, // max_range: Scalar, // range_noise: Scalar, // angle_noise: Angle } impl LaserScanner { pub fn sc...
true
64ee4170a04af75d3e42e4d3d0ec6e8845fe3d8f
Rust
garious/loom
/src/state.rs
UTF-8
4,742
2.8125
3
[ "Apache-2.0" ]
permissive
//! state machine for transactions use data; use result::Result; use hasht::Key; #[repr(C)] pub struct State { accounts: Vec<data::Account>, used: usize, } impl State { pub fn new(size: usize) -> State { State { accounts: vec![data::Account::default(); size], used: 0, ...
true
1cd1c80244b3cfa67aaba4dd023489a6670f2f3c
Rust
jrieck1991/genproto
/lib/src/lib.rs
UTF-8
4,451
3.15625
3
[]
no_license
use bincode; use byteorder::{BigEndian, ByteOrder}; use serde::{Deserialize, Serialize}; use std::io::prelude::*; use std::net::TcpStream; // protocol tag const TAG: &[u8; 1] = b"\x00"; #[derive(Serialize, Deserialize, PartialEq, Debug)] pub struct Data { pub key: Vec<u8>, pub value: Option<Vec<u8>>, } #[der...
true
07bfb20bf8115b22e26016c7a58819a1b748ca70
Rust
Phaiax/rsaltpack
/src/base62_num.rs
UTF-8
9,082
3.234375
3
[]
no_license
use num_bigint::BigUint; use std::iter::repeat; use armor::{SPACE_EVERY, NEWLINE_EVERY, BUF_SIZE, CHARS_PER_BLOCK, BYTES_PER_BLOCK}; use errors::*; /// This function converts a zero based digit in base 62 to its ascii equivalent. #[inline] pub fn alphabet(i : u8) -> u8 { if i <= 9 { i + b'0' } else...
true
a260375d9e7afefbb7b8266b513f04c9a7bb5246
Rust
rainliu/leetcode
/src/599MinimumIndexSumOfTwoLists/599MinimumIndexSumOfTwoLists.rs
UTF-8
1,413
3.234375
3
[]
no_license
use std::collections::HashMap; impl Solution { pub fn find_restaurant(list1: Vec<String>, list2: Vec<String>) -> Vec<String> { let mut map = HashMap::new(); for j in 0..list2.len() { map.insert(&list2[j], j); } let mut global = list1.len()+list2.len(); for i in 0....
true
12602c2fbb90304c8a8353cf585ba58dbe6c6134
Rust
chad-orwig/AoC
/2022_rust/src/bin/14.rs
UTF-8
4,026
2.859375
3
[]
no_license
use std::{collections::HashMap, vec::IntoIter, cmp::{min, max}}; use lib::{inputs::d14::PRIMARY, grid::Point}; use crate::Material::*; #[derive(Default, Clone, Debug)] pub enum Material { Rock, Sand, #[default] Air, } impl Default for &Material { fn default() -> Self { &Air } } struct Caver...
true
5ed6017f769e0c303c149073794d1f1bc584726d
Rust
justin1dennison/rust-exercism
/diffie-hellman/src/lib.rs
UTF-8
299
2.921875
3
[]
no_license
extern crate rand; use rand::prelude::*; pub fn private_key(p: u64) -> u64 { let mut rng = thread_rng(); rng.gen_range(2, p) } pub fn public_key(p: u64, g: u64, a: u64) -> u64 { g.pow(a as u32) % p } pub fn secret(p: u64, b_pub: u64, a: u64) -> u64 { b_pub.pow(a as u32) % p }
true
64104434604f9c7723fccdf6510ee9ee3140d631
Rust
scotow/advent-of-code
/2018/src/bin/day_15.rs
UTF-8
5,573
2.78125
3
[]
no_license
use pathfinding::prelude::dijkstra_all; advent_of_code_2018::main!(); type Grid = Vec<Vec<Cell>>; type CellMatch = fn(Cell) -> bool; #[derive(Copy, Clone, PartialEq)] enum Cell { Wall, Empty, Elf(u32), Goblin(u32), } impl Cell { fn is_empty(self) -> bool { matches!(self, Cell::Empty) ...
true
c738faf823fa4b8f83acb6b4008c746fc084b4fb
Rust
lucasig11/tcp-rust
/src/main.rs
UTF-8
1,343
2.953125
3
[]
no_license
use std::{ io::{self, Read, Write}, thread, }; use tcp_rust::Interface; fn main() -> io::Result<()> { eprintln!("\u{001b}c"); let port = std::env::args() .collect::<Vec<String>>() .get(1) .or(Some(&String::from("9000"))) .unwrap() .parse::<u16>() .unwrap...
true
4112f5669274f0cf0cd02f57eff7868d7531182b
Rust
carlmartus/rscsg
/src/dim3/bsp_node.rs
UTF-8
4,944
3.421875
3
[]
no_license
use dim3::{Plane, Polygon}; /// Holds a node in a BSP tree. A BSP tree is built from a collection of polygons by picking a /// polygon to split along. That polygon (and all other coplanar polygons) are added directly to /// that node and the other polygons are added to the front and/or back subtrees. This is not a ///...
true
fe86670bccdb332d76c640dd9e8a02b6b8b5d108
Rust
briete/yukicoder
/no264/src/main.rs
UTF-8
1,162
3.328125
3
[]
no_license
use std::io::{self, stdin, Read, StdinLock}; struct Input { n: i32, k: i32, } fn read_input(cin_lock: &mut StdinLock) -> Input { Input { n: next_token(cin_lock).parse().unwrap(), k: next_token(cin_lock).parse().unwrap(), } } fn solve(input: Input) { if input.n == input.k { ...
true
15487535eb6e31f95b2066e752f24e2acc463008
Rust
Batch21/rust-gr
/src/utils.rs
UTF-8
413
2.765625
3
[]
no_license
pub fn s_curve1(t: f64, days: f64) -> f64 { if t <= 0.0 { return 0.0; } else if t < days { return (t / days).powf(2.5); } 1.0 } pub fn s_curve2(t: f64, days: f64) -> f64 { if t <= 0.0 { return 0.0; } else if t < days { return 0.5 * (t / days).powf(2.5); } els...
true
1866f339547f5150406c86130bed39f3ccae2eae
Rust
ilammy/merkle-tree
/tests/merkle-tree.rs
UTF-8
2,521
3.0625
3
[ "MIT" ]
permissive
// Copyright (c) 2018, ilammy // // Licensed under MIT license (see LICENSE in the root directory). // This file may be copied, distributed, and modified only // in accordance with the terms specified by the license. extern crate merkle_tree; use merkle_tree::{MerkleTree}; fn as_hex_str(bytes: &[u8]) -> String { ...
true
971c96ac8aa1070a667b624072a2b051f10bf32a
Rust
Kimundi/generic-str-lib
/src/splits/nsplits.rs
UTF-8
2,940
2.78125
3
[]
no_license
use super::super::{Pattern, LeftMatcher, Splits, StrSlice_}; pub struct NSplits<M> { splits: Splits<M>, count: uint } impl<M> NSplits<M> { pub fn new<'a, P: Pattern<'a, M>>(s: &'a str, pat: P, n: uint) -> NSplits<M> { NSplits { splits: s._split(pat), count: n } ...
true
2cf714617fcc9a12339c952bd017e073a534aef6
Rust
sebastian-xyz/nushell
/crates/nu-command/src/dataframe/values/nu_groupby/custom_value.rs
UTF-8
1,031
2.5625
3
[ "MIT" ]
permissive
use super::NuGroupBy; use nu_protocol::{CustomValue, ShellError, Span, Value}; // CustomValue implementation for NuDataFrame impl CustomValue for NuGroupBy { fn typetag_name(&self) -> &'static str { "groupby" } fn typetag_deserialize(&self) { unimplemented!("typetag_deserialize") } ...
true
5f6594e02d3903848f773d64dd9f2bca1e8abf5c
Rust
eira-fransham/ethabi
/src/constructor.rs
UTF-8
748
2.890625
3
[]
no_license
//! Contract constructor call builder. use spec::Constructor as ConstructorInterface; use function::type_check; use token::Token; use error::Error; use encoder::encode; /// Contract constructor call builder. #[derive(Clone, Debug)] pub struct Constructor { _interface: ConstructorInterface, } impl Constructor { ///...
true
7ebf15cb299a78169d2db0c242199d2e7b0c5538
Rust
IThawk/rust-project
/rust-master/src/test/rustdoc-ui/coverage/statics-consts.rs
UTF-8
615
2.8125
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// compile-flags:-Z unstable-options --show-coverage // build-pass (FIXME(62277): could be check-pass?) //! gotta make sure we can count statics and consts correctly, too /// static like electricity, right? pub static THIS_STATIC: usize = 0; /// (it's not electricity, is it) pub const THIS_CONST: usize = 1; /// ass...
true
dc1bb7781a81594371124a36fbfd561f0489fb46
Rust
wangds/libflic
/src/codec/codec011.rs
UTF-8
7,177
2.6875
3
[ "MIT" ]
permissive
//! Codec for chunk type 11 = FLI_COLOR64. use std::io::{Cursor,Read,Seek,SeekFrom,Write}; use byteorder::LittleEndian as LE; use byteorder::{ReadBytesExt,WriteBytesExt}; use ::{FlicError,FlicResult,Raster,RasterMut}; use super::{Group,GroupByEq}; /// Magic for a FLI_COLOR64 chunk - 64-Level Color. /// /// This chun...
true
50fbb87c6783f11ecb43fede1c2d0c3f4c1ad04e
Rust
kaioken7/3photons-rust
/src/random/standard.rs
UTF-8
2,113
3.21875
3
[]
no_license
//! This module mimicks the interface of RanfGenerator on top of the //! abstractions of the standard "random" crate. use crate::numeric::Real; use rand::Rng; // Select random number generation engine in use #[cfg(feature = "f32")] type Engine = ::xoshiro::Xoshiro128Plus; #[cfg(not(feature = "f32"))] type Engine = ::...
true
6f66276e5b218ccb19da831b75a2175aae426ceb
Rust
jiyilanzhou/chw
/bifrost_note/compile_info/src/main.rs
UTF-8
1,788
3.390625
3
[]
no_license
/* 0. 使用私有属性 在另一文件内如" model.rs "内 AccountId32 的定义为" pub struct AccountId32([u8; 32]); " pub struct AccountId32([u8; 32]); impl From<[u8; 32]> for AccountId32 { fn from(x: [u8; 32]) -> AccountId32 { AccountId32(x) } } impl From<AccountId32> for [...
true
dc6132dd4b79a0c530efaa3458b62500ef5f61f4
Rust
dennisss/dacha
/pkg/math/src/big/secure/uint.rs
UTF-8
27,160
3.359375
3
[ "Apache-2.0" ]
permissive
use alloc::vec::Vec; use common::ceil_div; use core::cmp::Ord; use core::cmp::Ordering; use core::marker::PhantomData; use core::ops; use core::ops::Div; use core::ops::Index; use core::ops::IndexMut; use generic_array::{arr::AddLength, ArrayLength, GenericArray}; use typenum::Quot; use typenum::{Prod, U32}; use crat...
true
d128b23ecb3b84adf009d20515685928df98464a
Rust
DTFN/occlum
/src/libos/src/fs/file_ops/symlink.rs
UTF-8
2,849
2.875
3
[ "BSD-3-Clause" ]
permissive
use super::*; pub fn do_readlink(path: &str, buf: &mut [u8]) -> Result<usize> { println!("readlink: path: {:?}", path); let file_path = { if path == "/proc/self/exe" { current!().process().exec_path().to_owned() } else if path.starts_with("/proc/self/fd") { let fd = path...
true
b2cefe39398f93e8684e3d0a550c9f8144bd35b3
Rust
procuteboy/inko
/vm/src/gc/collector.rs
UTF-8
9,185
3.109375
3
[]
no_license
//! Functions and macros for performing garbage collection. use gc::trace_result::TraceResult; use process::RcProcess; use object_pointer::{ObjectPointer, ObjectPointerPointer}; use object::ObjectStatus; /// Macro used for conditionally moving objects or resolving forwarding /// pointers. macro_rules! move_object { ...
true
4982378764d887152c2ed59df94fb1cac0b42ec3
Rust
dandavison/ok-compiler
/src/ok_bitflags.rs
UTF-8
798
3.40625
3
[]
no_license
use bitflags::bitflags; bitflags! { struct Choice: u8 { const EMPTY = 0; const OREGANO = 1; const ARTICHOKEHEARTS = 2; const OLIVES = 4; const CAPERS = 8; } } pub fn main() { let mut pizza = Choice::EMPTY; pizza |= Choice::ARTICHOKEHEARTS; pizza |= Choice::C...
true
26c836b01f2788ed04b953d61e45ce3489503ec2
Rust
dalalsunil1986/Methylenix
/src/kernel/drivers/efi/text/output.rs
UTF-8
1,658
2.640625
3
[ "Apache-2.0" ]
permissive
//! //! EFI Output Protocol Manager //! use super::super::{EfiStatus, EFI_SUCCESS}; #[repr(C)] #[derive(Clone)] pub struct EfiOutputProtocol { reset: extern "win64" fn(*const EfiOutputProtocol, bool) -> EfiStatus, output: extern "win64" fn(*const EfiOutputProtocol, *const u16) -> EfiStatus, test_string: u...
true
17feba296c8ad05fc8d2a3ee91330c7ce60ce93b
Rust
filiprejmus/algeng
/src/ideas/cyclelb.rs
UTF-8
2,172
2.8125
3
[]
no_license
use crate::*; #[derive(Clone)] pub struct CycleLB; impl Idea for CycleLB { fn new(_: &Graph) -> Self { CycleLB } fn priority(&self, _state: &State, dirty: &HashSet<Vx>) -> usize { if dirty.is_empty() { return 0; } 3 } fn apply(&mut self, state: &mut State, _dirty: &HashSet<Vx>) -> O...
true
eaa91fb28be996a759413f8de2062724503db20f
Rust
alagerkvist/sample
/src/slice.rs
UTF-8
11,164
3.359375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! This module provides various helper functions for performing operations on slices of frames. use {Box, Frame, Sample, ToSampleSlice, ToSampleSliceMut, ToBoxedSampleSlice, ToFrameSlice, ToFrameSliceMut, ToBoxedFrameSlice, FromSampleSlice, FromSampleSliceMut, FromBoxedSampleSlice, FromFrameSlice, FromFrame...
true
c789744b0485fd492e42f249184dd7156e330b72
Rust
tomtau/tendermint-rs
/tendermint/src/abci/data.rs
UTF-8
1,532
2.953125
3
[ "Apache-2.0" ]
permissive
use crate::{Error, ErrorKind}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::{ fmt::{self, Display}, str::FromStr, }; use subtle_encoding::hex; /// ABCI transaction data. /// /// Transactions are opaque binary blobs which are validated according to /// application-specific rules. #[de...
true
e911dd0cef5d1661f021d08f9929ae6ab892fe68
Rust
dylannash/stm32-rust-test
/src/main.rs
UTF-8
3,653
2.59375
3
[]
no_license
#![deny(unsafe_code)] #![no_main] #![no_std] /* Test of different communications interfaces SPI I2C PB6 - scl PB7 - sda USART PA9 PA10 */ // Halt on panic #[allow(unused_extern_crates)] // NOTE(allow) bug rust-lang/rust#53964 extern crate panic_halt; // panic handler use cortex_m; use cortex_m_rt::entry; use ...
true
e3bd38c5fb3ab1e71d5dd716fa54f39cf79c5d7a
Rust
iliekturtles/uom
/src/si/mass_flux.rs
UTF-8
2,204
3.140625
3
[ "MIT", "Apache-2.0" ]
permissive
//! Mass flux (base unit kilogram per square meter second, m⁻² · kg · s⁻¹). quantity! { /// Mass flux (base unit kilogram per square meter second, m⁻² · kg · s⁻¹). quantity: MassFlux; "mass flux"; /// Dimension of mass flux, L⁻²MT⁻¹ (base unit kilogram per square meter second, /// m⁻² · kg · s⁻¹). ...
true
793231cfa2850f4ce7cbbb5dd3cbd61a37563e0c
Rust
Qitmeer/qitmeer-utreexo
/ri/rust-zkvm-ri/src/serialization.rs
UTF-8
4,203
3.0625
3
[ "MIT" ]
permissive
//! Utilities to support serialization needs macro_rules! serialize_bytes32 { ($type_name:ident) => { impl serde::Serialize for $type_name { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { ser...
true
3e479a131193e529c35d59407068dee5e8c837a7
Rust
bklimt/advent
/2022/03/rucksack/src/main.rs
UTF-8
3,310
3.328125
3
[]
no_license
use clap::Parser; use itertools::fold; use std::collections::HashSet; use std::fs::File; use std::io::{BufRead, BufReader}; #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] struct Args { #[arg(short, long)] path: String, #[arg(long)] part2: bool, } #[derive(thiserror::Er...
true
997e406c0fe0dbd1dd9437e6dbdac1a332eeb630
Rust
kieranelby/AoC2020Rust
/day7/src/main.rs
UTF-8
2,300
3.40625
3
[]
no_license
use std::collections::HashMap; fn main() { let content = std::fs::read_to_string("input.txt").expect("could not read file"); let rules_by_name: HashMap<&str, Rule> = content .lines() .map(|ln| parse_rule(ln)) .map(|r| (r.name, r)) .collect(); println!( "part_one: {}", rules_by...
true
02ea3db3d03eaa5bb82203947a81b54b00bf39f3
Rust
emptyrivers/advent2019
/src/tyranny.rs
UTF-8
637
3.046875
3
[]
no_license
use std::time::Instant; fn get_fuel(mass: i64) -> i64 { ((mass / 3) - 2).abs() } pub fn solve() -> u128 { let data = super::get_data_as_ints("01_tyranny.txt"); let mut mass = 0; let mut supermass = 0; let start = Instant::now(); for &num in data.iter() { let mut rem_mass = get_fuel(num)...
true
7977bf7d8e583c8beacead4f2b9b9f31dca0c5e5
Rust
FloydATC/rlox
/src/lox/common/value/obj/native/native_callables.rs
UTF-8
1,169
2.703125
3
[]
no_license
use std::collections::HashMap; use super::Value; use super::{NativeFn, NativeCallable}; // Built-in functions and methods #[allow(dead_code)] pub struct NativeCallables { methods: HashMap<String, Value>, functions: HashMap<String, Value>, } #[allow(dead_code)] impl NativeCallables { pub fn new() -...
true
cbae0784544d2bdb8d888bdcdfaa4b74bec403a3
Rust
spebern/ringbahn
/src/ring.rs
UTF-8
6,024
2.828125
3
[ "MIT", "Apache-2.0" ]
permissive
use std::io; use std::mem; use std::pin::Pin; use std::task::{Context, Poll}; use futures_core::ready; use crate::completion::Completion; use crate::drive::Completion as ExternalCompletion; use crate::drive::Drive; use crate::Cancellation; use State::*; /// A low-level primitive for building an IO object on io-urin...
true
57320b628ddc1b6c0bea3b5f561fd665c2c9d0b5
Rust
jsen-/kay
/src/error.rs
UTF-8
2,894
2.953125
3
[]
no_license
use std::path::PathBuf; use std::io; use std::fmt; use super::{InputStream, OutputStream, ExprInternalError, VarsError}; pub enum Error<'a> { UnknownFormat, FileRead(PathBuf, io::Error), FileWrite(PathBuf, io::Error), Input(InputStream<'a>, io::Error), Output(OutputStream<'a>, io::Error), JsonP...
true
77372e694d5da16eb2fadf6a596b350fd1de4c37
Rust
itsHabib/grpc-translate-service
/src/server.rs
UTF-8
8,617
2.5625
3
[]
no_license
mod protos; use crate::protos::language::{ ErrorType, LanguageCode, LanguageRequest, SynthesizeResponse, TranslateResponse, }; use crate::protos::language_grpc::{create_language, Language}; use futures::future::Future; use grpcio::{self, Environment, RpcContext, RpcStatus, RpcStatusCode, ServerBuilder, UnarySink};...
true
6120050a618626e9c477633622d69f8bc0746b4e
Rust
YushiOMOTE/perde
/perde-core/src/decode/set.rs
UTF-8
930
2.53125
3
[ "MIT" ]
permissive
use crate::{error::Convert, object::Object, schema::*}; use serde::de::{DeserializeSeed, Deserializer, SeqAccess, Visitor}; use std::fmt; pub struct SetVisitor<'a>(pub &'a Set); impl<'a, 'de> Visitor<'de> for SetVisitor<'a> { type Value = Object; fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { ...
true
0342c4d1a6e41f0542da9b93b674d5d570937d17
Rust
zoniony/lc
/src/unique_paths_ii.rs
UTF-8
805
2.515625
3
[]
no_license
struct Solution; impl Solution { pub fn unique_paths_with_obstacles(obstacle_grid: Vec<Vec<i32>>) -> i32 { let (m, n) = (obstacle_grid.len(), obstacle_grid[0].len()); let mut dp = vec![vec![0; n]; m]; for i in 0..m { for j in 0..n { if obstacle_grid[i][j] == 1 { ...
true
a447d594cc142fa3604481a067628c6aa8849f8f
Rust
endor/adventcalendar-2018
/day02/src/main.rs
UTF-8
5,645
3.453125
3
[]
no_license
// --- Day 2: Inventory Management System --- // You stop falling through time, catch your breath, and check the screen on the device. "Destination reached. Current Year: 1518. Current Location: North Pole Utility Closet 83N10." You made it! Now, to find those anomalies. // // Outside the utility closet, you hear foots...
true
a847fed15c7310bf70b94b35ffd4c08b3089e1dc
Rust
erszcz/visual-search
/search/src/map/mod.rs
UTF-8
2,801
3.1875
3
[]
no_license
use std::ops::{ Index, IndexMut }; pub mod png; pub type Position = (usize, usize); #[derive(Clone, PartialEq, Eq, Hash)] pub struct Map { pub width: usize, pub height: usize, pub fields: Vec<Field> } #[derive(Clone, Copy, PartialEq, Eq, Hash)] pub enum Field { Start, Goal, Path, Current...
true
a03c50149d49b19a8005964cfa29cc83945d5626
Rust
gperinazzo/advent-of-code-2018
/puzzle-2/src/main.rs
UTF-8
1,457
3.328125
3
[]
no_license
use std::collections::HashMap; use std::io::{stdin, BufRead, BufReader, Read}; fn part_1() { let buffer = BufReader::new(stdin()); let mut two = 0; let mut three = 0; for line in buffer.lines().filter_map(Result::ok) { println!("Processing line {}", &line); let mut has_two = false; ...
true
eb10cc4ae4688300f39a3211be09bda70dafc117
Rust
zhangyuang/leetcode
/dynamic-programing/medium/robs3/src/lib.rs
UTF-8
1,461
3.046875
3
[]
no_license
/* * @lc app=leetcode.cn id=337 lang=rust * * [337] 打家劫舍 III */ struct Solution {} #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } impl TreeNode { #[inline] pub fn new(val: i32) -> Self { ...
true
6ae80636e70fecd0e40678d4ead097faa683202e
Rust
hooops/crypto-crawler-rs
/crypto-rest-client/tests/binance_inverse.rs
UTF-8
1,644
2.625
3
[ "Apache-2.0" ]
permissive
#[cfg(test)] mod inverse_swap { use crypto_market_type::MarketType; use crypto_rest_client::{fetch_l2_snapshot, fetch_open_interest, BinanceInverseRestClient}; #[test] fn test_agg_trades() { let text = BinanceInverseRestClient::fetch_agg_trades("BTCUSD_PERP", None, None, None).unwra...
true
ef7e547f83d82dbc8b48886035e24883e77c7229
Rust
mosmeh/tamago
/src/index/suffix_array/hashing.rs
UTF-8
3,963
2.546875
3
[]
no_license
use crate::{hash::HashFunc, sequence}; use serde::{Deserialize, Serialize}; use std::{collections::BTreeMap, ops::Range}; use sufsort_rs::sufsort::SA; #[derive(Serialize, Deserialize)] pub struct Hashing { array: Vec<u32>, offsets: Vec<u32>, k: usize, hash_func: HashFunc, mask: u32, } impl Hashin...
true
07ad45a3df71f9f6d7e0451807d42ce57ddc02ed
Rust
rwaldron/euler
/rust/euler.rs
UTF-8
535
2.53125
3
[]
no_license
#[link(name = "euler", vers = "0.1")]; fn is_prime(n: int) -> bool { let flt: float = n as float; let sroot: int = float::sqrt(flt) as int; let i = 3; let rbool = true; if n == 1 || (n > 2 && n % 2 == 0) { false } else { while ( i <= sroot ) { if n % i == 0 { rbool = false; ...
true
061c4a6d955139c31fa43381c4b23a636799d1ef
Rust
bytecodealliance/wasmtime
/examples/tokio/wasm/tokio-wasi.rs
UTF-8
210
3.09375
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
fn main() { let name = std::env::var("NAME").unwrap(); println!("Hello, world! My name is {}", name); std::thread::sleep(std::time::Duration::from_secs(1)); println!("Goodbye from {}", name); }
true
7de39b8ab43a216ef3a1a2f8a850e69a8c4fc586
Rust
wangandi/rust-sql
/src/lexer.rs
UTF-8
8,463
3.140625
3
[]
no_license
use std::iter::*; #[derive(Debug, PartialEq)] pub enum ReservedKeyword { All, And, Any, As, Asc, Between, By, Case, Create, Delete, Desc, Distinct, Drop, Else, End, Except, Exists, False, Group, Having, In, Index, Inner, In...
true
1ac30f02caf4a200fb6d30f24871ed1fc297aeb1
Rust
sandouli/advent-of-code
/2019/day_05/src/main.rs
UTF-8
9,302
3.125
3
[]
no_license
use std::error::Error; use std::io::{self, Read, Write}; type Result<T> = ::std::result::Result<T, Box<dyn Error>>; fn main() -> Result<()> { let mut input = String::new(); io::stdin().read_to_string(&mut input)?; part_1(&input)?; part_2(&input)?; Ok(()) } fn part_1(input: &str) -> Result<()> { ...
true
f9f9ca6c332a15846ca0f95d05d4b329f98eeda6
Rust
tonymichaelhead/gb-emulator
/lib-gb-emu/src/cpu.rs
UTF-8
29,701
2.890625
3
[]
no_license
const ZERO_FLAG_BYTE_POSITION: u8 = 7; const SUBRACT_FLAG_BYTE_POSITION: u8 = 6; const HALF_CARRY_FLAG_BYTE_POSITION: u8 = 5; const CARRY_FLAG_BYTE_POSITION: u8 = 4; const VRAM_BEGIN: usize = 0x8000; const VRAM_END: usize = 0x9FFF; const VRAM_SIZE: usize = VRAM_END - VRAM_BEGIN + 1; pub struct Registers { pub a: ...
true