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
0f7a39a3022c4ddd8943a74c362e541fdb556682
Rust
across-travel/ruby-on-rust
/src/ast/node.rs
UTF-8
30,032
2.78125
3
[]
no_license
// https://raw.githubusercontent.com/whitequark/parser/2a73841d6da04a5ab9bd270561165fd766722d43/lib/parser/builders/default.rb use parser::token::Token; #[derive(Debug, PartialEq, Clone)] pub enum Node { // for rules which doesnot need to return a real node Dummy, // for rules which returns a vec of nodes...
true
e07ca38d20d3a044e5e45e8ea8dfcd17de8d1f29
Rust
sapsan4eg/dialog
/src/test/mod.rs
UTF-8
350
2.828125
3
[]
no_license
use log::*; use Logger; use Handler; struct DummyHandler; impl Handler for DummyHandler { fn handle(&self, record: &LogRecord) -> bool { println!("{}", record.args().to_string()); true } } #[test] fn test_handler() { let logger = Logger::new(LogLevelFilter::Info); logger.append(DummyH...
true
a65f38e5f09806be52c28be604ba217ba022326f
Rust
pluxtore/maze-server
/maze_gameserver/src/gamelogic/unlocks.rs
UTF-8
615
3.171875
3
[]
no_license
use serde::{Serialize, Deserialize}; #[derive(Debug, Clone, Serialize, Deserialize,Copy)] pub struct Unlocks { raw: u8, } impl Unlocks { pub fn new() -> Self { Self { raw: 0 } } pub fn get(&self,index : u8) -> bool { ( self.raw>>index ) & 1 == 1 } pub fn get_raw(&self) -> u8 ...
true
847999430b4873e182a729c189d95d7139660039
Rust
cthulhua/aoc2020
/d19/src/main.rs
UTF-8
546
2.5625
3
[]
no_license
#[macro_use] extern crate pest_derive; use pest::Parser; use std::error::Error; use std::fs::File; use std::io::{BufRead, BufReader}; #[derive(Parser)] #[grammar = "rules.pest"] struct RuleParser; fn main() -> Result<(), Box<dyn Error>> { let filename = std::env::args().nth(1).unwrap(); let input = File::ope...
true
faef61c9743c3cef146e2739d1c4083ac0b4fa61
Rust
oshbec/grit
/tests/common/test_bed.rs
UTF-8
9,163
2.8125
3
[]
no_license
use std::{env, fs, path::PathBuf, process::Command}; use uuid::Uuid; use grit::compression; #[derive(Debug)] pub struct TestBed { pub root: PathBuf, } #[allow(dead_code)] impl TestBed { pub fn setup() -> TestBed { let root = env::temp_dir().join(format!("grit_test/{}", Uuid::new_v4())); let t...
true
a2d86fa2ee23ef6f70f8178e4186efff04b1e64f
Rust
vctibor/Zuma
/zuma/src/code_generation/mod.rs
UTF-8
2,110
2.9375
3
[]
no_license
use crate::interpretation::*; mod tests; static INDENT_SIZE: usize = 4; //static SVG_OPEN: &str = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"500\" height=\"500\">"; static SVG_OPEN: &str = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1000\" height=\"1000\">"; static SVG_CLOSE: &str = "</svg>"; pub fn ...
true
4373ef9b46b634cf5f9d3b0a0a8d76233c058588
Rust
mark-i-m/os1
/kernel/fs/error.rs
UTF-8
191
2.90625
3
[ "MIT" ]
permissive
//! A simple Error object for FS errors pub struct Error<'err> { msg: &'err str, } impl<'err> Error<'err> { pub fn new(msg: &'err str) -> Error { Error { msg: msg } } }
true
9d976e62e7fb1c937f5e58f973015cf6714ebb63
Rust
olanod/ruma
/ruma-api-macros/src/util.rs
UTF-8
15,251
2.828125
3
[ "MIT" ]
permissive
//! Functions to aid the `Api::to_tokens` method. use std::collections::BTreeSet; use proc_macro2::{Span, TokenStream}; use proc_macro_crate::{crate_name, FoundCrate}; use quote::quote; use syn::{ AngleBracketedGenericArguments, AttrStyle, Attribute, GenericArgument, Ident, Lifetime, ParenthesizedGenericArgum...
true
76e414c071d1ed49a9d82ba24404587f0e4707bb
Rust
wang-q/intspan
/src/libs/coverage.rs
UTF-8
3,555
3.296875
3
[ "MIT" ]
permissive
use crate::IntSpan; use std::collections::BTreeMap; #[derive(Default, Clone)] pub struct Coverage { max: i32, tiers: BTreeMap<i32, IntSpan>, } impl Coverage { pub fn max(&self) -> &i32 { &self.max } pub fn tiers(&self) -> &BTreeMap<i32, IntSpan> { &self.tiers } pub fn new(...
true
1bf68639991957b57718a2fcd42bac0aacb7a415
Rust
fabien-michel/advent-of-code-2020
/src/days/day01.rs
UTF-8
1,466
2.75
3
[]
no_license
// use crate::utils::read_lines; // mod utils; use crate::utils::print_day_banner; use crate::utils::read_lines; use itertools::iproduct; pub fn day01_01() { print_day_banner(1, 1); let mut expenses = load_expenses(); expenses.sort(); for (exp_1, exp_2) in iproduct!(expenses.iter(), expenses.iter()) { ...
true
650672c0c633050ba352fc7448a27b0340102462
Rust
Pajn/wlral
/wlral/src/input/event_filter.rs
UTF-8
3,378
2.515625
3
[]
no_license
use crate::input::events::*; use std::{cell::RefCell, ops::Deref, rc::Rc}; use wlroots_sys::{wlr_backend, wlr_backend_get_session, wlr_session_change_vt}; use xkbcommon::xkb; /// Implement EventFilter to handle input events. /// /// Each event handler return a bool to inform if it has handled /// the event or not. Eve...
true
edc1ad4fa4f3a430244dae233bd217ce34489159
Rust
trondhe/trace-rs
/src/camera.rs
UTF-8
2,365
2.78125
3
[]
no_license
use crate::object::HitableList; use crate::tracer::Tracer; use crate::types::{Frame, TraceValueType, Vec3}; use crate::viewport::Viewport; use rayon::prelude::*; pub struct Camera { vp: Viewport, sensor: Sensor, tracer: Tracer, samples: usize, } pub struct CameraConfig { pub y_size: usize, pub...
true
4602d063dc4f66d86d4ca69a51d7e08dfe227c29
Rust
CarloMicieli/trenako
/crates/catalog/src/catalog_items/category.rs
UTF-8
3,601
2.859375
3
[ "MIT", "Apache-2.0" ]
permissive
use strum_macros; use strum_macros::{Display, EnumString}; /// The enumeration of the model categories. #[derive(Debug, Copy, Clone, PartialEq, Eq, EnumString, Display)] #[strum(serialize_all = "snake_case")] #[strum(ascii_case_insensitive)] pub enum Category { /// The steam locomotives category Locomotives, ...
true
d8f842315e1befcd32ca3837238d723813d78cf1
Rust
overdrivenpotato/rust
/src/tools/clippy/tests/ui/only_used_in_recursion.rs
UTF-8
2,647
3.15625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-other-permissive", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
#![warn(clippy::only_used_in_recursion)] fn simple(a: usize, b: usize) -> usize { if a == 0 { 1 } else { simple(a - 1, b) } } fn with_calc(a: usize, b: isize) -> usize { if a == 0 { 1 } else { with_calc(a - 1, -b + 1) } } fn tuple((a, b): (usize, usize)) -> usize { if a == 0 { 1 } else { tuple((a - 1, b ...
true
4331474567500d44eb14a77b486155091c2294dc
Rust
birktj/gl-canvas-rs
/examples/hello_world.rs
UTF-8
1,509
2.578125
3
[]
no_license
extern crate glium; extern crate nalgebra as na; extern crate gl_canvas_rs; use std::io::Write; use glium::Surface; use glium::glutin::{Event, self, WindowEvent}; fn main() { let mut event_loop = glutin::EventsLoop::new(); let window = glutin::WindowBuilder::new().with_dimensions((1024, 768).into()); le...
true
e2120ae1f870f13ace5884c5c95cb106b9f59c65
Rust
rleyva/ray-tracer
/src/utils.rs
UTF-8
1,749
3.171875
3
[]
no_license
// Utilities use std::fs::File; use std::io::prelude::*; use std::path::Path; // Public function used to write a PPM-formatted string to a file. pub fn write_ppm_to_file(file_path: &String, ppm_content: &String, width: usize, height: usize) { // Header given to generated PPMs. let header = "P3\n".to_string() ...
true
843360e1c18f5f1902a9bec69fd856830dc3dfbd
Rust
suhanyujie/rust-cookbook-note
/src/notes/kvs/src/kv.rs
UTF-8
25,038
2.859375
3
[]
no_license
//! 通过 [indexmap](https://github.com/bluss/indexmap) 实现简单的 KV 数据库 //! 为了防止 data race,将 IndexMap 用 Arc 进行包装 //! 具体实现可以参考:https://github.com/pingcap/talent-plan/blob/master/courses/rust/projects/project-2/src/kv.rs use super::util::HandyRwLock; use crate::{KvsError, Result}; use indexmap::IndexMap; use serde::{Deseriali...
true
608671a929699fca24ae4491dce6c355f599c390
Rust
itaibn/scheme
/src/scheme.rs
UTF-8
13,140
3.109375
3
[]
no_license
// For some reason importing std::borrow::Borrow produces a name collision with // RefCell::borrow but just importing std::borrow doesn't. use std::borrow; use std::fmt; use std::iter::DoubleEndedIterator; use gc::{self, Gc, GcCell}; use num::FromPrimitive; //use crate::equality::SchemeEq; use crate::number::Number;...
true
847d5d0cff4f61cf2606fe52536459b50ac62e69
Rust
cargo-crates/orm-rs
/src/methods/table_name.rs
UTF-8
739
3
3
[]
no_license
use std::any::type_name; use inflector::{string::{demodulize, pluralize}, cases::snakecase}; pub fn table_name<T>() -> String where T: ?Sized { // eg: arel::UserTable let full_namespace = type_name::<T>(); // eg: UserTable let struct_name = demodulize::demodulize(&full_namespace); // eg: user_table...
true
dcc6135544bab3fb9b1ca0e0ad3801a52a4cef4a
Rust
jakubdabek/metaheuristic-algorithms
/list3/z3/src/board.rs
UTF-8
7,384
3.015625
3
[]
no_license
use crate::direction::{Direction, DIRECTIONS}; use crate::point::Point; use itertools::{EitherOrBoth, Itertools}; use ndarray::prelude::*; use ndarray::IntoDimension; use std::fmt; use std::io::BufRead; use std::time::Duration; #[derive(Debug, Clone, Copy, PartialOrd, PartialEq, Ord, Eq)] pub enum Field { Empty, ...
true
5ea2c696b6e737ca0797f0677e1dbea03007f0ec
Rust
luisholanda/asphalt-orm
/asphalt-core/src/types/impls.rs
UTF-8
1,219
2.671875
3
[ "Apache-2.0" ]
permissive
macro_rules! __define_aliases { ($($alias_ty: ident)+, $sql_ty: ty, $name: expr) => { $( #[doc = "Alias to `"] #[doc = $name] #[doc = "`"] pub type $alias_ty = $sql_ty; )+ }; } macro_rules! define_sql_types { ($($sql_name: literal $sql_ty: ide...
true
b25a5b9d13971931f18e3a633bcae967824ac185
Rust
weworld/rusty-leetcode
/src/tree_tag/closest_binary_search_tree_value_270.rs
UTF-8
1,958
3.171875
3
[ "WTFPL" ]
permissive
/* * @lc app=leetcode.cn id=270 lang=rust * * [270] 最接近的二叉搜索树值 */ use crate::utils::tree::TreeNode; // @lc code=start use std::rc::Rc; use std::cell::RefCell; impl Solution { pub fn closest_value(root: Option<Rc<RefCell<TreeNode>>>, target: f64) -> i32 { Solution::closest_value_rec(&root, target).unwra...
true
85c783a89e2d4259e55f15f72fef5fa1f82fad76
Rust
aidanbabo/minesweeper
/src/main.rs
UTF-8
2,721
2.640625
3
[]
no_license
// TODO // - MAKE AN ALERT FOR JEFFERY BECAUSE YOU LOVE HIM // - BUG - when bomb is on far right side, the space directly to the left often doesn't get // calculated properly // - add smiley // - requires facial animations while clicking on flagged // - add numbers // - need to create time and mines variables that...
true
226e6c88f76c46ca2d06646a826be078bb8e7b60
Rust
davechallis/ocypod
/src/application/manager.rs
UTF-8
33,269
2.5625
3
[ "Apache-2.0" ]
permissive
//! Defines most of the core queue/job application logic. //! //! Main struct provided is `RedisManager`, through which all job queue operations are exposed. //! These will typically have HTTP handlers mapped to them. use std::collections::HashMap; use std::default::Default; use log::{debug, info, warn}; use redis::{a...
true
268ecffe970214803a3e1b007a1a3f4493cd24c8
Rust
dimohy/rust-learning
/exercise1/src/ex2.rs
UTF-8
603
3.578125
4
[ "MIT" ]
permissive
use std::io; use std::io::Write; /* 2. 터미널에서 문자열을 입력 받아서 그 문자열을 역순으로 출력하세요. 예를 들어 터미널에서 "abbd" 를 입력 받았으면 "dbba"를 출력하세요. **/ #[allow(dead_code)] pub fn run() { print!("? "); io::stdout().flush().unwrap(); let mut input = String::new(); io::stdin().read_line(&mut input) .expect("Failed t...
true
433423497ad1c0884004e235fd9007a89358a227
Rust
ericsink/rust-raytracer
/src/geometry/prims/triangle.rs
UTF-8
7,933
3.203125
3
[ "MIT" ]
permissive
#![allow(dead_code)] use crate::prelude::*; use crate::geometry::bbox::{union_point, union_points, BBox, PartialBoundingBox}; use crate::geometry::prim::Prim; use crate::material::Material; use crate::mat4::{Mat4, Transform}; use crate::raytracer::{Ray, Intersection}; use crate::vec3::Vec3; use crate::material::mater...
true
99ff915cf9433bb6def5060514afca1ef77c5d56
Rust
mesalock-linux/crates-io
/vendor/hyper-0.10.16/src/server/request.rs
UTF-8
9,476
3.15625
3
[ "Apache-2.0", "Unlicense", "BSD-3-Clause", "0BSD", "MIT" ]
permissive
//! Server Requests //! //! These are requests that a `hyper::Server` receives, and include its method, //! target URI, headers, and message body. use std::io::{self, Read}; use std::net::SocketAddr; use std::time::Duration; use buffer::BufReader; use net::NetworkStream; use version::{HttpVersion}; use method::Method;...
true
d8f732d1b2f5713a822773414db44c16bffb6c57
Rust
LordAro/AdventOfCode
/2016/src/bin/day6.rs
UTF-8
1,267
3.21875
3
[]
no_license
use std::collections::btree_map::BTreeMap; use std::env; use std::fs::File; use std::io::{BufRead, BufReader}; fn most_least_common(btm: BTreeMap<char, i32>) -> (char, char) { let mut count_vec: Vec<_> = btm.into_iter().collect(); // Reverse sort the vector of pairs by "value" (sorted by "key" in case of tie) ...
true
d1174ddb309a006c75521c4466efbc4f1c40e4bb
Rust
ilkkahanninen/juhlakalu
/backend/src/errors.rs
UTF-8
4,056
2.65625
3
[ "MIT" ]
permissive
use std::io::{Error, ErrorKind}; use actix_web::{http::StatusCode, Error as ActixError, HttpResponse, ResponseError}; use config::ConfigError; use deadpool_postgres::config::ConfigError as PoolConfigError; use deadpool_postgres::PoolError; use derive_more::{Display, From}; use serde::{Deserialize, Serialize}; use toki...
true
da480578a152c0eb2c7fa9cb59751f027be03552
Rust
x7Gv/qpasswd
/src/gen.rs
UTF-8
1,859
3.140625
3
[]
no_license
use anyhow::Result; use rand::seq::SliceRandom; use rand_core::OsRng; #[derive(Debug)] pub enum CharsetType { Lowercase, Uppercase, Symbols, Numbers, Special, } #[derive(Debug, Default)] pub struct PasswdGenBuilder { pub length: i16, pub charsets: Vec<CharsetType>, } #[derive(Debug, Defau...
true
901aa46b9485a7b309c8a3461f922d9ac6573e3e
Rust
JacobVanGeffen/shuttle
/tests/basic/pct.rs
UTF-8
7,762
3.03125
3
[ "Apache-2.0" ]
permissive
use shuttle::scheduler::PctScheduler; use shuttle::sync::Mutex; use shuttle::{check_random, thread, Config, MaxSteps, Runner}; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; use std::sync::Arc; use std::time::Duration; use test_env_log::test; const TEST_LENGTH: usize = 20; /// Based on Fig 5 of ...
true
b47cf6d7421a83dfe4ae55393337ec17167b87dd
Rust
MaxOhn/Bathbot
/bathbot/src/core/events/interaction/command.rs
UTF-8
3,453
2.578125
3
[ "ISC" ]
permissive
use std::{mem, sync::Arc}; use eyre::Result; use crate::{ core::{ commands::{ checks::check_authority, interaction::{InteractionCommandKind, InteractionCommands, SlashCommand}, }, events::{EventKind, ProcessResult}, BotConfig, Context, }, util::{inte...
true
fd58c014e063f71b7e7d021607a11298c1298580
Rust
d2verb/rush
/src/main.rs
UTF-8
2,686
3.109375
3
[]
no_license
use nix::sys::wait::*; use nix::unistd::*; use rush::builtin; use rush::command::*; use rustyline::error::ReadlineError; use rustyline::Editor; use std::env; use std::ffi::CString; use std::path::Path; /// Find real path of given command. /// /// # Examples /// /// ```rust /// let path = find_realpath("sh"); /// asser...
true
b42024cd2107ff0026353dfbe7c479cd05c606e0
Rust
fharding1/adventofcode-2019
/day1/src/main.rs
UTF-8
667
3.375
3
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader}; fn fuel_requirement(mass: i64) -> i64 { let mut total_fuel = 0; let mut cur_mass = mass; loop { cur_mass = (cur_mass / 3) - 2; if cur_mass <= 0 { break; } total_fuel += cur_mass; } return total_fuel...
true
565287223af3b3aa2caaa7c0884dad35f0d88b54
Rust
nathan-at-least/wormcode
/wormcode_inst/src/instruction/intermediate/tests.rs
UTF-8
1,259
2.6875
3
[]
no_license
use super::{Intermediate, OpCode0, OpCode1, OpCode2, OpCode3}; use crate::{Mode, Operand}; use test_case::test_case; use wormcode_bits::B; #[test] fn test_instruction_data_0xabcdef() { use crate::Instruction; use wormcode_bits::Encode; let expected = B::<28>::from(0xabcdef); let inst = Instruction::Da...
true
24bffb18abcd4aa2bb6f6ede5b3314bbf54da159
Rust
noxabellus/uir
/support/src/utils.rs
UTF-8
3,979
3.078125
3
[]
no_license
use std::{cell::{Ref, RefMut}, ops::{Deref, DerefMut}}; pub fn flip_ref_opt_to_opt_ref<T> (r: Ref<Option<T>>) -> Option<Ref<T>> { match r.deref() { Some(_) => Some(Ref::map(r, |o| o.as_ref().unwrap())), None => None } } pub fn ref_and_then<'r, T, U: 'static, F: FnOnce (&T) -> Option<&U>> (r: Ref<'r, T>, f: F) ...
true
a46ae4f2faf432154999c473b3ccb80b596e20d9
Rust
FJJ-Oneday/rust-study
/smart-pointer/src/main.rs
UTF-8
1,766
3.109375
3
[]
no_license
use crate::List::{Cons, Nil}; use std::ops::Deref; use std::rc::{Rc, Weak}; use std::cell::RefCell; fn main() { // let b = Box::new(5); // println!("b = {}", b); // let list = Cons(1, Box::new(Cons(2, Box::new(Cons(3, Box::new(Nil)))))); // let a = Rc::new(List2::Cons(1, Rc::new(List2::Cons(2, Rc::ne...
true
af4e6bed615031a59b4d6e875220443d23c18b7c
Rust
rnleach/sounding-analysis
/src/layers.rs
UTF-8
4,899
3.328125
3
[ "MIT" ]
permissive
//! This module finds significant layers. //! //! Examples are the dendritic snow growth zone, the hail growth zone, and inversions. //! //! The `Layer` type also provides some methods for doing basic analysis on a given layer. //! use crate::sounding::DataRow; use metfor::{CelsiusDiff, CelsiusPKm, HectoPascal, Km, Met...
true
6434ff7f02dad725a8d8dc14d00ba061f3d6f2a8
Rust
HerringtonDarkholme/leetcode
/src/reverse_k_group.rs
UTF-8
937
3.09375
3
[]
no_license
use crate::util::linked_list::ListNode; pub struct Solution; impl Solution { pub fn reverse_k_group(mut node: Option<Box<ListNode>>, k: i32) -> Option<Box<ListNode>> { None // I don't think rust is capable of doing below... or I don't have time to do // it can be done // https://github.com/...
true
fc0a745254d42b9fc0a3d260765b1126b82479ed
Rust
williewillus/advent_of_code_2017
/src/day21.rs
UTF-8
3,042
3.078125
3
[]
no_license
use std::collections::HashMap; use std::fs::File; use std::io::BufRead; use std::io::BufReader; use pathfinding::Matrix; use itertools::Itertools; use itertools::iterate; fn to_matrix(side: &str) -> Matrix<bool> { Matrix::square_from_vec( side.bytes() .filter(|b| *b != b'/') .map(|b...
true
8dab9d96b0c6e0d2739dc8007b0bde7628ae6bb1
Rust
h2gb/h2transformer
/src/lib.rs
UTF-8
62,610
3.6875
4
[ "MIT" ]
permissive
//! [![Crate](https://img.shields.io/crates/v/h2transformer.svg)](https://crates.io/crates/h2transformer) //! //! H2Transformer is a library for transforming raw data between encodings. //! //! As part of [h2gb](https://github.com/h2gb), it's common to extract a buffer //! from a binary that's encoded in some format - ...
true
2f2c6faabd14bd6bc9c002d940e4d648a15a05b5
Rust
gbdev/gb-asm-tutorial
/i18n-helpers/src/bin/mdbook-xgettext.rs
UTF-8
5,014
2.765625
3
[ "Apache-2.0", "MIT", "CC0-1.0", "CC-BY-SA-4.0" ]
permissive
// Copyright 2023 Google LLC // // 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 law or agreed to in ...
true
842631f0dfbccbc600ebaa964a5a0843542615ff
Rust
Mrmaxmeier/lua-interpreter
/src/instructions/relational_and_logic.rs
UTF-8
1,768
3.234375
3
[]
no_license
use instruction::*; macro_rules! logic { ($name:ident, $op:expr) => ( #[derive(Debug, Clone, Copy, PartialEq)] pub struct $name { pub lhs: DataSource, pub rhs: DataSource, pub inverted: bool } impl LoadInstruction for $name { fn load(...
true
997581d5002a945f7b2da6f345b7d6b0f06c5df2
Rust
shaunstanislauslau/jormungandr
/jormungandr/src/network/p2p/policy.rs
UTF-8
2,843
2.9375
3
[ "MIT", "Apache-2.0" ]
permissive
use jormungandr_lib::time::Duration; use poldercast::{Node, PolicyReport}; use serde::{Deserialize, Serialize}; use slog::Logger; /// default quarantine duration is 30min const DEFAULT_QUARANTINE_DURATION: std::time::Duration = std::time::Duration::from_secs(1800); /// This is the P2P policy. Right now it is very sim...
true
d35e3e1c5b5a3f71730dde7033aaf03dc0836fe7
Rust
aconley/Algorithms
/TAOCP/Implementations/taocp/src/backtracking/sudoku.rs
UTF-8
29,662
3.734375
4
[ "MIT" ]
permissive
// A sudoku solver using basic backtracking. // // If there is more than one solution, this will return an arbitrary one. use std::fmt; use std::mem; #[derive(Debug, PartialEq, Eq)] pub struct SudokuSolution { rows: Vec<Vec<u8>>, } impl SudokuSolution { fn create(values: &[u8]) -> Self { assert_eq!(values.le...
true
6d5065957a3d861aac5b914b72e36a936cbc8482
Rust
matthiasbeyer/rust-ipfs-api
/ipfs-api-examples/examples/dns.rs
UTF-8
1,277
2.625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
// Copyright 2017 rust-ipfs-api Developers // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except accord...
true
9ea25155d599eda73dd2812ccf2d9912dc32c615
Rust
billnote/rust-exercism
/luhn-from/src/lib.rs
UTF-8
353
3.15625
3
[ "MIT" ]
permissive
extern crate luhn; use std::convert::From; use std::fmt::Display; pub struct Luhn<T> where T: Display, { number: T, } impl<T: Display> Luhn<T> { pub fn is_valid(&self) -> bool { luhn::is_valid(&self.number.to_string()) } } impl<T: Display> From<T> for Luhn<T> { fn from(f: T) -> Self { ...
true
933f33c7e51a15785f3add9a10f20bcbd09a6e91
Rust
plugblockchain/plug-blockchain
/primitives/election-providers/src/lib.rs
UTF-8
9,084
2.546875
3
[ "Apache-2.0", "GPL-3.0-or-later", "Classpath-exception-2.0", "GPL-1.0-or-later", "GPL-3.0-only" ]
permissive
// This file is part of Substrate. // Copyright (C) 2020 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // 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://...
true
3a49fd8f74e420b4570558fdc5db04d27ba49364
Rust
07th-mod/python-patcher
/install_loader/build.rs
UTF-8
331
2.703125
3
[]
no_license
use std::io; #[cfg(windows)] use winres::WindowsResource; fn main() -> io::Result<()> { // At compile time this includes the .ico file in the executable so it has the correct icon. #[cfg(windows)] { WindowsResource::new() .set_icon("src/resources/icon.ico") .compile()?; } ...
true
2474f81b2994c2a51c40fafe08e2eb8ec557cc0b
Rust
hesch/assembler-8bit
/src/microcode.rs
UTF-8
6,479
2.65625
3
[]
no_license
use crate::output_datastructures::{ ControlWord, ACCUMULATOR, AND, INSTRUCTION, LOGIC_B, LOGIC_ZERO, MEMORY, MEMORY_ADDRESS, OR, PROGRAM_COUNTER, SHIFT_LEFT, SHIFT_RIGHT, SHIFT_ZERO, UNCHANGED, XOR, }; use gen_microcode::GenMicrocode; use gen_microcode_macro::gen_microcode; use field_size_macro::FieldSize; use...
true
b49deb5a09618c9e5e80ecb943a8c9117d9ca5e4
Rust
noobLue/tmc-langs-rust
/tmc-langs-util/src/error.rs
UTF-8
1,943
3.21875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Contains the FileError error type for file operations. use std::path::PathBuf; use thiserror::Error; /// A wrapper for std::io::Error that provides more context for the failed operations. #[derive(Error, Debug)] pub enum FileError { // file_util errors #[error("Failed to open file at {0}")] FileOpen(P...
true
a77ef46298f6628dddb987a7f99f1b8882119fd5
Rust
suspend0/aws-sdk-rust
/sdk/codestar/src/client.rs
UTF-8
87,689
2.578125
3
[ "Apache-2.0" ]
permissive
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. #[derive(Debug)] pub(crate) struct Handle< C = aws_smithy_client::erase::DynConnector, M = aws_hyper::AwsMiddleware, R = aws_smithy_client::retry::Standard, > { client: aws_smithy_client::Client<C, M, R>, conf: crate::C...
true
6754dd0fe5a78b9ede214d10997d5ba894f6653c
Rust
5c077m4n/noder
/src/lib/utils/os.rs
UTF-8
964
2.859375
3
[]
no_license
pub fn get_os_name() -> Option<&'static str> { match std::env::consts::OS { "linux" => Some("linux"), "macos" => Some("darwin"), "windows" => Some("win"), _ => None, } } pub fn get_os_arch() -> Option<&'static str> { match std::env::consts::ARCH { "x86" => Some("x86"...
true
f4cf9eb2f99164d4a99ff51bdfc71c9b9eb25cf4
Rust
TyOverby/ares
/src/parse/mod.rs
UTF-8
4,815
2.78125
3
[]
no_license
// Based on Norvig's lisp interpreter use std::rc::Rc; use Value; use intern::SymbolIntern; mod errors; mod util; pub mod tokens; use parse::tokens::{TokenType, Token, Open, TokenIter}; pub use parse::errors::ParseError; use parse::errors::ParseError::*; fn one_expr<'a, 'b>(tok: Token, tok_stream...
true
0e4ba4163fd6771ab79f7ca2ccc3af124a43c294
Rust
y-usuzumi/survive-the-course
/survive-the-course-rs/src/problems/leetcode/_31_Next_Permutation.rs
UTF-8
1,788
3.609375
4
[ "BSD-3-Clause" ]
permissive
// https://leetcode.com/problems/next-permutation/ pub struct Solution; impl Solution { pub fn next_permutation(nums: &mut Vec<i32>) { if nums.len() < 1 { return; } let mut boundl = 0; let boundr = nums.len() - 1; 'outer: for idx in (0..nums.len() - 1).rev() { ...
true
c0e46f647953bb7d2d8c1185556c3f1cb04bfe85
Rust
mcoffin/zinc
/src/drivers/dht22.rs
UTF-8
3,206
2.75
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Zinc, the bare metal stack for rust. // Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com> // // 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.o...
true
0828eba984702af600f0ec2ca72cecc65b69edbc
Rust
gvissers/babs
/src/ubig/sub.rs
UTF-8
34,841
3
3
[ "Apache-2.0" ]
permissive
// Copyright, 2021, Gé Vissers // // 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 law or agreed to in ...
true
d963bbf4b9ab41f4503180b1a80dbd7d156b635d
Rust
nervosnetwork/ckb
/network/src/peer_store/types.rs
UTF-8
4,115
2.6875
3
[ "MIT" ]
permissive
//! Type used on peer store use crate::{ peer_store::{Score, SessionType, ADDR_MAX_FAILURES, ADDR_MAX_RETRIES, ADDR_TIMEOUT_MS}, Flags, }; use ipnetwork::IpNetwork; use p2p::multiaddr::{Multiaddr, Protocol}; use serde::{Deserialize, Serialize}; use std::net::IpAddr; /// Peer info #[derive(Debug, Clone)] pub st...
true
15796b8ce857a86ec089f98524bab9be326b6a9b
Rust
jordanbray/chess_uci
/src/gui/gui_command.rs
UTF-8
11,452
2.609375
3
[ "MIT" ]
permissive
use chess::{Board, ChessMove}; use error::Error; use nom::combinator::rest; use std::fmt; use std::str::FromStr; #[cfg(test)] use chess::{File, Piece, Rank, Square}; use gui::go::{parse_go, Go}; use parsers::*; use nom::IResult; use nom::combinator::{map, complete, value}; use nom::bytes::streaming::tag; use nom::by...
true
31035b0b9c3b3e30e6df6531de2cc07b8264552c
Rust
tomasbasham/echo-echo-echo
/src/main.rs
UTF-8
3,235
3.203125
3
[]
no_license
#![deny(warnings)] // A function which runs a future to completion using the Hyper runtime. use hyper::rt::run; // Miscellaneous types from Hyper for working with HTTP. use hyper::{Body, Method, Request, Response, Server, StatusCode}; // This function turns a closure which returns a future into an // implementation ...
true
0f5f2fa9585c2aca1cf7d3704385db4a50e739b5
Rust
Keats/kickstart
/src/terminal.rs
UTF-8
3,196
3.328125
3
[ "MIT" ]
permissive
use std::fmt; use std::io::prelude::*; /// Show an error message pub fn error(message: &str) { if let Some(mut t) = term::stderr() { match t.fg(term::color::BRIGHT_RED) { Ok(_) => { write!(t, "{}", message).unwrap(); t.reset().unwrap(); } ...
true
7dc6854abca53dd9d842f9dc34052a2bd6d43b5d
Rust
rillrate-fossil/rillrate
/pkg-dashboard/rate-ui/src/common/middler.rs
UTF-8
883
2.765625
3
[ "Apache-2.0" ]
permissive
use yew::{html, Children, Component, ComponentLink, Html, Properties, ShouldRender}; pub struct Middler { props: Props, } #[derive(Properties, Clone)] pub struct Props { pub children: Children, } impl Component for Middler { type Message = (); type Properties = Props; fn create(props: Self::Prop...
true
f73be106b07c533f125174ff6567d51f9ac50428
Rust
balintbalazs/hdf5-rust
/src/hl/space.rs
UTF-8
7,214
2.640625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::convert::AsRef; use std::fmt::{self, Debug}; use std::ops::Deref; use std::ptr; use ndarray::SliceOrIndex; use hdf5_sys::h5s::{ H5Scopy, H5Screate_simple, H5Sget_simple_extent_dims, H5Sget_simple_extent_ndims, H5Sselect_hyperslab, H5S_SELECT_SET, }; use crate::internal_prelude::*; /// Represents th...
true
0b54122112fed9a198e35f69aae029c39389d201
Rust
ericrobolson/Archived_Tremor
/v0/src/gfx/voxels/mod.rs
UTF-8
14,751
2.609375
3
[ "MIT" ]
permissive
use rayon::prelude::*; use wgpu::util::DeviceExt; use super::{model_transform::ModelTransform, poly_renderer::BindGroups, vertex::Vertex}; use crate::lib_core::{ ecs::{Entity, Mask, MaskType, World}, spatial, time::GameFrame, voxels::{Chunk, Voxel}, }; pub mod palette; pub mod texture_voxels; type P...
true
48f900a92c13551742c88db8db5d5f3913779a2b
Rust
EugeneGonzalez/aoc_2020
/src/day2.rs
UTF-8
1,186
3.125
3
[]
no_license
use aoc_runner_derive::{aoc, aoc_generator}; use parse_display::{Display, FromStr}; use std::error::Error; #[derive(Display, FromStr, PartialEq, Debug)] #[display("{min}-{max} {letter}: {password}")] struct PasswordRule { min: usize, max: usize, letter: char, password: String, } #[aoc_generator(day2)]...
true
dc064094bfb5382b3257d80679ae9d9329a65d03
Rust
suren-m/rsw
/async-app/src/main.rs
UTF-8
741
2.8125
3
[]
no_license
use async_std::fs; use std::io::Error; use tide::prelude::*; use tide::Request; const CONFIG_FILE: &str = "config.txt"; async fn get_config(path: &str) -> Result<String, Error> { fs::read_to_string(path).await } #[derive(Debug, Deserialize)] struct Animal { name: String, legs: u8, } #[async_std::main] a...
true
20b1d4e52f614cbedeaf472333c5f5227204b749
Rust
zaeleus/noodles
/noodles-fasta/src/writer.rs
UTF-8
3,140
3.53125
4
[ "MIT" ]
permissive
//! FASTA writer. mod builder; pub use self::builder::Builder; use std::io::{self, Write}; use super::{record::Sequence, Record}; /// A FASTA writer. pub struct Writer<W> { inner: W, line_base_count: usize, } impl<W> Writer<W> where W: Write, { /// Creates a FASTA writer. /// /// # Example...
true
d54ef4e50caf53fa890e9caeaea60e4a69fbb65b
Rust
AravindGopala/PracticePrograms
/Rust/helloworld/src/main.rs
UTF-8
114
2.921875
3
[]
no_license
fn main() { // Variables can be type annotated. let i: i32 = 10; println!("Hello, world!, {}", i); }
true
070cc45f9098d892097a1ca13b89d2b5ebd451c4
Rust
danambrogio/roll20
/src/main.rs
UTF-8
1,710
3.109375
3
[ "MIT" ]
permissive
#[macro_use] extern crate clap; extern crate rand; use clap::App; use rand::Rng; fn main() { let yaml = load_yaml!("../cli.yml"); let matches = App::from_yaml(yaml).get_matches(); let die_opt = matches.value_of("die").unwrap_or("20").parse::<i32>().unwrap(); let num_opt = matches.value_of("num").unwrap_or("1...
true
2b74b5d9cb64e2dcab2d513e41a66206b696b23b
Rust
gen0083/atcoder_python
/rust/abc230/src/bin/c.rs
UTF-8
978
2.59375
3
[]
no_license
use std::cmp::{max, min}; use proconio::input; fn main() { input!{ n: i64, a: i64, b: i64, p: i64, q: i64, r: i64, s: i64, } let template = ".".repeat((s-r+1) as usize); let p1f = max(1 - a, 1 - b); let p2f = max(1 -a, b - n); let p1t = m...
true
de82c635e5658e7ea45aa8a981440ec7e07da655
Rust
topecongiro/allocators-rs
/malloc-bind/src/lib.rs
UTF-8
23,257
2.75
3
[ "Apache-2.0" ]
permissive
// Copyright 2017 the authors. See the 'Copyright and license' section of the // README.md file at the top-level directory of this repository. // // Licensed under the Apache License, Version 2.0 (the LICENSE file). This file // may not be copied, modified, or distributed except according to those terms. //! Bindings ...
true
a8532c940538311c03135ba5b784b561c23f2b4f
Rust
AntonGepting/tmux-interface-rs
/src/commands/windows_and_panes/move_window_tests.rs
UTF-8
2,306
2.9375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
#[test] fn move_window() { use crate::{MoveWindow, TargetWindow}; use std::borrow::Cow; // Like join-pane, but `src-pane` and `dst-pane` may belong to the same window // // # Manual // // tmux ^3.2: // ```text // move-window [-abrdk] [-s src-window] [-t dst-window] // (alias: mo...
true
93c77e6fe0f388ce901f8ed0ea68891c8cc1c148
Rust
JeeZeh/advent-of-code
/2018/day10/src/main.rs
UTF-8
3,527
3.078125
3
[]
no_license
use std::{ collections::HashMap, fs, io::{stdin, stdout, Read, Write}, }; #[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)] struct Point { x: i32, y: i32, } #[derive(Debug)] struct Star { position: Point, velocity: Point, } impl Star { fn step(&mut self) { self.position.x += ...
true
94509e2f7174c9af312b8d8169bbfb1714de9b5b
Rust
jonalmeida/random-code
/rust/learning/modules-again/src/reader.rs
UTF-8
1,238
3.65625
4
[]
no_license
use std::io::File; use std::io::BufferedReader; pub type ReaderResult<T, E> = Result<T, E>; pub struct Reader { path: Path, } pub trait ReaderFile { fn create(&self); fn open(&self) -> File; //fn insert(&self, String); fn spill(&self); } impl Reader { pub fn new(path: Path) -> Reader { ...
true
2fc3b75012f2a45e02143d93954ec129c79bb022
Rust
nbanal/toy-payment-engine
/src/main.rs
UTF-8
1,757
2.78125
3
[ "Apache-2.0" ]
permissive
use std::{collections::HashMap, io}; use std::env; use std::fs::File; use std::io::BufReader; mod bank; fn main() -> io::Result<()> { let mut bank = bank::Bank { accounts: HashMap::new(), ledger: HashMap::new(), }; let csv_filename = env::args().nth(1); let file = File::open(csv_filena...
true
d3eb71fa3e86faf1ac3b910db6761e8ea8353cd9
Rust
irjones/aoc2020
/dec_5/common/src/lib.rs
UTF-8
2,506
3.609375
4
[ "MIT" ]
permissive
pub mod day_five { #[derive(Debug)] pub struct Seat { row: i32, column: i32 } fn adjust_boundary(a: i32, b: i32) -> i32 { (a + b) / 2 } impl Seat { pub fn id(&self) -> i32 { self.row * 8 + self.column } pub fn from(pass: &'_ str) ->...
true
f4da65aae94bd54ca397cc1e053ce1d4fac50886
Rust
jakosimov/blockkey
/src/crypto/hashing/hash.rs
UTF-8
3,167
3.078125
3
[ "MIT" ]
permissive
use data_encoding::HEXUPPER; use sha2::{Digest, Sha256}; use std::convert::TryInto; use std::fmt; use std::marker::PhantomData; #[derive(Debug)] pub struct Hash<T: ?Sized = ()>([u8; 32], PhantomData<T>); impl<T: ?Sized> Clone for Hash<T> { fn clone(&self) -> Self { Hash(self.0, PhantomData) } } impl<...
true
f925ddd1500cff7c29429558dd740145c77560ee
Rust
mythmon/hackerrank
/src/algorithms/warmup/time-conversion.rs
UTF-8
3,168
3.640625
4
[]
no_license
use std::io; use std::str::FromStr; use std::fmt::{Display, Formatter, Error}; #[derive(Clone)] pub enum Time { AmPm { hour: u8, minute: u8, second: u8, am: bool }, TwentyFour { hour: u8, minute: u8, second: u8 }, } impl Time { pub fn new_ampm(hour: u8, minute: u8, second: u8, am: bool) -> Time { ...
true
faa24c02d6c93d559ca5b83def3bd356dbcd82e9
Rust
kyleoneill/adventofcode
/2019/2/2.rs
UTF-8
1,930
3.234375
3
[]
no_license
use std::fs::File; use std::io::{self, prelude::*, BufReader}; fn main() -> io::Result<()> { let file = File::open("input.txt")?; let reader = BufReader::new(file); for line in reader.lines() { let result_line = line?; let values: Vec<i32> = result_line.split(',').map(|x| x.parse()).collect...
true
2dcf5b1cdc6442d9ac7b4b7e78f27ec96e265e43
Rust
AI-and-ML/alumina
/alumina_ops/src/elementwise/softsign.rs
UTF-8
2,197
2.9375
3
[ "MIT" ]
permissive
// y = x / (abs(x) + 1) // y' = 1 / (abs(x) + 1)^2 use crate::{ elementwise::elementwise_single::{UnaryElementwise, UnaryFunc}, elementwise::{abs::abs, div::Div, offset::offset, sqr::sqr}, }; use alumina_core::{ base_ops::OpSpecification, errors::{GradientError, OpBuildError}, grad::GradientContext, graph::{Node...
true
661c95375575d0ec5ed62702864692da9dbb452d
Rust
tech-paws/vm
/src/commands_reader.rs
UTF-8
7,089
3.078125
3
[]
no_license
//! Commands reader. use vm_buffers::BytesReader; use vm_buffers::IntoVMBuffers; pub struct CommandsReader<'a> { pub bytes_reader: &'a mut BytesReader, pub address: String, pub count: u64, command_breakpoint: u64, command_len: u64, read_commands: u64, } pub struct Command<'a> { pub id: u6...
true
4b2afd3d592fb3ed3abf4fa68eb5bd03921dc1ef
Rust
nephele-rs/nephele
/nephele/src/proto/h1/client/encode.rs
UTF-8
3,789
2.5625
3
[ "MIT", "Apache-2.0" ]
permissive
use cynthia::future::swap::{self, AsyncRead, Cursor}; use cynthia::runtime::task::{Context, Poll}; use std::io::Write; use std::pin::Pin; use crate::common::http_types::headers::{CONTENT_LENGTH, HOST, TRANSFER_ENCODING}; use crate::common::http_types::{Method, Request}; use crate::proto::h1::body_encoder::BodyEncoder;...
true
48990c7637f12893c900ac3914efeed75acfb4a5
Rust
maboesanman/cargo-llvm-codecov-converter
/src/main.rs
UTF-8
4,450
2.6875
3
[ "MIT" ]
permissive
use crate::string_seek::get_region_text; use crate::string_seek::shrinkwrap; use defaultmap::DefaultBTreeMap; use rayon::prelude::*; use std::error::Error; use std::io::Read; use std::path::Path; mod codecov; mod llvm; mod string_seek; #[derive(Clone)] pub struct Region { id: usize, start: (usize, usize), ...
true
c3d5df8b11e50519edf4a945a42d548a5c9e9787
Rust
ia7ck/competitive-programming
/AtCoder/abc221/src/bin/c/main.rs
UTF-8
971
2.75
3
[]
no_license
use input_i_scanner::{scan_with, InputIScanner}; fn main() { let stdin = std::io::stdin(); let mut _i_i = InputIScanner::from(stdin.lock()); let n = scan_with!(_i_i, String); let n: Vec<char> = n.chars().collect(); let f = |x: &[u64]| -> u64 { let mut res = 0; for d in x { ...
true
2fc266abf4a8ba07bc5d77e0e4429377739fa567
Rust
rowanhill/aoc16
/day25/src/parser.rs
UTF-8
3,435
3.546875
4
[]
no_license
use parser::Operand::*; use parser::Instruction::*; use regex::Regex; lazy_static! { static ref CPY_RE:Regex = Regex::new(r"cpy (.+?) (.+)").unwrap(); static ref INC_RE:Regex = Regex::new(r"inc (.+?)").unwrap(); static ref DEC_RE:Regex = Regex::new(r"dec (.+?)").unwrap(); static ref JNZ_RE:Regex = Reg...
true
45512e6dcb583e29733377ab21936c876911a644
Rust
mwilliammyers/elasticsearch-rs
/elasticsearch/src/cat/mod.rs
UTF-8
3,583
2.6875
3
[ "Apache-2.0" ]
permissive
/* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not u...
true
3a60665b8e5d78839086e96cfcb82ca71f27573c
Rust
rust3d/glium
/tests/vertex_buffer.rs
UTF-8
14,107
2.65625
3
[ "Apache-2.0" ]
permissive
extern crate glutin; #[macro_use] extern crate glium; use glium::Surface; use std::default::Default; mod support; #[test] fn vertex_buffer_creation() { let display = support::build_display(); #[derive(Copy, Clone)] struct Vertex { field1: [f32; 3], field2: [f32; 3], } implement...
true
0325d3b68ef87b608221e3bac46088b11572b383
Rust
icyJoseph/codejam-js
/src/rounding/src/rounding.rs
UTF-8
2,278
3.28125
3
[]
no_license
use std::io; type Res<T> = Result<T, Box<dyn std::error::Error>>; fn nxt() -> String { let mut input = String::new(); match io::stdin().read_line(&mut input) { Ok(_) => input, _ => panic!("Error reading line"), } } fn ptc<T: std::str::FromStr>() -> T { match nxt().trim().parse::<T>() ...
true
c5ac680b4e51eef23d8da90e214a66e2c01f393b
Rust
jumpersdevice/solana
/sdk/program/src/account.rs
UTF-8
3,466
2.796875
3
[ "Apache-2.0" ]
permissive
use crate::{clock::Epoch, pubkey::Pubkey}; use std::{cell::RefCell, cmp, fmt, rc::Rc}; /// An Account with data that is stored on chain #[repr(C)] #[frozen_abi(digest = "Upy4zg4EXZTnY371b4JPrGTh2kLcYpRno2K2pvjbN4e")] #[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Default, AbiExample)] #[serde(rename_all = "cam...
true
9a530d8e16811ea480ba8418a8fb2b1641614a4a
Rust
iCodeIN/ybc
/src/layout/tile.rs
UTF-8
3,008
3.296875
3
[ "MIT", "Apache-2.0" ]
permissive
#![allow(clippy::redundant_closure_call)] use derive_more::Display; use yew::prelude::*; use yewtil::NeqAssign; #[derive(Clone, Debug, Properties, PartialEq)] pub struct TileProps { #[prop_or_default] pub children: Children, #[prop_or_default] pub classes: Option<Classes>, /// The HTML tag to use ...
true
5681e425b4b6b3d76fa578caea4fa5dbeffce86e
Rust
dinfuehr/dora
/dora-asm/src/lib.rs
UTF-8
2,180
3.09375
3
[ "MIT" ]
permissive
use byteorder::{LittleEndian, WriteBytesExt}; pub mod arm64; pub mod x64; use std::convert::TryInto; #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub struct Label(usize); struct AssemblerBuffer { code: Vec<u8>, position: usize, labels: Vec<Option<u32>>, } impl AssemblerBuffer { fn new() -> Assemble...
true
ac144e150c6321448784ebf75196624af81cdb78
Rust
thomastaylor312/krustlet
/crates/kubelet/src/store/oci/file.rs
UTF-8
15,771
2.96875
3
[ "Apache-2.0" ]
permissive
use crate::store::Storer; use oci_distribution::client::ImageData; use std::path::{Path, PathBuf}; use std::sync::Arc; use async_trait::async_trait; use log::debug; use oci_distribution::Reference; use tokio::sync::Mutex; use tokio::sync::RwLock; use super::client::Client; use crate::store::LocalStore; /// A module ...
true
d050f0539c4d0070938daeca27ea80a900dc7be2
Rust
japaric/ultrascale-plus
/firmware/zup-rtfm/macros/src/check.rs
UTF-8
7,951
2.625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use std::collections::{ hash_map::{Entry, HashMap}, HashSet, }; use proc_macro2::Span; use syn::parse; use crate::{syntax::App, NSGIS}; pub fn app(app: &App) -> parse::Result<()> { // in single-core context no static should use the `#[global]` attribute if app.cores == 1 { let main = &app.mai...
true
1d9431c745cf3bb6fc272e42ef0b6570f01cce28
Rust
EFanZh/Introduction-to-Algorithms
/src/chapter_8_sorting_in_linear_time/section_8_2_counting_sort/exercises/exercise_8_2_3.rs
UTF-8
1,035
3.234375
3
[]
no_license
pub fn modified_counting_sort(a: &[usize], b: &mut [usize], k: usize) { let mut c = vec![0; k]; for &x in a { c[x] += 1; } // C[i] now contains the number of elements equal to i. for i in 1..k { c[i] += c[i - 1]; } // C[i] now contains the number of elements less than or ...
true
8663f292101a18a266d5bb9a178982ffc40bb3a5
Rust
impuls71/grammers
/lib/grammers-client/src/types/entity_set.rs
UTF-8
4,962
3.484375
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::types::Entity; use grammers_tl_types as tl; use std::collections::HashMap; use std::ops::Index; /// Hashable `Peer`. #[derive(Hash, PartialEq, Eq)] enum Peer { User(i32), Chat(i32), Channel(i32), } pub enum MaybeBorrowedVec<'a, T> { Borrowed(&'a [T]), Owned(Vec<T>), } /// Helper struct...
true
02979bb7eea23f9c927dafbda5bae43455debdca
Rust
saranshr/HSMW_RandD_Project
/1_Rust/Rust_Basics/1_CommonProgrammingConcepts/2_data_types/src/main.rs
UTF-8
4,521
4.125
4
[]
no_license
fn main() { /* DATA TYPES: SCALAR TYPES --> represent a single value: --> integers --> floating-point numbers --> booleans --> characters */ /* INTEGERS length signed unsigned 8 Bit i8 u8 16 Bit i16 u16 32 Bit ...
true
4b9874d8e386e051d0068b6e2abfe83ab02865c4
Rust
songlinshu/elvis
/core/src/state.rs
UTF-8
853
3.40625
3
[ "MIT" ]
permissive
//! State machine use crate::Node; use std::collections::HashMap; /// State store map pub type StateKV = HashMap<Vec<u8>, Vec<u8>>; /// state for tree pub struct State { /// Elvis Node child: Node, /// State Machine state: StateKV, } impl State { /// New State pub fn new(node: impl Into<Node>...
true
e57275374f46a870e525a3b02d5db37b1ebb42fc
Rust
cang-mang/TrueMan
/RUST/util/hash/src/bkdr/mod.rs
UTF-8
1,075
2.59375
3
[]
no_license
/* * encoding=utf-8 * BKDR-HASH散列操作接口。 * 历史: * 2020-11-10,完成。 */ /*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/ //适用于对字符串进行计算。 //seed可以取31、131、1313、13131、131313等。 //magic是HASH初始值,一般取0即可。 //如果字符串内容主要是英文字母和数字字符,seed建议取31;一般seed是取131。 pub fn x_0(key: &[u8], seed: u32, magic: u32)...
true
9988de8b2d4d91292c3aa8c1ec6b2c2920d75de4
Rust
wg/rusoto
/rusoto/credential/src/variable.rs
UTF-8
9,857
3.625
4
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::convert::From; use std::env::{var, VarError}; use std::fmt; use std::sync::Arc; /// Variable is an abstraction over parameters to credential providers, allowing to abstract on /// how (source) and when (time) parameter values are resolved. A lot of credentials providers /// use external information sources su...
true
0405f76dbf5fc67b1a8cfa5a57178df7592e80f0
Rust
TehPers/BevyGame
/engine/crates/game_tiles/src/world/region.rs
UTF-8
3,991
3.125
3
[ "MIT" ]
permissive
use std::{convert::TryInto, num::TryFromIntError}; use crate::{Tile, TileRegionCoordinate, TileRegionPosition, TileRegionRect, TileWorldPosition}; use game_lib::{ bevy::{math::Vec2, prelude::*}, derive_more::{Display, Error}, }; use game_morton::Morton; // TODO: implement Serialize/Deserialize, doesn't suppor...
true