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
e22c61a983c93b03caca65e6665ce312b9de71e8
Rust
willglynn/artichoke
/artichoke-backend/tests/manual.rs
UTF-8
2,848
2.5625
3
[ "MIT", "BSD-2-Clause" ]
permissive
#![deny(clippy::all)] #![deny(clippy::pedantic)] #[macro_use] extern crate artichoke_backend; use artichoke_backend::class; use artichoke_backend::convert::RustBackedValue; use artichoke_backend::def; use artichoke_backend::exception::Exception; use artichoke_backend::sys; use artichoke_backend::types::Int; use artic...
true
6116f4166ef55284becc6c50052211ed043e5589
Rust
nikofil/ray-tracing
/async_worker.rs
UTF-8
3,241
2.953125
3
[]
no_license
use std::task::{Waker, Context, Poll}; use std::sync::{Arc, Mutex}; use std::future::Future; use std::pin::Pin; use std::time::Duration; use std::thread; use std::thread::sleep; use futures::task::{ArcWake, waker_ref}; use std::sync::mpsc::{Receiver, SyncSender, sync_channel}; use futures::future::BoxFuture; use futur...
true
e8887bf2a46ae1ad9242beb93ed2542d609731e9
Rust
TDHGroupWork/northwind-rs
/apps/actix/src/errors.rs
UTF-8
1,472
2.765625
3
[ "MIT" ]
permissive
//! Custom error module use actix_http::ResponseBuilder; use actix_web::{error::ResponseError, http::header, http::StatusCode, HttpResponse}; use northwind_core::errors::{AppError, AppErrorMessage}; #[derive(Debug)] pub struct ApiError(AppError); impl From<AppError> for ApiError { fn from(error: AppError) -> Sel...
true
8ee0ce31e4a690a77d104707fa53246a8f893205
Rust
Krenodeno/YARRT
/src/structs/resources_manager.rs
UTF-8
1,814
3.40625
3
[]
no_license
use std::collections::HashMap; use std::sync::{Arc, Weak}; pub trait Resource {} pub trait ResourceConfig: std::cmp::Eq + std::hash::Hash + Sized + Clone { type AssociatedResource: ?Sized; fn create_resource(&self, res_mgr: &mut ResourceManager<Self>) -> Arc<Self::AssociatedResource>; } /// Used to ...
true
38c7136900b00e0380eb5647a4cc537fd723266c
Rust
ptrkalm/AoC2020
/src/day10.rs
UTF-8
1,834
3.15625
3
[]
no_license
pub fn part1(input: &str) -> u128 { let jolts = parse(input); let mut ones = 0; let mut threes = 0; for i in 1..jolts.len() { match jolts[i] - jolts[i-1] { 1 => ones += 1, 3 => threes += 1, _ => {} } } ones * threes } pub fn part2(input: &...
true
61f3d29050cdc22eb8e69a3466620fcef1a0b797
Rust
dwarrier/enigma-discovery
/secret_contracts/simple_addition/src/lib.rs
UTF-8
1,541
3.09375
3
[]
no_license
// Rust’s standard library provides a lot of useful functionality, but assumes support for various // features of its host system: threads, networking, heap allocation, and others. SGX environments // do not have these features, so we tell Rust that we don’t want to use the standard library #![no_std] // The eng_wasm...
true
08acf141d8657f7de03a5dfbfcac3fcfb31310c5
Rust
dmitry-pechersky/algorithms
/leetcode/42_Trapping_Rain_Water.rs
UTF-8
898
3.4375
3
[]
no_license
struct Solution {} impl Solution { pub fn trap(height: Vec<i32>) -> i32 { let (mut s, mut max_height) = (0, 0); for i in 0..height.len() { if height[i] < max_height { s += max_height - height[i]; } else { max_height = height[i]; } ...
true
e0abcf730ffe43c062ea46cc5283e707c72aed8a
Rust
marony/rust3d
/src/util/screen.rs
UTF-8
966
3.25
3
[]
no_license
use util::size2::Size2; use util::point3::Point3; use util::polygon3::Polygon3; #[derive(Debug)] pub struct Screen { pub size: Size2, pub scale: f64 } impl Screen { pub fn new(size: &Size2, scale: f64) -> Screen { Screen { size: *size, scale } } // 投影面をディスプレイに合わせる fn _co...
true
e02e6c8d27eabf0c2ab91d6dc4c066dc2d192b98
Rust
silky/jagger
/src/solver/implication_graph.rs
UTF-8
21,118
2.796875
3
[ "MIT" ]
permissive
use std::collections::{HashMap, VecDeque}; use std::iter::FromIterator; use std::borrow::Cow; use graphviz as dot; use solver::types::{Var, Clause}; use solver::types::Term::{self, Lit, Not}; use solver::types::SolutionValue::{self, True, False}; use collections::VecSet; // ------------------------------------------...
true
8d38c9c9781ff7c93733fd9f028d172557b6d6a9
Rust
pombredanne/sentry-cli
/src/macho.rs
UTF-8
2,787
3
3
[ "BSD-2-Clause" ]
permissive
//! Provides support for working with macho binaries. use std::io::{Read, Seek, SeekFrom, Cursor}; use std::fs::File; use std::path::Path; use std::collections::HashSet; use prelude::*; use memmap; use uuid::Uuid; use mach_object::{OFile, LoadCommand, MachCommand}; const FAT_MAGIC: &'static [u8; 4] = b"\xca\xfe\xba...
true
f067a9f9c5e563c869de0a2c6c1c1291349bc5d3
Rust
wael852/evmap
/src/lib.rs
UTF-8
16,573
3.59375
4
[ "MIT", "Apache-2.0" ]
permissive
//! A lock-free, eventually consistent, concurrent multi-value map. //! //! This map implementation allows reads and writes to execute entirely in parallel, with no //! implicit synchronization overhead. Reads never take locks on their critical path, and neither //! do writes assuming there is a single writer (multi-wr...
true
925edc8eca7f664871690d83fc604308504490c5
Rust
exul/ruma-client-api
/src/r0/membership.rs
UTF-8
13,467
3.046875
3
[ "MIT" ]
permissive
//! Endpoints for room membership. use ruma_signatures::Signatures; // TODO: spec requires a nesting ThirdPartySigned { signed: Signed { mxid: ..., ... } } // for join_room_by_id_or_alias but not for join_room_by_id, inconsistency? /// A signature of an `m.third_party_invite` token to prove that this user owns...
true
98fef18186f756ad045d852b6d32b2b086a87247
Rust
sean-h/raytracer
/src/hitable/mesh.rs
UTF-8
1,538
2.859375
3
[]
no_license
use tdmath::Ray; use hitable::triangle::Triangle; use material::{Material, NoMaterial}; use hitable::{Hitable, HitRecord}; use std::path::Path; use std::fs::File; use std::io::prelude::*; use modelloader::parse_obj_file; use aabb::AABB; use bvh::BVH; pub struct Mesh { material: Box<Material>, bounding_box: Opt...
true
4dcacb2763f4812986273fa30addf97496f71f98
Rust
listless/Project-Euler-in-Rust
/src/Problem 031.rs
UTF-8
896
3.5
4
[]
no_license
use std::iter; fn main() { let coins: ~[int] = ~[1, 2, 5, 10, 20, 50, 100, 200]; let target: int = 200; println("The number of different ways to make £2 using any number of coins is " + number_of_ways(coins.len() - 1, 0, &coins, target).to_str() + "!"); } fn number_of_ways(index: uint, collected_value: int, coins...
true
a5451e003e52154849d3d5865b2150ba7b751dc4
Rust
cholcombe973/isilon
/src/models/cluster_config_device.rs
UTF-8
751
2.515625
3
[ "LicenseRef-scancode-unknown", "MIT" ]
permissive
#[allow(unused_imports)] use serde_json::Value; #[derive(Debug, Serialize, Deserialize)] pub struct ClusterConfigDevice { /// Device ID. #[serde(rename = "devid")] pub devid: i32, /// Device GUID. #[serde(rename = "guid")] pub guid: String, /// If true, this node is online and communicating...
true
4aae721368bb382df3a01d78c10b905a6ddf35b9
Rust
kanishkd4/Rust-by-example
/src/bin/c10_modules_use_self_hierarchy.rs
UTF-8
1,563
3.453125
3
[]
no_license
// The use declaration can be used to bind a full path to a new name // an example - `import torch.data.utils.DataLoader as data_loader` becomes `use torch::data::utils::DataLoader as data_loader;` // use bindings have a local scope. if a use is declared in a scope, the binding is not valid outside that scope // SUPE...
true
5a35476512e5e6cd7a1cc8d86ccfa8c306e5f910
Rust
pfernie/synacor-rs
/src/errors.rs
UTF-8
1,374
2.953125
3
[]
no_license
use memory::Register; error_chain!{ foreign_links { Io(::std::io::Error); ParseInt(::std::num::ParseIntError); } errors { InvalidMemorySize(u: usize) { description("Memory image must be 65536 bytes or less and of even size") display("Memory image must be 6553...
true
928e21b5c5b64fe633eb6abd513d394937c2ff57
Rust
marco-c/gecko-dev-wordified
/third_party/rust/nom/src/lib.rs
UTF-8
18,053
2.921875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "CC0-1.0" ]
permissive
/ / ! # nom eating data byte by byte / / ! / / ! nom is a parser combinator library with a focus on safe parsing / / ! streaming patterns and as much as possible zero copy . / / ! / / ! # # Example / / ! / / ! rust / / ! use nom : : { / / ! IResult / / ! bytes : : complete : : { tag take_while_m_n } / / ! combinator : ...
true
c5f26fb9a330478b451e2968de950ae61c40e837
Rust
sumanksp/effitask
/src/widgets/priority.rs
UTF-8
3,414
2.796875
3
[ "MIT" ]
permissive
use gtk::prelude::*; #[derive(relm_derive::Msg)] pub enum Msg { More, Set(u8), Updated(u8), } impl Priority { fn more(&self) { self.hbox.hide(); self.button.show(); } fn less(&self) { self.hbox.show(); self.button.hide(); } fn set(&self, priority: u8) ...
true
402f7ca3380cea7e3b0217801103b4698f2211bc
Rust
nick-lehmann/rust-tutorial
/linked-list/src/second.rs
UTF-8
4,836
3.78125
4
[]
no_license
#![allow(dead_code)] pub struct LinkedList<T> { head: Link<T>, } struct Node<T> { value: T, next: Link<T>, } type Link<T> = Option<Box<Node<T>>>; pub struct IntoIter<T>(LinkedList<T>); pub struct Iter<'a, T> { next: Option<&'a Node<T>>, } pub struct IterMut<'a, T> { next: Option<&'a mut Node<T>...
true
e2de580a21dab5394a5b02a1aaf742e7f7c1cbaa
Rust
will-hart/markdown-server
/src/main.rs
UTF-8
2,753
2.890625
3
[ "MIT", "Apache-2.0" ]
permissive
#![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate rocket; #[macro_use] extern crate serde_derive; extern crate rocket_contrib; extern crate glob; extern crate open; extern crate handlebars; use glob::glob; use handlebars::Handlebars; use rocket::response::content::Html; use rocket::config::{Config...
true
874b57b8175f895c2089f646c4efc1533d82d6b5
Rust
qtumproject/neutron-host
/src/syscall_interfaces/logging.rs
UTF-8
2,370
3.234375
3
[]
no_license
use crate::callstack::*; use crate::neutronerror::*; use crate::neutronerror::NeutronError::*; /* ## Logging ID: 2 Functions: * log_debug(count, string, ...) * log_info(count, string, ...) * log_warning(count, string, ...) * log_error(count, string, ...) The exact order of printing messages is backward from what wo...
true
da6c2a634876c77132b4afc967b051624ab2457d
Rust
rwcrosby/cofc_csis616_f20
/Ch1Part2/string_types/src/main.rs
UTF-8
1,045
3.75
4
[]
no_license
// Strings fn main() { // Characters println!("\n**** Characters"); let ch1 = "a"; let ch2 = "🍕"; println!("ch1 - {}:{:X?}:{}", ch1, ch1.as_bytes(), std::mem::size_of_val(ch1)); println!("ch2 - {}:{:X?}:{}", ch2, ch2.as_bytes(), std::mem::size_of_val(ch2)); // Byte strings print...
true
f241f3684867ebf031f9f8cbe37b6d1b15384bb3
Rust
jcbrockschmidt/advent-of-code-2020
/day09/src/main.rs
UTF-8
3,990
3.4375
3
[ "MIT" ]
permissive
use std::env; use std::path::Path; use std::process; use utils::read_lines; /// Prints usage statement for the executable. fn usage(args: Vec<String>) { println!("Usage: {} input_file scope", args[0]); } /// Reads numbers from a file. fn read_numbers<P>(filename: P) -> Result<Vec<usize>, String> where P: AsRe...
true
bca0bc5797ba89245da7d8cd41b51e63960322f5
Rust
tjnt/atcoder-rust
/src/accept/abc172_d.rs
UTF-8
204
2.609375
3
[]
no_license
use proconio::input; fn main() { input! { n: usize } let mut res = 0; for i in 1..=n { let g = n / i; res += (g * (g+1) / 2) * i; } println!("{}", res); }
true
77dbef6b15e572316f39e338e117f70bc0dbfea8
Rust
fortitudepub/rustdhipv2
/src/storage/SecurityAssociations.rs
UTF-8
7,940
2.59375
3
[ "MIT" ]
permissive
use crate::crypto::{aes, factory::*}; use crate::utils::misc::*; use core::convert::TryInto; use core::{cmp::Ordering, fmt}; use heapless::{consts::*, String}; use managed::ManagedMap; use std::fmt::Display; use crate::{HIPError, Result}; use super::HIPState::MapDesc; /// Enum to represent AES keys (i.e. ESP keys) #...
true
b1c5503f6a104f22059d2f3046d6434b5adf705d
Rust
kylestang/Battlesnake-gravity
/src/structures.rs
UTF-8
4,893
3.0625
3
[ "MIT" ]
permissive
use serde::{Serialize, Deserialize}; use std::fmt::Debug; #[derive(Serialize, Deserialize, Debug)] pub struct Coordinate { x: i64, y: i64 } impl Coordinate { pub fn new(x: i64, y: i64) -> Coordinate { Coordinate {x, y} } pub fn get_x(&self) -> i64 { self.x } pub fn get_y(...
true
195201a6d2b2cb4770286dcf68e9c400c065ce1b
Rust
swfsql/ovrt-sys
/src/log.rs
UTF-8
2,293
2.734375
3
[]
no_license
/// Wrapper for the `log_<n>` functions. #[macro_export] macro_rules! log { () => { unsafe { $crate::web_sys::console::log_0() }; }; ( $t0:expr ) => { unsafe { $crate::web_sys::console::log_1(&$t0.into()) }; }; ( $t0:expr, $t1:expr ) => { unsafe { $crate::web_sy...
true
8df33f6c83654c97da9f8dfb9c47623e154833bd
Rust
mystor/refptr
/macros/src/lib.rs
UTF-8
5,742
2.640625
3
[ "MIT" ]
permissive
extern crate proc_macro; use proc_macro2::{Span, TokenStream}; use quote::quote; use syn::{ parse_macro_input, parse_quote, AttributeArgs, Data, DataStruct, DeriveInput, Error, Field, Fields, Type, Visibility, }; macro_rules! fail { ($ts:expr, $err:expr) => { return Err(Error::new_spanned($ts, $er...
true
aa502fc64193a07b5c62a27de90be03da3d6f742
Rust
declanvk/scalable-concurrent-containers
/benches/hash_map.rs
UTF-8
2,346
2.765625
3
[ "Apache-2.0" ]
permissive
use criterion::{criterion_group, criterion_main, Criterion}; use scc::HashMap; use std::convert::TryInto; use std::time::Instant; fn insert_cold(c: &mut Criterion) { c.bench_function("HashMap: insert, cold", |b| { b.iter_custom(|iters| { let hashmap: HashMap<u64, u64> = HashMap::default(); ...
true
5c90191a18b0dfc1fb9792ccee29f8bfae569715
Rust
songlinshu/egui
/egui/src/paint/tessellator.rs
UTF-8
24,067
2.921875
3
[ "Apache-2.0", "MIT" ]
permissive
#![allow(clippy::identity_op)] use { super::{ color::{self, srgba, Color}, fonts::Fonts, LineStyle, PaintCmd, }, crate::math::*, }; /// The UV coordinate of a white region of the texture mesh. const WHITE_UV: (u16, u16) = (1, 1); #[derive(Clone, Copy, Debug, Default)] pub struct V...
true
78be7849ce3d15c3f95e7fddc830e532c6d217f4
Rust
Connicpu/direct3d11-rs
/src/enums/map.rs
UTF-8
1,342
3.109375
3
[ "MIT", "Apache-2.0" ]
permissive
#[auto_enum::auto_enum(u32, checked)] /// Identifies a resource to be accessed for reading and writing by the /// CPU. Applications may combine one or more of these flags. /// /// [More Information][1] /// /// [1]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476181(v=vs.85).aspx pub enum Map { /// Re...
true
3c40517ce72757f346bb1d2b65afee1630c07413
Rust
mellemahp/ray-tracing-in-one-weekend-in-rust
/src/main55.rs
UTF-8
1,813
2.828125
3
[]
no_license
mod utils; use utils::vec3::{Vec3, unit_vector}; use utils::ray::Ray; use utils::hitable::{Hitable, HitableList, HitRecord}; use utils::sphere::Sphere; use utils::material::DummyMat; fn color(r: &Ray, world: &Hitable) -> Vec3 { let mut rec = HitRecord::new(Box::new(DummyMat::new())); if world.hit(r, 0., std::...
true
1992704db3101848a6e50ec9555c41daa08f2aa7
Rust
mkeeter/advent-of-code
/2016/18/src/main.rs
UTF-8
1,201
3.203125
3
[]
no_license
use std::collections::HashSet; use std::io::Read; fn run(mut traps: HashSet<i32>, rows: usize, cols: usize) -> usize { let mut safe = 0; for _ in 0..rows { safe += cols - traps.len(); let mut next = HashSet::new(); for x in 0..cols { let x = x as i32; let left = ...
true
e459c2dec5c9393e0aec7a71c57e664089523883
Rust
llogiq/koto
/src/serialize/src/lib.rs
UTF-8
1,852
3.046875
3
[ "MIT" ]
permissive
//! Serde serialization support for Koto value types use { koto_runtime::Value, serde::ser::{Serialize, SerializeMap, SerializeSeq, Serializer}, }; pub struct SerializableValue<'a>(pub &'a Value); impl<'a> Serialize for SerializableValue<'a> { fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error> w...
true
84a24febff909e840ccc856d8752d698934fccb6
Rust
dmerkus/Quenya
/quenya/src/lexicon.rs
UTF-8
1,453
3.453125
3
[]
no_license
use std::collections::HashMap; use wn::pos::{Part, as_char}; pub struct Lexeme { pub lemma: String, pub pos: Part, } #[derive(Default)] pub struct Lexicon { lexemes: HashMap<String, Lexeme> } fn lexeme_key(lemma: &str, pos: Part) -> String { format!("{}:{}", lemma, as_char(pos)) } impl Lexicon { ...
true
96978ac93e3ec389cde7b1da8cd28c55d3e9fc4e
Rust
mgax/rustiles
/src/workqueue.rs
UTF-8
7,946
3.109375
3
[]
no_license
// Copyright 2012-2013 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-MI...
true
9aa336d2a939fb1dda588f8b02e1bbce0680afdf
Rust
mrobakowski/voca_rs
/src/index.rs
UTF-8
2,582
3.9375
4
[ "MIT" ]
permissive
//! Returns the index of `search` in `subject`. use count; use split; /// Returns the first occurrence index of `search` in `subject` or -1 if not found. /// /// # Arguments /// /// * `subject` - The string where to search. /// * `search` - The string to search. /// * `from_index` - The index to start searching /// //...
true
8c4d758e24546d9b00628c1853a1a30244833572
Rust
wolfgang/sa
/src/raylib_renderer.rs
UTF-8
1,123
2.796875
3
[]
no_license
use std::collections::HashMap; use raylib::{Color, RaylibHandle, Rectangle, Texture2D, Vector2}; use crate::gfx::game_renderer::GameRenderer; pub struct RaylibRenderer<'a> { rl: &'a RaylibHandle, sprite_sheet: Texture2D, sprites: HashMap<u8, Rectangle>, } impl<'a> RaylibRenderer<'a> { pub fn new(rl:...
true
446fad0ad5188c64480484f5e9def34e7ea8820e
Rust
Ach113/oxa-bytecode
/src/test.rs
UTF-8
438
2.859375
3
[]
no_license
#[cfg(test)] mod tests { use crate::value::Value; use crate::*; #[test] fn variable_tests() -> Result<(), Error> { assert_eq!(Value::NIL, crate::interpret("var a; a;".to_string())?); // variable initializes to nil assert_eq!(Value::FLOAT(5.0), crate::interpret("var a = 5; a;".to_string(...
true
c1a70533baac9171ca21d3e8b33487776e050e45
Rust
hicommonwealth/edgeware-contracts-tutorials
/1/assets/1.3-template.rs
UTF-8
869
3.09375
3
[ "MIT" ]
permissive
#![cfg_attr(not(feature = "std"), no_std)] use ink_lang as ink; #[ink::contract] mod incrementer { #[ink(storage)] pub struct Incrementer { value: i32, } impl Incrementer { #[ink(constructor)] pub fn new(init_value: i32) -> Self { Self { value: in...
true
36f7e5dcff71781f84f60dad7a73bb30c2de7c7b
Rust
rkat0/AtCoder
/ABC087/D.rs
UTF-8
3,453
2.984375
3
[]
no_license
use std::io::*; use std::collections::HashMap; use std::collections::HashSet; fn read<T: std::str::FromStr>() -> T { let stdin = stdin(); let mut buf = String::new(); stdin.lock().read_line(&mut buf); buf.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>().trim()...
true
4b9f4386226e4376df1c58aa1f6af84522447d7f
Rust
iyyel/rust-chat-server
/test-client/src/client.rs
UTF-8
8,979
2.8125
3
[ "MIT" ]
permissive
use futures::{future, pin_mut, StreamExt}; use std::collections::HashSet; use async_std::io; use serde::{Deserialize, Serialize}; use async_std::prelude::*; use async_std::task; use async_tungstenite::async_std::connect_async; use async_tungstenite::tungstenite::protocol::Message as TungMessage; #[derive(Serialize,...
true
190c125a2d578e245f99553b264864cf2532736e
Rust
rambothanh/minigrep-rust
/src/main.rs
UTF-8
748
2.71875
3
[]
no_license
extern crate minigrep; use std::env; use minigrep::Config; use std::process; fn main() { //chức năng env::args trả về một interator. Thay vì thu thập các giá trị ở đối số nhập vào rồi đưa vào //Vector dể Config::new, bây giờ lấy quyền sở hữu của trả về từ env::args() để Config::new //trưc tiếp let config = Con...
true
dd1c00b8a3f292cf99240d1f0edae1a864d311c5
Rust
kurayamisatoshi/NGC-224
/src/gameboy/joypad.rs
UTF-8
5,393
3.3125
3
[ "BSD-3-Clause" ]
permissive
use std::cell::RefCell; use std::convert::From; use std::rc::Rc; use super::cpu::IntFlag; use super::cpu::IntReg; use super::IOHandler; const SELECT_FUNC_KEY_MASK: u8 = 0b0010_0000; const SELECT_DIRECTION_KEY_MASK: u8 = 0b0001_0000; #[derive(Clone, PartialEq, Debug)] pub enum JoypadKey { Right, Left, Up,...
true
8f752a5a56bb39b9c9398180478f47e41cf7544a
Rust
Boyux/rust-json
/json_derive/parse/src/utils.rs
UTF-8
4,973
3.359375
3
[ "MIT" ]
permissive
use std::iter::FromIterator; use proc_macro::{TokenTree, TokenStream}; // punct_eq generate a closure to judge whether a TokenTree is // the given punct, which usually use in iter.filter() method. pub fn punct_eq(c: char) -> impl FnMut(&TokenTree) -> bool { move |x: &TokenTree| { if let TokenTree::Punct(p)...
true
9e3582f0a32d58a83158817a65431eed6c003d73
Rust
doytsujin/yew
/examples/function_todomvc/src/main.rs
UTF-8
4,478
2.609375
3
[ "Apache-2.0", "MIT" ]
permissive
use gloo::storage::{LocalStorage, Storage}; use state::{Action, Filter, State}; use strum::IntoEnumIterator; use yew::prelude::*; mod components; mod hooks; mod state; use components::entry::Entry as EntryItem; use components::filter::Filter as FilterItem; use components::header_input::HeaderInput; use components::in...
true
52a82af838f171e0751827d78b1359b4ea2c0574
Rust
peterhorne/gba
/src/main.rs
UTF-8
1,475
2.59375
3
[]
no_license
#![feature(box_syntax)] extern crate byteorder; extern crate core; #[macro_use] extern crate structopt; mod bit; mod bus; mod cpu; mod decode; mod execute; mod instruction; mod interrupt_controller; mod memory_map; use cpu::Cpu; use interrupt_controller::InterruptController; use memory_map::MemoryMap; use std::cell:...
true
76d28df0c0bb95c04e4dc6873f9c72376f52f9dc
Rust
extrawurst/gitui
/asyncgit/src/sync/patches.rs
UTF-8
1,756
2.625
3
[ "MIT" ]
permissive
use super::diff::{get_diff_raw, DiffOptions, HunkHeader}; use crate::error::{Error, Result}; use git2::{Diff, DiffLine, Patch, Repository}; #[allow(clippy::redundant_pub_crate)] pub(crate) struct HunkLines<'a> { pub hunk: HunkHeader, pub lines: Vec<DiffLine<'a>>, } #[allow(clippy::redundant_pub_crate)] pub(crate) f...
true
6a405ee0f89f2dc9ba827edc03d05bc0049213a0
Rust
vezdekod-doomers/sec5
/encoder/src/helper.rs
UTF-8
690
2.890625
3
[]
no_license
use std::io::{BufRead, Read}; use std::error::Error; use std::env::{var, temp_dir}; use std::fs::File; use std::process::Command; pub fn read_line() -> String { let stdin1 = std::io::stdin(); let mut iter = stdin1.lock().lines(); iter.next().unwrap().unwrap().trim().to_owned() } pub fn read_multiline() ->...
true
21ef8b5e03739e9c1695203121eb5c10bdf3e086
Rust
aschrab/broot
/src/skin.rs
UTF-8
4,578
2.703125
3
[ "MIT" ]
permissive
/// Defines the Skin structure with its defautl value. /// /// A skin is a collection of skin entries which are crossterm /// objectstyles: /// - an optional fg color /// - an optional bg color /// - a vector of attributes (bold, italic) use std::collections::HashMap; use std::fmt; use crossterm_style::{ Attribute...
true
75936d274fcfb3437e0b4269e52423ee27494301
Rust
tbarusseau/chip8-rust
/src/chip.rs
UTF-8
21,247
2.75
3
[]
no_license
use std::io; use std::io::prelude::*; use std::fs::File; use super::opcodes::*; const MEMORY_SIZE: usize = 4096; const NUMBER_OF_REGISTERS: usize = 16; pub const SCREEN_WIDTH: usize = 64; pub const SCREEN_HEIGHT: usize = 32; const STACK_SIZE: usize = 16; const KEYBOARD_SIZE: usize = 16; const APPLICATION_MEMORY_LOCA...
true
492cd13af2d84bab7f3772c2cdf8cf638bb84eea
Rust
MirecIT/amethyst
/amethyst_utils/src/app_root_dir.rs
UTF-8
1,628
3.359375
3
[ "Apache-2.0", "MIT" ]
permissive
//! Provides the directory of the executable. use std::{env, io, path}; /// Returns the cargo manifest directory when running the executable with cargo or the directory in /// which the executable resides otherwise, traversing symlinks if necessary. /// /// The algorithm used is: /// /// * If the `CARGO_MANIFEST_DIR`...
true
6e19e859e53fdb4b436b1e5fea2768624acdf699
Rust
backup-isaac/rustos
/lib/fat32/src/vfat/cluster.rs
UTF-8
589
2.921875
3
[]
no_license
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Copy, Clone, Hash)] pub struct Cluster(u32); impl From<u32> for Cluster { fn from(raw_num: u32) -> Cluster { Cluster(raw_num & !(0xF << 28)) } } impl Cluster { pub fn fat_table_sector(&self, fat_start_sector: u64, bytes_per_sector: u16) -> u64 { ...
true
2af768f199f9f972627a1f929cc92ef84beeff76
Rust
ia7ck/competitive-programming
/AtCoder/abc265/src/bin/e/main.rs
UTF-8
1,689
2.546875
3
[]
no_license
use proconio::input; use std::collections::HashSet; fn main() { input! { n: usize, m: usize, a: i64, b: i64, c: i64, d: i64, e: i64, f: i64, banned: [(i64, i64); m], }; const MOD: u64 = 998244353; macro_rules! add { ($a: ...
true
fe78c40ec4aa77758864b448decf0673f5c9362e
Rust
cloudhead/nakamoto
/p2p/src/fsm/cbfmgr/rescan.rs
UTF-8
8,945
2.53125
3
[ "MIT" ]
permissive
//! Blockchain (re-)scanning for matching scripts. use std::collections::BTreeSet; use std::ops::RangeInclusive; use std::rc::Rc; use nakamoto_common::bitcoin::util::bip158; use nakamoto_common::bitcoin::{Script, Txid}; use nakamoto_common::block::filter::BlockFilter; use nakamoto_common::block::tree::BlockReader; use...
true
5a924f77ffa3afd25a625fab3cc2b944f7845c88
Rust
atrense/libxivdat
/src/dat_file.rs
UTF-8
57,563
3.125
3
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
use std::convert::{TryFrom, TryInto}; use std::fs::{File, Metadata, OpenOptions}; use std::io::{Read, Seek, SeekFrom, Write}; use std::path::Path; use crate::dat_error::DATError; use crate::dat_type::*; /// Header size in bytes. pub const HEADER_SIZE: u32 = 0x11; /// Offset of the max_size header value from the actua...
true
e18ccde904193ca97e5f4bd9406452a7617dc7d2
Rust
stm32-rs/stm32-rs-nightlies
/stm32h5/src/stm32h563/ramcfg/m5ecckeyr.rs
UTF-8
1,821
2.578125
3
[]
no_license
#[doc = "Register `M5ECCKEYR` writer"] pub type W = crate::W<M5ECCKEYR_SPEC>; #[doc = "Field `ECCKEY` writer - ECC write protection key The following steps are required to unlock the write protection of the ECCE bit in the RAMCFG_MxCR register. 1) Write 0xAE into ECCKEY\\[7:0\\]. 2) Write 0x75 into ECCKEY\\[7:0\\]. Not...
true
f45f4b910206c169f285207bcc0136a377dbd43b
Rust
hyyking/rustracts
/parc/src/lib.rs
UTF-8
17,327
3.53125
4
[ "MIT" ]
permissive
//! This crate exposes [`ParentArc<T>`](struct.ParentArc.html) which is comparable to an //! [`Arc<T>`](https://doc.rust-lang.org/std/sync/struct.Arc.html) but "strong" references cannot //! be cloned which allows the `ParentArc<T>` to lock its weak references and block until all //! strong references are dropped. Once...
true
6be87c0393bee73a8b4e2b21dbb19688c7c998f7
Rust
exe-dealer/rust-md5
/src/cryptoutil.rs
UTF-8
7,830
2.96875
3
[ "MIT", "Apache-2.0" ]
permissive
// Copyright 2012-2013 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-MI...
true
b5c4e1b88b3f233e2059bc3b1f1f080a9219c95f
Rust
g2xpf/lrfrp
/lrfrp-examples/examples/sim_fan_controller.rs
UTF-8
1,367
2.703125
3
[]
no_license
use std::{thread, time::Duration}; use lrfrp_macros::frp; frp! { mod SimFanController; Args { th_init: f32, } In { tmp: f32, hmd: f32 } Out { fan: bool, di: f32, th_out: f32, } fn calc_di(tmp: f32, hmd: f32) -> f32 = 0.81 * tmp + 0.01...
true
01e3157d0cb935b5d7a0effc3d286319c7a38490
Rust
Jonesey13/generic_game
/src/window/glutin_handler.rs
UTF-8
1,082
2.8125
3
[ "MIT" ]
permissive
use glium::glutin::Event; use glium::Display; use super::WindowHandler; use glium::glutin::EventsLoop; use glium::glutin::WindowEvent; pub struct GlutinInput { focused_flag: bool, requested_close: bool } impl GlutinInput { pub fn new() -> GlutinInput { GlutinInput { focused_flag: true,...
true
e0925d6eb26ad087b5798fe3d88bdb7fe5fc294d
Rust
RusPiRo/ruspiro-register
/src/lib.rs
UTF-8
7,619
3.0625
3
[ "Apache-2.0", "MIT" ]
permissive
/*********************************************************************************************************************** * Copyright (c) 2019 by the authors * * Author: André Borrmann <pspwizard@gmx.de> * License: Apache License 2.0 / MIT ****************************************************************************...
true
a29a110fab3269ed4ef19c9c7aa8200461ba0a42
Rust
jolestar/starcoin
/state/state-store-api/src/lib.rs
UTF-8
1,293
2.53125
3
[ "Apache-2.0" ]
permissive
use anyhow::Result; use forkable_jellyfish_merkle::node_type::Node; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use starcoin_crypto::hash::HashValue; use std::collections::BTreeMap; #[derive(Clone, Debug, PartialEq, Eq)] pub struct StateNode(pub Node); impl StateNode { pub fn inner(&self) -> &No...
true
e534c81cdab71aa3e677550da5815af8038ec4df
Rust
dur4ng/SecretNumber
/solanaProgram/src/instruction.rs
UTF-8
2,698
3.265625
3
[]
no_license
use solana_program::program_error::ProgramError; use std::convert::TryInto; use crate::error::EscrowError::*; use core::intrinsics::size_of; pub enum EscrowGameInstruction { /// Starts the game creating a game account and transferring ownership of the given token account to the PDA /// /// /...
true
643044b71aa3dc26ce892b62c32096ffdf49c9ef
Rust
anymost/rustapp
/src/refCell.rs
UTF-8
3,569
3.453125
3
[]
no_license
// RefCell允许在不可变引用的情况下修改内部值 // 通常,借用检查发生在编译时,没有性能损耗,如果检查不通过,则编译失败 // RefCell的检查发生在运行时,有一定性能损耗,检查不通过,会触发panic // 内部可变性:不可变的值可变借用 // RefCell::new(v).borrow RefCell::new(v).borrow_mut() // RefCell负责维护Ref和RefMut两个智能指针,其包含引用计数,其也遵守借用规则,一个可变引用或多个不可变引用 // Rc 和 RefCell可配合使用 use std::cell::RefCell; use std::rc::Rc; use List:...
true
81e7b105b1fce59d39dc7987c1e4d99e12cc7534
Rust
trashbyte/os
/kernel/src/task/sleep.rs
UTF-8
1,352
2.625
3
[ "MIT" ]
permissive
///////////////////////////////////////////////////////////////////////////////L ///////////////////////////////////////////////////////////////////////////////L use crate::time::Instant; use alloc::sync::Arc; use core::future::Future; use core::pin::Pin; use core::task::{Context, Poll}; use core::time::Duration; use ...
true
58cd1e56296b97630a64f2baf0988b6889b0ae1d
Rust
emakman/rust-binary-terminfo
/src/format/mod.rs
UTF-8
29,667
3.125
3
[ "MIT" ]
permissive
//! `format` provides the formatting macro `tparm!(...)` and related types. mod types; use types::*; #[macro_use] mod macros; /// The [`TerminfoString`](struct.TerminfoString.html) struct represents a terminfo string /// capability which has been parsed as a format string. /// /// The primary use of TerminfoString i...
true
36c8139a9edb45e936a0f2eabe6305ebd6a0943f
Rust
binp-dev/epics-rs
/src/record/any.rs
UTF-8
10,421
3
3
[ "MIT" ]
permissive
use std::convert::{TryFrom}; use std::ops::{Deref, DerefMut}; use super::{ Record, ReadRecord, WriteRecord, AiRecord, AoRecord, AiHandler, AoHandler, BiRecord, BoRecord, BiHandler, BoHandler, LonginRecord, LongoutRecord, LonginHandler, LongoutHandler, StringinRecord, StringoutRecord, StringinHandle...
true
e52c11eacaa3126f6821cdbac34e2b4d80cd8f01
Rust
newcomb-luke/maptiler-cloud
/tests/api.rs
UTF-8
2,005
3.25
3
[ "MIT" ]
permissive
use maptiler_cloud::errors::ArgumentError; use maptiler_cloud::{Maptiler, TileRequest, TileSet}; use std::env; #[tokio::test] async fn get_tile() { let api_key = env::var("MAPTILER_KEY").expect("Environment variable MAPTILER_KEY not set"); let maptiler = Maptiler::new(api_key).unwrap(); // Gets a satelli...
true
d3c0ee7ae5e38dadd3ca9bb2688a1e21130286c1
Rust
jw3/chipper
/src/gui/mod.rs
UTF-8
696
2.578125
3
[]
no_license
use gtk::{Image, Window}; pub mod app; pub mod event; pub mod state; #[derive(Copy, Clone)] pub struct Rect { pub x: u32, pub y: u32, pub w: u32, pub h: u32, } impl Default for Rect { fn default() -> Self { Rect { x: 0, y: 0, w: 0, h: 0, ...
true
e75074bd996f526753039778799852243b1b99d9
Rust
sean-purcell/gba-rs
/src/mmu/gba/mod.rs
UTF-8
8,162
2.84375
3
[ "MIT" ]
permissive
// FIXME: implement open bus // FIXME: move unaligned access logic here from CPU use shared::Shared; use cpu::Cpu; use rom::GameRom; use io::IoReg; use super::ram::Ram; use super::{MemoryRead, MemoryUnit, Mmu}; mod bios; mod save; use self::bios::Bios; use self::save::Eeprom; #[derive(Clone, Copy, PartialEq, Eq...
true
6e316f52142ff6168098ca6bfbbe35f4c41ff1e4
Rust
seppo0010/limitd-rs
/src/protocol/pb/mod.rs
UTF-8
4,384
2.828125
3
[ "MIT" ]
permissive
pub mod request; pub mod response; use std::io; use std::sync::Arc; use futures::{Future, BoxFuture}; use protobuf::CodedInputStream; use protobuf::Message; use protobuf::ProtobufError; use io2::{Parse, Serialize}; use database::{Database, Error}; use handle::{Req, Res, handle, Method, HandlerData, TimeGenerator}; ...
true
5024d7bd67bd938eff421102eed59f1fdc37740c
Rust
yohandev/voxels
/voxels/src/common/transform/c_ltw.rs
UTF-8
702
2.828125
3
[]
no_license
use ezmath::*; /// local to world component #[derive(Debug, Clone, Default)] pub struct CLocalToWorld(pub float4x4); impl CLocalToWorld { /// get the forward of this local to world matrix pub fn forward(&self) -> float3 { let row = self.0.column(0); float3::new(row[0], row[1], row[2]) ...
true
77b9470a0b30c276f3cdbb35b32752f53b5482bf
Rust
ANEP-Research/quickn-ps
/quickn/P10650.rs
UTF-8
7,067
2.828125
3
[]
no_license
/* date : 2020 / 5 / 5 author : quickn (quickn.ga) email : quickwshell@gmail.com */ use std::io::{self, BufWriter, Write}; mod scanner { use std::{io, str}; /* https://github.com/EbTech/rust-algorithms */ /// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts ...
true
7cc798c24ea814054a6ecb008383f1b75d0d8396
Rust
jporch/advent-of-code-2020-rust
/day5-1/src/main.rs
UTF-8
747
3.0625
3
[ "MIT" ]
permissive
use std::fs; fn main() { let contents = fs::read_to_string("src/input.txt") .expect("Something went wrong reading the file"); let passes: Vec<&str> = contents.split("\n").collect(); let mut ids: Vec<u32> = vec![]; for p in &passes { ids.push(parse_pass(p)); } ids.sort(); for...
true
e8673d52a81a5f43ca9ea5517bb9418305d05846
Rust
maroider/git2_things
/src/commands.rs
UTF-8
6,709
2.890625
3
[]
no_license
use std::{ collections::HashMap, path::{self, Path, PathBuf}, }; use git2::{BranchType, ErrorCode, ObjectType, Oid, ReferenceType, Repository, TreeEntry}; // macro_rules! unwrap_result_or_else { // ($result:expr, $err:ident, $else_:expr) => { // match $result { // Ok(ok) => ok, // ...
true
b13a09a4897e4ecfca3c76d708f2a24b6577eedd
Rust
mikkyang/rust-jwt
/src/token/signed.rs
UTF-8
5,324
3.125
3
[ "MIT" ]
permissive
use crate::algorithm::store::Store; use crate::algorithm::SigningAlgorithm; use crate::error::Error; use crate::header::{BorrowedKeyHeader, Header, JoseHeader}; use crate::token::{Signed, Unsigned}; use crate::{ToBase64, Token, SEPARATOR}; /// Allow objects to be signed with a key. pub trait SignWithKey<T> { fn si...
true
c2aaf13df640e7684a9bd758c479a4b89b4fc589
Rust
Mic92/cntr
/src/procfs/unix.rs
UTF-8
687
2.515625
3
[ "MIT" ]
permissive
use simple_error::try_with; use std::fs::File; use std::io::prelude::*; use std::io::BufReader; use std::path::PathBuf; use crate::result::Result; #[allow(dead_code)] pub fn read_open_sockets() -> Result<Vec<PathBuf>> { let file = try_with!(File::open("/proc/net/unix"), "cannot open /proc/net/unix"); let mut...
true
e6a5f70d29fb3ac186f1dcb533763634f8c25dc8
Rust
ceciliacsilva/my_sonic_client
/src/frame/mod.rs
UTF-8
1,237
2.84375
3
[]
no_license
use std::fmt; use std::num::ParseIntError; use std::string::FromUtf8Error; pub mod recv; pub mod send; #[derive(Debug, PartialEq)] pub enum Mode { Search, Ingest, } impl ToString for Mode { fn to_string(&self) -> String { match self { Mode::Ingest => "ingest".to_string(), ...
true
763e4d6926f426619f1594d38d586ced29225358
Rust
anlumo/zboxurls
/src/main.rs
UTF-8
615
2.65625
3
[]
no_license
use url::Url; use zbox::RepoOpener; fn main() { zbox::init_env(); let mut path = std::env::current_exe().unwrap(); path.pop(); path.push("test-fs"); if let Err(err) = std::fs::remove_dir_all(&path) { if err.kind() != std::io::ErrorKind::NotFound { panic!("Unable to remove archi...
true
2044e8b19e37e6a45f94ca5fe3d1d5ec08c67544
Rust
s-petersson/RIP-8
/src/display.rs
UTF-8
3,994
2.953125
3
[]
no_license
extern crate sdl2; use self::sdl2::render::Renderer; use self::sdl2::pixels::Color; use self::sdl2::rect::Rect; const SCREEN_WIDTH: usize = 64; const SCREEN_HEIGHT: usize = 32; const SCREEN_PIXELS: usize = SCREEN_WIDTH * SCREEN_HEIGHT; const DISPLAY_WIDTH: usize = SCREEN_WIDTH * 20; const DISPLAY_HEIGHT: usize = SCR...
true
db004c4296c0a811fac6235e51e24cecf81b2875
Rust
leudz/shipyard
/src/scheduler/workload.rs
UTF-8
84,252
2.6875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::all_storages::AllStorages; use crate::borrow::Mutability; use crate::component::{Component, Unique}; use crate::scheduler::info::{ BatchInfo, Conflict, DedupedLabels, SystemId, SystemInfo, TypeInfo, WorkloadInfo, }; use crate::scheduler::label::{SystemLabel, WorkloadLabel}; use crate::scheduler::system::...
true
aca5f6cc584c92face54cef3fcbcc5e1b8810c4b
Rust
yo-kondo/seven_zip_extract
/src/main.rs
UTF-8
3,184
3.359375
3
[ "MIT" ]
permissive
#[macro_use] extern crate serde_derive; extern crate toml; use std::path::Path; use std::process::Command; use std::{env, fs}; /// Settings構造体 #[derive(Debug, Serialize, Deserialize)] struct Setting { /// 7-zipのインストールパス(7z.exeのパス) seven_zip_path: String, /// 解凍パスワード(複数可能) extract_passwords: Vec<String...
true
df4452e6da5c744c4b33821686e70c70ca0c3ecc
Rust
kalyan63/Rust-shell
/src/rm/src/main.rs
UTF-8
3,373
3.375
3
[]
no_license
use std::env; use std::vec::Vec; use std::string::String; fn main() { let args: Vec<String> = env::args().collect(); rm(&args); } fn rm(args: &Vec<String>) -> (){ use std::io::ErrorKind; use std::path::Path; if args.len() == 1 { println!("insufficient input arguments"); } if args.len(...
true
20d65213e74cf24021d1e775a53316a1a2869031
Rust
beoboo/rustnes
/lib/src/bus/mod.rs
UTF-8
815
3.1875
3
[]
no_license
use log::trace; use crate::types::{Byte, Word}; pub mod simple_bus; pub mod bus_impl; pub trait Bus { fn read(&self, start: Word, end: Word) -> &[Byte]; fn read_byte(&mut self, address: Word) -> Byte; fn read_word(&mut self, address: Word) -> Word { let low = self.read_byte(address) as Word; ...
true
09cc1355fd9d858bffeabd61e8b69aaa1ba76bc8
Rust
mschlr/rust_book
/src/hashmap.rs
UTF-8
2,855
3.765625
4
[]
no_license
use std::io; use std::mem; use std::collections::HashMap; pub fn exercise() { arrays(); // repeat some stuff with arrays // Error Handling out of boundaries println!("\nQuery Element from Vector v1!\n"); let small_vector = vec![3, 7, 1, 4, 2, 5]; // v1 loop { println!("v1 = {:?}\n", smal...
true
20aec56ae61a73e106f03cec00f65287fdb11c5d
Rust
pashh/fui
/src/fields/autocomplete.rs
UTF-8
2,852
2.828125
3
[ "MIT" ]
permissive
use std::rc::Rc; use cursive::view::AnyView; use cursive::views::{LinearLayout, TextView}; use serde_json::value::Value; use feeders::Feeder; use fields::WidgetManager; use fields; use views; /// Convienient wrapper around `Field<AutocompleteManager, String>`. pub struct Autocomplete; impl Autocomplete { /// Cr...
true
bf3a11fda6e28f369ff5499e5a3c87b1df0371d3
Rust
ajcarvajal/adventofcode
/aoc2017/day4/src/main.rs
UTF-8
1,961
3.4375
3
[]
no_license
use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; use std::collections::HashSet; use std::collections::HashMap; fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>> where P: AsRef<Path>, { let file = File::open(filename)?; Ok(io::BufReader::new(file).lines()...
true
e47eae74f85e6b4964b0761cbdf3869362e5d2f0
Rust
flagpoonage/taxes-rust
/src/rates.rs
UTF-8
1,623
2.609375
3
[]
no_license
use crate::income::IncomeBracket; pub fn get_nz_tax () -> Vec<IncomeBracket> { return vec![ IncomeBracket { from: 0.0, to: Some(14000.0), tax: 10.5 }, IncomeBracket { from: 14000.0, to: Some(48000.0), tax: 17.5 }, IncomeBracket...
true
47e1c4f431ecb3bb0302f627e4830e2b277531a6
Rust
mrzv/duet
/src/scan/mod.rs
UTF-8
9,402
2.6875
3
[ "MIT" ]
permissive
use std::path::{PathBuf,Path}; use std::cmp::Ordering; use std::os::unix::fs::{MetadataExt,FileTypeExt}; use serde::{Serialize,Deserialize}; use color_eyre::eyre::Result; use tokio::sync::{mpsc,Semaphore}; use std::sync::Arc; use async_recursion::async_recursion; use log; use crate::profile::{Ignore}; use regex:...
true
d26b5a22cb164e74cc6e926090b8a236cca49e68
Rust
ouchxp/Code4Fun
/rust/src/reference.rs
UTF-8
1,218
4.5625
5
[]
no_license
pub fn test() { // pass reference, so the function does not take ownership over s1 let s1 = String::from("hello"); let len = calculate_length(&s1); // which is same as `s1.borrow()` println!("The length of '{}' is {}.", s1, len); // pass mutable reference let mut s1 = String::from("hello"); ...
true
a35bb34f21867a3db200e75c431a395f72549a4b
Rust
Lichtso/WebGL2Experiments
/prototype2/src/camera.rs
UTF-8
3,661
2.9375
3
[]
no_license
#[derive(Default, Debug)] pub struct Ray { origin: glam::Vec3A, direction: glam::Vec3A, } pub fn ray_sphere_intersection(ray: &Ray, sphere_radius: f32) -> Option<(f32, glam::Vec3A, glam::Vec3A)> { let parallel = ray.direction*ray.origin.dot(ray.direction); let orthogonal = ray.origin-parallel; let ...
true
d41d48d90ef1886185f280ce7ee93f64e4c4f571
Rust
betrusted-io/xous-core
/services/gam/src/modal/slider.rs
UTF-8
8,909
2.578125
3
[]
no_license
use crate::*; use graphics_server::api::*; use core::fmt::Write; // This structure needs to be "shallow copy capable" so we can use it with // the enum_actions API to update the progress state in an efficient manner. // Thus it does not include its own GAM reference; instead we create one on // the fly when needed. ...
true
43bcc87344e7f9c1bed7baf0f08c72c5051ee01c
Rust
serenity-rs/distributed-worker-sample
/src/error.rs
UTF-8
1,361
2.515625
3
[ "ISC" ]
permissive
use redis_async::error::Error as RedisError; use serde_json::Error as JsonError; use std::{ error::Error as StdError, fmt::{Display, Formatter, Result as FmtResult}, io::Error as IoError, net::AddrParseError, result::Result as StdResult, }; pub type Result<T> = StdResult<T, Error>; #[derive(Debug)...
true
1a18674226b6a5029055b84039b9094cbe2792e4
Rust
DavidPRolfe/yapl
/src/parser/ast.rs
UTF-8
4,872
3
3
[ "MIT" ]
permissive
/* program -> declaration* EOF declaration -> function | var | statement function -> FUN IDENTIFIER "(" arg_decl? ")" block var -> ( "val" | "var" ) IDENT "=" expression statement -> loop | print | return | if | expression loop -> "loop" block print -> "print("...
true
e67a677ee2b04d80d4263d7db50761e2b4a7e88a
Rust
fvictorio/matasano-rust
/src/bin/e02.rs
UTF-8
274
2.734375
3
[]
no_license
extern crate hex; use matasano::xor; fn main() { let a = hex::decode("1c0111001f010100061a024b53535009181c").unwrap(); let b = hex::decode("686974207468652062756c6c277320657965").unwrap(); let result = hex::encode(xor(&a, &b)); println!("{}", result); }
true
105477b6eabceb99a21da0216477e7deaadcc656
Rust
alakahakai/vector
/src/sources/kubernetes_logs/util.rs
UTF-8
2,310
2.671875
3
[ "Apache-2.0" ]
permissive
use bytes05::Bytes; use file_source::{paths_provider::PathsProvider, FileServer, FileServerShutdown}; use futures::future::{select, Either}; use futures::{pin_mut, Sink}; use std::convert::Infallible; use std::error::Error; use std::{future::Future, time::Duration}; use tokio::task::spawn_blocking; /// A tiny wrapper ...
true
fc123035f9cccb7ca5a88b1b8bc50707958bd449
Rust
Zengor/parallelized-acotsp
/src/aco/mod.rs
UTF-8
3,388
2.96875
3
[]
no_license
mod aco_parameters; mod acs; mod acspar; mod ant; mod colony; mod mmas; mod result_log; use crate::instance_data::InstanceData; use crate::util::IntegerMatrix; pub use self::aco_parameters::{AcoParameters, Algorithm}; pub use self::ant::Ant; use self::colony::Colony; pub use self::result_log::{ResultLog, TimestampedR...
true
35bbb9edb298f9926af921872be2d27fc4b695ba
Rust
Actyx/rust-cid
/tests/lib.rs
UTF-8
11,793
2.890625
3
[ "MIT" ]
permissive
use multihash::*; /// Helper function to convert a hex-encoded byte array back into a bytearray fn hex_to_bytes(s: &str) -> Vec<u8> { let mut c = 0; let mut v = Vec::new(); while c < s.len() { v.push(u8::from_str_radix(&s[c..c + 2], 16).unwrap()); c += 2; } v } macro_rules! assert_...
true