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
8e51248ea7085b5cfc691aadd0308df7a45c5f2c
Rust
davidpdrsn/dilemma
/src/query_dsl.rs
UTF-8
7,600
2.546875
3
[]
no_license
use crate::group::*; use crate::order::*; use crate::select::*; use crate::*; pub trait QueryDsl<T> { fn select(self, selectable: impl Into<Select>) -> QueryWithSelect<T>; fn filter(self, filter: impl Into<Filter>) -> Query<T>; fn or_filter(self, filter: impl Into<Filter>) -> Query<T>; fn join<K>(se...
true
50540956f15dc69f9dc298f4f8ee986c0a6ec91f
Rust
ktomsic/xrl
/src/protocol/message.rs
UTF-8
4,594
3.140625
3
[ "MIT" ]
permissive
use std::io::Read; use serde_json::{from_reader, to_vec, Value}; use super::errors::*; #[derive(PartialEq, Clone, Debug)] pub enum Message { Request(Request), Response(Response), Notification(Notification), } #[derive(Serialize, PartialEq, Clone, Debug)] pub struct Request { pub id: u64, pub meth...
true
24c03dd7309d9a93f47abe650a605278ff3dc289
Rust
nguyenminhhieu12041996/casper-node
/node/src/components/deploy_acceptor.rs
UTF-8
8,307
2.625
3
[ "Apache-2.0" ]
permissive
mod config; mod event; use std::{convert::Infallible, fmt::Debug}; use thiserror::Error; use tracing::{debug, error, info}; use crate::{ components::Component, effect::{ announcements::DeployAcceptorAnnouncement, requests::{ContractRuntimeRequest, StorageRequest}, EffectBuilder, Effec...
true
cceb4dcc0ff8e22935332f91c56dd2f53f619ff9
Rust
cbackas/hookbuffer
/src/env.rs
UTF-8
2,341
3.203125
3
[]
no_license
pub fn get_server_port() -> u16 { match std::env::var("HOOKBUFFER_PORT") { Ok(port) => { println!("[INFO] Found HOOKBUFFER_PORT: {}", port); match port.parse::<u16>() { Ok(port) => port, Err(_) => { println!("[ERROR] Custom HOOKBUFF...
true
cfc2b3d27caf96f7c35dab1841553dfaa52d8b35
Rust
kolgotko/command-pattern.rs
/src/main.rs
UTF-8
774
2.84375
3
[]
no_license
extern crate command_pattern; use std::error::Error; use std::any::Any; use command_pattern::*; fn main() -> Result<(), Box<Error>> { let mut inv: Invoker<Box<dyn Any>> = Invoker::new(); let result = exec_or_undo_all!(inv, { exec: move { println!("exec 1"); Ok(Box::new("i a...
true
8b1b2f4d48def979b339b6a5590870648503b701
Rust
TGElder/rust
/frontier/src/pathfinder/pathfinder.rs
UTF-8
19,721
2.546875
3
[ "CC-BY-4.0" ]
permissive
use crate::travel_duration::*; use commons::grid::Grid; use commons::index2d::*; use commons::manhattan::ManhattanDistance; use commons::*; use network::algorithms::ClosestOrigins; use network::ClosestTargetResult as NetworkClosestTargetResult; use network::Edge as NetworkEdge; use network::Network; use std::collection...
true
bcaf9d3f99e0a68e63e1e63442583929a21db891
Rust
EFanZh/LeetCode
/src/problem_0594_longest_harmonious_subsequence/iterative.rs
UTF-8
947
3
3
[]
no_license
pub struct Solution; // ------------------------------------------------------ snip ------------------------------------------------------ // use std::collections::HashMap; impl Solution { pub fn find_lhs(nums: Vec<i32>) -> i32 { let mut counts = HashMap::with_capacity(nums.len()); for num in nu...
true
0a2ba570d42aa5f8f327f04510c432e9394662f2
Rust
randombit/botan-rs
/botan-sys/tests/tests.rs
UTF-8
2,809
2.625
3
[ "MIT" ]
permissive
extern crate botan_sys; use std::ffi::CString; use botan_sys::*; #[test] fn test_hex() { let bin = vec![0x42, 0x23, 0x45, 0x8F]; let mut out = Vec::new(); out.resize(bin.len() * 2, 0); unsafe { assert_eq!( botan_hex_encode(bin.as_ptr(), bin.len(), out.as_mut_ptr(), 0), ...
true
2c2f10806286ec065cb281031338e2cc84722d4f
Rust
ThomasZumsteg/adventofcode2015
/day16.rs
UTF-8
2,161
3.15625
3
[]
no_license
use common::get_input; use std::collections::HashMap; use regex::Regex; type Input = Vec<HashMap<String, usize>>; fn part1(sues: &Input) -> usize { let facts = HashMap::from([ ("children", 3), ("cats", 7), ("samoyeds", 2), ("pomeranians", 3), ("akitas", 0), ("vizsl...
true
14c8f3d4108b23e7ed59648d781626b8e30e6b01
Rust
Artemkaaas/indy-sdk
/vcx/dummy-cloud-agent/src/indy/wallet_plugin.rs
UTF-8
10,374
2.578125
3
[ "Apache-2.0" ]
permissive
use std::ffi::CString; use indyrs::ErrorCode; use libc::c_char; use serde_json::Value; use crate::utils::dyn_lib::load_lib; pub fn load_storage_library(library: &str, initializer: &str) -> Result<libloading::Library, String> { debug!("Loading storage plugin '{:}' as dynamic library.", library); match load_li...
true
54e754ffadcb5fcf6f930b7a4f2071852249f7e5
Rust
dsouzadyn/smsh
/src/main.rs
UTF-8
2,274
3.46875
3
[]
no_license
use std::io::{self, Write}; use std::process::Command; use std::collections::HashMap; #[derive(PartialEq)] struct ShellCommand { name:&'static str, command_type: CommandType, } #[derive(PartialEq)] enum CommandType { INBUILT = 0, CUSTOM = 1, } fn flush(stdout: &mut io::Stdout) { stdout.flush().ex...
true
ef6c2c51eafc68bf4901f57a10fb317bd1792fb3
Rust
sgravrock/adventofcode
/2020/rust/day3p1/src/main.rs
UTF-8
1,793
3.3125
3
[ "MIT" ]
permissive
mod input; use std::collections::HashMap; fn main() { println!("{}", n_trees_visited(&Grid::parse(input::puzzle_input()))); // 153 } #[derive(PartialEq, Eq, Hash, Debug)] struct Coord { x: usize, y: usize } #[derive(PartialEq, Eq, Debug)] struct Grid { pattern: HashMap<Coord, char>, max: Coord, } impl Grid...
true
914121a5e5e80c8426a83ccb87ec963635bb9048
Rust
Jason-Cooke/gluon
/base/src/resolve.rs
UTF-8
10,096
2.75
3
[ "MIT" ]
permissive
use std::borrow::Cow; use crate::{ fnv::FnvMap, symbol::Symbol, types::{AliasRef, Type, TypeContext, TypeEnv, TypeExt}, }; quick_error! { #[derive(Debug, PartialEq)] pub enum Error { UndefinedType(id: Symbol) { description("undefined type") display("Type `{}` does n...
true
bb902ddcf6a6eb98e82875552ca71bc00f11473c
Rust
richard-dennehy/raytracer_rs
/src/renderer/render.rs
UTF-8
3,183
2.859375
3
[]
no_license
use super::*; use crate::core::Colour; use crate::scene::World; use smallvec::SmallVec; use std::fmt; use std::fmt::{Display, Formatter}; use std::num::NonZeroU8; use std::slice::Iter; /// # Parameters /// `show_progress`: set to `true` when using e.g. `cargo run` for real-time progress updates; /// s...
true
be9ed04478088200e0e142961076db4fed79f37d
Rust
simon-auch/rust_GrandiOS
/GrandiOS/src/utils/exceptions/software_interrupt.rs
UTF-8
8,088
2.671875
3
[]
no_license
//Syscalls interface //How should a syscall look like (example read_char): // 1. reserve space for the return value of the syscall // 2. create a pointer to the reserved space for the return value // 3. reserve space for the parameters of the syscall // 4. create a pointer to the reserved space for the parameters /...
true
8f1b2ea97f80ed9c693c2b7060edeb2be6c3a9bc
Rust
GarmOfGnipahellir/advent-of-code
/2022/src/bin/10.rs
UTF-8
5,447
3.5625
4
[]
no_license
fn main() { println!("01: {}", part01(include_str!("../inputs/10"))); println!("02:"); part02(include_str!("../inputs/10")); } #[derive(Debug, PartialEq, Clone, Copy)] enum Instruction { NoOp, AddX(i32), } impl Instruction { fn parse(s: &str) -> Self { match s { "noop" => S...
true
99a2b5005196f216965f23b2adeb0f29f4ef3737
Rust
ThomasdenH/casimir-fdfd
/src/greenfunctions/cosinebasis.rs
UTF-8
10,138
2.921875
3
[ "MIT" ]
permissive
use crate::config::SimulationConfig; use crate::fields::{ScalarField, VectorField}; use crate::greenfunctions::operator::{Operator, OperatorType}; use nalgebra::*; use pbr::ProgressBar; use std::f32::consts::PI; use std::io::Stdout; use std::sync::{Arc, Mutex}; /// Determines a direction in space. #[derive(Eq, Partial...
true
f60306d2e952f7c5276a2a6b27bc4e5b6b17639b
Rust
iCalculated/RandomImage
/benches/number_gen_bench.rs
UTF-8
1,076
2.75
3
[ "MIT" ]
permissive
#[macro_use] extern crate criterion; extern crate rand; use criterion::Criterion; use rand::Rng; use rand::distributions::{Distribution, Uniform}; fn get_uniform() -> (u8, u8, u8) { let mut rng = rand::thread_rng(); let uniform = Uniform::from(1..255); (uniform.sample(&mut rng), uniform.sample(&mut rng),...
true
07bb3af1cb33fc37f9b6811afa86a594842a032c
Rust
EzgiS/rust-ncc
/src/animator/mod.rs
UTF-8
3,843
2.6875
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::math::v2d::V2D; use crate::world::{Cells, Snapshot}; use crate::NVERTS; use cairo::{Context, Format, ImageSurface}; use std::io::Write; use std::path::Path; use std::process::{Command, Stdio}; fn set_background(context: &Context) { context.set_source_rgb(1.0, 1.0, 1.0); context.paint(); } fn draw_c...
true
6414b316e4f6da90564f2c6741fff67c94d72a9f
Rust
muthu95/ART
/src/node48.rs
UTF-8
5,776
2.765625
3
[]
no_license
use std; use std::{mem, ptr}; use crate::constants; use crate::node256; use crate::node16; use crate::key_interface; use crate::art_node_base; use crate::art_nodes; use crate::art_node_interface; macro_rules! make_array { ($n:expr, $constructor:expr) => {{ let mut items: [_; $n] = std::mem::uninitialized()...
true
cb589fc40cbce5cfabe643808e4b9c09ce8cc8f0
Rust
starblue/advent_of_code
/a2018/src/bin/a201814a.rs
UTF-8
1,647
3.5
4
[]
no_license
use std::fmt; struct State { data: Vec<usize>, i1: usize, i2: usize, } impl State { fn next(&mut self) { let d1 = self.data[self.i1]; let d2 = self.data[self.i2]; let n = d1 + d2; if n >= 10 { self.data.push(1); } self.data.push(n % 10); ...
true
2f4ae92461e11fd5287b04a0b876452a4faf32a0
Rust
thibautRe/rustrogueliketutorial
/chapter-34-vaults/src/map_builders/waveform_collapse/mod.rs
UTF-8
5,480
2.703125
3
[ "MIT" ]
permissive
use super::{MapBuilder, Map, TileType, Position, spawner, SHOW_MAPGEN_VISUALIZER, generate_voronoi_spawn_regions, remove_unreachable_areas_returning_most_distant}; use rltk::RandomNumberGenerator; use std::collections::HashMap; mod common; use common::*; mod constraints; use constraints::*; mod solver; use solver::...
true
72c4b9a20bd9414c020c9f066fd86640f76266bd
Rust
isgasho/cio
/cio/src/main.rs
UTF-8
7,801
2.671875
3
[ "Apache-2.0" ]
permissive
use std::{fs::File, sync::Arc}; use cio_api::{ applicants::{Applicant, Applicants}, auth_logins::{AuthUser, AuthUsers}, configs::{ Building, Buildings, ConferenceRoom, ConferenceRooms, Group, Groups, Link, Links, User, Users, }, db::Database, journal_clubs::{JournalClubMeeting, ...
true
ecf2c2bcdc7ea91915d6d3d8dbde1d67b51b3ab5
Rust
anderspitman/nphysics
/src/volumetric/volumetric_capsule.rs
UTF-8
224
2.703125
3
[ "BSD-2-Clause" ]
permissive
use volumetric::cylinder_volume; use volumetric::ball_volume; /// Computes the volume of a capsule. pub fn capsule_volume(half_height: &N, radius: &N) -> N { cylinder_volume(half_height, radius) + ball_volume(radius) }
true
ab33bebac561d743a8446cbdcc64c78ee74ea568
Rust
tafia/rulinalg
/src/matrix/decomposition.rs
UTF-8
54,876
3.0625
3
[ "MIT" ]
permissive
//! Matrix Decompositions //! //! References: //! 1. [On Matrix Balancing and EigenVector computation] //! (http://arxiv.org/pdf/1401.5766v1.pdf), James, Langou and Lowery //! //! 2. [The QR algorithm for eigen decomposition] //! (http://people.inf.ethz.ch/arbenz/ewp/Lnotes/chapter4.pdf) //! //! 3. [Computation of the ...
true
9b005ec1bca94dd67a01471b6ac54974fe9a7fa5
Rust
Hanaasagi/kurumi
/memory/src/frame.rs
UTF-8
1,074
3.25
3
[ "MIT" ]
permissive
use super::PAGE_SIZE; use super::PhysicalAddress; #[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] pub struct Frame { pub number: usize, } impl Frame { pub fn containing_address(address: usize) -> Frame { Frame { number: address / PAGE_SIZE } } pub fn start_address(&self) -> PhysicalAddress {...
true
b003bce2d5146df8b95093aeaffabc8c08b66d06
Rust
Naalunth/aoc_2018
/src/year2018/day01.rs
UTF-8
1,681
2.90625
3
[]
no_license
type GeneratorOut = Vec<i64>; type PartIn = [i64]; #[aoc_generator(day1)] pub fn gen(input: &str) -> GeneratorOut { input .lines() .map(|l| l.parse::<i64>().unwrap()) .collect::<Vec<_>>() } #[aoc(day1, part1)] pub fn p1(input: &PartIn) -> i64 { input.iter().sum::<i64>() } #[aoc(day1, part2)] pub fn p2(input:...
true
dda271c5c5a7d3b6746074a764606bf2160fca54
Rust
elpiel/adex-validator-stack-rust
/validator/src/infrastructure/sentry.rs
UTF-8
2,849
2.6875
3
[]
no_license
use domain::{Channel, ValidatorId}; use futures::compat::Future01CompatExt; use futures::future::{ok, try_join_all, FutureExt, TryFutureExt}; use futures::Future; use futures_legacy::Future as LegacyFuture; use reqwest::r#async::{Client, Response}; use reqwest::Error; use serde::Deserialize; use std::iter::once; #[der...
true
f2c5f500c4d31caa314b269e4995bf8f59e16572
Rust
sharnoff/passman
/src/subcmd/update.rs
UTF-8
1,002
2.625
3
[ "MIT" ]
permissive
//! Tools for updating a storage file use super::print_err_and_exit; use crate::version::{self, FileContent}; use std::fs::File; use std::io::{self, Write}; use std::path::PathBuf; #[derive(clap::Args)] pub struct Args { /// Sets the input file to read from #[clap(short, long)] input: PathBuf, /// Se...
true
86d39efda4852600a98e7ffb414fdf7884e7439a
Rust
Knabin/Rust-Study
/4.3_slices/src/main.rs
UTF-8
2,250
4.25
4
[]
no_license
fn main_1() { let mut s = String::from("Hello world"); let word = first_word(&s); // word == 5 s.clear(); // s == "" // word는 5를 가지고 있겠지만, 5라는 값을 의미 있게 쓸 수 있는 String이 존재하지 않는다. } // word는 유효하지 않다. fn first_word(s: &String) -> usize { // String을 요소별로 보면서 공백인지 확인해야 하므로 byte 배열로 전환한다. let by...
true
79a0e239140056b6310da30e8030867991f69ec6
Rust
mtratsiuk/mtratsiuk.github.io
/rustache/src/rustache.rs
UTF-8
13,395
2.78125
3
[ "Unlicense" ]
permissive
use std::collections::HashMap; use std::error::Error; use std::path::Path; use std::{fs, result}; use crate::pipe::{self}; use crate::ron; use crate::ron::Value as RonValue; pub type Result<T> = result::Result<T, Box<dyn Error>>; type TemplatePair = (u8, u8); const TEMPLATE_NAME: &str = "index.rustache"; const VARI...
true
7f78e9997e0833c627b42655558b3056d85365a0
Rust
WillQu/woodpusher
/src/game.rs
UTF-8
45,806
2.96875
3
[ "MIT" ]
permissive
use im::Vector; use board::Board; use board::Piece; use board::PieceType; use board::Player; use board::Position; mod bishop; mod king; mod knight; mod move_list; mod pawn; mod queen; mod rook; #[derive(Clone, Debug, PartialEq)] pub struct Game { board: Board, player_turn: Player, en_passant: Option<Posi...
true
e0592a86efb6391ec833d295b2bf93c21ea31dd4
Rust
danielCutipa/migration_csv_to_postgresql
/src/main.rs
UTF-8
14,009
2.84375
3
[]
no_license
#![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate rocket; extern crate chrono; extern crate migration_csv_to_postgresql; extern crate postgres; use chrono::offset::{TimeZone, Utc}; use postgres::{Connection, TlsMode}; use std::fs::File; use std::io::{BufRead, BufReader}; use migration_csv_to_postg...
true
a272ae72dc7345f902c30fa03e0c5217f8481821
Rust
micxjo/rust-advent
/src/day16.rs
UTF-8
2,198
2.875
3
[ "MIT" ]
permissive
use std::collections::HashMap; fn check_thing(analysis: &HashMap<String, u32>, thing: &str, count: u32, part: u32) -> bool { let real_count = analysis.get(thing).unwrap(); if part == 2 && (thing == "cats:" || thing == "trees:") { &count > real...
true
a1f6958c65dc00e82cc3568d5370cfd8c1629289
Rust
isgasho/algorithm-1
/tests/test_strings_alphabet.rs
UTF-8
566
2.875
3
[ "MIT" ]
permissive
use algo::strings::alphabet; #[test] fn t_alphabet() { let s = "NowIsTheTimeForAllGoodMen"; let encoded = alphabet::BASE64.to_indices(s); let decoded = alphabet::BASE64.to_chars(&encoded); assert_eq!(s, decoded); let s = "AACGAACGGTTTACCCCG"; let encoded = alphabet::DNA.to_indices(s); let ...
true
3e115cb9e35f83d69291fc9a295710a8eda62630
Rust
AIT-S/solidity-rs
/solast/src/analysis/ineffectual_statements.rs
UTF-8
4,987
3.125
3
[ "MIT" ]
permissive
use solidity::ast::*; use std::io; pub struct IneffectualStatementsVisitor; impl IneffectualStatementsVisitor { fn print_message( &mut self, contract_definition: &ContractDefinition, definition_node: &ContractDefinitionNode, source_line: usize, description: &str, ex...
true
ef8d20c6319f3a590978a4a7d03395201a292e0a
Rust
rust-lang/rust
/src/tools/clippy/tests/ui/mem_replace.rs
UTF-8
3,608
2.96875
3
[ "Apache-2.0", "MIT", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "LicenseRef-scancode-other-permissive" ]
permissive
#![allow(unused)] #![warn( clippy::all, clippy::style, clippy::mem_replace_option_with_none, clippy::mem_replace_with_default )] use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque}; use std::mem; fn replace_option_with_none() { let mut an_option = Some(1)...
true
70fa4f3182c5d66959edf8e5bdda919ed20faa80
Rust
wasmerio/wasmer
/lib/virtual-fs/src/builder.rs
UTF-8
6,015
2.75
3
[ "MIT" ]
permissive
use crate::random_file::RandomFile; use crate::{FileSystem, VirtualFile}; use std::path::{Path, PathBuf}; use tracing::*; use super::ZeroFile; use super::{DeviceFile, NullFile}; use crate::tmp_fs::TmpFileSystem; pub struct RootFileSystemBuilder { default_root_dirs: bool, default_dev_files: bool, add_wasme...
true
bf786bc88ce7d82d97db4d68a4379aad2c40af78
Rust
hcorrada/rusty_rosalind
/approximate_matching/src/main.rs
UTF-8
1,527
2.875
3
[]
no_license
extern crate itertools; extern crate rosalind_lib; use std::env; use std::fs::File; use std::io::BufReader; use std::io::BufRead; use itertools::Itertools; use rosalind_lib::kmers::find_matches; /// read input /// pub fn read_input(filename: &str) -> (String, String, usize) { let fhandle = File::open(filename) ...
true
aa10ec6dc22bf95af266435e804f2f745644cdd8
Rust
Liamolucko/differential-datalog
/rust/template/differential_datalog/src/program/timestamp.rs
UTF-8
2,834
2.953125
3
[ "MIT" ]
permissive
//! Datalog timestamps use abomonation::Abomonation; use differential_dataflow::lattice::Lattice; use num::One; use std::{ ops::{Add, Mul}, sync::atomic::AtomicU32, }; use timely::{ order::{PartialOrder, Product}, progress::{PathSummary, Timestamp}, }; /// 16-bit timestamp. // TODO: get rid of this an...
true
b04b879215504a2d52c4c65695c2a89890f339e3
Rust
seanwallawalla-forks/nushell
/crates/nu-command/tests/commands/drop.rs
UTF-8
1,188
3.046875
3
[ "MIT" ]
permissive
use nu_test_support::{nu, pipeline}; #[test] fn columns() { let actual = nu!( cwd: ".", pipeline(r#" echo [ [arepas, color]; [3, white] [8, yellow] [4, white] ] | drop column | get | lengt...
true
64bf72d314e82c2f626a5eda6850e03cc4dd3363
Rust
hawkw/mycelium
/maitake/src/task.rs
UTF-8
51,075
2.78125
3
[ "MIT" ]
permissive
//! The `maitake` task system. //! //! This module contains the code that spawns tasks on a [scheduler], and //! manages the lifecycle of tasks once they are spawned. This includes the //! in-memory representation of spawned tasks (the [`Task`] type), and the //! handle used by the scheduler and other components of the...
true
810dbb4b9b8052816910b6735174fcbe8b410a50
Rust
robatipoor/cbs
/src/user_group.rs
UTF-8
1,335
2.9375
3
[ "Apache-2.0", "MIT" ]
permissive
use log::*; use users; #[derive(Debug)] pub struct UserGroup { user: Option<String>, group: Option<String>, } impl Default for UserGroup { /// Returns current UserGroup fn default() -> UserGroup { let user = users::get_current_username() .or_else(|| { error!("unable...
true
cef0dc9e0e085e0c5d4b356e31671f102e7522ba
Rust
Devolutions/siquery-rs
/siquery/src/common/services.rs
UTF-8
5,145
3.15625
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::tables::{EtcServices,EtcServicesIface}; use regex::Regex; use std::str::FromStr; use std::borrow::Borrow; cfg_if! { if #[cfg(target_os = "linux")] { use crate::linux::EtcServicesReader; } else if #[cfg(target_os = "macos")] { use crate::macos::EtcServicesReader; } else if #[cfg(ta...
true
a9cf68e96b5a87863025f41ccc702fb8dca55e41
Rust
bitex-la/tiny_ram_db
/src/lib.rs
UTF-8
4,277
3
3
[]
no_license
/* TODO: * - Make db available to all Records. * - Serialize and deserialize db from jsonapi. */ #[macro_use] extern crate error_chain; #[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; pub extern crate hashbrown; use std::cmp::Eq; use hashbrown::{HashMap, HashSet}; use std::...
true
089a92807b09e5768e2d07156d7c3666d151bd5c
Rust
andyrsmith/learnRust
/src/pin_cracker.rs
UTF-8
2,763
4.15625
4
[]
no_license
///Takes a random number which it calls a pin, and then tells you how fast it will take to crack it. extern crate time; //look a struct struct Point { x: int, y: int, } enum OptionalInt { Value(int), Missing, } fn main(){ //i means integer let (code, five) = (111995i, 5i); mult_value(); a_struct(...
true
e1ec6f9e54ca3f0c7c8abf27ee7f517afc608ca6
Rust
phil-opp/redox-kernel
/src/arch/x86_64/interrupt/syscall.rs
UTF-8
1,729
2.640625
3
[ "MIT" ]
permissive
use arch::x86_64::pti; use syscall; #[naked] pub unsafe extern fn syscall() { #[inline(never)] unsafe fn inner(stack: &mut SyscallStack) -> usize { let rbp; asm!("" : "={rbp}"(rbp) : : : "intel", "volatile"); syscall::syscall(stack.rax, stack.rbx, stack.rcx, stack.rdx, stack.rsi, stack...
true
8dd7482cd33b82b2f6d3276daa128e368e0e7896
Rust
rgardner/bsh-rs
/src/builtins/history.rs
UTF-8
1,879
3.265625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use crate::{ builtins::{self, prelude::*}, editor::Editor, }; pub struct History; impl builtins::BuiltinCommand for History { const NAME: &'static str = builtins::HISTORY_NAME; const HELP: &'static str = "\ history: history [-c] [-s size] [n] Display the history list with line numbers. Argument o...
true
a59f94df228e312274836a0b165c7f9a494e3801
Rust
mathiznogoud/wasabi
/lib/wasm/src/binary.rs
UTF-8
27,492
2.6875
3
[ "MIT" ]
permissive
use std::io; use std::marker::PhantomData; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use ordered_float::OrderedFloat; use rayon::prelude::*; use wasabi_leb128::{ReadLeb128, WriteLeb128}; use crate::{BlockType, Idx, Limits, RawCustomSection, ValType}; use crate::error::{AddErrInfo, Error, ErrorKind, ...
true
7d5844e520de44fe3dbfdb002f2d1ae7dacbca3d
Rust
delewit/rust
/src/test/run-pass/where-clause-early-bound-lifetimes.rs
UTF-8
695
2.625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive", "MIT", "Unlicense", "BSD-3-Clause", "bzip2-1.0.6", "NCSA", "ISC", "LicenseRef-scancode-public-domain", "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
de980d7d8e37df95f92ea5f30afd45879462ac25
Rust
vx416/solana_play
/bank/program/src/instruction.rs
UTF-8
6,518
3
3
[]
no_license
use solana_program::instruction::{AccountMeta, Instruction}; // use crate::error::{self}; use solana_program::{program_error::ProgramError, pubkey::Pubkey}; use std::convert::TryInto; use std::iter::Inspect; use std::mem::size_of; #[repr(C)] #[derive(Clone, Debug, PartialEq)] pub enum BankInstruction { InitializeB...
true
079c9781152a5d88a8dfe4c9b09f58fd48ce32fa
Rust
xtremerui/gcf-resource
/src/check.rs
UTF-8
2,644
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
extern crate gcf_resource; extern crate hyper; extern crate hyper_rustls; extern crate yup_oauth2 as oauth2; extern crate google_cloudfunctions1 as cloudfunctions1; use cloudfunctions1::{Result, Error}; use std::default::Default; use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorag...
true
02fd908416c00b3631eaf09213960e81d63921ed
Rust
jay-tyler/rust_toy_raytracer
/src/lib.rs
UTF-8
4,454
2.875
3
[]
no_license
pub mod rays; pub mod vectors; pub mod hitable; pub mod sphere; pub mod camera; #[cfg(test)] mod test_vectors { // crate ray_tracer; use vectors; #[test] fn test_vector_fields() { // Stupid sanity test let v1 = vectors::ThreeVector(1.,2.,3.); assert_eq!(v1.0, 1.); } #[te...
true
7c55c2de3cd1c5891a2d730317d44ec6d19142dd
Rust
bickfordb/rust-euler
/one.rs
UTF-8
316
2.890625
3
[]
no_license
fn main() { println("one!"); let mut s : int = 0; let mut i : int = 1; loop { if i >= 1000 { break } if ((i % 3) == 0) { s += i; } else if ((i % 5) == 0) { s += i; } else { } i += 1; println("s:" + s.to_str()); } println("result: " + s.to_str()); }
true
476f7b0d4de9de4096a3dc87211f7ca8d7f299e6
Rust
y-usuzumi/survive-the-course
/survive-the-course-rs/src/problems/neetcode/arrays_and_hashing/Product_of_Array_Except_Self.rs
UTF-8
1,726
3.640625
4
[ "BSD-3-Clause" ]
permissive
// https://leetcode.com/problems/product-of-array-except-self/ pub struct Solution; impl Solution { // 以长度为6的数组,比如要计算index为2的值,其值为arr[0] * arr[1] * arr[3] * arr[4] * arr[5] // 亦即其前缀数组的积乘以后缀数组的积。 // 想象我们可以创建两个额外数组,其中一个存储所有到当前位置的前缀之积,另一个存储后缀之积。 // 创建前缀数组时,我们只需从前到后遍历一次;创建后缀数组时,只需反向遍历一次。 // 此题的挑战项目为:使...
true
9f8c40ef78ddd72ddee338705dcffd459059b928
Rust
hortonberman/tun-driver
/examples/dump_iface.rs
UTF-8
1,537
3.546875
4
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
//! An example of reading from tun //! //! It creates a tun device, sets it up (using shell commands) for local use and then prints the //! raw data of the packets that arrive. //! //! You really do want better error handling than all these unwraps. extern crate tun_tap; use std::process::Command; use tun_tap::{Iface...
true
07a66996ee770cbb02e4082e03ebbcf730815bf9
Rust
misoton665/skylink
/src/domain/link.rs
UTF-8
409
2.890625
3
[]
no_license
#[derive(RustcDecodable, RustcEncodable, Clone, Debug)] pub struct Link { pub id: String, pub path: String, pub has_gitrep: bool, } impl Link { pub fn new(id: &'static str, path: &'static str, has_gitrep: bool) -> Link { Link{id: id.to_string(), path: path.to_string(), has_gitrep: has_gitrep} } } impl P...
true
f16bf84e3607ea918b27df3d95b50f4ee17ead37
Rust
nabijaczleweli/bloguen
/tests/ops/output/wrapped_element/style_element/deserialisation/object/err.rs
UTF-8
2,029
2.6875
3
[ "MIT" ]
permissive
use toml::from_str as from_toml_str; use bloguen::ops::StyleElement; #[derive(Deserialize)] struct Data { pub data: StyleElement, } #[test] fn invalid_class() { let res: Result<Data, _> = from_toml_str("[data]\nclass = 'helnlo'\ndata = '//nabijaczleweli.xyz/kaschism/assets/column.css'\n"); assert_eq!(for...
true
df713293a9a82a129bf2e3636082d1259014134b
Rust
miquels/nntp-rs
/src/util/buffer.rs
UTF-8
10,587
3.546875
4
[ "MIT" ]
permissive
//! Buffer implementation like Bytes / BytesMut. //! //! It is simpler and contains less unsafe code. use std::default::Default; use std::fmt; use std::io::{self, Read, Write}; use std::marker::Unpin; use std::mem; use std::ops::{Deref, DerefMut}; use std::pin::Pin; use std::slice; use std::task::{Context, Poll}; use t...
true
9e2d2c2aaf59923e4871c22d0f193487a94ec307
Rust
gbutler69/rust-exercism
/diamond/src/lib.rs
UTF-8
775
3.28125
3
[]
no_license
pub fn get_diamond(c: char) -> Vec<String> { let mut result = Vec::new(); if !('A'..='Z').contains(&c) { return result; } let max_fill = c as usize - 'A' as usize; let width = max_fill * 2 + 1; for fill in (0..=max_fill).rev().chain(1..=max_fill) { let mut line = vec![b' '; width...
true
5e82efdbd8846bc9f67007d4f49dd3c1889e646a
Rust
Michael-F-Bryan/include_dir
/include_dir/src/metadata.rs
UTF-8
1,143
3.328125
3
[ "MIT" ]
permissive
use std::time::{Duration, SystemTime}; /// Basic metadata for a file. #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct Metadata { accessed: Duration, created: Duration, modified: Duration, } impl Metadata { /// Create a new [`Metadata`] using the number of seconds since the /// [`SystemTime...
true
46a6df07ddeb4b922083f84c4b05a0f6b897de88
Rust
parkovski/scifiweb
/model-mem/src/cache/messaging.rs
UTF-8
7,250
2.96875
3
[]
no_license
use std::collections::{BTreeMap, HashMap}; use std::collections::hash_map::Entry as HEntry; use std::collections::btree_map::Entry as BTEntry; use model::instance::Target; use model::instance::messaging::{Mailbox, MessagingError, Message, MessageThread}; pub struct MailboxCache { // Mailbox ID to mailbox mailboxe...
true
3fea4050d05f9584c1313138a08c65f77383700e
Rust
Mackirac/image_processing
/src/intensity/pow.rs
UTF-8
431
2.9375
3
[]
no_license
use crate::{ Transformation, ImageBuffer, Pixel }; pub struct Pow(pub f64); impl <PI: Pixel<Subpixel=u8> + 'static> Transformation<PI> for Pow { type PO = PI; fn transform (&self, mut image: ImageBuffer<PI, Vec<u8>>) -> ImageBuffer<Self::PO, Vec<u8>> { for pixel in image.iter_mut(...
true
c06cf4d1a6bde35ee5758aa407f3e589d31cbab4
Rust
hoangpq/edit-text
/build-tools/src/mdbook_bin/preprocessors.rs
UTF-8
2,579
2.984375
3
[ "Apache-2.0", "MIT" ]
permissive
//! Svgbob preprocessing use mdbook::book::{ Book, BookItem, }; use mdbook::errors::Error; use mdbook::preprocess::*; use regex::{ Captures, Regex, }; pub struct SvgbobPreprocessor; impl Preprocessor for SvgbobPreprocessor { fn name(&self) -> &str { "svgbob" } fn run(&self, ctx: ...
true
560a00bd94e5be0953cf110ceba75b73dae3db9f
Rust
AZanellato/AOC_2019
/four_2/src/main.rs
UTF-8
2,640
3.6875
4
[]
no_license
use std::collections::HashMap; fn main() { let lower_bound = 147_981; let upper_bound = 691_423; let count = (lower_bound..upper_bound) .filter(|n| check_not_decreasing(*n)) .filter(|n| check_for_double(*n)) .count(); println!("The count is: {}", count); } fn check_not_decrea...
true
f94b3fb4ba415bbc9c583721bd1c65f5957a7024
Rust
j-keck/clic
/tests/selftest-runner.rs
UTF-8
1,899
2.84375
3
[]
no_license
use env_logger::Env; use log::{debug, info}; use std::process::Command; use std::{ffi::OsStr, fs, path::PathBuf}; #[test] fn selftest_runner() { env_logger::from_env(Env::default().default_filter_or("info")).init(); let spec_files_path = "tests/selftest"; let entries = fs::read_dir(spec_files_path...
true
edf46d8d1ded1567d1953ef9d9fe5e129af9d442
Rust
MostafaAlnasr/idolsched
/src/cards_api/cache.rs
UTF-8
1,157
2.734375
3
[]
no_license
#![allow(dead_code)] // rustc spuriously considers this dead bc of #[cfg]s use serde::{Deserialize, Serialize}; use std::collections::HashMap; use super::{Error, Cfg}; use super::json_card::JsonCard; #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] pub struct CardCache { pub provider: String, pub...
true
2001a5f636c767bcd880a55a82ec614b2b1d4a2c
Rust
rebo/comp_state
/src/list.rs
UTF-8
7,232
3.25
3
[]
no_license
use crate::state_access::{CloneState, StateAccess}; use crate::state_functions::use_state; use slotmap::{new_key_type, DenseSlotMap, Key}; new_key_type! { pub struct ListKey; } pub fn use_list<T, F>(initial_list_fn: F) -> ListControl<T> where F: FnOnce() -> Vec<T>, T: Clone, { let list_access = use_st...
true
02f82a01c9fa59137e1da5d4078da1c37288326c
Rust
Arnavion/k8s-openapi
/src/v1_24/api/core/v1/http_get_action.rs
UTF-8
11,381
2.703125
3
[ "Apache-2.0" ]
permissive
// Generated from definition io.k8s.api.core.v1.HTTPGetAction /// HTTPGetAction describes an action based on HTTP Get requests. #[derive(Clone, Debug, Default, PartialEq)] pub struct HTTPGetAction { /// Host name to connect to, defaults to the pod IP. You probably want to set "Host" in httpHeaders instead. pub...
true
d756985b193c60a7885ca309c0d6c01bbcdff58f
Rust
redsnapper2006/leetcode-cn
/C/2315-count-asterisks/main.rs
UTF-8
285
3.046875
3
[]
no_license
struct Solution {} impl Solution { pub fn count_asterisks(s: String) -> i32 { let mut ret: i32 = 0; let mut cnt: i32 = 0; for b in s.chars() { if b == '|' { cnt += 1; } else if b == '*' && cnt % 2 == 0 { ret += 1; } } ret } }
true
f37b3a800a17d90775f0a5b1f2c7b8776ce75572
Rust
AndrewGrim/NoteMaker
/src/debug.rs
UTF-8
909
2.9375
3
[ "MIT" ]
permissive
#![allow(dead_code)] pub fn info(text: &str) { let color = "\x1b[94m"; let end = "\x1b[0m"; println!("{}{}{}", color, text, end); } pub fn ok(text: &str) { let color = "\x1b[96m"; let end = "\x1b[0m"; println!("{}{}{}", color, text, end); } pub fn success(text: &str) { let color = "\x1b[92...
true
b08ba0b277a6e1a37a28dd0552f1d668f32e43df
Rust
luketchang/Rust-HTTP-Server
/src/main.rs
UTF-8
704
2.78125
3
[]
no_license
#![allow(dead_code)] use std::env; use server::Server; use site_handler::SiteHandler; mod http; mod server; mod site_handler; /* Function: main * ______________ * - gets default path as the project's director with /public appended * - looks for another file path in as user environment variable and defaults to de...
true
bf02ebfc7fb54cc9fbceddd49afc756a5e8b5801
Rust
alexcrichton/rust-central-station
/run-on-change/src/main.rs
UTF-8
2,096
3.015625
3
[]
no_license
use sha1::Sha1; use std::path::{Path, PathBuf}; use std::error::Error; static CACHE_PATH: &str = "/tmp/run-on-change"; fn cached_path(url: &str) -> PathBuf { Path::new(CACHE_PATH).join(Sha1::from(url).digest().to_string()) } fn cached_hash(url: &str) -> Result<Option<String>, Box<Error>> { let path = cached_...
true
373aede2f888821a9fe33a86a67a884341d9d826
Rust
TakeZNt/bitonic-sorter
/src/first.rs
UTF-8
3,144
4.0625
4
[]
no_license
/// 配列をソートする /// # 引数 /// - array : 配列。ただし、要素数は2^nでなければならない /// - asc : 昇順の場合true、降順の場合false pub fn sort(array: &mut [u32], asc: bool) { if array.len() <= 1 { return; } // バイトニック列を作成する let mid = array.len() / 2; sort(&mut array[..mid], true); // 前半を昇順でソート sort(&mut array[mid..], false);...
true
243d41369bc3391fe3f009dd3ce713f3ebd6542e
Rust
megascrapper/rsgames
/src/gladiator_game/army.rs
UTF-8
3,918
3.359375
3
[]
no_license
use std::collections::VecDeque; use std::io; use crate::gladiator_game::fighter::{Archer, Cavalry, Fighter, Soldier}; enum ArmyFormation<'a> { Stack(Vec<Box<dyn Fighter + 'a>>), Queue(VecDeque<Box<dyn Fighter + 'a>>), } pub enum FormationType { Stack, Queue, } pub struct Army<'a> { name: String,...
true
aa9dd4c8a642beb07a46552e4cb7d522e7976c1e
Rust
Syfaro/advent-of-code-rs
/src/bin/2015-02.rs
UTF-8
4,345
3.625
4
[]
no_license
const PROBLEM_NAME: &str = "2015-02"; /// A package's three dimensions. #[derive(Clone, Debug, PartialEq)] struct Package { length: i32, width: i32, height: i32, } #[cfg(test)] impl Package { fn new(length: i32, width: i32, height: i32) -> Self { Self { length, width, ...
true
a3248007712499692dd71ca22c79fc0b9cfeb433
Rust
emilio/rkv
/src/store/integermulti.rs
UTF-8
4,515
2.703125
3
[ "Apache-2.0" ]
permissive
// Copyright 2018 Mozilla // // 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 writing, software...
true
92b2761724d7a3fa5e1e84d422d986ba57c5e8e5
Rust
felixmc/gerrit-cli
/src/gerrit.rs
UTF-8
4,888
2.515625
3
[]
no_license
use std::env; // use std::io::Read; // use ansi_term::Colour::{Red, Green}; use serde_json; use serde_json::*; use curl; pub enum ReviewResult { Rejected, Approved, Disliked, Liked, Neutral, } impl ReviewResult { pub fn value (&self) -> &str { match *self { ReviewResult::...
true
abcec4de682ddba6515c10253531a14f22b7c60c
Rust
alex/abscissa
/core/src/application/lock/reader.rs
UTF-8
745
3.234375
3
[ "Unlicense", "MPL-2.0", "MIT", "Apache-2.0" ]
permissive
//! Mutex guard for immutably accessing global application state use super::Application; use std::{ops::Deref, sync::RwLockReadGuard}; /// Generic `RwLockWriteGuard` for a `'static` lifetime. pub(crate) type Guard<T> = RwLockReadGuard<'static, T>; /// Wrapper around a `RwLockReadGuard` for reading global application...
true
589de5dd7ff3dd4c1f0f3226b0d1b477643284a6
Rust
Microsvuln/IRL
/src/lang/util.rs
UTF-8
3,515
3.34375
3
[]
no_license
use std::cell::{Ref, RefCell, RefMut}; use std::cmp::Ordering; use std::collections::HashSet; use std::hash::{Hash, Hasher}; use std::iter::FromIterator; use std::ops::Deref; use std::rc::Rc; /// A auxiliary structure to make `Rc` act like pointer. /// The extended behavior include pointer-equality testing and hash. p...
true
afe0b5d35ca54712da307324ff9660cc75bd5095
Rust
kubo/rosy
/src/mixin/class/classify.rs
UTF-8
1,110
2.71875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{ prelude::*, string::Encoding, vm::InstrSeq, }; /// A type that can be instantiated from a typed `Class` instance. pub trait Classify: Object { /// Returns the typed class that can be used to get an instance of `self`. fn class() -> Class<Self>; } macro_rules! impl_trait { ($($t:ty...
true
8be1ae2b1679034b41684a9f489131af04e10fc8
Rust
hpatjens/hmath
/src/vector.rs
UTF-8
9,642
3.0625
3
[]
no_license
use std::{ ops::{Add,AddAssign,Sub,SubAssign,Mul,MulAssign,Div,DivAssign,Neg}, mem, }; use crate::traits::*; use num_traits::Signed; use serde::{Serialize, Deserialize}; pub use float_cmp::{Ulps,ApproxEq}; macro_rules! implement_vector { ($type:ident { dim: $dim:expr, elems: { $($num:exp...
true
c7caeb9a37f0be38f33b37e51bfba63cdb6084d9
Rust
codyd51/axle
/rust_programs/ide/src/status_view.rs
UTF-8
2,126
2.546875
3
[ "MIT" ]
permissive
use agx_definitions::{ Color, Drawable, LayerSlice, LikeLayerSlice, NestedLayerSlice, Point, Rect, RectInsets, Size, }; use alloc::{ boxed::Box, format, rc::{Rc, Weak}, vec::Vec, }; use libgui::{ bordered::Bordered, button::Button, label::Label, ui_elements::UIElement, view::View, KeyCode, }; us...
true
179f87e78a400c1e5587a3b80a87ecbf7d49d54d
Rust
mitsuhiko/minijinja
/minijinja-contrib/src/globals.rs
UTF-8
433
2.59375
3
[ "Apache-2.0" ]
permissive
#[allow(unused)] use minijinja::value::Value; /// Returns the current time in UTC as unix timestamp. /// /// To format this timestamp, use the [`datetimeformat`](crate::filters::datetimeformat) filter. #[cfg(feature = "datetime")] #[cfg_attr(docsrs, doc(cfg(feature = "datetime")))] pub fn now() -> Value { let now ...
true
35dec8d5f047b950012628f114943d1b8569a886
Rust
sirlag/leftgang
/src/filters.rs
UTF-8
1,280
2.578125
3
[]
no_license
use crate::handlers; use sqlx::{Pool, Postgres}; use warp::Filter; pub fn movers( token: String, pool: Pool<Postgres>, ) -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone { move_users_to_new(token.clone(), pool.clone()) .or(move_users_to_original(token, pool)) .or(...
true
a8c9eff07bae3f1a1468322f7ec23f931b089f75
Rust
u5surf/rust_sample
/trait_boundary/trait_boundary.rs
UTF-8
573
3.4375
3
[]
no_license
trait DuckLike { fn quack(&self); fn walk(&self) { println!("walking"); } } struct Duck; impl DuckLike for Duck { fn quack(&self) { println!("quack"); } } impl DuckLike for i64 { fn quack(&self) { for _ in 0..*self { println!("quack"); } } } //generics type parameters that "para...
true
5d6d3363f3ea4a1a688d09111019618ab7eb6679
Rust
Frans-Willem/ZigbeeRustPlayground
/old_src/ieee802154/mac/frame.rs
UTF-8
23,378
2.53125
3
[]
no_license
use crate::ieee802154::{ExtendedAddress, ShortAddress, PANID}; use crate::parse_serialize::{ Deserialize, DeserializeError, DeserializeResult, DeserializeTagged, Serialize, SerializeError, SerializeResult, SerializeTagged, }; use bitfield::bitfield; #[cfg(test)] use std::convert::{TryFrom, TryInto}; /*=== Publ...
true
c64d4040a061289b008a4bbceeae4b153145d312
Rust
zaynetro/krokodil
/src/main.rs
UTF-8
20,592
2.640625
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::env; use std::sync::Arc; use std::time::{Duration, Instant}; use log::info; use serde::{Deserialize, Serialize}; use tokio::{ sync::{mpsc, Mutex}, time::interval, }; use uuid::Uuid; use warp::ws::Message; use warp::Filter; mod errors; mod games; use games::{CanvasSize...
true
727f6c68cad23da0e5fe63cc829a0ebead27c1c8
Rust
hermetique/rustzx
/rustzx-core/src/zx/keys.rs
UTF-8
1,619
3.453125
3
[ "MIT" ]
permissive
//! Module with hardware key port\masks /// Struct, which contains mast and port of key #[rustfmt::skip] #[derive(Clone, Copy)] pub enum ZXKey { // Port 0xFEFE Shift, Z, X, C, V, // Port 0xFDFE A, S, D, F, G, // Port 0xFBFE Q, W, E, R, T, // Port 0xF7FE N1, N2, N3, N4, N5, // Port 0...
true
2aeae10a67434fbb7c8bdc68f035ea7875d11ace
Rust
seungdols/practice
/rust/tuples/src/main.rs
UTF-8
309
3.28125
3
[]
no_license
fn main() { // let tup1 = (20, "Rust", 30, 35, false, 3.5, (1,4,7)); // println!("{}", tup1.5); let tup1 = (20, "Rust", 30); // let tup1 = (20, "Rust", 30, 45); // 아래 구문에서 에러 발생함. let (a, b, c) = tup1; println!("a: {}", a); println!("b: {}", b); println!("c: {}", c); }
true
16aa2af580c076c9089cd3728bde01bf3b1e1f99
Rust
wildarch/toy-compiler
/src/mips/instruction.rs
UTF-8
1,879
3.453125
3
[]
no_license
use std::fmt::{Formatter, Display, Error as FormatError}; use super::register::Register; use super::label::Label; #[derive(Debug)] pub enum Instruction { La(Register, Label), Add(Register, Register, Register), Addi(Register, Register, i32), Sub(Register, Register, Register), Seq(Register, Register,...
true
dac8300e9b0d5ad567fb59dc5b1256e27003a12f
Rust
pawanjay176/libp2p_test
/src/rpc/methods.rs
UTF-8
6,265
3.03125
3
[]
no_license
//! Available RPC methods types and ids. use ssz_derive::{Decode, Encode}; pub type Hash256 = String; /// Maximum number of blocks in a single request. pub const MAX_REQUEST_BLOCKS: u64 = 1024; /// Maximum length of error message. pub const MAX_ERROR_LEN: u64 = 256; /// Wrapper over SSZ List to represent error mes...
true
5f647f292087e6a488b2c534a24c29b73ed6dd7c
Rust
dialtone/advent
/advent11/src/solution.rs
UTF-8
3,467
3.140625
3
[ "MIT" ]
permissive
use crate::intcode; use std::collections::HashMap; use std::fmt::Display; pub fn part1(input: &str) -> impl Display { let mut computer = intcode::Computer::from(input); let mut board: HashMap<(isize, isize), isize> = HashMap::new(); // UP RIGHT DOWN LEFT let directions = vec![...
true
cb4e067ff24c4dadadc9d744097894d344614cab
Rust
shelbyd/kyber
/cli/src/refactorings/parser/lex.rs
UTF-8
1,297
3.296875
3
[]
no_license
use logos::*; use std::collections::*; pub type Tokens = VecDeque<Token>; pub fn lex(contents: &str) -> Result<Tokens, String> { let mut tokens = Token::lexer(contents); std::iter::from_fn(|| { Some(match tokens.next()? { Token::Error => Err(tokens.slice().to_owned()), t => Ok(...
true
66c58f77afa3f1574bcf7a7ea2f3e6547fe39634
Rust
cgdilley/AdventOfCode2018
/day01_0/src/main.rs
UTF-8
2,453
4.125
4
[]
no_license
use std::fs::File; use std::io; use std::io::prelude::*; fn main() { // Read the lines from the file let mut data = read_lines("../input/day1.txt").expect("Could not load file."); // Convert the lines into integers let numbers = extract_values(&mut data).expect("Could not parse lines."); // Calcu...
true
43ea0e6c45aa11ff607d25fc8d4c66f09e6fb81b
Rust
keroro520/shot
/src/utils/unspent.rs
UTF-8
1,030
2.640625
3
[]
no_license
use ckb_types::core::BlockNumber; use ckb_types::packed::{CellOutput, OutPoint}; use std::collections::HashMap; #[derive(Clone, Debug)] pub struct LiveCell { pub cell_output: CellOutput, pub out_point: OutPoint, pub tx_index: usize, pub block_number: BlockNumber, } #[derive(Clone, Debug)] pub struct U...
true
0c6e0805d9eeb1c1f92c5e9219aa2f08d9f04d84
Rust
omar2535/leetcode
/rust/src/problems/p344_reverse_string.rs
UTF-8
926
3.3125
3
[]
no_license
pub struct Solution; impl Solution { pub fn reverse_string(s: &mut Vec<char>) { if s.len() == 1 { return; } let midway_point = s.len() / 2; for i in 0..midway_point { let end_point = s.len() - i - 1; s.swap(i, end_point); } } } #[cf...
true
99a0b737df480f2beb7b230b5462084202e34093
Rust
Follpvosten/mudders
/src/lib.rs
UTF-8
27,514
3.578125
4
[ "MIT" ]
permissive
/*! Generate lexicographically-evenly-spaced strings between two strings from pre-defined alphabets. This is a rewrite of [mudderjs](https://github.com/fasiha/mudderjs); thanks for the original work of the author and their contributors! ## Usage Add a dependency in your Cargo.toml: ```toml mudders = "0.0.4" ``` Now...
true
405b2b62ef98708ef0209b57e8b8912147f1248e
Rust
UnHumbleBen/learning-todomvc
/src/controller.rs
UTF-8
7,315
2.90625
3
[]
no_license
// Controller needs access to Item, ItemQuery, and Store structs/enums. pub use crate::store::*; // Controller needs to send messages to View. pub use crate::view::ViewMessage; // Needs to add messages to the Scheduler. pub use crate::{Message, Scheduler}; // Used for generating ids. pub use js_sys::Date; pub use std::...
true
8e3cfbf2d761322b5eca8ce6a62370bc8a6ce953
Rust
cyndis/rust-edid
/src/lib.rs
UTF-8
5,862
2.578125
3
[ "MIT" ]
permissive
#[macro_use] extern crate nom; use nom::{be_u16, le_u8, le_u16, le_u32}; mod cp437; #[derive(Debug, PartialEq)] pub struct Header { pub vendor: [char; 3], pub product: u16, pub serial: u32, pub week: u8, pub year: u8, // Starting at year 1990 pub version: u8, pub revision: u8, } fn parse_vendor(v: u16) -> [c...
true