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
062765bba5aad1262eadae57ca2ec33b55d0d09d
Rust
enutts/bigDaddyCollatz
/src/main.rs
UTF-8
3,362
3.140625
3
[]
no_license
use std::{env, thread, fs}; use std::sync::{Arc, Mutex, mpsc}; fn main() -> std::io::Result<()> { let args: Vec<String> = env::args().collect(); let crange = args[1].as_str(); let crange: u128 = match crange.trim().parse() { Ok(num) => num, Err(e) => { panic!("{}", e); ...
true
a4263f99feafe43505703957dda5bd7358a96254
Rust
zdebra/rust-chess
/src/board.rs
UTF-8
8,390
3.4375
3
[]
no_license
use super::pieces::Piece; use super::Action; struct Board { my_pieces: Vec<Piece>, enemy_pieces: Vec<Piece>, } impl Board { fn legal_moves(&self) -> Vec<Action> { self.my_pieces .iter() .flat_map(|my_piece| my_piece.legal_moves()) .flat_map(|ray| ray.move_action...
true
6ee574d68bbd4a8b18c4609c26234f3b0f49a996
Rust
linyinfeng/toyfio
/src/lib.rs
UTF-8
5,807
2.578125
3
[ "MIT" ]
permissive
#![feature(futures_api, async_await, await_macro, arbitrary_self_types)] use futures::{ future::{Future, FutureObj}, task::{local_waker, LocalWaker, Spawn, SpawnError, Wake}, Poll, }; use log::{debug, trace}; use std::{cell::RefCell, io, ops::Deref, pin::Pin, rc::Rc, sync::Arc, thread_local}; mod leak_sto...
true
b3108263231f86ecaaafc1e0e14f61c5e6b40521
Rust
Kortekaasy/aoc2020
/day13/src/main.rs
UTF-8
3,083
3.21875
3
[]
no_license
// ========================= Challenge Logic ============================ pub fn part1(input: String) -> String { let eta = input.lines().nth(0).expect("Expected first line to be available") .parse::<i128>().expect("Exped to parse bus ID"); let mut bustimes = input.lines().nth(1).expect("Ex...
true
76b8834c730450620bca77895420c2d8604e999b
Rust
ldesgoui/head-empty
/src/de.rs
UTF-8
4,499
2.875
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use crate::{DeserializeFn, Registration, Store}; use erased_serde as erased; use serde::de::{self, DeserializeSeed, Deserializer, MapAccess, Visitor}; use std::any::Any; use std::borrow::Cow; use std::collections::{HashMap, HashSet}; use std::fmt; pub(crate) fn deserialize<'de, Der>(regs: &[Registration], der: Der) ->...
true
c0f05cbe4d6609169a4b47ce565bacd9b29266bd
Rust
jonysy/float
/benches/construct.rs
UTF-8
1,151
2.921875
3
[]
no_license
#![feature(plugin, test)] #![plugin(speculate)] extern crate float; extern crate ordered_float; extern crate test; use float::FloatGuard; speculate! { bench "construct an unwrapped float w/ guard 100x" |b| { b.iter(|| { for _ in 0..100 { // *`unwrap` has a performance cost.. ...
true
8f6c4012b93df5b4b67e7f4cdc9fb47c16b4ef45
Rust
msiglreith/panopaea
/panopaea/src/dec/manifold.rs
UTF-8
5,158
2.828125
3
[]
no_license
use sparse::{SparseMatrix}; use std::marker::PhantomData; use std::ops::Mul; /// Storage type for 0-simplices (vertex). /// A differential primal 0-form is stored for each 0-simplex. /// Storage type for 1-simplices (edge). /// A differential primal 1-form is stored for each 1-simplex. /// Storage type for 2-simplice...
true
8500708652d5e2bdf3387aec41f49aa73ae26665
Rust
shiznit0587/AdventOfCode2018
/src/day20.rs
UTF-8
5,828
2.890625
3
[]
no_license
use std::collections::HashSet; use std::collections::VecDeque; pub fn day20(lines: &mut Vec<String>) { println!("Running Day 20 - a"); let mut doors = HashSet::new(); let tokens = lines[0].chars().filter_map(|c| Token::parse(c)).collect(); branch(&tokens, 0, (0, 0), &mut doors); let (doors, star...
true
88e1fd40ecca9e43fb57604d26f5586579dfb503
Rust
nascheinkman/chord2key
/src/input/device.rs
UTF-8
2,227
3.296875
3
[]
no_license
//use super::types::*; //use crate::events::*; use super::events::*; use std::convert::TryFrom; use std::io::prelude::*; /// A wrapper around input devices to simplify use for this crate. pub struct InputDevice { device: evdev::Device, } impl From<evdev::Device> for InputDevice { fn from(evd: evdev::Device) -...
true
58972b1d7f1cd39d3da267e47398fd5372121456
Rust
SpaceManiac/discord-rs
/examples/channel_permissions.rs
UTF-8
1,590
3.09375
3
[ "MIT" ]
permissive
extern crate discord; use discord::model::{ permissions, ChannelId, PermissionOverwrite, PermissionOverwriteType, RoleId, UserId, }; use discord::Discord; use std::env; fn main() { // Log in to Discord using a bot token from the environment let discord = Discord::from_bot_token(&env::var("DISCORD_TOKEN").expect("E...
true
de5778173c8d1231a7b2c209c264a49b227a033b
Rust
musiciancodes/aoc
/2019_05/src/lib.rs
UTF-8
4,171
3.21875
3
[]
no_license
use std::convert::TryInto; // setup tests for the library function pub struct Computer { loc: usize, instructions: Vec<i32>, input: i32, output: i32, } impl Computer { pub fn run(&mut self) { loop { let mut ins = self.instructions[self.loc].to_string(); while ins.c...
true
b8983e049e6f20bd4cc638145378c6531a524517
Rust
hardy613/jira_peek
/src/jira.rs
UTF-8
2,985
2.75
3
[]
no_license
extern crate futures; extern crate reqwest; use std::process::Command; use std::path::Path; use reqwest::header::ContentType; use params::Params; pub fn fetch_top_5(params: &Params) -> Result<reqwest::Response, reqwest::Error> { let mut url = String::new(); let host: &str = &params.host; let user: &str = &...
true
441ef4be274a475b053b4948f52787f41450c057
Rust
cloudflare/lol-html
/src/parser/lexer/actions.rs
UTF-8
9,089
2.6875
3
[ "BSD-3-Clause", "CC-BY-SA-4.0" ]
permissive
use super::*; use crate::parser::state_machine::StateMachineActions; use NonTagContentTokenOutline::*; use TagTokenOutline::*; // NOTE: use macro instead of the function to make borrow // checker happy with range construction inside match arm // with a mutable borrow of lexer. macro_rules! get_token_part_range { ...
true
1c6a94cec108794587d797b9ce4cb0922a4cdbb2
Rust
mrkgnao/sqlx
/sqlx-core/src/mysql/protocol/err.rs
UTF-8
1,472
2.9375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use byteorder::LittleEndian; use crate::io::Buf; use crate::mysql::io::BufExt; use crate::mysql::protocol::{Capabilities, Decode, Status}; // https://dev.mysql.com/doc/dev/mysql-server/8.0.12/page_protocol_basic_err_packet.html // https://mariadb.com/kb/en/err_packet/ #[derive(Debug)] pub struct ErrPacket { pub e...
true
3e19a5c3864789da0d615e0a6f29203bb2f86281
Rust
AtheMathmo/learning-machines
/src/models/mod.rs
UTF-8
1,194
2.671875
3
[]
no_license
//! This module contains the handlers for the various //! rusty-machine models. use iron::prelude::*; use rustc_serialize::json::{Json, Object}; use rm::linalg::Matrix; pub mod k_means; pub mod dbscan; pub trait ModelHandler: Send + Sync + 'static { fn handle(&self, input: Object) -> IronResult<Response>; } fn...
true
76a566dacf5d5ffe35291d71e44fbdfe353a35eb
Rust
LucioFranco/clique
/clique-tonic/src/server.rs
UTF-8
2,757
2.65625
3
[ "MIT" ]
permissive
use futures::future::FutureExt; use tokio::sync::{mpsc, oneshot}; use tonic::{transport::Server, Request, Response, Status}; use clique::transport; use crate::membership::{ membership_server::{Membership, MembershipServer}, RapidRequest, RapidResponse, }; pub(crate) type TransportItem = ( transport::Requ...
true
88754af92b8fd46fce33774a53d007e883b7332f
Rust
zonotope/powalert
/src/system/notification.rs
UTF-8
2,224
2.71875
3
[ "MIT" ]
permissive
use super::snapshot::Snapshot; use std::time::Duration; use battery::units::ratio::percent; use battery::units::time::second; use battery::units::{Ratio, Time}; use notify_rust::{Notification, NotificationUrgency}; fn icon_level(r: Ratio) -> String { let level = (r.value * 10.0).round(); format!("{:02}0", l...
true
7f213eb05b84153290a57e3d546881a2232ac0f8
Rust
gabe565/advent-of-code-2020
/src/days/day02/mod.rs
UTF-8
1,152
3.046875
3
[]
no_license
use password::Password; mod password; const EXAMPLE_INPUT: &'static str = include_str!("example.txt"); const PROBLEM_INPUT: &'static str = include_str!("problem.txt"); fn part1(input: &'static str) -> usize { input.split("\n") .map(|i| Password::from(i).part1_valid()) .filter(|i| i == &true) ...
true
961ffcc030165646438b6bee5b37b30da43862e0
Rust
EFanZh/LeetCode
/src/problem_0943_find_the_shortest_superstring/mod.rs
UTF-8
1,003
2.90625
3
[]
no_license
pub mod kmp_and_held_karp; pub trait Solution { fn shortest_superstring(words: Vec<String>) -> String; } #[cfg(test)] mod tests { use super::Solution; pub fn run<S: Solution>() { let test_cases = [ (&["alex", "loves", "leetcode"] as &[_], 17), (&["catg", "ctaagt", "gcta", ...
true
8ce1ec616c0efbcd1c6bd8f7dfc6b6b9fc1c6a52
Rust
bave/qselect
/src/bin/select.rs
UTF-8
443
2.625
3
[ "BSD-2-Clause" ]
permissive
//echo "1 2 3 4" | cargo run --release --bin part extern crate qselect; use self::qselect::*; fn read_vec<T: std::str::FromStr>() -> Vec<T> { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().split_whitespace() .map(|e| e.parse().ok().unwrap()).collect() } fn main() { ...
true
ef23d64b70e2d5b0bc1baee43126fff2b74d94a4
Rust
ferrum-rs/ferrum-router
/src/uri_for/mod.rs
UTF-8
4,168
2.796875
3
[ "MIT" ]
permissive
use regex::Regex; use ferrum::{Request, Uri}; use ferrum::error::{HyperResult, HyperError}; use router::RouterInner; use recognizer::{Recognizer, Params, ParamChunk}; pub trait UriFor { fn generate(&self, glob_path: Option<&str>, recognizer: &Recognizer, params: Params) -> HyperResult<Uri>; } impl UriFor for Uri...
true
fdb988bc5748d51a9a11d6e1bd5d3f58eafe4fe1
Rust
AdrienChampion/fast_expr
/fast_expr_gen/src/cxt/zip/zipper_trait.rs
UTF-8
28,446
2.546875
3
[ "Apache-2.0" ]
permissive
//! Handles data specific to the zipper trait and its implementations. prelude! {} fn auto_impl_call( fun_id: impl ToTokens, params: impl IntoIterator<Item = impl ToTokens>, from: &impl ToTokens, ) -> TokenStream { let params = params.into_iter(); quote! { #from :: #fun_id(self #(, #params...
true
c88ab4af710473f933e50afc4175aa40393de874
Rust
Nukesor/pueue
/pueue/src/daemon/state_helper.rs
UTF-8
8,294
2.96875
3
[ "MIT" ]
permissive
use std::collections::BTreeMap; use std::fs; use std::path::{Path, PathBuf}; use std::sync::MutexGuard; use std::time::SystemTime; use anyhow::{Context, Result}; use chrono::prelude::*; use log::{debug, info}; use pueue_lib::settings::Settings; use pueue_lib::state::{Group, GroupStatus, State, PUEUE_DEFAULT_GROUP}; u...
true
834b35b75785211d4e1309a1bb9daec6c712fcdf
Rust
chinedufn/percy
/crates/percy-dom/tests/testing_utilities.rs
UTF-8
2,083
2.71875
3
[ "MIT", "Apache-2.0" ]
permissive
//! Various helper functions and types for writing tests. use std::cell::RefCell; use std::rc::Rc; use virtual_node::event::{ElementEventsId, VirtualEventNode, VirtualEvents}; use virtual_node::VirtualNode; use wasm_bindgen::JsCast; use web_sys::Node; // Tests share the same DOM, so IDs need to be unique across tests...
true
2568f9e29f103bf5837f3b60583519f8ad59e07d
Rust
rickprice/rust-forth-tokenizer
/src/lib.rs
UTF-8
13,073
3.859375
4
[ "MIT" ]
permissive
/// This is how to use the Forth tokenizer library /// ``` /// use rust_forth_tokenizer::ForthToken; /// use rust_forth_tokenizer::ForthTokenizer; /// /// let tokenizer = ForthTokenizer::new("word : wordname 1 2 3 ; definition"); /// // The code also supports the regular for loop iterator syntax /// let col...
true
055501aa8e365b6b0165faa06084f66cfccb6279
Rust
n1o/project_euler
/src/problem2.rs
UTF-8
468
3.34375
3
[]
no_license
fn problem2(){ let mut i = 1; let mut fib = fibonacci(1, 2, i); let mut acc = 0; while fib < 4_000_000 { if fib % 2 == 0 { acc += fib; } i += 1; fib = fibonacci(1, 2, i) } println!("{}", fibonacci(1, 2, 10)); fn fibonacci(first: i32, second...
true
0f517e46cd40df0d39331272841da57bb82ca330
Rust
Devolutions/IronRDP
/crates/ironrdp-pdu/src/input/fast_path.rs
UTF-8
8,573
2.71875
3
[ "Apache-2.0", "MIT" ]
permissive
use std::io::{self}; use bit_field::BitField; use bitflags::bitflags; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use num_derive::{FromPrimitive, ToPrimitive}; use num_traits::{FromPrimitive, ToPrimitive}; use crate::fast_path::EncryptionFlags; use crate::input::{InputEventError, MousePdu, MouseXPdu};...
true
048761074c5850e5e18ecb818c02093063e3b1dd
Rust
lordievader/advent_of_code
/2019/rust/day_11/src/intcode.rs
UTF-8
25,422
2.96875
3
[]
no_license
use std::fmt; #[derive(Clone)] pub struct Amp { pub state: Vec<i64>, pub index: usize, pub input_values: Vec<i64>, pub output_value: i64, pub finished: usize, pub relative_base: i64, } impl fmt::Display for Amp { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ...
true
1da79c8f715b886dfa600d7b5cbc6c6f7aee9680
Rust
facebook/hhvm
/hphp/hack/src/parser/syntax_by_ref/positioned_syntax.rs
UTF-8
1,199
2.6875
3
[ "PHP-3.01", "Zend-2.0", "MIT" ]
permissive
// Copyright (c) 2019, Facebook, Inc. // All rights reserved. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. use super::positioned_token::PositionedToken; use super::positioned_value::PositionedValue; use super::syntax::Syntax; use cra...
true
1e252467eb395f7bcb758e0c299eeef2c93a9c6d
Rust
favilo/kompression
/src/lz78/mod.rs
UTF-8
3,433
2.921875
3
[]
no_license
mod code; mod compress; mod decompress; use std::io::Write; use crate::{error::Error, utils::format_bits}; pub use self::{compress::LZ78Compressor, decompress::LZ78Decompressor}; const MAX_BYTES: usize = std::mem::size_of::<u64>(); const MAX_BITS: usize = MAX_BYTES * 8; #[derive(Default, Clone, Copy)] pub struct B...
true
5c352a161071a082a535f3659ef3c345d92da985
Rust
frxstrem/enum-as-derive
/examples/simple.rs
UTF-8
554
3.125
3
[]
no_license
use enum_as_derive::*; fn main() { let foo = get_foo(); println!("Foo:"); println!("as_a = {:?}", foo.as_a()); println!("is_b = {:?}", foo.is_b()); println!("as_c = {:?}", foo.as_c()); let bar = get_bar(); println!("Bar:"); println!("as_a = {:?}", bar.as_a()); println!("is_b = {:?...
true
cdd5db42bd5b9ecd9ec452323cd6458afa1287ed
Rust
anyska/luster
/src/operators.rs
UTF-8
1,049
3.484375
3
[]
no_license
use value::Value; #[derive(Debug, Eq, PartialEq, Copy, Clone)] pub enum UnaryOperator { Not, Minus, BitNot, Len, } #[derive(Debug, Eq, PartialEq, Copy, Clone)] pub enum BinaryOperator { Add, Sub, Mul, Mod, Pow, Div, IDiv, BitAnd, BitOr, BitXor, ShiftLeft, ...
true
864a2cc62d0ceaac5bb6f624458e678b278719ff
Rust
saigono/raytrace
/src/geometry/aabb.rs
UTF-8
2,170
2.9375
3
[]
no_license
use crate::linalg::{Ray, Vec3}; #[derive(Debug, Copy, Clone)] pub struct AABB { pub min: Vec3, pub max: Vec3, } #[inline(always)] fn fmax(a: f32, b: f32) -> f32 { if a > b { a } else { b } } #[inline(always)] fn fmin(a: f32, b: f32) -> f32 { if a < b { a } else { ...
true
9eb5cc8b74b2a97fe740936cd9a4f816b38db120
Rust
shapedbyregret/matasano-crypto-challenge
/rust/1-7/src/main.rs
UTF-8
830
2.796875
3
[]
no_license
extern crate serialize; extern crate openssl; use std::io::File; use openssl::crypto::symm; // Base64 decoding fn unb64(b64_str:&str) -> Vec<u8> { use serialize::base64::{FromBase64}; let byte_str = b64_str.from_base64().unwrap(); return byte_str; } fn main() { // Decrypt AES-12...
true
008d77cf424c56c2fbb8b1f319cdaada9da6a2b4
Rust
consenlabs/token-core
/tcx-crypto/src/numberic_util.rs
UTF-8
412
3.296875
3
[ "Apache-2.0" ]
permissive
use rand::{thread_rng, RngCore}; use std::vec; pub fn random_iv(len: usize) -> Vec<u8> { let mut v = vec![0u8; len]; thread_rng().fill_bytes(&mut v); v } #[cfg(test)] mod tests { use crate::numberic_util::random_iv; #[test] fn it_works() { let ret = random_iv(32); assert_eq!(3...
true
385697b780f4084d5288ec39c81ea54bef9fb325
Rust
MaderNoob/pwm
/src/locker/io.rs
UTF-8
366
2.546875
3
[]
no_license
use crate::locker::Result; pub trait EncryptedRead { fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>; fn read_until(&mut self, terminator: u8) -> Vec<u8>; } pub trait EncryptedWrite { fn write(&mut self, byte: u8) -> &mut Self; fn write_all(&mut self, buf: &[u8]) -> &mut Self; } pub trait Encryp...
true
1c0f7260de4552d31c383f27dbb9c356cb06afee
Rust
Sarath18/raytracer_rust
/src/vector.rs
UTF-8
3,418
3.578125
4
[]
no_license
use std::ops::{Add, Sub, Neg, Mul, Div}; use rand::Rng; #[derive(Copy, Clone, Debug)] pub struct Vector3 { pub x: f64, pub y: f64, pub z: f64 } impl Add for Vector3 { type Output = Vector3; fn add(self, vec: Vector3) -> Vector3 { Vector3 { x: self.x + vec.x, y: self.y + vec.y, z: self...
true
4e6c2973bcdd7af274a6c27bfdcbdc6827755cdf
Rust
filipealfaiate/Estagio
/Simulador/src/processor.rs
UTF-8
15,676
3.765625
4
[]
no_license
use std::collections::HashMap; #[derive(Debug)] pub struct Processor { pub pc: i32, // program counter pub cod_machine: i32, // codigo mauqina da instrucao pub regs: [i32; 32], // arr com 32 registos [0..31] todos do tipo i32 } impl Processor { pub fn new() -> Processor { Processor {...
true
8bbd2d7caec84e8ae8e83d8fb6c21c2907de9f5b
Rust
BrianMiller793/rust-examples
/philosophers/src/table.rs
UTF-8
9,807
3.4375
3
[ "MIT" ]
permissive
extern crate parking_lot; use self::parking_lot::{Mutex, MutexGuard}; use std::{thread, time}; // Settings have two forks, and a Mutex to act as a seating place. pub struct Setting { left_fork: usize, right_fork: usize, place_index: usize, place: Mutex<()>, } pub type ForksAndPlace<'a> = (Option<...
true
20b29d5e05f27edab43fd53dd23acf77d6e8503b
Rust
bjrnmrtns/xp-game-engine
/low_poly_nice_graphics/src/renderer/renderer.rs
UTF-8
2,722
2.578125
3
[]
no_license
use crate::renderer::{depth_texture::DepthTexture, error::RendererError, vertex_buffer::VertexBuffer}; use std::collections::HashMap; use winit::window::Window; pub struct Renderer { surface: wgpu::Surface, pub device: wgpu::Device, pub queue: wgpu::Queue, pub swap_chain_descriptor: wgpu::SwapChainDesc...
true
2f7ec732bd07f22d5d69503cd5a4151446f79857
Rust
pingw33n/pure_vorbis
/src/huffman.rs
UTF-8
12,493
2.90625
3
[]
no_license
use std::{cmp, io, usize}; use bitstream::BitRead; use error::{Error, Result}; use util::{self, Bits}; #[derive(Debug)] pub struct HuffmanDecoder { lookup_table: LookupTable, long_codes: Box<[LongCode]>, max_code_len: usize, } impl HuffmanDecoder { pub fn builder(lookup_table_bits: usize) -> HuffmanD...
true
c5f88efa609e46f36cbeeb59c7d3900eb674624f
Rust
shangfeiSF/rust-grope
/main/01_guessing_game/src/main.rs
UTF-8
3,042
3.9375
4
[]
no_license
// Rust 标准库中未包含生成随机数的库 // Rust 团队提供了一个rand crate,一个"包装箱"(crate)是一个 Rust 代码的包 // rand 是一个"库包装箱",一个"二进制包装箱",也就是一个可执行文件,包含被其它程序使用的代码 // 使用外部包装箱是 Cargo 的亮点 // extern crate来让Rust知道正在使用 rand,这也等同于一个use rand // extern 类似C++中用来表示变量或者函数定义在其他文件中 extern crate rand; // 引入标准库io use std::io; use std::cmp::Ordering; // 要使用一个方法Rng(如...
true
3813679f67ce5fad2609c65f49a3cf285eb0711a
Rust
dvdsk/bluebus
/src/util.rs
UTF-8
1,843
2.53125
3
[ "MIT" ]
permissive
use crate::dbus_helpers::{unwrap_container, unwrap_variant}; use crate::error::Error; use crate::Ble; use rustbus::MessageBuilder; use std::fs::remove_file; use std::io::ErrorKind; use std::path::PathBuf; impl Ble { fn adapter_adress(&mut self) -> Result<String, Error> { let mut get_addr = MessageBuilder:...
true
3fd29a274019aa373a40d139ca246f19d9407e63
Rust
seb-odessa/pattern_strategy
/src/main.rs
UTF-8
4,163
3.46875
3
[]
no_license
mod fly { pub trait FlyBehavior { fn perform(&self); } pub struct FlyWithWings; impl FlyWithWings { pub fn new() -> Self { FlyWithWings } } impl FlyBehavior for FlyWithWings { fn perform(&self) { println!("I am flying by the wings !!!"); ...
true
f1016e07315e6296f30b943fe8d2f7eadaecf92e
Rust
J-F-Liu/lopdf
/src/creator.rs
UTF-8
7,449
3.109375
3
[ "MIT" ]
permissive
use crate::{Dictionary, Document, Object, ObjectId}; use crate::{Error, Result}; impl Document { /// Create new PDF document with version. pub fn with_version<S: Into<String>>(version: S) -> Document { let mut document = Self::new(); document.version = version.into(); document } ...
true
b6fd306b57433c21cdc6f22db3091a07c21aed24
Rust
kildevaeld/freja-lang
/OLD/_freja-parser/src/ast.rs
UTF-8
4,764
3.171875
3
[]
no_license
use super::owned::*; use super::traits::{ExprRefVisitor, StmtRefVisitor}; use std::fmt; #[derive(Serialize, Debug, Clone, PartialEq, Eq, Hash, Deserialize)] pub struct Location(pub usize, pub usize); #[derive(Serialize, Debug, PartialEq, Eq, Hash, Clone)] pub struct TokenRef<'a> { pub location: Location, pub ...
true
1829c3339324f86632e70393a01e2c29735d1133
Rust
Phantomical/raytracer-rs
/raytracer-lib/src/object/box_obj.rs
UTF-8
567
2.625
3
[ "MIT" ]
permissive
use lib::*; use lib::object::*; #[derive(Copy, Clone, Serialize, Deserialize)] pub struct BoxObj { #[serde(with = "tag")] #[serde(rename = "type")] #[serde(skip_deserializing)] tag: (), pub bounds: Vec3d, } type_serialization_decl!("box"); impl BoxObj { pub fn new(bounds: Vec3d) -> Self { ...
true
6138b8bcae23863f4f313e6b5bf9f149e3b13441
Rust
sebastiencs/rustorrent
/src/utils.rs
UTF-8
3,397
2.6875
3
[]
no_license
use async_channel::{Sender, TrySendError}; use async_trait::async_trait; use byteorder::{BigEndian, ReadBytesExt}; use std::net::SocketAddr; use tokio::net::TcpStream; use std::{ io::Cursor, net::{Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6}, time::Duration, }; pub trait FromSlice<T> { fn from_slic...
true
bd2034982787985e8ffb52cfe00696156239df88
Rust
pandaman64/succ_nix
/src/domain/attr_set.rs
UTF-8
3,297
3.15625
3
[]
no_license
use crate::typing::Type; use std::{ collections::{BTreeMap, BTreeSet}, fmt, }; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] pub struct AttrSetType { pub attrs: BTreeMap<String, Type>, pub rest: Box<Type>, } impl fmt::Display for AttrSetType { fn fmt(&self, f: &mut fmt::Formatter<'_>) ->...
true
0a1fac14f14af17c6cac46707331c6a4530db8a2
Rust
Mimikkk/leetcode-rust
/src/tests/algorithms.rs
UTF-8
943
2.90625
3
[]
no_license
use crate::algorithms::{pascal_triangle_i, pascal_triangle_ii}; #[test] fn pascal_triangle_i_row_1_to_4() { assert_eq!(pascal_triangle_i(0), Vec::<Vec<i32>>::new(), "Should be []"); assert_eq!(pascal_triangle_i(1), vec![vec![1]], "Should be [[1]]"); assert_eq!(pascal_triangle_i(2), vec![vec![1], vec![1, 1]...
true
4eca0f36c93db1860dabf0034b51bf860dd2999c
Rust
adek05/AdventOfCode2020
/src/docking_data.rs
UTF-8
4,509
3.171875
3
[]
no_license
#[macro_use] extern crate scan_rules; use scan_rules::scanner::Word; use std::collections::HashMap; use std::fs::File; use std::io; use std::io::prelude::*; use std::path; #[derive(Clone)] struct Bitmask(String); struct Program { bitmask: Bitmask, memory: HashMap<u64, u64>, } #[derive(Clone)] enum Operation...
true
c296b7e83a039a8f6fdbfa96ca1c6d66cb4ccd34
Rust
rustyforks/moonlander
/moonrender/src/types/generic/heading.rs
UTF-8
1,976
3.03125
3
[ "MIT" ]
permissive
use crate::lines::Line; use crate::Theme; use cairo::Context; use pango::{Alignment, Layout, Weight, WrapMode}; pub struct Heading { line: String, size: u8, x: f64, y: f64, width: f64, height: f64, } impl Heading { pub fn new(line: String, size: u8) -> Self { Self { l...
true
4f776eb82d60345551503c4919715ca1f88208f8
Rust
ED-NEWP/eddb
/src/serde_utils.rs
UTF-8
1,412
3.09375
3
[]
no_license
use std::fmt; use std::marker::PhantomData; use serde::de::{self, Visitor}; use serde::Deserializer; pub fn bool_or_bit<'de, D: Deserializer<'de>>(deserializer: D) -> Result<bool, D::Error> { struct BoolOrBit(PhantomData<fn() -> bool>); impl<'de> Visitor<'de> for BoolOrBit { type Value = bool; ...
true
f7d3efba3a70fc15841503c9727f7c7c680d5133
Rust
theseus-os/Theseus
/old_crates/dbus/src/lib.rs
UTF-8
4,598
2.75
3
[ "MIT" ]
permissive
#![no_std] #[macro_use] extern crate log; extern crate alloc; extern crate spin; extern crate irq_safety; extern crate util; use alloc::string::String; use alloc::collections::{BTreeMap, VecDeque}; use irq_safety::{RwLockIrqSafe}; use spin::{Once, RwLock}; use alloc::sync::Arc; use util::c_str::{CStr}; #[derive(Clo...
true
5934fa1cdd20523d650b56e7b87608d94df59b69
Rust
lewisdaly/iota-rust-cli
/src/api.rs
UTF-8
4,543
2.828125
3
[]
no_license
use api_commands; use api_models; use api_commands::FindTransactionsType; use request::IotaRequest; use models::*; use alloc::Vec; use trytes::string::char_to_trits; use trytes::Trit; use serde_json; use curl::*; use curl_cpu::CpuCurl; use sign::iss::KEY_LENGTH; use sign::iss::DIGEST_LENGTH; use sign::iss::ADDRESS_LENG...
true
84c9b494997c64700e6a5d9161ee717fac2c21bf
Rust
solana-labs/solana
/sdk/src/account.rs
UTF-8
38,902
2.765625
3
[ "Apache-2.0" ]
permissive
//! The Solana [`Account`] type. use { crate::{ clock::{Epoch, INITIAL_RENT_EPOCH}, lamports::LamportsError, pubkey::Pubkey, }, serde::{ ser::{Serialize, Serializer}, Deserialize, }, solana_program::{account_info::AccountInfo, debug_account_data::*, sysvar::S...
true
c0b177880bb98cb63fc9eb9407ae8e3feabed267
Rust
risooonho/rs-breakout
/src/blueprints/blu_ball.rs
UTF-8
820
2.5625
3
[]
no_license
use std::f32::consts::PI; use crate::math::vec2::Vec2; use crate::blueprints::blu_common::Blueprint; use crate::components::com_draw2d::Draw2d; use crate::components::com_move::Move; use crate::components::com_controll_ball::ControlBall; use crate::components::com_collide::Collide; pub fn get_ball(x: f32, y: f32) -> B...
true
10432f8ebe2970edb35c66a6b85e75aa9cde1fbc
Rust
stevechuck/adventofcode-2020-rust
/day06/src/ans.rs
UTF-8
1,647
3.140625
3
[]
no_license
use aoc2020::input::parse_newline_sep; use std::collections::HashSet; use std::path::Path; use thiserror::Error; struct CustomsDeclarationForm(Vec<HashSet<char>>); impl std::str::FromStr for CustomsDeclarationForm { type Err = std::convert::Infallible; fn from_str(s: &str) -> Result<Self, Self::Err> { ...
true
ee35ded3ee5f294410ca37090d9df2b446ac7f76
Rust
wimpheling/hit
/src/prelude/validators/string_enum.rs
UTF-8
758
2.8125
3
[]
no_license
use crate::model::validators::{Validator, ValidatorContext}; use crate::{HitError, ValidationError}; pub struct StringEnumValidator { values: Vec<String>, } impl Validator<String> for StringEnumValidator { fn validate( &self, value: &String, _context: &ValidatorContext, ) -> Result...
true
6790c828df70cf37d71715eb462dc1dafe526c93
Rust
migerh/aoc-2020-rs
/src/template/mod.rs
UTF-8
564
2.8125
3
[ "MIT" ]
permissive
use super::utils::ParseError; fn parse_input() -> Vec<i32> { let input = include_str!("./data/input.txt"); input .lines() .filter(|v| *v != "") .map(|v| v.parse::<i32>().unwrap()) .collect::<Vec<_>>() } pub fn problem1() -> Result<(), ParseError> { let input = parse_input()...
true
df3a48414c4419755d04ab231220a6c8217c0935
Rust
PayasR/rust_road_router
/utils/src/bin/compare_vector.rs
UTF-8
3,645
2.96875
3
[ "BSD-3-Clause" ]
permissive
use rust_road_router::{cli::CliErr, io::*}; use std::{env, error::Error, fmt::Display}; fn main() -> Result<(), Box<dyn Error>> { let mut args = env::args().skip(1); match &(args.next(), args.next(), args.next()) { (Some(data_type), Some(input1), Some(input2)) => { match data_type.as_ref() ...
true
1a85ad51c7bd85e72f4143d65c12b27c4078cabd
Rust
IThawk/rust-project
/rust-master/src/test/ui/span/destructor-restrictions.rs
UTF-8
232
3
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// Tests the new destructor semantics. use std::cell::RefCell; fn main() { let b = { let a = Box::new(RefCell::new(4)); *a.borrow() + 1 }; //~^ ERROR `*a` does not live long enough println!("{}", b); }
true
4a44eaf61c7a2fa227fd516d4ba60adbb1d32ee6
Rust
J-F-Liu/geom3d
/src/utils/meshgen.rs
UTF-8
6,721
3.109375
3
[ "MIT" ]
permissive
use crate::consts::HALF_SQRT_3; use crate::{utils::Point, Float, Point2}; use std::collections::VecDeque; /// generate triangular mesh by advancing front method pub fn generate_triangular_mesh(points: &[Point2], polygons: &[usize]) -> (Vec<Point2>, Vec<u32>) { let mut triangles = Vec::new(); let mut vertices =...
true
3009e4cc2d7de10539900639bf1f2b2fa08aeea2
Rust
lucypero/rusty-jam
/src/player.rs
UTF-8
12,239
2.75
3
[]
no_license
use bevy::{math::vec2, prelude::*}; use crate::{DAMAGED_INVINCIBILITY_FRAMES, DASH_COOLDOWN_TIME, DASH_DURATION, DASH_SPEED, MOVEMENT_SPEED}; use crate::mouse::MouseState; use crate::collision::{HitBoxEvent, Team, CanHitTeam, Hurtbox}; #[derive(Bundle)] pub struct PlayerBundle { player: Player, hurtbox: Hurtbo...
true
640106a2c74d82c239bb180b41de77fb3dd87c27
Rust
andymac-2/action
/src/action_arrow.rs
UTF-8
5,485
2.71875
3
[ "Apache-2.0" ]
permissive
mod error; mod identity; pub use error::Error; pub use identity::Identity; use std::marker::PhantomData; #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] pub struct FromFunc<'a, 'b, A, B, F> { func: F, _input_type: PhantomData<&'a A>, _output_type: PhantomData<&'b B>, } pub fn f<'a,...
true
2c5ecdba4c7ab1f31b40add87f40119298985de8
Rust
mckinnsb/rusty_z
/src/zmachine/instruction_set.rs
UTF-8
48,056
2.828125
3
[]
no_license
extern crate rand; use super::super::interfaces::zinterface::ZInterface; use super::header::*; use super::memory_view::MemoryView; use super::object_properties_view::*; use super::object_view::ObjectView; use super::opcode::*; use super::zmachine::MachineState; use super::zmachine::ZMachine; use super::zstring::*; us...
true
f9510ecd3e446b20cc41e394dd098af7ee8bdda8
Rust
input-output-hk/chain-libs
/chain-impl-mockchain/src/milli.rs
UTF-8
3,723
3.40625
3
[ "MIT", "Apache-2.0" ]
permissive
use std::str::FromStr; use std::{fmt, iter}; const MILLI_MULTIPLIER: u64 = 1000; #[derive(Clone, Copy, Debug, Default, Eq, Ord, PartialEq, PartialOrd)] pub struct Milli(u64); impl Milli { pub const ZERO: Milli = Milli(0); pub const HALF: Milli = Milli(MILLI_MULTIPLIER / 2); pub const ONE: Milli = Milli(M...
true
b0170d63ae96ab405fdd46d02713c16b95d75297
Rust
topecongiro/libmcs
/src/main.rs
UTF-8
2,736
3.3125
3
[ "MIT" ]
permissive
extern crate libmcs; use std::str::FromStr; use std::env; use std::thread; use std::sync::Arc; use std::sync::mpsc; use std::time; /// A default value for thread number. const THREAD_NUM: usize = 4; /// A default number for number of critical section per thread. const LOOP: usize = 1000000; /// Run a simple benchma...
true
32dfb93528c95272d7d06a0e74cf25daa3db7178
Rust
thanadolps/chembasics
/src/lib.rs
UTF-8
2,186
2.890625
3
[ "MIT" ]
permissive
use std::mem; use ptable::Element; mod ion; mod basic_formulas; mod structural; pub mod consts; pub use ion::*; pub use structural::*; pub use basic_formulas::*; fn parse_element(string: &[u8]) -> (Option<Element>, &[u8]) { let mut end = 1; if string.len() >= 2 && string[1] >= b'a' && string[1] <= b'z' { ...
true
f4ad7ba639c0d0bd2502717cd766533b1474292f
Rust
lowellmower/server
/src/bin/main.rs
UTF-8
1,500
2.8125
3
[]
no_license
extern crate server; use server::ThreadPool; use std::io::prelude::*; use std::net::TcpListener; use std::net::TcpStream; use std::thread; use std::time::Duration; use std::fs::File; fn main() { let listener = TcpListener::bind("127.0.0.1:8080").unwrap(); let pool = ThreadPool::new(4); for stream in liste...
true
eee90695732b5f656aab799fcd1e450c4466d532
Rust
fernandomarca/rust_exemplos
/src/ref e borrowing copy.rs
UTF-8
298
4.21875
4
[ "MIT" ]
permissive
fn main() { let mut s1 = String::from("texto"); let tamanho = calcula_tamanho(&mut s1); println!("O tamanho de '{}' é {}.", s1, tamanho); } fn calcula_tamanho(s: &mut String) -> usize { let tamanho = s.len(); s.push_str(" longo"); // len() retorna o tamanho de uma String. tamanho }
true
e0e2fb5d7e835e2c62a2a23a2e56ce631e085fb7
Rust
ghuls/arrow2
/src/array/primitive/iterator.rs
UTF-8
606
2.59375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{ bitmap::utils::{zip_validity, ZipValidity}, types::NativeType, }; use super::PrimitiveArray; impl<'a, T: NativeType> IntoIterator for &'a PrimitiveArray<T> { type Item = Option<&'a T>; type IntoIter = ZipValidity<'a, &'a T, std::slice::Iter<'a, T>>; #[inline] fn into_iter(self) -...
true
6e0a4b7ea6abe5ade2662591abdfd36bf4d40c30
Rust
stanciua/adventofcode2017
/day16/src/main.rs
UTF-8
3,284
3.546875
4
[]
no_license
#![feature(slice_rotate)] use std::fs::File; use std::io::prelude::*; use std::str::FromStr; #[derive(Debug)] enum Move { Spin(usize), Exchange(usize, usize), Partner(char, char), } impl FromStr for Move { type Err = &'static str; fn from_str(s: &str) -> Result<Self, Self::Err> { match s.c...
true
bc48572a6a2890c0c69865187f4419d10f55ebc4
Rust
fospring/bithumb-chain-rust-cdt2
/bxa-api/src/storage.rs
UTF-8
1,287
2.890625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Storage extensions for pwasm-ethereum. //! Storage api is a key-value storage where both key and value are 32 bytes in len use bxa_std::{vec, Vec}; extern "C" { fn storage_read(key: *const u8, klen: u32, val: *mut u8, vlen: u32, offset: u32, vt: u8) -> u32; fn storage_write(key: *const u8, klen: u32, src: *const ...
true
2f0cc3c4faf2ab37c99cc3ffd093e9bb184ac99a
Rust
sansom/rust-fil-proofs
/storage-proofs/porep/src/nse/vanilla/butterfly_graph.rs
UTF-8
4,616
3.4375
3
[ "Apache-2.0", "MIT" ]
permissive
use super::config::Config; use super::Parent; /// The butterfly graph which provides the parents for the butterfly layers. #[derive(Debug)] pub struct ButterflyGraph { /// The degree of the graph. pub degree: usize, /// The number of nodes in a window. Must be a power of 2. pub num_nodes_window: u32, ...
true
82b6a79e45e9e02379450f1aa042a95837e3ec93
Rust
magnusstrale/aoc2019
/day3/src/main.rs
UTF-8
649
2.859375
3
[]
no_license
use std::fs::File; use std::io::prelude::*; use std::io::{BufReader, Lines}; mod wire; use wire::Wire; fn main() { let file_name = "src/day3.txt"; let mut lines = read_file(&file_name); let w1 = Wire::new(&lines.next().unwrap().unwrap()); let w2 = Wire::new(&lines.next().unwrap().unwrap()); let ...
true
ad4a43bd993e53a9be4e54d0cef27d0532d20193
Rust
alistairmgreen/AdventOfCode2019
/day11/src/main.rs
UTF-8
4,268
3.375
3
[]
no_license
use intcode::{IntcodeMachine, ProgramError, ProgramState}; use std::collections::HashMap; use std::fmt; fn main() -> Result<(), ProgramError> { let program: Vec<i64> = include_str!("puzzle_input.txt") .split(",") .map(|n| n.parse().unwrap()) .collect(); let part1 = paint_picture(program.clone(), C...
true
6ab1af53d1847865b5ecd7fe617a527fd53750e2
Rust
bwinkler/wmfocus
/src/utils.rs
UTF-8
14,968
2.546875
3
[ "MIT" ]
permissive
use cairo; use cairo::enums::{FontSlant, FontWeight}; use cairo::prelude::SurfaceExt; use clap::{ crate_authors, crate_description, crate_name, crate_version, value_t, App, AppSettings, Arg, }; use css_color_parser::Color as CssColor; use font_loader::system_fonts; use itertools::Itertools; use log::debug; use rege...
true
eaff2c7fd6ecf84719f6de45c73591f760248006
Rust
balajisivaraman/gprompt
/tests/tests.rs
UTF-8
3,767
2.75
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use std::fmt; use std::process::Command; use util::{Dir, TestCommand}; // Macros useful for testing. #[macro_use] mod macros; // Utilities for making tests nicer to read and easier to write. mod util; gptest!(retrieve_branch, |dir: Dir, mut cmd: TestCommand| { Command::new("git") .current_dir(&dir.dir) ...
true
66a6f6445e1fb9e26ac3c1f637d48eef1732e47e
Rust
bokuweb/docx-rs
/docx-core/examples/toc_with_tc.rs
UTF-8
1,230
2.8125
3
[ "MIT" ]
permissive
use docx_rs::*; pub fn main() -> Result<(), DocxError> { let path = std::path::Path::new("./output/toc_with_tc.docx"); let file = std::fs::File::create(&path).unwrap(); let p1 = Paragraph::new() .add_run(Run::new().add_text("Hello")) .style("Heading1") .page_break_before(true); ...
true
a549a0d67c8833b6694312b3c6122fb5c20bce59
Rust
metzenseifner/alacritty-theme
/src/lib/cli.rs
UTF-8
1,824
2.84375
3
[]
no_license
use crate::lib::{AlacrittyConfig, Error}; use std::path::PathBuf; use structopt::{clap::AppSettings, StructOpt}; #[derive(StructOpt, Debug)] #[structopt( name = "Alacritty Themes", about = "List and swap your Alacritty themes.", setting(AppSettings::ColoredHelp) )] pub enum Cli { #[structopt( name = "list...
true
1c5bd6e053dba2b42ee0793ba61ff811274c44ee
Rust
rainliu/libwebm
/src/mkvmuxer/audio_track.rs
UTF-8
2,970
2.625
3
[ "MIT" ]
permissive
use super::track::Track; use super::util; use super::writer::Writer; use crate::MkvId; use std::ops::Deref; pub struct AudioTrack { track_: Track, // Audio track element names. bit_depth_: u64, channels_: u64, sample_rate_: f64, } impl Deref for AudioTrack { type Target = Track; fn dere...
true
b7c3984573f39975bddfb3aa97d62cfed853de87
Rust
emakryo/cmpro
/src/facebook2021_qual/src/bin/a1.rs
UTF-8
1,017
2.671875
3
[]
no_license
#![allow(unused_macros, unused_imports)] use std::collections::BTreeMap; use proconio::marker::{Bytes, Chars}; macro_rules! dbg { ($($xs:expr),+) => { if cfg!(debug_assertions) { std::dbg!($($xs),+) } else { ($($xs),+) } } } fn main() { proconio::input!{ ...
true
46f93d6bd77e9c14fe931c40db0329ca6ac925bc
Rust
tommady/leetcode
/rust/src/p1306_jump_game_iii.rs
UTF-8
2,088
3.578125
4
[]
no_license
// Given an array of non-negative integers arr, you are initially positioned at start index of the array. When you are at index i, you can jump to i + arr[i] or i - arr[i], check if you can reach to any index with value 0. Notice that you can not jump outside of the array at any time. Example 1: Input: arr = [4,2,3,0,3...
true
62aa5d9ed9b7d2eb7b39f3ec48484616201663fc
Rust
CinchBlue/toql
/toql_derive/tests/update_test.rs
UTF-8
2,113
3.21875
3
[ "Apache-2.0", "MIT" ]
permissive
use toql::derive::Toql; use toql::indelup::Indelup; #[derive(Debug, PartialEq, Toql)] #[toql(skip_query, skip_query_builder)] struct UpdateBook { #[toql(delup_key)] id: u8, title: Option<String>, // Selectable, update if some value #[toql(select_always)] pages: Option<u8>, // Nullable column, upda...
true
0b96e4763e7135e2c3ce0700e40ac0fced0ab420
Rust
pka/ganja-rs
/examples/cga3d_intersections.rs
UTF-8
3,951
3.09375
3
[]
no_license
#![allow(non_snake_case)] use ganja_rs::cga::*; use ganja_rs::ganja_graph; use std::fs::File; use std::io::BufWriter; // https://enkimute.github.io/ganja.js/examples/coffeeshop.html#cga3d_intersections // We start by defining a null basis, and upcasting for points // var ni = 1e4+1e5, no = .5e5-.5e4, nino = ni^no;...
true
df2e43b0302abaec9decf8505a18639df6886b80
Rust
rsaarelm/morlock-hunter
/src/morlock/mob.rs
UTF-8
4,099
2.734375
3
[ "MIT" ]
permissive
use time; use color::rgb::consts::*; use cgmath::vector::{Vec2}; use cgmath::point::{Point}; use area::Location; use transform::Transform; use sprite::{Sprite, tile}; use sprite; use misc::{cycle_anim, single_anim}; // How many seconds to show the hurt blink. static HURT_TIME_S : f64 = 0.2; static DEATH_TIME_S : f64...
true
a7c6537631f171b12374c37da5b6c463153baf34
Rust
Thomasdezeeuw/gaea
/tests/signals.rs
UTF-8
6,633
2.796875
3
[ "MIT" ]
permissive
use std::io::{self, Read}; use std::ops::{Deref, DerefMut}; use std::panic; use std::process::{Child, Command, Stdio}; use std::thread::sleep; use std::time::Duration; use gaea::event; use gaea::os::{Signal, Signals, SignalSet}; mod util; use self::util::init_with_os_queue; #[test] fn signal_bit_or() { // `Sign...
true
80d7ee6fc4559c00f3364f6d1425b58bd48abc85
Rust
aconbere/anders-gameboy-emulator
/src/device/mod.rs
UTF-8
1,840
2.953125
3
[]
no_license
pub mod cartridge; pub mod hardware_io; pub mod interrupt; pub mod not_implemented; pub mod ram_bank; pub mod tile_data; pub mod tile_map; pub mod zero_page; pub mod boot_rom; #[derive(Debug)] pub enum Kind { RestartAndInterrupt, CartridgeHeader, CartridgeROMBank0, CartridgeROMBank1, TileMap1, ...
true
a1b0f6e94a1b7949405ab5eef09f4f1ca7bff3dc
Rust
AndrewMendezLacambra/rust-programming-contest-solutions
/atcoder/agc031_b.rs
UTF-8
1,500
3.15625
3
[]
no_license
use std::collections::BTreeMap; const MOD: u64 = 1e9 as u64 + 7; fn main() { let s = std::io::stdin(); let mut sc = Scanner { stdin: s.lock() }; let n = sc.read(); let mut a = vec![]; for _ in 0..n { let x: usize = sc.read(); if a.is_empty() || *a.iter().next_back().unwrap() != x ...
true
6ede6f265de04fb29a17f5a0f05e14f2b2591e11
Rust
MacDaih/ectopus
/src/db/model.rs
UTF-8
1,772
2.734375
3
[]
no_license
use serde::{Deserialize,Serialize}; use chrono::{ DateTime, Utc }; #[derive(Debug, Deserialize, Serialize)] pub struct Report { pub name: String, pub start_at: DateTime<Utc>, pub duration: i32, pub total_tests: i32, pub failed: i32, pub passed: i32, pub runs: Vec<Run>, } #[derive(Debug, Des...
true
e50f78de0d6348cb5be5e853e626692fd45c0e17
Rust
ferdyrurka/rust-codewars
/src/katas/sum_of_odd_numbers.rs
UTF-8
1,124
3.453125
3
[]
no_license
#![allow(unused)] /* 2 = 2 values (3, 5) result = 3 + 5 = 8 *** value: an = a(n - 1) + 2; *** 2 = (3, 5) = 8 -> 1 + 2 * 2 = 5 (last element) 3 = (7, 9, 11) = 27 -> 2 + 3 * 3 = 11 (last element) 4 = (13, 15, 17, 19) -> 3 + 4 * 4 = 19 (last element) for last element an_max = (n - 1) + n * n *** 2 = (3, 5) = 8 -...
true
571cde24f178f3d1ae421699ad0f108a756ff458
Rust
bauhaus93/mw-parse
/logger/src/lib.rs
UTF-8
1,136
2.5625
3
[]
no_license
extern crate log; extern crate env_logger; extern crate chrono; use std::env; use log::{ LogRecord, LogLevelFilter, SetLoggerError }; use env_logger::LogBuilder; use chrono::{ Datelike, Timelike, Local }; pub enum LogLevel { Trace, Debug, Info, Warn, Error } pub fn init(log_level: LogLevel) -> ...
true
eb76058684b7b50dd44044b1eaf5241420fb8180
Rust
yangcancai/captcha
/src/lib.rs
UTF-8
4,590
2.671875
3
[ "Apache-2.0" ]
permissive
extern crate image; extern crate num_complex; use std::rc::Rc; use std::{cell::RefCell, collections::HashMap}; pub mod captcha; pub mod phx; pub mod token; pub mod time; /// 管理模块 pub struct Plug<'a> { pub name: &'a str, } impl<'a> Task<'a, Plug<'a>> for Plug<'a> { fn new() -> Self { Plug { name: &"pl...
true
6ccb588c03d3c0d7fe7888d4690851b75bd37eee
Rust
ComanAdrian/exercism
/grade-school/src/lib.rs
UTF-8
859
3.375
3
[]
no_license
use std::collections::HashMap; pub struct School { roster: HashMap<u32, Vec<String>>, } impl School { pub fn new() -> School { School { roster: HashMap::new(), } } pub fn add(&mut self, grade: u32, student: &str) { let grade_students = self.roster.get_mut(&grade); ...
true
da50d874fd26704aa28c0276ef72c49fb3007c64
Rust
fyang93/rust-leetcode
/src/p0013_roman_to_integer.rs
UTF-8
817
4.21875
4
[]
no_license
pub fn roman_to_int(s: String) -> i32 { if s.is_empty() { return 0; } let mut chars = s.chars(); let mut num = 0; let mut cur = parse(chars.next().unwrap()); for c in chars { let next = parse(c); num += if cur < next { -cur } else { cur }; cur = next; } num + cur } f...
true
8a84c9ed01fc7604be3709fc4c5ad561190f3577
Rust
i10416/ods
/chapter14/src/blockstore.rs
UTF-8
1,067
2.90625
3
[ "MIT" ]
permissive
#![allow(clippy::many_single_char_names,clippy::explicit_counter_loop)] use chapter01::interface::List; use chapter02::arraystack::Array as ArrayStack; #[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct BlockStore<T: Clone> { blocks: ArrayStack<T>, free: ArrayStack<usize>, } imp...
true
eb840eba8f0d539ca565a1c4374cb03faea6436e
Rust
tokio-rs/tokio
/tests-integration/src/bin/test-cat.rs
UTF-8
464
2.6875
3
[ "MIT" ]
permissive
//! A cat-like utility that can be used as a subprocess to test I/O //! stream communication. use std::io; use std::io::Write; fn main() { let stdin = io::stdin(); let mut stdout = io::stdout(); let mut line = String::new(); loop { line.clear(); stdin.read_line(&mut line).unwrap(); ...
true
135f6b93aa1d0fb88382c84550509650737d9984
Rust
davgit/bfpd-rs
/graphql/src/views.rs
UTF-8
8,238
2.703125
3
[]
no_license
#[cfg(feature="maria")] use mariadb::models::*; #[cfg(feature="postgres")] use pg::models::*; use crate::graphql_schema::Context; #[derive(juniper::GraphQLObject, Debug)] #[graphql(description = "Defines a branded food product")] pub struct Foodview { #[graphql(description = "Date food was updated")] pub publi...
true
6c1e7aa50ef75404e4090f3409aa1894a9d06659
Rust
Trangar/artnet_protocol
/src/command/output/mod.rs
UTF-8
6,827
2.859375
3
[ "MIT" ]
permissive
#[cfg(test)] mod tests; use crate::{command::ARTNET_PROTOCOL_VERSION, convert::Convertable, Error, PortAddress, Result}; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use std::io::Cursor; data_structure! { #[derive(Debug)] #[doc = "ArtDmx is the data packet used to transfer DMX512 data. The format ...
true