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
01da00144f6b8aaa43789c38f838bf4957deff3e
Rust
reitermarkus/cargo-eval
/src/file_assoc.rs
UTF-8
5,251
2.84375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! This module deals with setting up file associations. //! Since this only makes sense on Windows, this entire module is Windows-only. use std::io; use itertools::Itertools; use winreg::{enums as wre, RegKey}; use crate::error::{Blame, Result}; #[derive(Debug)] pub enum Args { Install { amend_pathext: bool },...
true
d4a86ae615952f8cada82e0b19bbd0e765426ffc
Rust
jaborn/mmix
/src/machine/state/mem.rs
UTF-8
5,146
3.046875
3
[]
no_license
use machine::state::types::*; use std::ops::{Index, IndexMut}; #[derive(Copy, Clone)] pub struct ByteAt(pub u64); #[derive(Copy, Clone)] pub struct WydeAt(pub u64); #[derive(Copy, Clone)] pub struct TetraAt(pub u64); #[derive(Copy, Clone)] pub struct OctaAt(pub u64); pub struct Memory { buf: Vec<Octa>, } imp...
true
bad90cd6c4124a6550382989bc88e8e6e4597c1f
Rust
canndrew/malk-rs
/src/core/term.rs
UTF-8
16,182
3.171875
3
[]
no_license
use std::rc::Rc; use std::ops::Deref; use std::collections::HashMap; use core::{Name, Rank, substitute, try_lower_index}; use core::ops::normalise; use core::meta::MVar; use core::Origin; //use core::Ctx; //use debug::Debug; use self::TermKind::*; pub struct Intrinsic { pub arg_type: Term, pub ret_type: Ter...
true
230cba3d7e7de7ba8bf72e3a7f81f260d2f229e3
Rust
killercup/convey
/src/test_buffer.rs
UTF-8
1,242
2.953125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use std::io; use std::sync::{Arc, RwLock}; use termcolor::{Buffer, ColorSpec, WriteColor}; #[derive(Clone)] pub(crate) struct TestBuffer(pub(crate) Arc<RwLock<Buffer>>); impl From<Buffer> for TestBuffer { fn from(x: Buffer) -> Self { TestBuffer(Arc::new(RwLock::new(x))) } } impl io::Write for TestBuf...
true
379225ab73f75f0fab5cad9a026a7b56215d1b04
Rust
aiifabbf/leetcode-memo
/295.rust/src/main.rs
UTF-8
9,061
3.875
4
[]
no_license
/* 从一个流里面读数字,计算至今为止见过的所有数的中位数。 想一想中位数的定义 - 如果array是偶数长度,中位数是从小到大排好序之后,最中间两个数的平均 - 如果array是奇数长度,中位数就是最中间那个数 需要快速得到最中间那两个数。 看了 `评论区 <https://leetcode.com/problems/find-median-from-data-stream/discuss/74062/Short-simple-JavaC%2B%2BPython-O(log-n)-%2B-O(1)>`_ ,想了一下想出来了。搞两个heap - 第一个heap是一个最大heap,存至今为止见过的所有数字从小到大...
true
9f0e01840bc36a6696ba2163d8a99c47dff23206
Rust
willi-kappler/nom
/src/multi.rs
UTF-8
57,944
2.96875
3
[ "MIT" ]
permissive
//! Parsers for applying parsers multiple times /// `separated_list!(I -> IResult<I,T>, I -> IResult<I,O>) => I -> IResult<I, Vec<O>>` /// separated_list(sep, X) returns Vec<X> will return Incomplete if there may be more elements #[macro_export] macro_rules! separated_list( ($i:expr, $sep:ident!( $($args:tt)* ), $su...
true
1e7fe26f517c216c39201909c63caeaa62cca96a
Rust
fhnw-rust-group/begin-rust-book-examples-tricktron
/03/chapter3/src/main.rs
UTF-8
1,220
4.125
4
[]
no_license
fn main() { 42; // needs ";" because main cannot return i32 println!("{}", 42) // works because println -> () //say_apples(42); //exercise3(); } fn say_apples(apples: i32) { println!("I nave {}", apples); } fn exercise3() { let x = 5; { let x =...
true
51230ef6cc68862f29985d4da63b29b2faedf896
Rust
Hell0XD/config-parsers
/src/dotenv/mod.rs
UTF-8
693
2.859375
3
[]
no_license
use crate::parsers::*; use crate::types::string; use std::collections::HashMap; fn key_pair<'a>() -> impl Parser<'a, (&'a str, &'a str)> { pair( identifier(|ch| !(ch == '=' || ch == '\n')), right(skip_whitespace_left(match_literal("=")), or(skip_whitespace_left(string()), skip_whitespace_left(...
true
7d27542d3faa1cfa6dd4295a14cafc4a8434f9f4
Rust
MarioSieg/KESTD-Ronin-Advanced
/src/engine.rs
UTF-8
4,722
2.59375
3
[]
no_license
use super::config::CoreConfig; use super::resources::ResourceManager; use super::scenery::Scenery; use super::scheduler::{self, ScheduleHandle}; use super::systems::SystemSupervisor; use humantime::Duration; use log::info; use std::process; use std::time::Instant; pub struct Engine { pub config: CoreConfig, pu...
true
b6ba2e81dc1d85bf1318ce70311677a6513679a1
Rust
halazouna/stm32f429zi_tockos
/capsules/src/net/sixlowpan.rs
UTF-8
41,650
3.296875
3
[ "Apache-2.0", "MIT" ]
permissive
//! 6loWPAN (IPv6 over Low-Power Wireless Networks) is standard for compressing //! and fragmenting IPv6 packets over low power wireless networks, particularly //! ones with MTUs (Minimum Transmission Units) smaller than 1280 octets, like //! IEEE 802.15.4. 6loWPAN compression and fragmentation are defined in RFC 4944 ...
true
949e24026dc62966c85c1ce60151736f98137053
Rust
kennethlarsen/rember-cli
/src/main.rs
UTF-8
1,726
2.71875
3
[]
no_license
use clap::{clap_app}; use rember::new::{generate_new_application}; use rember::component::{generate_component, generate_component_class}; fn main() { let matches = clap_app!(myapp => (version: env!("CARGO_PKG_VERSION")) (author: "Kenneth Larsen <hello@kennethlarsen.org>") (about: "Rust clon...
true
9bbf84dacd2070927c8304b964b45a8afbb27551
Rust
Nyrox/ssnr
/src/server.rs
UTF-8
1,861
2.828125
3
[]
no_license
use std::io::prelude::*; use std::net::{TcpListener}; use std::thread; use std::mem::{transmute}; use std::fs::File; extern crate zip; use api; // Will start a server in a seperate thread and return control back to the caller #[allow(dead_code)] pub fn start_server_local() -> thread::JoinHandle<()> { thread::spawn(...
true
bac67003feb0cf7fec8de2099539b59d3ab2bf3d
Rust
flappyBug/leetcode-rs
/src/p0002.rs
UTF-8
2,059
3.546875
4
[]
no_license
// https://leetcode.com/problems/add-two-numbers/ pub struct Solution; type ListNode = crate::utils::ListNode<i32>; impl Solution { pub fn add_two_numbers( l1: &Option<Box<ListNode>>, l2: &Option<Box<ListNode>>, ) -> Option<Box<ListNode>> { Solution::add_two_numbers_with_carry(l1, l2, ...
true
434d4971c3c0f7fbb622d6a3ba19e5540c4b04ff
Rust
bklimt/advent
/2022/06/streams/src/main.rs
UTF-8
1,767
3.046875
3
[]
no_license
use anyhow::{anyhow, Context, Result}; use clap::Parser; use std::collections::{HashMap, VecDeque}; 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: b...
true
cd4086bd9fcea6af1c83ffaa32cf049d1d7fc335
Rust
charredlot/cryptopals-rust
/src/hex.rs
UTF-8
1,194
3.515625
4
[]
no_license
const NIBBLE_CHAR: [char; 16] = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', ]; pub fn bytes_to_hex(buf: &[u8]) -> String { let mut s = String::new(); for &b in buf { s.push(NIBBLE_CHAR[((b >> 4) & 0xfu8) as usize]); s.push(NIBBLE_CHAR[(b & 0xfu8...
true
f7ee4fbe49180dc3d4691087f638af15f65d45ad
Rust
InnProgress/cp437_decoder
/src/lib.rs
UTF-8
2,297
2.96875
3
[]
no_license
pub mod converter; pub mod memoizer; use memoizer::Memoizer; use std::{collections::HashMap, fs, io::prelude::*, process, str}; pub type CodePage = HashMap<u8, u32>; pub fn load_codepage(file_name: &'static str) -> CodePage { let rules_string = fs::read_to_string(file_name); let rules_string = match rules_st...
true
a1991f8c1296af4fb84503f273b6b15716cee3c4
Rust
Skp80/kubexplorer
/src/input/mod.rs
UTF-8
2,170
3
3
[ "Apache-2.0" ]
permissive
use clap::{App, Arg}; use std::str::FromStr; pub fn parse_user_input() -> UserArgs { let matches = App::new("KubEx - Kubernetes Explorer") .version("0.1.0") .author("Pavel Pscheidl <pavelpscheidl@gmail.com>") .about("Discovers unused ConfigMaps and Secrets") .arg( Arg::w...
true
10aa220c795b0ba6086af56d99e82f2cd149759d
Rust
Jorelsin/Rust_Training
/raindrops/src/lib.rs
UTF-8
398
3.046875
3
[]
no_license
pub fn raindrops(n: u32) -> String { let mut raindrop = String::from(""); if n%3 == 0{ raindrop.push_str("Pling"); } if n%5 == 0{ raindrop.push_str("Plang"); } if n%7 == 0{ raindrop.push_str("Plong"); }else{ } if raindrop.is_empty...
true
f1efa6fa5570ff65d5fe40b3a974c64709e96561
Rust
mhintz/platform
/src/standard_pipeline.rs
UTF-8
3,412
2.71875
3
[]
no_license
#![allow(unused)] use gfx; use platform::{ColorFormat, DepthFormat}; gfx_defines! { // #[derive(Default)] vertex Vertex { pos: [f32; 3] = "a_position", color: [f32; 4] = "a_color", normal: [f32; 3] = "a_normal", tex_coord0: [f32; 2] = "a_tex_coord0", } pipeline standar...
true
a9972084d421cbfc87e04871f4bac97a63f39bc1
Rust
polarathene/acmed
/acmed/src/jws.rs
UTF-8
4,088
2.640625
3
[ "Apache-2.0", "MIT", "FSFAP", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::jws::algorithms::SignatureAlgorithm; use acme_common::b64_encode; use acme_common::crypto::{sha256, sha384, KeyPair, KeyType}; use acme_common::error::Error; use serde::Serialize; use serde_json::value::Value; pub mod algorithms; #[derive(Serialize)] struct JwsData { protected: String, payload: Str...
true
a62a3040c29caef6fd2f121a688f8e26c5a6ad68
Rust
sile/cannyls
/src/deadline.rs
UTF-8
2,188
3.515625
4
[ "MIT" ]
permissive
//! デバイスに対する各種操作のデッドライン. use std::time::Duration; /// 各種操作のデッドラインを表現するためのオブジェクト. /// /// # 注意 /// /// ここでの"デッドライン"とは、厳密な上限ではなく、 /// 「可能であれば、この時間までに実行してほしい」というヒントに過ぎないことは注意が必要。 /// /// そのため、ハードリミットというよりは、操作間の優先順位を示すためのもの、という意味合いが強い /// (e.g., リソースに余裕がない場合には、デッドラインが近いものから優先的に処理される)。 /// /// なお、デッドラインが等しい場合には、先にデバイスに到着した...
true
d8152f5ef4f3eb6d755e0868e18f6dd0ade80aa3
Rust
go-numb/matching-engine
/engine/src/algos/art_book.rs
UTF-8
10,640
2.828125
3
[]
no_license
use std::cmp::{max, min}; use std::collections::{HashMap, VecDeque}; use std::iter::FromIterator; use adaptive_radix_tree::u64_art_map::U64ArtMap; use crate::algos::book::*; /// Price-time priority (or FIFO) matching engine implemented using an Adaptive Radix Tree for /// indexing. /// /// Implemented as a state-mac...
true
c0e987511cc6a7e3fb73ccc284a068548003a586
Rust
ni-balexand/rust-msi
/src/internal/column.rs
UTF-8
22,919
3.171875
3
[ "MIT" ]
permissive
use crate::internal::category::Category; use crate::internal::stringpool::StringRef; use crate::internal::value::{Value, ValueRef}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use std::io::{self, Read, Write}; use std::str; use std::{fmt, i16, i32}; // ==================================================...
true
02a177c4ce448dd26b3e81c9fec7d4b41bcfeb44
Rust
jtdowney/ray_tracer
/src/intersection.rs
UTF-8
13,272
2.921875
3
[]
no_license
use crate::{Point, Ray, Shape, Vector, EPSILON}; use core::f64; use ord_subset::OrdSubsetIterExt; use std::{ collections::HashMap, fmt::{self, Debug, Formatter}, iter::FromIterator, ops::Index, ptr, slice, vec, }; pub fn intersection(time: f64, object: &dyn Shape) -> Intersection { Intersection...
true
4e8410f83a5839eaace08b42b64bf497685f2dc7
Rust
wladimir/today
/backend/src/db/models.rs
UTF-8
243
2.578125
3
[]
no_license
use diesel::Queryable; use serde::{Deserialize, Serialize}; #[derive(Queryable, Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct User { pub id: u32, pub username: String, pub email: String, pub password: String, }
true
969f674f612ca4621bdafee4db264eea298e59d4
Rust
iasoon/KeyboardOptimizer-LayoutGen-3000
/src/algorithm/generator.rs
UTF-8
4,723
2.984375
3
[]
no_license
use data::*; use cat::*; use Result; use std::collections::HashSet; use std::iter::FromIterator; pub struct Backtracker<'d> { domain_walker: DomainWalker<'d>, stack: Vec<Step>, unassigned: HashSet<Num<Key>>, } struct Step { key_num: Num<Key>, values: Vec<Num<Value>>, pos: usize, } impl Step...
true
53ba43d836c759ee85ee02356113d5bf933c448a
Rust
thealexhoar/ligeia
/ligeia-graphics/src/primitive_type.rs
UTF-8
327
2.953125
3
[]
no_license
use gl; use gl::types::*; pub enum PrimitiveType { TRIANGLES, LINES } impl PrimitiveType { pub fn to_gluint(&self) -> GLuint { unsafe { match self { PrimitiveType::TRIANGLES => gl::TRIANGLES, PrimitiveType::LINES => gl::LINES } } ...
true
d3d7be9598a3d50bfffd2ff9cc56146f5118096d
Rust
rubhatt/euler-project
/prime.rs
UTF-8
475
3.21875
3
[]
no_license
// long prime number test fn long_test(num: i64) -> bool { if 0 == num%2 || 0 == num%3 { return false; } for i in range(5 as i64, ((num as f64).sqrt() as i64) + 1) { if 0 == num%i { return false; } } return true; } // complete prime number test pub fn is_pri...
true
63dcc4b1638035cd7fd4a110bc80832a5c0d19b7
Rust
moshg/rust-std-ja
/src/test/run-pass/trait-object-auto-dedup.rs
UTF-8
1,961
2.890625
3
[ "MIT", "Apache-2.0", "BSD-3-Clause", "NCSA", "LicenseRef-scancode-other-permissive", "BSD-2-Clause" ]
permissive
// Copyright 2014 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
0263d349a8f46b9a03c98c3bef988b59cae9951e
Rust
SveinungOverland/RustPractice
/game_test/src/components.rs
UTF-8
961
2.9375
3
[]
no_license
use specs::prelude::*; // Components #[derive(Debug, Clone, Copy)] pub struct Position { pub x: u8, pub y: u8, pub z: u8, } impl Component for Position { type Storage = VecStorage<Self>; } pub struct Renderable { pub path: String, } impl Component for Renderable { type Storage = VecStorage<Se...
true
ef606a5cafdf8edc89c0e470650254bb9ecd1f99
Rust
GrandmasterTash/nails
/src/routes/create_account.rs
UTF-8
5,360
2.703125
3
[ "MIT" ]
permissive
use serde_json::json; use mongodb::bson::{self, Document}; use actix_web::{HttpResponse, dev::HttpResponseBuilder, http::StatusCode, web::Json}; use super::{get_account_profile::get_account_profile, get_device_profile::get_device_profile}; use crate::{clients::auth, model::{account::{prelude::*, Account, NewAccount}, d...
true
501f686661aeedad821aff136d3dd60b5eb9cd90
Rust
jamescarterbell/bloxel
/src/main.rs
UTF-8
4,140
2.875
3
[]
no_license
mod renderer; use renderer::*; use winit::dpi::*; use winit::*; #[allow(unused_imports)] use log::{debug, error, info, trace, warn}; fn main() { simple_logger::init().unwrap(); let mut winit_state = WinitState::default(); let mut hal_state = HalState::new(&winit_state.window, "New Window").unwrap(); ...
true
48966bae60c576ae8ccfe2a4d5a90d95e8b4a6b5
Rust
nabijaczleweli/codepage-437
/tests/cp437_control/decode/borrow_from_cp437/borrowing.rs
UTF-8
1,320
2.515625
3
[ "MIT" ]
permissive
use codepage_437::{CP437_CONTROL, BorrowFromCp437}; use self::super::super::super::is_borrowed; use std::borrow::Cow; #[test] fn borrowed_for_ascii_subset() { let mut data = vec![]; while data.len() <= 0x7F { let dlen = data.len(); data.push(dlen as u8); assert!(is_borrowed(&Cow::borr...
true
f991dfc8ca9340fcb572204c093d147a88a828f8
Rust
xande0812/cp-rs
/AtCoder/000_ABS/abc083_b/src/main.rs
UTF-8
576
3.03125
3
[]
no_license
fn read_stdio_to_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() { let input: Vec<u32> = read_stdio_to_vec(); println!( "...
true
6d674d1040a0662dd48f778cc03acafe54c84e2a
Rust
tarpaha/advent-of-code-2015-rust
/day11/src/solver.rs
UTF-8
2,494
3.609375
4
[]
no_license
pub fn part1(str: &str) -> String { let mut bytes: Vec<u8> = str.bytes().collect(); while !acceptable(&bytes) { take_next(&mut bytes); } String::from_utf8(bytes).unwrap() } pub fn part2(str: &str) -> String { let mut bytes: Vec<u8> = part1(str).bytes().collect(); take_next(&mut bytes);...
true
935f36a42f6fe1320187838b921ccd6936edb7be
Rust
BronTron4k/Rust-Boy
/src/gpu.rs
UTF-8
4,993
2.828125
3
[]
no_license
const TILE_MAP_SIZE: usize = 0x180; const BG_MAP_SIZE: usize = 0x400; const SCREEN_HEIGHT: usize = 144; const SCREEN_WIDTH: usize = 160; const SCREEN_PIXELS: usize = SCREEN_WIDTH * SCREEN_HEIGHT; const TILE_WIDTH: usize = 8; const TILE_HEIGHT: usize = 8; const TILE_PIXELS: usize = TILE_WIDTH * TILE_HEIGHT; const SCREE...
true
0e5e3df659312901bf28a1bbfc54be33de248424
Rust
YushiOMOTE/rgy
/core/src/timer.rs
UTF-8
2,975
3.03125
3
[ "MIT" ]
permissive
use crate::device::IoHandler; use crate::ic::Irq; use crate::mmu::{MemRead, MemWrite, Mmu}; use log::*; pub struct Timer { irq: Irq, div: u8, div_clocks: usize, tim: u8, tim_clocks: usize, tim_load: u8, ctrl: u8, } impl Timer { pub fn new(irq: Irq) -> Self { Self { ...
true
fc65221652e6ae06fe541c5387527f71788cb5a8
Rust
idanarye/tmp-learnpiston
/src/util.rs
UTF-8
2,532
2.765625
3
[]
no_license
#[macro_export] macro_rules! super_default { // Collect all attributes in parenthesis so we can parse them without interfering with $vis ( @collect_attrs ( $( #[$attrs:meta] )* ) #[$attr:meta] $( $tail:tt )* ) => { super_default! { @collect_attrs ( $( ...
true
fec49ca41c1e9a7dc7491b4b82c55d7e7fc2a14c
Rust
Cloudxtreme/astro-rust
/src/orbit/mod.rs
UTF-8
233
2.75
3
[ "MIT" ]
permissive
//! Elliptic, parabolic and near-parabolic orbits pub mod elliptic; pub mod parabolic; pub mod near_parabolic; /// Represents an orbital node pub enum Node { /// Ascending node Ascend, /// Descending node Descend }
true
8b44266183cc013b038e8ebe67ff411414c7b6e7
Rust
nimiq/core-rs
/utils/src/unique_ptr.rs
UTF-8
899
3.015625
3
[ "Apache-2.0" ]
permissive
use std::ops::Deref; use std::cmp::Ordering; #[derive(Debug)] pub struct UniquePtr<T>(*const T); impl<T> UniquePtr<T> { pub fn new(v: &T) -> Self { UniquePtr(v as *const T) } } impl<T> Deref for UniquePtr<T> { type Target = T; fn deref(&self) -> &<Self as Deref>::Target { unsafe { &*...
true
713015a06f5566d3401a9060ed7a95827807eedb
Rust
siku2/russ
/russ-internal-macro/src/vds/multiplier.rs
UTF-8
8,520
2.890625
3
[]
no_license
use super::generate::TypeInfo; use syn::{ braced, parse::{Parse, ParseStream}, parse_quote, spanned::Spanned, token, Expr, Ident, LitInt, Token, Type, }; pub struct ZeroOrMore { pub asteriks: Token![*], } impl Parse for ZeroOrMore { fn parse(input: ParseStream) -> syn::Result<Self> { ...
true
c59925ab65b2bfa18b91c5cce42515c95ca96d1b
Rust
drbawb/koko
/src/graphics.rs
UTF-8
6,219
2.796875
3
[ "MIT" ]
permissive
//use glium::backend::glutin_backend::GlutinFacade; use glium::draw_parameters::DrawParameters; use glium::{self, backend::Facade, texture, Surface}; use glium::uniforms::{MinifySamplerFilter, MagnifySamplerFilter, SamplerWrapFunction}; use util; static TEXT_VRT: &'static str = include_str!("shaders/text.v.glsl"); st...
true
057173b7f6bd227ebb81de68fddc49a35187708f
Rust
gpaulu/AdventOfCode2020
/day01/src/main.rs
UTF-8
1,942
3.609375
4
[]
no_license
use std::{ fs::File, io::{BufRead, BufReader}, }; fn main() { let f = File::open("input.txt").expect("No input.txt file found"); let reader = BufReader::new(f); let nums: Vec<i32> = reader .lines() .map(|s| s.unwrap().parse().unwrap()) .collect(); println!("Part 1: ");...
true
62d6d05981dba1ba94719e7624b031847e5fb46c
Rust
Matthias247/futures-intrusive
/tests/oneshot_channel.rs
UTF-8
12,148
2.796875
3
[ "Apache-2.0", "MIT" ]
permissive
use futures::future::{FusedFuture, Future}; use futures::task::{Context, Poll}; use futures_intrusive::channel::{ChannelSendError, LocalOneshotChannel}; use futures_test::task::{new_count_waker, panic_waker}; use pin_utils::pin_mut; macro_rules! gen_oneshot_tests { ($mod_name:ident, $channel_type:ident) => { ...
true
5b62f0914fa13e0313217594a789eaf487418c39
Rust
barskern/couchdb
/src/testing/fake_server.rs
UTF-8
7,004
2.96875
3
[ "MIT", "Apache-2.0" ]
permissive
use {Error, regex, std, tempdir}; // RAII wrapper for a child process that kills the process when dropped. struct AutoKillProcess(std::process::Child); impl Drop for AutoKillProcess { fn drop(&mut self) { let AutoKillProcess(ref mut process) = *self; process.kill().unwrap(); process.wait()...
true
701a750f2a2dfe87b5de00a660554eff4ec6321e
Rust
pierg75/ddh-remover
/src/main.rs
UTF-8
3,617
2.984375
3
[ "MIT" ]
permissive
use clap::{App, Arg}; use ddh_remover::{Args, Duplicates, WorkItem}; use log::{debug, trace}; use std::{fs::File, io, io::prelude::*, path::Path, process, thread}; type Error = Box<dyn std::error::Error>; fn main() -> Result<(), Error> { env_logger::init(); let matches = App::new("ddh-remover") .versi...
true
e5e1b847893ca906612fed569458ece6f7c5ac94
Rust
19h/rustun
/src/attribute.rs
UTF-8
6,938
3.390625
3
[ "MIT" ]
permissive
//! STUN attribute related components. use std::io::{Read, Write}; use handy_async::sync_io::{ReadExt, WriteExt}; use Result; use message::RawMessage; /// STUN attribute. /// /// > Attribute: The STUN term for a Type-Length-Value (TLV) object that /// > can be added to a STUN message. Attributes are divided into two...
true
347da00e06cf5af6d6340f9b31ea1f4f6925c29c
Rust
AntonGepting/tmux-interface-rs
/src/commands/windows_and_panes/new_window.rs
UTF-8
8,197
3.140625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use crate::commands::constants::*; use crate::TmuxCommand; use std::borrow::Cow; /// Structure for creating new window, using `tmux new-window` command /// /// # Manual /// /// tmux ^3.2: /// ```text /// new-window [-abdkPS] [-c start-directory] [-e environment] [-F format] [-n window-name] /// [-t target-window] [she...
true
851492195c39cd7803ed4e3ac6d1bb5b384d9bee
Rust
mesalock-linux/crates-sgx
/vendor/uuid/src/adapter/compact.rs
UTF-8
2,601
3.28125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Module for use with `#[serde(with = "...")]` to serialize a [`Uuid`] //! as a `[u8; 16]`. //! //! [`Uuid`]: ../../struct.Uuid.html /// Serializer for a [`Uuid`] into a `[u8; 16]` /// /// [`Uuid`]: ../../struct.Uuid.html pub fn serialize<S>(u: &crate::Uuid, serializer: S) -> Result<S::Ok, S::Error> where S: ser...
true
2ebac73961830581f8959806899231b6812e7851
Rust
gbinian/leetcode
/src/primary/lc387.rs
UTF-8
575
3.5
4
[ "MIT" ]
permissive
/// 给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1 pub fn first_uniq_char(s: String) -> i32 { use std::collections::HashMap; s.chars().enumerate() .fold(HashMap::new(), |mut m, (i, c)|{ m.entry(c).and_modify(|(_, e)| *e += 1 ).or_insert((i, 1)); m }).values().fold(-1, |mut res, &(i,v) |{ if v == 1 && (res == ...
true
273264ebfcd5884026067c3a5663c270cc976b13
Rust
Roberto-XY/exercism
/rust/assembly-line/src/lib.rs
UTF-8
555
2.765625
3
[]
no_license
pub fn production_rate_per_hour(speed: u8) -> f64 { let speed = speed as u64; let base_production_per_hour: u64 = 221; let production_per_hour = (speed * base_production_per_hour) as f64; if speed <= 4 { production_per_hour } else if speed <= 8 { let success_rate = 0.9; prod...
true
a6369803f90b3b9072282234848a4be07cc3e7c7
Rust
eqrion/dodrio-it-bench
/todomvc/dodrio-wb-cl/src/utils.rs
UTF-8
770
2.609375
3
[ "MIT" ]
permissive
//! Small utility functions. use wasm_bindgen::UnwrapThrowExt; /// Get the top-level window. pub fn window() -> web_sys::Window { web_sys::window().unwrap_throw() } /// Get the current location hash, if any. pub fn hash() -> Option<String> { window() .location() .hash() .ok() ...
true
08f3735da1270c9ec50e27ca9348ec6f9e25d5ce
Rust
bouzuya/rust-atcoder
/cargo-atcoder/contests/abc276/src/bin/d.rs
UTF-8
1,864
3.1875
3
[]
no_license
use std::collections::{HashMap, HashSet}; use proconio::input; fn prime_factorization(n: usize) -> HashMap<usize, usize> { let mut p = HashMap::new(); if n < 2 { return p; } let mut n = n; // shadowing for i in 2.. { if i * i > n { break; } let mut c = 0...
true
6381da02d4c67d6b787da8bb04a88620adb68376
Rust
bagedevimo/diffuse
/src/git/database.rs
UTF-8
3,396
3.078125
3
[]
no_license
use crypto::digest::Digest; use crypto::sha1::Sha1; use std::collections::HashMap; pub struct Database { pub entries: HashMap<ObjectID, Record>, } impl Database { pub fn new() -> Database { Database { entries: HashMap::new(), } } pub fn insert(&mut self, record: Record) ->...
true
44c355d0a7513bcee97026622caa0126f3ce9b54
Rust
VeerGoiporia/aoc-2020
/src/day1.rs
UTF-8
2,242
3.609375
4
[]
no_license
use std::fs; pub fn day_one() { println!("-----DAY1------"); let numbers: Vec<i32> = convert_file_to_nums("inputs/input_day1.txt"); let target_sum = 2020; println!("Part 1"); part_one(numbers.clone(), target_sum); println!("Part 2"); part_two(numbers, target_sum); } fn part_one(numbers: V...
true
d969fac0a07dc7d6e99ece3461fae585fe41128c
Rust
project-alvarium/streams-author
/src/http/handlers.rs
UTF-8
4,525
2.5625
3
[ "Apache-2.0" ]
permissive
use hyper::{Request, Body, Response, StatusCode, header}; use crate::streams::ChannelAuthor; use std::sync::{Mutex, Arc}; use crate::models::subscription::SubscriptionRequest; type GenericError = Box<dyn std::error::Error + Send + Sync>; pub async fn preflight_response( ) -> Result<Response<Body>, GenericError> { ...
true
a2ab18b085ea8bf9aad4101a7a7475f3a3adc1a5
Rust
wang-yuhao/rust-vorlesung
/Tutorial/assignment04/collatz/u04-gap/src/main.rs
UTF-8
6,568
2.703125
3
[]
no_license
// http://gtk-rs.org/docs/requirements.html extern crate gdk; extern crate gdk_pixbuf; extern crate gtk; extern crate cairo; extern crate ___________; // TODO (a) use gdk::ContextExt; use gdk_pixbuf::{Colorspace::Rgb, Pixbuf, PixbufExt}; use gtk::prelude::*; use gtk::{Window, WindowType}; use ___________::_______; // ...
true
98b1762558294cde3eeabb54cb66b6884cbfad06
Rust
pklazy/lpc54628-rust
/src/syscon/mainclksela.rs
UTF-8
4,912
2.625
3
[]
no_license
#[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::MAINCLKSELA { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(...
true
f40c2f60f9cd2235caed97e9e9a8acb21b13dee7
Rust
dmitry-pechersky/algorithms
/leetcode/103_Binary_Tree_Zigzag_Level_Order_Traversal.rs
UTF-8
1,859
3.609375
4
[]
no_license
#[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 { TreeNode { val, left: None, right: None ...
true
1475a014a6a0ba61be959eea2238fa9e7bb9d8cd
Rust
psyomn/programming-exercise-solutions
/archive/challenge-0029/palindrome.rs
UTF-8
698
3.484375
3
[]
no_license
use std::io; trait Palindrome { fn palindromic(&self) -> bool; } impl Palindrome for String { fn palindromic(&self) -> bool { let len = self.len(); let stopping_ix = if len % 2 == 0 { len / 2 } else { len / 2 + 1 }; let mut start_iter = self.chars(); let mut end_iter = self.ch...
true
744688a834836ce2ea9096b19f65395d5b35488f
Rust
caspark/algorithms1
/5-kd-tree/src/redblacktree.rs
UTF-8
15,373
3.609375
4
[]
no_license
use std::cmp::{Ord, Ordering}; use std::mem; #[derive(Debug, Eq, PartialEq, Copy, Clone)] enum Color { Red, Black, } impl Color { /// If red, change to black. If black, change to red. fn invert(&mut self) { let opposite = self.opposite(); mem::replace(self, opposite); } /// If...
true
b2ac6fde74fba33c8b9cd8f41dd3733d7c892e14
Rust
hazer-hazer/alpha
/src/exp.rs
UTF-8
10,112
3.171875
3
[]
no_license
//! Untyped AST use std::convert::TryInto; use std::error::Error; use simple_error::{bail, simple_error}; use crate::sexp::SExp; use crate::symbol::{Symbol, SymbolInterner}; #[derive(Debug, PartialEq, Clone)] pub enum Exp { Type(TypeDefinition), /// Function declaration/definition Function(Function), ...
true
2f134afc6f038b92fdc0e0cb447a85b6d28658d8
Rust
anchorite/unibilium
/src/term.rs
UTF-8
8,150
3.46875
3
[]
no_license
use crate::boolean::{Boolean, ExtBoolean}; use crate::error::TermError; use crate::numeric::{ExtNumeric, Numeric}; use crate::string::{ExtString, String}; use std::error::Error; use std::ffi::CString; use unibilium_sys::{ unibi_boolean, unibi_from_env, unibi_from_term, unibi_numeric, unibi_string, unibi_term, }; /...
true
3cd9e4541b49e19f044b8be9aa8e20e02e5e9bc9
Rust
sisshiki1969/cilk
/src/exec/interpreter/interp.rs
UTF-8
13,626
2.578125
3
[ "MIT" ]
permissive
// TODO: CAUTION: this code is no longer usable // use crate::ir::{function::*, module::*, opcode::*, types::*, value::*}; use crate::ir::{function::*, module::*, types::*}; use rustc_hash::FxHashMap; #[derive(Debug, Clone, PartialEq)] pub enum ConcreteValue { Void, Int1(bool), Int32(i32), Mem(*mut u8...
true
d3d1c53f13298ecc7d767c5847c085d19b52d488
Rust
jmdejong/tsorak
/src/gamefield.rs
UTF-8
2,638
3.171875
3
[]
no_license
use std::collections::HashMap; use crate::{ brush::{Brush, brush}, scene::{Scene, ShapeObject, plane, wall, sprite}, texture::Texture, screenbuffer::ScreenBuffer, grid::Grid }; #[derive(Debug, Clone, PartialEq)] pub struct GameTile { pub floor: Option<Brush>, pub shape: TileShape, pub ceiling: Option<Brush>,...
true
f9262fec3232b7f43323a04c5fee30ea0acd8548
Rust
Roxxik/Evolve5.0
/src/organism.rs
UTF-8
3,206
3.09375
3
[ "MIT" ]
permissive
use std::cell::RefCell; use std::rc::Rc; use types::*; use event::EventType; use instruction::Instruction; pub type Block = Vec<Instruction>; pub type Code = Vec<Block>; pub type OrgRef = Rc<RefCell<Organism>>; #[derive(Debug)] pub struct Organism { pub id: CellID, pub step: Step, pub x: Coord, pub y...
true
4b2df41280479229df888d2172a1fa233d86610b
Rust
hacspec/hacspec
/utils/abstract-integers/tests/test_natmod.rs
UTF-8
1,384
3.046875
3
[ "Apache-2.0", "MIT" ]
permissive
use abstract_integers::*; abstract_unsigned_secret_integer!(BigBounded, 256); abstract_secret_modular_integer!( Felem, BigBounded, BigBounded::pow2(255) - BigBounded::from_literal(19) ); #[test] fn arith() { let x1 = Felem::from_literal(24875808327634644); let x2 = Felem::from_literal(919872763653...
true
57020ddaa597641b1e16ce0c38574146931c89ff
Rust
hooman734/Rust-Example
/src/main.rs
UTF-8
10,195
4.125
4
[]
no_license
fn main() { // defining a variable println!("-------defining a variable"); println!("Hello, Hooman!"); let mut x = 45; // all variables initially are immutable otherwise it is mentioned println!("The value of x is {}", x); x = 10; println!("The value of x is {}", x); let y: i64; y =...
true
381c88eb8707578b9214f340258847e34a3a4832
Rust
KarLe15/Graph-handler
/src/main.rs
UTF-8
5,088
2.796875
3
[]
no_license
use std::io::Write; use std::fs::File; use std::io; //use serde::{Serialize, Deserialize}; use actix_multipart::Multipart; use actix_web::{web, post, get, delete, App, Error, HttpServer, Responder, HttpResponse, HttpRequest}; use actix_cors::Cors; use futures::{StreamExt, TryStreamExt}; //use log::{info, warn, debug,...
true
2d737cda7d0964bc22d9698496800883e30f6e2a
Rust
arifSuwadji/rust-programming-tutorial
/latihan/luas.rs
UTF-8
974
3.3125
3
[]
no_license
use std::io; use std::io::Write; //Luas tandah dari 2 argument: panjang (meter), lebar (meter). //tampilkan info jika luas lebih besar dari 100 meter persegi fn main() { //input panjang print!("masukkan panjang(m): "); io::stdout().flush().unwrap(); let mut inputpanjang = String::new(); io::stdin...
true
049ea97ad47a386e60668a9f81ecda16ff2d1eab
Rust
aplbrain/bossphorus
/src/data_manager.rs
UTF-8
19,658
2.8125
3
[ "Apache-2.0" ]
permissive
/* Copyright 2020 The Johns Hopkins University Applied Physics Laboratory Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable ...
true
835b110d709ef422c6952b22eb377281af1f7471
Rust
GaloisInc/crucible
/crux-mir/lib/crucible/alloc.rs
UTF-8
681
3.296875
3
[ "BSD-3-Clause" ]
permissive
/// Allocate an array of `len` elements of type `T`. The array begins uninitialized. pub fn allocate<T>(len: usize) -> *mut T { unimplemented!("allocate") } /// Allocate an array of `len` elements of type `T`. The array initially contains all zeros. This /// fails if `crux-mir` doesn't know how to zero-initiali...
true
27eacf0c38824ad5f9d754dfbf5d8120433a64c9
Rust
ioncodes/machina
/src/optimized_cache.rs
UTF-8
277
2.765625
3
[]
no_license
#[derive(Hash)] pub struct OptimizedCache { pub name: String, pub value: usize, } impl Eq for OptimizedCache {} impl PartialEq for OptimizedCache { fn eq(&self, other: &OptimizedCache) -> bool { self.name == other.name && self.value == other.value } }
true
44358b53074629f23eb0d5542520a19e741d7f89
Rust
heliumbrain/axum
/src/service/future.rs
UTF-8
2,903
2.671875
3
[ "MIT" ]
permissive
//! [`Service`](tower::Service) future types. use crate::{ body::{box_body, BoxBody}, response::IntoResponse, util::{Either, EitherProj}, BoxError, }; use bytes::Bytes; use futures_util::ready; use http::{Method, Request, Response}; use http_body::Empty; use pin_project_lite::pin_project; use std::{ ...
true
c0f6c00b75c8848a4bf1fdeff00233f783e8d650
Rust
Strongman86/Rust-Learning
/chapter6/6_62.rs
UTF-8
161
2.546875
3
[]
no_license
fn main(){ let a:[i32;3]=[1,2,3]; let mut iter=a.iter(); assert_eq!((3,Some(3)),iter.size_hint()); iter.next(); assert_eq!((2,Some(2)),iter.size_hint()); }
true
c9159ec1142b125d2513f223d59d5be45019438d
Rust
Ameobea/advent-of-code-2018
/src/day16.rs
UTF-8
4,547
2.578125
3
[]
no_license
use std::collections::HashSet; use crate::asm_common::*; const INPUT: &str = include_str!("../input/day16.txt"); use regex::Regex; lazy_static! { static ref RGX: Regex = Regex::new(".*?(\\d+).+?(\\d+).+?(\\d+).+?(\\d+).*").unwrap(); } fn parse_line(line: &str) -> [usize; 6] { let mut res = [0usize; 6]; ...
true
688acadabf43491624bc6c5af3697252a5989965
Rust
bidinzky/AdsServer
/src/json_diff.rs
UTF-8
6,747
2.859375
3
[]
no_license
use nom::{self, types::CompleteStr as Input, IResult}; use serde_json::{Map, Value}; #[derive(Debug, PartialEq, Clone)] pub enum Schema { Tag(String), Obj(String, Vec<Schema>), Root(Vec<Schema>), } #[derive(Debug)] pub enum Either { Resolve(Schema), Subscription(Schema), } impl ToString for Schem...
true
65917dc396fea040de7afbf392f1e7eb72b53e2d
Rust
robbycerantola/orbgame
/src/sprite.rs
UTF-8
1,975
2.890625
3
[ "MIT" ]
permissive
use std::cell::{Cell, RefCell}; use orbtk::Rect; use orbimage::Image; use orbclient::Renderer; #[derive(Clone, Debug, Deserialize, Default)] #[serde(rename = "Sprite")] pub struct SpriteConfig { pub sheet: String, pub rows: u32, pub columns: u32, } #[derive(Clone)] pub struct Sprite { sheet: RefCell<...
true
369040afde291aa96fb5755848b4c8dfd67013f3
Rust
tania-andersen/extract2csv-rust
/src/main.rs
UTF-8
4,248
2.90625
3
[ "Unlicense" ]
permissive
use regex::Regex; use std::ffi::OsStr; use std::io; use std::path::{Path, PathBuf}; use std::{env, fs}; const DEFAULT_OUT_FILENAME: &str = "out.csv"; fn main() -> io::Result<()> { let mut args: Vec<String> = env::args().collect(); for i in 0..args.len() { // Prefix regex expression with (?ms) for "mul...
true
5591c32f1861db37b934de6127131a6773815f2f
Rust
Takuma-Ikeda/other-LeetCode
/src/neetcode/arrays_and_hashing/src/answers/group_anagrams.rs
UTF-8
3,171
3.78125
4
[]
no_license
struct Solution; use std::collections::HashSet; impl Solution { // 遅くて LeetCode ではタイムアップしてしまう pub fn group_anagrams(strs: Vec<String>) -> Vec<Vec<String>> { use std::collections::HashMap; let mut result: Vec<Vec<String>> = Vec::new(); let mut patterns: Vec<HashMap<char, i64>> = Vec::n...
true
9110112ba37c951330a6d325e6d6dc26a37a3823
Rust
Anonyfox/wired
/src/block_storage/backend/allocation.rs
UTF-8
2,012
3.015625
3
[ "MIT" ]
permissive
use super::frames::Frame; use super::header::Header; use super::Backend; use std::error::Error; impl Backend { /// allocator with runtime O(1) pub fn next_free_frame(&mut self) -> Result<usize, Box<dyn Error>> { // try to use an existing frame that got "deleted" if self.header.first_free_frame ...
true
98dfac11223bcb5b48371b3561192ee2e72fe23c
Rust
ArunGust/sauron
/examples/futuristic-ui/src/paragraph.rs
UTF-8
1,059
2.71875
3
[ "MIT" ]
permissive
use crate::{ animate_list, AnimateList, }; use sauron::{ prelude::*, Node, }; #[derive(Clone, Debug)] pub enum Msg { AnimateIn, AnimateListMsg(animate_list::Msg), } /// accepts a markdown and animate the content pub struct Paragraph<MSG> { animated_list: AnimateList<MSG>, } impl<MSG> Para...
true
b9e21efcba72c160070204c3ed67c6dad25635c3
Rust
altusnets/rpc-perf
/ratelimiter/src/lib.rs
UTF-8
2,986
3.546875
4
[ "Apache-2.0" ]
permissive
// Copyright 2019 Twitter, Inc. // Licensed under the Apache License, Version 2.0 // http://www.apache.org/licenses/LICENSE-2.0 //! This library provides a thread safe token bucket ratelimitier use datastructures::*; /// A token bucket ratelimiter pub struct Ratelimiter { available: AtomicU64, capacity: Atom...
true
2c9a720ea706a3505673a776896e571ea3da3b47
Rust
holdhun/rust
/mysql_project/src/main.rs
UTF-8
1,771
2.984375
3
[]
no_license
use mysql::*; use mysql::prelude::*; use std::panic; #[derive(Debug, PartialEq, Eq)] struct User { id: i32, name:String, } fn main() { let dsn = String::from("mysql://root:root@127.0.0.1:3306/test"); let pool = Pool::new(dsn).unwrap(); let mut conn = pool.get_conn().unwrap(); //数据库 user(id,na...
true
79da028fae0b1b36ae272ae6d6f7b51fc183a3b6
Rust
brymko/AdventOfCode2020
/src/d2.rs
UTF-8
2,026
3.09375
3
[]
no_license
use crate::Perf; const INPUT: &str = include_str!("d2input"); #[derive(Debug)] struct PolicyPw { min: u8, max: u8, ch: char, pw: Vec<char>, } impl PolicyPw { fn from(input: &str) -> Option<Self> { let mut parts = input.split(' '); let mut min_max = parts .next()? ...
true
79c2c0ef6ef790100ee6bb521a846cb9273a6d06
Rust
desweemerl/price-sniffer
/src/config.rs
UTF-8
1,044
3.171875
3
[ "MIT" ]
permissive
use errors::AppError; use ini::Ini; pub struct ConfigParser<'a> { conf: &'a Ini, } impl<'a> ConfigParser<'a> { pub fn new(conf: &'a Ini) -> Self { ConfigParser{conf} } pub fn section<'b: 'a>(&self, section: &'b str) -> SectionParser<'a, 'b> { SectionParser{ conf: self.con...
true
860940aa5c9d1016046452dbc955f75d1d9d7398
Rust
nphyx/scrapsrl
/src/component/ai_brain.rs
UTF-8
774
3.03125
3
[]
no_license
use serde::{Deserialize, Serialize}; use specs::{Component, Entity, VecStorage}; #[derive(Clone, Serialize, Deserialize)] pub enum MovementBehavior { Idle, BrownianWalk, Pursue, } #[derive(Clone, Serialize, Deserialize)] pub enum Attitude { Passive, } /// the "brain" of an NPC, aimed at being a basic...
true
a06746278c65769cc10b7e69bf331ad8ed3942e7
Rust
msiemens/archer-rs
/src/download/pool.rs
UTF-8
2,828
2.890625
3
[ "MIT" ]
permissive
use std::thread; use chan; use daggy::petgraph::graph::NodeIndex; use url::Url; use download; use tasks; #[derive(Debug)] struct Task { idx: NodeIndex, url: Url, try: i32, } #[derive(Debug)] pub struct Download { pub idx: NodeIndex, pub result: download::DownloadResult, } pub struct Download...
true
e9d8cee6b8b04be6d8fccc31e8ec03ffd7d43703
Rust
mahulst/advent-of-code-2018
/day12/src/lib.rs
UTF-8
7,436
3.5
4
[]
no_license
use core::fmt; #[derive(Debug, PartialEq, Copy, Clone)] pub enum Pot { Plant, Empty, } #[derive(PartialEq)] pub struct Row { pub pots: Vec<Pot>, pub first_index: i32, } type Pattern = [Pot; 5]; pub fn input_to_list_with_index(input: &str, first_index: i32) -> Row { let mut pots = Vec::new(); ...
true
8bf8dabf59cef0b2a72e97174684e53ecaa7d06b
Rust
sorajate/tsclientlib
/utils/tsproto-structs/src/enums.rs
UTF-8
1,276
2.90625
3
[ "MIT", "Apache-2.0" ]
permissive
use once_cell::sync::Lazy; use serde::Deserialize; pub const DATA_STR: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/declarations/Enums.toml")); pub static DATA: Lazy<Enums> = Lazy::new(|| toml::from_str(DATA_STR).unwrap()); #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] pub struct Enums { ...
true
8df6c28d7331bd5559aaaf6e115d9d1b12547a69
Rust
maxjoehnk/emulato-rs
/gameboy/src/cpu/instructions/inc.rs
UTF-8
6,464
3.4375
3
[]
no_license
use gameboy::GameBoy; use cpu::Instruction; use std::fmt; use cpu::register::{Flags, Register8, Register16}; pub struct IncrementRegister(Register8); impl IncrementRegister { pub fn new(opcode: u8) -> IncrementRegister { let register = match opcode { 0x04 => Register8::B, 0x0C => R...
true
2e641b147a21e0201fd564acbe4792795aae82d1
Rust
whidbey/queen
/src/port/conn.rs
UTF-8
3,330
2.78125
3
[ "MIT" ]
permissive
use std::collections::VecDeque; use std::io::{self, Read, Write, ErrorKind::{WouldBlock, BrokenPipe, InvalidData}}; use std::os::unix::io::AsRawFd; use nson::Message; use crate::net::Stream; use crate::util::{slice_msg, sign, verify}; pub struct Connection { stream: Stream, read_buffer: Vec<u8>, write_bu...
true
ee3ccbaf7e5c5143f0328c965434f6c1e163eead
Rust
compactcode/exercism
/rust/simple-linked-list/src/lib.rs
UTF-8
2,903
3.59375
4
[]
no_license
use std::iter::FromIterator; pub struct SimpleLinkedList<T> { head: Option<Box<Node<T>>> } struct Node<T> { data: T, next: Option<Box<Node<T>>> } impl<T> SimpleLinkedList<T> { pub fn new() -> Self { SimpleLinkedList { head: None } } pub fn len(&self) -> usize { self.iter().co...
true
777aafbddf81918aad2617c842a6a4645b817e5d
Rust
Alex-Addy/Advent-of-Code-2019
/src/utilities/intcode.rs
UTF-8
11,668
3.6875
4
[]
no_license
//! This module implements an IntCode interpreter. use std::convert::TryFrom; // The following terminology notes are taken from day 2 part 2 // - memory: the list of integers used when interpreting // - address/position: the value at a given index into memory // - opcode: mark the beginning of an instruction and d...
true
91fa4fd20e273a035acc44add0844019a0661d22
Rust
m110/notes
/src/cli.rs
UTF-8
3,420
3.234375
3
[ "MIT" ]
permissive
use time; use std::io; use std::io::prelude::*; use std::collections::HashMap; use editor::text_from_editor; use storage::Storage; const DB_PATH: &'static str = "~/.notes"; const TIME_FORMAT: &'static str = "%d-%m-%Y %H:%M:%S"; pub enum Action { Output(String), Exit, None, } pub struct Cli { current...
true
ae8766470706f5ddde0c595c54d2c2df62c2b188
Rust
jeikabu/runng
/runng/src/asyncio/pull_stream.rs
UTF-8
4,610
2.78125
3
[ "MIT" ]
permissive
//! Async push/pull ("pipeline") use super::*; use crate::protocol::*; #[derive(Debug, PartialEq)] enum PullState { Ready, Receiving, } #[derive(Debug)] struct PullContextAioArg { aio: NngAio, state: PullState, sender: mpsc::Sender<Result<NngMsg>>, socket: NngSocket, } impl PullContextAioArg...
true
db8e6eb15fb9eb177b410e83e511209e2ff4b7d4
Rust
tranvietphuoc/leetcode
/rust/01_two_sum.rs
UTF-8
394
2.78125
3
[]
no_license
impl Solution { pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> { let mut res = Vec::<i32>::new(); for i in 0..(nums.len() - 1) { for j in (i + 1)..nums.len() { if nums[i] + nums[j] == target { res.push(i as i32); res.push(j...
true
0582548d53ca1b7ea4bfb0325753f19934d7fca6
Rust
booyaa/happv
/src/error.rs
UTF-8
2,193
3.328125
3
[ "Apache-2.0" ]
permissive
//! A composite error type for errors that can occur while interacting with Appveyor. // errors // use std::{self, fmt}; use std; use hyper; use serde_json; #[derive(Debug)] pub enum Error { ///The response from Twitter gave a response code that indicated an error. The enclosed value ///was the response code...
true
b6ac10cdb958c9e94df7accdfb1b2dd3c10bd6ef
Rust
haraldmaida/advent-of-code-2018
/src/day19/mod.rs
UTF-8
13,372
4.03125
4
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! # Day 19: Go With The Flow //! //! With the Elves well on their way constructing the North Pole base, you turn //! your attention back to understanding the inner workings of programming the //! device. //! //! You can't help but notice that the device's opcodes don't contain any flow //! control like jump instructi...
true
2ce4ee965c0a03938cdc25a7092ee7a3b94e6b3f
Rust
thril/serverless-scripting-examples
/wasm-rust/rust-image/src/lib.rs
UTF-8
3,736
2.53125
3
[ "MIT" ]
permissive
use futures::Future; use std::io::Cursor; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use wasm_bindgen_futures::{future_to_promise,JsFuture}; #[allow(unused_macros)] macro_rules! console_log { ($($t:tt)*) => (web_sys::console::log_1(&format!($($t)*).into())) } #[wasm_bindgen] pub fn init() { cons...
true