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
0c57b0937880a07fce3d18af4f33489a3c923646
Rust
BusyJay/pecan
/pecan/src/extension.rs
UTF-8
3,232
3.046875
3
[ "MIT" ]
permissive
use std::marker::PhantomData; use std::{ collections::{hash_map::Values, HashMap}, fmt::{self, Debug, Formatter}, }; use crate::prelude::*; use crate::Result; use bytes::{Bytes, BytesMut}; pub struct Extension<T, C> { tag: u64, _marker: PhantomData<(T, C)>, } impl<T, C> Extension<T, C> { pub cons...
true
214af850610d68561a4b1329775fb688e06628f4
Rust
MaiCw4J/leetcode.rs
/src/algorithms/nim_game_292.rs
UTF-8
212
2.984375
3
[]
no_license
// https://leetcode.com/problems/nim-game/ pub fn can_win_nim(n: i32) -> bool { n % 4 != 0 } #[cfg(test)] mod tests { use super::*; #[test] fn test() { assert!(can_win_nim(3)); } }
true
af38b03cb39f954adfd412f1c43c9311d5da6534
Rust
paulinerouvel/mypipe
/src/main.rs
UTF-8
1,225
3.09375
3
[]
no_license
extern crate clap; use clap::App; use std::process::Command; fn main() { let matches = App::new("mypipe") .version("1.0") .author("Pauline") .arg( clap::Arg::with_name("in") .takes_value(true) .long("in") .requires("out") ...
true
aedab96fe9e8fe649b0ab659bdaf8b5eb993e395
Rust
AdelaideAuto-IDLab/bTracked
/btracked-server/src/map.rs
UTF-8
2,185
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use std::io::Cursor; use image::{self, DynamicImage, ImageBuffer, RgbaImage, ImageFormat}; use na; use palette::{Hsv, rgb::LinSrgb, RgbHue}; use tracking::{GeometryConfig, geometry::World, distance_field::DistanceField}; fn to_color_image(field: &DistanceField) -> RgbaImage { ImageBuffer::from_fn(field.width, fi...
true
3d60fc9a1bd646bffc43f1a5282dc7479eb7993b
Rust
xelnagamex/desubot
/src/commands.rs
UTF-8
3,723
2.9375
3
[]
no_license
use crate::db; use crate::errors::Error; use html_escape::encode_text; use markov::Chain; use rand::Rng; use telegram_bot::prelude::*; use telegram_bot::{Api, Message, ParseMode}; pub(crate) async fn here(api: Api, message: Message) -> Result<(), Error> { let members: Vec<telegram_bot::User> = db::get_members(mess...
true
b0239d8ee28f4727dfdf337be658a490a1036b89
Rust
BenBergman/euler
/rust/0009.rs
UTF-8
532
3.046875
3
[]
no_license
#[cfg(not(test))] fn main() { } fn find_product_of_pythagorean_triplet_with_sum(n: u64) -> Option<u64> { for a in 1..n-2 { for b in a+1..n-a { let c = n - a - b; if a*a + b*b == c*c { return Some(a*b*c); } } } None } #[test] fn matches_...
true
66a0bae1fe2db496b47603b6401421e1e84a9b4f
Rust
tomasskare/advent_of_code_2016
/salkin-rust/day5/src/main.rs
UTF-8
1,461
2.921875
3
[]
no_license
extern crate input; extern crate crypto; use input::cli; use input::filereader; use crypto::md5; use crypto::digest::Digest; use std::slice; use std::str; const USAGE: &'static str = " Usage: day5 [--file=<FILE>] day5 (-h | --help) Options: -h --help show help --file=<FILE> Input file to use "; fn mai...
true
4c4674d73075d053fd5f3c15d51d914c7a029631
Rust
scr165/RustLang
/variables.rs
UTF-8
158
3.515625
4
[]
no_license
fn main() { let x=10; //assigning a varibale println!("the number is {}",x); //printing that varibale x=11; println!("the number is {}",x); }
true
0db13f8d4d957aa39a6a4f58774754723e0378dd
Rust
4meta5/signatory
/providers/signatory-yubihsm/src/error.rs
UTF-8
673
2.65625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![allow(unused_macros)] /// Create a new error (of a given enum variant) with a formatted message macro_rules! err { ($variant:ident, $msg:expr) => { ::signatory::error::Error::new( ::signatory::error::ErrorKind::$variant, Some($msg) ) }; ($variant:ident, $fmt:expr,...
true
54b681db28c292611e0435da7a1898372dd4dc49
Rust
katyo/gear
/src/refs.rs
UTF-8
2,295
2.796875
3
[]
no_license
#[cfg(not(feature = "parallel"))] use std::cell::RefCell; #[cfg(feature = "parallel")] use std::sync::RwLock as RefCell; #[cfg(not(feature = "parallel"))] pub use std::{ cell::{Ref as ReadRef, RefMut as WriteRef}, rc::{Rc as Ref, Weak}, }; #[cfg(feature = "parallel")] pub use std::sync::{Arc as Ref, RwLockRe...
true
4b5f85f91f11d9a490b2b20016e68b1cf2c952b5
Rust
mjkillough/rust-asgi-server
/src/msgs/http.rs
UTF-8
1,180
2.859375
3
[]
no_license
// We need to wrap Vec<u8>/&[u8] in this in order to make sure serde // serializes it as a byte string rather than a list of bytes. use serde::bytes::{ByteBuf, Bytes}; #[derive(Debug, Serialize)] pub struct Request<'a> { pub reply_channel: &'a str, pub http_version: &'a str, pub method: &'a str, pub s...
true
45a8571bb1d9e608efa75ca603edf41d3f014997
Rust
ccmlm/hotstuff-consensus
/pacemaker/src/elector.rs
UTF-8
830
2.6875
3
[]
no_license
//! leader election. use hs_data::{ReplicaID, ViewNumber}; pub struct RoundRobinLeaderElector { // next_leader = (this_leader + 1) % peers_nums round_mapper: Vec<ReplicaID>, } impl RoundRobinLeaderElector { pub fn init(&mut self, replicas: impl IntoIterator<Item = ReplicaID>) { let mut tmp = repl...
true
329ce7800d8b2d5cdef62d2a1ea41cf639d3de23
Rust
ackintosh/sandbox
/rust/crate-tokio/src/interval.rs
UTF-8
421
2.53125
3
[]
no_license
use tokio::time::Duration; #[test] fn interval() { let mut count = 0; let runtime = tokio::runtime::Runtime::new().unwrap(); runtime.block_on(async move { let mut interval = tokio::time::interval(Duration::from_secs(2)); loop { interval.tick().await; dbg!(); ...
true
946153e65a7ce1d3a0cf2de6be1a0bf66cbe23bb
Rust
Mackirac/lzw
/src/main.rs
UTF-8
3,506
3
3
[]
no_license
#![allow(dead_code)] extern crate bit_vec; use bit_vec::BitVec; use std::iter::repeat; use std::iter::FromIterator; use std::collections::HashMap; type EDict = HashMap<(usize, usize), usize>; type DDict = HashMap<usize, (usize, usize)>; fn bin (n: usize, len: usize) -> Result<Vec<bool>, String> { let b = format...
true
4fcd4b235229b035d8d0faf1e71f7a449aa4719a
Rust
baitcenter/gdlk
/api/src/vfs/program.rs
UTF-8
7,885
2.75
3
[]
no_license
//! Handlers for files specific to a hardware spec/program spec combo. Structure //! looks like: //! //! ``` //! <program_spec_slug>/ //! spec.txt //! program.gdlk //! ``` use crate::{ error::{Result, ServerError}, models::{NewUserProgram, ProgramSpec, UserProgram}, schema::{program_specs, user_program...
true
458dae32a366e1b48d4442f010aca85a22b1fc77
Rust
pandaman64/saikyou
/src/alpha.rs
UTF-8
4,176
3.1875
3
[]
no_license
//! alpha renaming use std::collections::HashMap; use crate::ast::*; use crate::parser::ParserExt; type ParserExpr<'s> = Expr<ParserExt<'s>>; type ParserFunc<'s> = Function<ParserExt<'s>>; pub type AlphaExpr = Expr<AlphaExt>; pub type AlphaFunc = Function<AlphaExt>; #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash...
true
c6898038355728864d586f64781a589127ed5291
Rust
adjivas/computor-v1
/src/polynomial/order/mod.rs
UTF-8
3,372
2.984375
3
[]
no_license
// @adjivas - github.com/adjivas. See the LICENSE // file at the top-level directory of this distribution and at // https://github.com/adjivas/computor-v1 // // This file may not be copied, modified, or distributed //! This module `order`'s interface is a list of term. pub mod term; use self::term::Term; use self::t...
true
72732cf095a74bc7e9a42eed8f3066bc30a4968f
Rust
Iniesta8/aoc2020
/src/bin/day02.rs
UTF-8
1,636
3.375
3
[]
no_license
use std::fs; struct PasswordData { min: usize, max: usize, ch: char, pw: String, } impl PasswordData { fn parse_input(s: &str) -> Option<PasswordData> { let mut token: Vec<&str> = s.split_whitespace().collect(); let pw = token.pop()?.to_string(); let ch = token.pop()?.char...
true
bf3bf6db239a3a5d80dc7d73cbbc65b5c0043467
Rust
willi-kappler/rayon
/src/par_iter/internal.rs
UTF-8
5,913
3.125
3
[]
no_license
//! Internal traits and functions used to implement parallel //! iteration. These should be considered highly unstable: users of //! parallel iterators should not need to interact with them directly. //! See `README.md` for a high-level overview. use join; use super::IndexedParallelIterator; use super::len::*; pub tr...
true
403f30b2b9afc7441c0b3a06df753fe8ec40eb2c
Rust
magj2006/Essential-Rust
/pascals-triangle/src/lib.rs
UTF-8
1,155
3.40625
3
[]
no_license
pub struct PascalsTriangle { rows: Vec<Vec<u32>>, } impl PascalsTriangle { pub fn new(row_count: u32) -> Self { let mut rows = vec![]; for n in 1..=row_count { match n { 1 => rows.push(vec![1]), 2 => rows.push(vec![1, 1]), n if n > 2 ...
true
69a1628648cc29926b4c9ae6bb2fa0fe3fc08ce6
Rust
yoiang/chip-8_rust
/base/src/instruction.rs
UTF-8
2,856
3.109375
3
[]
no_license
use std::{convert::TryInto, fmt}; pub struct Instruction { first: u8, second: u8 } // TODO: remove panics // TODO: double check trading in [bool; x]s vs one or two bytes from a design perspective impl Instruction { pub fn new(first: u8, second: u8) -> Instruction { Instruction { first...
true
19130dc7f3b509d7ee9754e49eb128f1728ce8a1
Rust
jiraffe1/knight
/rust/src/value.rs
UTF-8
7,830
3.25
3
[ "MIT" ]
permissive
use crate::{Function, Number, RcStr, RuntimeError}; use std::fmt::{self, Debug, Formatter}; use std::rc::Rc; use std::convert::TryFrom; #[derive(Clone)] pub enum Value { Null, Boolean(bool), Number(Number), String(RcStr), Variable(String), Function(Function, Rc<[Value]>) } impl Default for Value { fn default()...
true
9bea204341e1d76d6996682495515c69ffe8b11a
Rust
ebenpack/rtiaw
/src/material/dielectric.rs
UTF-8
1,899
3.109375
3
[ "MIT" ]
permissive
use crate::color::Color; use crate::material::Material; use crate::object::HitRecord; use crate::ray::Ray; use crate::vec3::Vec3; use rand::Rng; pub struct Dielectric { refraction_index: f64, } impl Dielectric { pub fn new(refraction_index: f64) -> Dielectric { Dielectric { refraction_index } } ...
true
5d667e95092f8f9fec225876cfa1f8be4f1b2259
Rust
turbosree/Cypher-Analytics
/Secure-UUID/src/main.rs
UTF-8
1,634
3.28125
3
[]
no_license
// A universally unique identifier (UUID) is a 128-bit label used to // identify entities in a distibuted system. // UUID can be generated using the X509 certificate data by simply // creting a SHA256 of the bytes and taking the first 16 bytes of the // hash. // In general, a 16-byte (i.e., 128-bit) unique ID generat...
true
274e60294ff50f84ca38367bf2fbb33fc3bc9f68
Rust
notarize/qlc
/tests/helpers/cmd.rs
UTF-8
7,734
2.65625
3
[ "MIT" ]
permissive
use assert_cmd::assert::Assert; use assert_cmd::prelude::*; use assert_fs::prelude::*; use predicates::str as p_str; use predicates::Predicate; use std::env; use std::fs; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; const DEFAULT_QLCRC_JSON_PATH: &str = ".qlcrc.json"; const FIXTURE_ROOT_PATH: &s...
true
204ca72321f218b0e51ca7f8725b2ea59e3cbcff
Rust
kohbis/leetcode
/algorithms/2299.strong-password-checker-ii/solution.rs
UTF-8
1,002
3.109375
3
[]
no_license
impl Solution { pub fn strong_password_checker_ii(password: String) -> bool { let chars: Vec<char> = password.chars().collect(); if chars.len() < 8 { return false; } let specials: Vec<char> = vec!['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '+']; let...
true
29935a1830ea83822a68955cacd537b72d1ee1fb
Rust
GDGToulouse/devfest-toolkit-rs
/dftk-common/src/models/sponsor/mod.rs
UTF-8
4,620
2.875
3
[ "Apache-2.0" ]
permissive
use std::str::FromStr; use serde::{Deserialize, Serialize}; use slug::slugify; use uuid::Uuid; use crate::models::language::Lang; use crate::models::socials::Social; use crate::models::sponsor::category::SponsorCategoryKey; use crate::models::Markdown; use crate::new_id; pub mod category; #[derive(Serialize, Deseri...
true
1493d5de6149dbda815f274cf79116abde6bd048
Rust
fyang93/rust-leetcode
/src/p0053_maximum_subarray.rs
UTF-8
1,477
3.625
4
[]
no_license
pub fn max_sub_array(nums: Vec<i32>) -> i32 { let mut max = i32::min_value(); let mut last_max = i32::min_value(); for num in nums { last_max = last_max.max(0) + num; max = max.max(last_max); } max } // divide and conquer pub fn max_sub_array_1(nums: Vec<i32>) -> i32 { assert!(!...
true
b2d006fb6b9ac63bd726024400e58facdd8a87b4
Rust
vtavernier/glsl-lang
/lang-lexer/src/v1.rs
UTF-8
16,107
2.703125
3
[ "BSD-3-Clause", "Vim" ]
permissive
//! Logos-based lexer definition use logos::Logos; use thiserror::Error; use lang_util::{position::LexerPosition, TextSize}; use crate::HasLexerError; use super::{LangLexer, LangLexerIterator, ParseContext, ParseOptions, Token}; pub(super) mod parsers; mod preprocessor_token; use preprocessor_token::*; #[cfg(tes...
true
3ceafcbbadf327eec292cd7fdc8a0c2aa8882dc8
Rust
halimath/rust-katas
/time-calculator/src/main.rs
UTF-8
267
2.515625
3
[]
no_license
extern crate rust_kata_time; use rust_kata_time::time; fn main() { let first = time::TimeInterval::parse("1m 45s").unwrap(); let second = time::TimeInterval::parse("1h 19s").unwrap(); let sum = first.add(&second); println!("{}", sum.as_string()); }
true
8fb9b719ddc8a6e6b3e4c592411a44efabe6e1e2
Rust
imbolc/perseus
/packages/perseus/src/errors.rs
UTF-8
6,462
2.875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![allow(missing_docs)] use crate::translations_manager::TranslationsManagerError; use thiserror::Error; /// All errors that can be returned from this crate. #[derive(Error, Debug)] pub enum Error { #[error(transparent)] ClientError(#[from] ClientError), #[error(transparent)] ServerError(#[from] Serve...
true
acb3f4377b3bc21048487a76b08a29e3f194d41d
Rust
cessen/led
/sub_crates/backend/src/buffer.rs
UTF-8
5,223
3.25
3
[ "MIT", "Apache-2.0" ]
permissive
use std::path::PathBuf; use ropey::Rope; use crate::{ history::{Edit, History}, marks::MarkSet, }; /// A path for an open text buffer. /// /// This indicates where the text data of the buffer came from, and /// where it should be saved to. #[derive(Debug, Clone, Eq, PartialEq)] pub enum BufferPath { File...
true
4c61f7b2cfa245514c4240ce867c06c9625d1d11
Rust
emakryo/cmpro
/src/tenkei90/src/bin/d074.rs
UTF-8
299
2.515625
3
[]
no_license
fn main() { proconio::input! { n: usize, s: proconio::marker::Bytes, } let mut ans = 0; for i in 0..n { if s[i] == b'b' { ans += 1u64 << i; } else if s[i] == b'c' { ans += 1 << i + 1; } } println!("{}", ans); }
true
81f4e18fef9c5481f63005d49e1a6f2a52129363
Rust
thomsavage/octobot
/src/git_clone_manager.rs
UTF-8
2,546
3.046875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use std::fs; use std::path::PathBuf; use std::sync::Arc; use log::info; use failure::format_err; use crate::config::Config; use crate::dir_pool::{DirPool, HeldDir}; use crate::errors::*; use crate::git::Git; use crate::github; use crate::github::api::Session; // clones git repos with given github session into a mana...
true
b83a992facb8c069a81839d4714aee6ef540480c
Rust
tiqwab/atcoder
/abc219/c/main.rs
UTF-8
1,029
3.203125
3
[]
no_license
pub fn main() { let X: String = { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); s.trim().to_string() }; let N: usize = { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); s.trim().parse().unwrap() }; le...
true
3a1a49935fe8ab09398f201ea7b8b60ec2bbec91
Rust
ymizushi/emola-rs
/src/emola/reader.rs
UTF-8
721
2.75
3
[]
no_license
use super::token::tokenize; use super::parse::parse; use super::eval::{Env, eval}; use std::cell::RefCell; use std::collections::HashMap; use std::io::{self, Write}; pub fn read<'a>() { loop { let mut buff = String::new(); print!("> "); io::stdout().flush().unwrap(); io::stdin().re...
true
02c9d3aeff9394bcf0a0af79ad62a4fbfe063acc
Rust
zaeleus/noodles
/noodles-sam/src/record/reference_sequence_name.rs
UTF-8
3,508
3.828125
4
[ "MIT" ]
permissive
//! SAM record reference sequence name. use std::{borrow::Borrow, error, fmt, ops::Deref, str::FromStr}; /// A SAM record reference sequence name. #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct ReferenceSequenceName(String); impl Borrow<str> for ReferenceSequenceName { fn borrow(&self) -> &str { ...
true
f7b8293736f28ea6f19dd83479866bcf2cf72510
Rust
paulotten/advent_of_code_2020
/day24/src/main.rs
UTF-8
3,437
3.46875
3
[]
no_license
mod data; use std::collections::HashSet; #[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)] struct Point { x: i32, y: i32, } impl Point { fn parse(str: &str) -> Point { let mut x = 0; let mut y = 0; let mut n = false; let mut s = false; for c in str.chars() { ...
true
3f40df9754c6ef63b6f67d7cbb6f9f949ccda194
Rust
ShaswatPrabhat/rustProjects
/owenership/src/main.rs
UTF-8
179
2.9375
3
[]
no_license
fn main() { let s1 = String::from("Some random String"); let s2 = s1; // println!("I am here with {} and {}", s1, s2); println!("I am here with {} ", s2); }
true
c72607f02d1be7edb515d0f10662ebc127faeb4e
Rust
ric2b/Vivaldi-browser
/chromium/third_party/rust/minimal_lexical/v0_2/crate/src/rounding.rs
UTF-8
4,286
3.59375
4
[ "Apache-2.0", "BSD-3-Clause", "LGPL-2.0-or-later", "MIT", "GPL-1.0-or-later", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Defines rounding schemes for floating-point numbers. #![doc(hidden)] use crate::extended_float::ExtendedFloat; use crate::mask::{lower_n_halfway, lower_n_mask}; use crate::num::Float; // ROUNDING // -------- /// Round an extended-precision float to the nearest machine float. /// /// Shifts the significant digit...
true
d04d586905706515f782f649f14d9d0acd3d2069
Rust
gevorgyana/proof_of_concept_haskell_lexer
/src/ascii.rs
UTF-8
333
3.015625
3
[]
no_license
pub struct ASCIIChar { character : char, } impl ASCIIChar { pub fn new(character : char) -> Option<Self> { if character.is_ascii() { Option::Some(Self {character : character} ) } else { Option::None } } pub fn get_char(&self) -> char { self.chara...
true
669da0fb4d206a87f6cb468334227cbdac3a1ade
Rust
mlabrenz117/intel_8080
/src/lib.rs
UTF-8
2,984
2.6875
3
[]
no_license
pub mod i8080; pub mod instruction; pub mod interconnect; pub(crate) mod mem_map; use log::error; use self::i8080::I8080; use self::instruction::{Instruction, Opcode}; use self::interconnect::{Interconnect, Rom}; use failure::Error; pub struct Emulator { cpu: I8080, interconnect: Interconnect, } impl Emul...
true
b29e058718adbac4a82e533c413b0279afd972c9
Rust
NDNLink/NDNProtocol
/libp2p/protocols/yamux/src/connection.rs
UTF-8
37,419
2.921875
3
[ "MIT" ]
permissive
// Copyright 2020 Netwarps Ltd. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, dis...
true
4e53dcd054076dab1bd61926a06e8eaceeff3b02
Rust
rink1969/zktx
/src/contract.rs
UTF-8
3,204
2.75
3
[]
no_license
use std::collections::HashMap; use std::collections::HashSet; use incrementalmerkletree::*; use pedersen::PedersenDigest; use base::*; use c2p::*; use p2c::*; use std::collections::VecDeque; use convert::*; #[derive(Clone)] pub struct SenderProof { pub proof: String, //hb:([u64;4],[u64;4]), pub coin: Strin...
true
60b79616dcaaaa881aecb7682abfc9383eee9221
Rust
IThawk/rust-project
/rust-master/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.rs
UTF-8
1,111
3.1875
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// This is testing an attempt to corrupt the discriminant of the match // arm in a guard, followed by an attempt to continue matching on that // corrupted discriminant in the remaining match arms. // // Basically this is testing that our new NLL feature of emitting a // fake read on each match arm is catching cases lik...
true
7671a0c88f0668ec61ce85447ddd77d0362b05fc
Rust
mindbeam/mindbase
/crates/fuzzyset/src/traits.rs
UTF-8
918
2.984375
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::fuzzyset::{FuzzySet, Item}; pub trait Member: Sized + Clone + std::fmt::Display { fn cmp(&self, other: &Self) -> std::cmp::Ordering; fn display_fmt(&self, item: &Item<Self>, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "(Member,{:0.2})", item.degree) } fn display_...
true
65c863c979afe0cad6d2c1eaca86926b21120b40
Rust
jturner314/typed_csv
/src/writer/field_names_encoder.rs
UTF-8
5,307
3.125
3
[ "MIT", "Unlicense" ]
permissive
use csv::{ByteString, Error, Result}; use rustc_serialize::Encoder; /// Encoder to extract field names from types that implement /// `rustc_serialize::Encodable`. #[derive(Debug)] pub struct FieldNamesEncoder { record: Vec<ByteString>, } impl FieldNamesEncoder { /// Creates a new `FieldNamesEncoder`. The valu...
true
f0d140ec96d93df42841c2508caa63d19402fdf6
Rust
cnruby/learn-rust-by-crates
/hello-trait/lib-hello/examples/function_methods.rs
UTF-8
863
3.5
4
[]
no_license
mod trait_exerci { pub struct StructType { data: u32, } impl StructType { pub fn new(data: u32) -> StructType { StructType { data: data } } pub fn get_data(&self) -> u32 { self.data } pub fn set_data(&mut self, data: &u32) { ...
true
d615a3f104e8cde4f2260e2858432387202585ea
Rust
Axect/Peroxide
/src/grave/lda_ls.rs
UTF-8
2,836
2.78125
3
[ "MIT", "Apache-2.0" ]
permissive
extern crate peroxide; use peroxide::fuga::*; const N: usize = 50; #[allow(non_snake_case)] fn main() { let cos_45 = 2f64.sqrt() / 2f64; let R = matrix(vec![cos_45, -cos_45, cos_45, cos_45], 2, 2, Row); // Group 1 let m1 = Coord { x: -1f64, y: 2f64 }; let x1_x_temp = Normal(0f64, 1f64).sample(N);...
true
e3efaa523caf755190476f6338871d1242832d51
Rust
codetojoy/gists
/rust/simple_console_with_modules_feb_2021/src/main.rs
UTF-8
1,457
2.859375
3
[ "Apache-2.0" ]
permissive
use std::io; use std::process; mod config; mod dealer; mod player; use crate::player::player::Player; use crate::config::config::get_players; use crate::dealer::dealer::deal_hands; fn list_players(players: &Vec::<Player>) { for player in players { println!("{:?}",player); } } fn new_game(players: &...
true
084f14ad62b420ae67a7430a41ca1b1a39ec9898
Rust
heinrich5991/libtw2
/tools/src/client.rs
UTF-8
804
2.8125
3
[ "MIT", "Apache-2.0" ]
permissive
use logger; use std::env; use std::net::SocketAddr; use std::net::ToSocketAddrs; use std::net::UdpSocket; fn to_socket_addr_or_panic(addr: &str) -> SocketAddr { addr.to_socket_addrs().unwrap().next().unwrap() // | | | | // io::Result Iterator Option SocketAddr } pub ...
true
20a13e67e1ac631050b2595c034f42e7374cedcc
Rust
emimvi/pathtracer
/src/material.rs
UTF-8
5,113
2.953125
3
[]
no_license
use algebra::vec3::Vec3; use f64; use geometry::Ray; use geometry::Surface; use microfacet::*; use mipmap::MipMap; use std::fmt::Debug; fn sample_cosine_weighted_hemisphere(normal: &Vec3) -> Vec3 { let rnd = ::rand::random::<f64>(); let cos_theta = f64::sqrt(rnd); let sin_theta = f64::sqrt(1.0 - rnd); ...
true
55b4b6e697a545cb03a4a3451fb5224b111f5e89
Rust
iqlusioninc/yubihsm.rs
/tests/command/device_info.rs
UTF-8
399
2.65625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
/// Get device information #[test] fn device_info_test() { let client = crate::get_hsm_client(); let device_info = client .device_info() .unwrap_or_else(|err| panic!("error getting device info: {err}")); // This should always be 2. The minor and patch versions will vary // depending on...
true
c65a0e72d69ab67b3b49e5a8ee5158140fdeab62
Rust
mofanv/veracruz
/veracruz-server/src/cli.rs
UTF-8
1,904
2.65625
3
[ "MIT", "CC-BY-SA-2.0" ]
permissive
//! Veracruz Server command-line interface //! //! ## Authors //! //! The Veracruz Development Team. //! //! ## Licensing and copyright notice //! //! See the `LICENSE.markdown` file in the Veracruz root directory for //! information on licensing and copyright. use actix_rt; use log::info; use std::{fs, path, process}...
true
51c2d6dbd18f69f2caa858a9d3fb2bff5ca25072
Rust
bouzuya/rust-atcoder
/before-cargo-atcoder/abc138_d/src/main.rs
UTF-8
1,716
3.125
3
[]
no_license
use std::collections::VecDeque; fn read<T: std::str::FromStr>( stdin_lock: &mut std::io::StdinLock, buf: &mut Vec<u8>, delimiter: u8, ) -> T { buf.clear(); let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap(); buf.truncate(l - 1); // remove delimiter let s = unsafe { st...
true
42db08fb7eb951f6dabe8cb75db9b6eb5acb46e7
Rust
fotoetienne/advent
/2022/src/day03.rs
UTF-8
2,205
3.1875
3
[]
no_license
use anyhow::{Context, Result}; use itertools::Itertools; use std::collections::HashSet; use crate::puzzle::{Puzzle, PuzzleFn::I32}; pub(crate) const PUZZLE: Puzzle = Puzzle { day: 3, part1: I32(part1), part2: I32(part2), }; fn part1(input: &str) -> i32 { input .lines() .map(|line| { ...
true
ba7230accf2244fad72bd4a1e8ec379d3f9e4a28
Rust
hwchen/ray-tracer
/src/vec3/mod.rs
UTF-8
2,328
3.5
4
[]
no_license
pub mod instances; pub use self::instances::{Color, Point}; /// Using a Vec3 trait means that I'll be able to get all of the /// implementation of Vec3 operations for free once the constructors /// are implemented. /// /// At the same time, this allows each type implementing Vec3 /// (e.g. Point, Color) to maintain t...
true
f3010a291516b1c28b5b675bf53da58ca60491e2
Rust
momobel/aoc-2020
/template/src/main.rs
UTF-8
732
2.984375
3
[]
no_license
use std::{env, fs}; fn get_input_path() -> String { let args: Vec<String> = env::args().collect(); args.get(1).unwrap().clone() } type Input = (); type Output1 = (); type Output2 = (); fn parse_input(input: &str) -> Input { unimplemented!() } fn solve_part_1(input: &Input) -> Output1 { unimplemented...
true
ca58e85d68cebda3245819f9bfa540a1a82abf79
Rust
justinas2314/Automated-Discord-Custom-Status
/src/client.rs
UTF-8
4,544
2.84375
3
[]
no_license
use std::collections::HashMap; use fancy_regex::Regex; use serde_json::Value; use reqwest::blocking::Client; use reqwest::header::HeaderMap; use serde::ser::{Serialize, Serializer, SerializeStruct}; use crate::Values; struct StatusWrapper { custom_status: StatusJson } struct StatusJson { emoj...
true
5b176ff27db49233d81888ab9d208625c33b1e07
Rust
chadoh/workshop-2016
/rust-sandbox/kangaroo/src/main.rs
UTF-8
1,060
3.53125
4
[]
no_license
use std::io; fn get_numbers() -> Vec<u16> { let mut line = String::new(); io::stdin().read_line(&mut line).ok().expect("Failed to read line"); line.split_whitespace().map(|s| s.parse::<u16>().unwrap()).collect() } enum Conclusion { Yes, No, Inconclusive, } fn will_conclude(x1: u16, v1: u16, x...
true
a9d7805219cfa40f0cb46dab06061677c420b6e7
Rust
mbilker/kbinxml-rs
/kbinxml/src/options.rs
UTF-8
1,181
3.109375
3
[ "MIT" ]
permissive
use crate::compression_type::CompressionType; use crate::encoding_type::EncodingType; #[derive(Clone, Debug, Default)] pub struct Options { pub(crate) compression: CompressionType, pub(crate) encoding: EncodingType, } #[derive(Default)] pub struct OptionsBuilder { compression: CompressionType, encodin...
true
b5e02bd6de881197915eac50933b614bfd3f09cf
Rust
jovobe/shit-cpu-emu
/assembler/src/span.rs
UTF-8
1,024
3.796875
4
[]
no_license
//! Defines `Span` and `Spanned`. A span is a pair of indices usually denoting //! a region in the source code. use std::{fmt, ops}; /// Represents a region in the source text. #[derive(Debug, Clone, Copy)] pub struct Span { /// Start of the span, inclusive pub lo: usize, /// End of the span, exclusive ...
true
c55a70445ffdbbfb5b70869409ea7a0a92101a1d
Rust
fyaniquez/erprus
/src/handlers/capitulo.rs
UTF-8
3,143
2.96875
3
[]
no_license
/// handler capitulo /// autor: fyaniquez /// fecha: 2021-07-12 18:54:46.497141369 -04:00 /// use crate::models::capitulo::Capitulo; use sqlx::{query, query_as, PgPool}; use tide::Error; /// consulta a la bd por registros de la tabla pub async fn hndl_list(db_pool: &PgPool) -> tide::Result<Vec<Capitulo>> { let row...
true
1faf9c4d276a292454b75f3aa210b214f521c37e
Rust
nimr0d/projecteuler-rs
/src/euler/primes.rs
UTF-8
3,264
3.375
3
[]
no_license
extern crate rand; use super::{ int_sqrt, modmul, modpow, modpow_s }; /// Deterministic primality test. pub fn is_prime(n : u64) -> bool { if n <= 1 { return false; } if n == 2 { return true; } if n & 1 == 0 { return false; } let mut x : u64 = 3; while x * x <= n { if n % x == 0 { return false; } ...
true
756eeddd1beb84e9cfa00d3b2b2c56f2af8b126e
Rust
TheIronBorn/simd_prngs
/src/prngs/xorshift128plus.rs
UTF-8
2,187
2.90625
3
[]
no_license
use rng_impl::*; macro_rules! make_xorshift128plus { ($rng_name:ident, $vector:ident) => { pub struct $rng_name { s0: $vector, s1: $vector, } impl_rngcore! { $rng_name } impl SimdRng for $rng_name { type Result = $vector; #[inline(a...
true
a5abbb0052469b343f95d2e3990618b04c59a30f
Rust
d3adc3II/nog
/twm/src/lua/runtime.rs
UTF-8
3,337
2.765625
3
[ "MIT" ]
permissive
use std::{fmt::Debug, path::PathBuf, sync::Arc}; use log::{debug, error}; use mlua::{Function, Lua, Table}; use parking_lot::Mutex; pub const CALLBACK_TBL_NAME: &'static str = "__callbacks"; //TODO: Fix unwraps #[derive(Clone)] pub struct LuaRuntime(pub Arc<Mutex<Lua>>); pub fn get_err_msg(e: &mlua::Error) -> Stri...
true
51df806a53bcfbd852e9a12e3b542bcf345aa2d2
Rust
occlum/occlum
/src/libos/src/net/socket/unix/stream/address_space.rs
UTF-8
5,170
2.828125
3
[ "BSD-3-Clause" ]
permissive
use super::endpoint::Endpoint; use super::endpoint::RelayNotifier; use super::stream::Listener; use super::*; use std::collections::btree_map::BTreeMap; lazy_static! { pub(super) static ref ADDRESS_SPACE: AddressSpace = AddressSpace::new(); } #[derive(PartialEq, Eq, PartialOrd, Ord)] pub enum AddressSpaceKey { ...
true
114ae1edfb436b4c37b4d5e2d64c4291562858bc
Rust
BroderickCarlin/embedded-graphics
/tinytga/tests/types.rs
UTF-8
6,435
2.5625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use tinytga::{Bpp, ImageOrigin, ImageType, Tga, TgaHeader}; const HEADER_DEFAULT: TgaHeader = TgaHeader { id_len: 0, has_color_map: false, image_type: ImageType::Empty, color_map_start: 0, color_map_len: 0, color_map_depth: None, x_origin: 0, y_origin: 0, width: 9, height: 5, ...
true
7b8b3294eeb1b0121d13736439096efba452cca6
Rust
catplayer233/rust-train
/unsafe-train/src/unsafe_trait_explorer.rs
UTF-8
355
3.46875
3
[]
no_license
//declare a trait is a unsafe trait, //add keyword unsafe when you define the trait pub unsafe trait UnsafeTrait { unsafe fn do_dangerously(&self); } //the implementation should add unsafe when the trait is a unsafe trait unsafe impl UnsafeTrait for String { unsafe fn do_dangerously(&self) { println!("...
true
4a2609fd4cf1dce8168820dd4ce649093b79b004
Rust
lambrosi/rust-pocs
/playground/smart_pointers_box/src/main.rs
UTF-8
919
3.703125
4
[]
no_license
use crate::List::{Cons, Nil}; fn main() { // Boxes allow us to store data on the heap rather than the stack // What remains on the stack is the pointer to the heap data // Use in this situations: // --> When you have a type whose size can’t be known at compile time and you want to use a value of that t...
true
ec11c6c03f4d8cbd68237e0c7e50320a3d4bbfab
Rust
krisnova/youki
/tests/rust-integration-tests/integration_test/src/tests/cgroups/pids.rs
UTF-8
5,245
2.546875
3
[ "Apache-2.0" ]
permissive
use std::{ fs, path::{Path, PathBuf}, }; use anyhow::{bail, Context, Result}; use oci_spec::runtime::{LinuxBuilder, LinuxPidsBuilder, LinuxResourcesBuilder, Spec, SpecBuilder}; use test_framework::{test_result, ConditionalTest, TestGroup, TestResult}; use crate::utils::{ test_outside_container, test_u...
true
b4e1f5358ae15e8182bb574f584b9376173db0ae
Rust
RangerStation/alexandrie-run
/.cargo/registry/src/github.com-1ecc6299db9ec823/migrations_internals-1.4.1/src/migration.rs
UTF-8
7,338
2.8125
3
[ "MIT", "Apache-2.0" ]
permissive
use diesel::connection::SimpleConnection; use diesel::migration::*; use std::fmt; use std::path::{Path, PathBuf}; #[allow(missing_debug_implementations)] #[derive(Clone, Copy)] pub struct MigrationName<'a> { pub migration: &'a dyn Migration, } pub fn name(migration: &dyn Migration) -> MigrationName { Migrati...
true
959b7d5d96f786f030d7158fe4db969f6ee650a7
Rust
danielrh/mousegame
/src/lib.rs
UTF-8
1,996
2.90625
3
[]
no_license
#[macro_use] extern crate serde_derive; extern crate serde_xml_rs; extern crate serde; extern crate regex; #[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] pub struct Transform { pub midx: f64, pub midy: f64, pub rotate: f64, pub tx: f64, pub ty: f64, pub scale: f64, } impl Transform {...
true
f3fe3a79190ce77e06eb710bfe883afbd1efdbe7
Rust
iPersona/algorithm
/src/search/greedy.rs
UTF-8
1,776
3.046875
3
[ "MIT" ]
permissive
use std::collections::{HashMap, HashSet}; use std::cmp::Eq; use std::hash::Hash; use std::clone::Clone; use std::fmt::{Debug, Display}; pub fn find_best_covered_state<T: Eq + Hash + Copy + Display + Debug>( stations: &HashMap<T, HashSet<T>>, states_needed: &HashSet<T>, ) -> HashSet<T> { let mut final_stati...
true
44eb1fcd9f6d61435959c2c798f292467836a12e
Rust
AXAz0r/discord-rpc-client.rs
/src/client.rs
UTF-8
1,054
2.75
3
[ "MIT" ]
permissive
use std::io::Result; use connection::Connection; use models::Handshake; #[cfg(feature = "rich_presence")] use models::{SetActivityArgs, SetActivity}; #[derive(Debug)] pub struct Client<T> where T: Connection { client_id: u64, version: u32, socket: T, } impl<T> Client<T> where T: Connection { p...
true
3f57028cc2f73a818dda118d25ebf271159c5950
Rust
marco-c/gecko-dev-wordified
/third_party/rust/wgpu-core/src/track/range.rs
UTF-8
6,105
3.046875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/ / Note : this could be the only place where we need SmallVec . / / TODO : consider getting rid of it . use smallvec : : SmallVec ; use std : : { fmt : : Debug iter ops : : Range } ; / / / Structure that keeps track of a I - > T mapping / / / optimized for a case where keys of the same values / / / are often grouped t...
true
378081a7879a670e9603aed56fbfa5efd9ebb28c
Rust
ashtuchkin/rypt
/src/ui.rs
UTF-8
10,742
3.078125
3
[ "MIT" ]
permissive
use failure::{bail, ensure, format_err, Error, Fallible}; use std::cell::{RefCell, RefMut}; use std::io::Read; use std::rc::Rc; use crate::terminal::{set_stdin_echo, TERMINAL_CLEAR_LINE}; use crate::util::to_hex_string; use crate::{Reader, ReaderFactory, Writer}; const ERROR_VERBOSITY: i32 = -1; const INTERACTIVE_VER...
true
4e13a131ddfe9f926478e4cc4c4e7df756d68fe8
Rust
rodrimati1992/abi_stable_crates
/examples/readme_example/readme_user/src/main.rs
UTF-8
2,011
2.609375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use abi_stable::std_types::RVec; use readme_interface::{ load_root_module_in_directory, AppenderBox, Appender_TO, BoxedInterface, ExampleLib_Ref, }; fn main() { // The type annotation is for the reader let library: ExampleLib_Ref = load_root_module_in_directory("../../../target/debug".as_ref()) .u...
true
6d112c3edd533a8b80a1bc6f4826c4b4a2db0b18
Rust
mteyssier/keystone-rs
/src/lib.rs
UTF-8
4,915
2.9375
3
[]
permissive
pub mod gen; #[derive(Debug)] pub struct Error { pub err: gen::ks_err, } impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { let err_msg = unsafe { std::ffi::CStr::from_ptr(gen::ks_strerror(self.err)) }; write!(f, "{}", err_msg.to_str().unwrap())...
true
a80d61d9ce1c8b2b76ba4a118215be7927968ae1
Rust
garasubo/AtCoderProblems
/atcoder-problems-backend/src/scraper/contest.rs
UTF-8
1,989
3
3
[ "MIT" ]
permissive
use crate::sql::models::Contest; use chrono::DateTime; use scraper::{Html, Selector}; pub(super) fn scrape(html: &str) -> Option<Vec<Contest>> { Html::parse_document(html) .select(&Selector::parse("tbody").unwrap()) .next()? .select(&Selector::parse("tr").unwrap()) .map(|tr| { ...
true
7d8270417ba142d81b7fab61bbef304c5fb1f8ff
Rust
WilsonGramer/small-step-interpreter
/src/lib.rs
UTF-8
4,521
3.765625
4
[]
no_license
use std::fmt; #[derive(Clone)] pub enum Value { Number(i32), True, False, Function(&'static str, Box<Expression>), } impl fmt::Display for Value { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Value::Number(n) => write!(f, "{}", n), Value::...
true
d0db2558f89910802fc79da51b1600b7607bd899
Rust
victor-zed/tink-rust
/mac/src/subtle/hmac.rs
UTF-8
2,344
2.53125
3
[ "Apache-2.0" ]
permissive
// Copyright 2020 The Tink-Rust Authors // // 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 ag...
true
653bab61bd3378ccbad02a6244c1a5adeae07fb5
Rust
wolf4ood/gremlin-rs
/gremlin-tutorial/src/chapters/ch32/ch323.rs
UTF-8
1,184
2.53125
3
[ "Apache-2.0" ]
permissive
use crate::chapters::example; use gremlin_client::process::traversal::{GraphTraversalSource, SyncTerminator}; pub fn chapter_323( g: &GraphTraversalSource<SyncTerminator>, ) -> Result<(), Box<dyn std::error::Error>> { let chapter = "3.2.3"; example( &g, chapter, "How many airports ...
true
0ac5dfd78c68ffbab44ab1accca00b5245209bd4
Rust
kydas/Rubet
/src/main.rs
UTF-8
433
2.546875
3
[]
no_license
use std::thread; extern crate consul; pub mod aws; pub mod write_kv; fn main() { // Get any config // spin off thread to fetch from aws sqs let queue = String::from("test-queue"); println!("About to kick off thread"); let aws_thread = thread::spawn(move || { aws::sqs_fetch(queue); ...
true
3a909dd5b172c47eeeb354cf4cf9a8c7aea6b755
Rust
cadelacruza/rust-practice
/003-boolean_to_string.rs
UTF-8
309
3.640625
4
[]
no_license
//Implement a function which convert the given boolean value into its string representation. fn boolean_to_string(b: bool) -> String { let mut result = String::new(); if b { result = "true".to_string(); } else { result = "false".to_string(); }; return result; }
true
02f70746f58a2f18d9eccf8107b3ecdd6f0f4e73
Rust
sebnilsson/from-csharp-to-rust
/fctr03-code-basics/src/collections.rs
UTF-8
488
3.6875
4
[]
no_license
use std::collections::HashMap; pub fn run() { // Array let mut arr = [1, 2, 3]; arr[0] = 0; // Vectors let mut vec = vec![1, 2]; vec.push(3); vec[0] = 0; // Conversion let _arr_from_vec = &vec[0..2]; let _vec_from_arr = arr.to_vec(); // Hashmap let mut map = HashMap::...
true
ebb27b5be8002cc513309ec926b6c1f24b87d8f4
Rust
Sam-Belliveau/TheSamBoy
/src/gb/opcodes/opcode.rs
UTF-8
453
2.65625
3
[]
no_license
use crate::gb::cpu::CPU; use std::fmt; type OPFunction = fn(&mut CPU) -> usize; pub struct OPCode { pub code: u8, pub name: &'static str, pub size: u16, pub func: OPFunction, } impl OPCode { pub fn exec(&self, cpu: &mut CPU) -> usize { (self.func)(cpu) } } impl fmt::Display for OP...
true
54179abe34685250a5d85c5aa049c231e9802054
Rust
hoangpq/android-rust-sdl2
/rust-lib/src/tetris/others.rs
UTF-8
583
2.859375
3
[ "Zlib" ]
permissive
use crate::tetris::game_color::GameColor; use rand::distributions::Standard; use rand::prelude::*; pub type PieceMatrix = [[Presence; 4]; 4]; pub type GameMap = [Vec<Presence>]; #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub enum Presence { No, Yes(GameColor), } #[derive(Debug, Clone)] pub enum PieceType {...
true
f09302aee2b847711280e702e5cf2bc3b365b4a6
Rust
CasperN/flatbuff-example
/src/main.rs
UTF-8
2,219
2.921875
3
[]
no_license
extern crate flatbuffers; mod monster_generated; mod monster_obj; use crate::monster_generated::my_game::sample::{ get_root_as_monster, Color, Equipment, Monster, MonsterArgs, Vec3, Weapon, WeaponArgs, }; fn make_monster() -> (Vec<u8>, usize) { let mut builder = flatbuffers::FlatBufferBuilder::new_with_capac...
true
2f2f1f3f22ede0044c5529de57e0a72a4feb9d14
Rust
piotr-cla/ockam
/implementations/rust/ockam/ockam_core/src/message.rs
UTF-8
692
2.5625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::lib::Vec; use crate::Result; use serde::{de::DeserializeOwned, Serialize}; // TODO: swap this for a non-heaped data structure pub type Encoded = Vec<u8>; /// A user defined message that can be serialised and deserialised pub trait Message: Serialize + DeserializeOwned + Send + 'static { fn encode(&self...
true
8b043f6282e358085b74047ad23aa0725083d248
Rust
jm96441n/TheRustBook
/src/four.rs
UTF-8
1,735
3.921875
4
[]
no_license
pub fn run() { scope_fun(); strings(); data_interaction(); its_cloning_time(); ownership_and_functions(); ref_len(); mut_ref(); } //// 4.1 What is ownership? fn scope_fun() { let s = "hello"; { let s = "inside scope"; println!("{s}") } println!("{s}") } fn s...
true
2408893cd2ac25b1bb00c8556d91ebbc1b56f51c
Rust
pabloariasal/sapo
/src/parsing/lexer.rs
UTF-8
16,756
3.28125
3
[ "MIT" ]
permissive
use crate::token::Token; use crate::token::TokenType; use std::collections::HashMap; const EOF: char = '\u{0}'; struct Keyword { token_type: TokenType, lexeme: &'static str, } pub struct Lexer { input: Vec<char>, position: usize, next_position: usize, current_char: char, keywords: HashMap...
true
71bc84bcf653605f3a22c65ddc85c6c3d2583ea3
Rust
philipr-za/bn-api
/db/tests/unit/events.rs
UTF-8
18,314
2.75
3
[ "BSD-3-Clause" ]
permissive
use bigneon_db::dev::TestProject; use bigneon_db::models::*; use chrono::prelude::*; #[test] fn create() { let project = TestProject::new(); let venue = project.create_venue().finish(); let user = project.create_user().finish(); let organization = project.create_organization().with_owner(&user).finish(...
true
0f7c8f81fe7003eb1205678943666dafe9f29b9a
Rust
eugenebox/libra
/types/src/account_config/constants/coins.rs
UTF-8
2,624
2.625
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::account_config::constants::{from_currency_code_string, CORE_CODE_ADDRESS}; use move_core_types::{ identifier::Identifier, language_storage::{ModuleId, StructTag, TypeTag}, }; use once_cell::sync::Lazy; pub const LBR...
true
744ef7e7b82a15a58441fa040623fa0b5ff0580c
Rust
knutaf/aoclib_rs
/src/list.rs
UTF-8
7,724
3.1875
3
[]
no_license
use std::rc::Rc; use std::rc::Weak; use std::cell::RefCell; pub type RcListNode<T> = Rc<RefCell<ListNode<T>>>; type WeakListNode<T> = Weak<RefCell<ListNode<T>>>; pub struct ListNode<T> { pub this : WeakListNode<T>, pub prev : WeakListNode<T>, pub next : Option<RcListNode<T>>, pub data : T, } pub stru...
true
229c59c6778c2aac1219029202f969aa22294f24
Rust
kb10uy/tissue-rs
/src/tissue.rs
UTF-8
3,050
3.109375
3
[ "Apache-2.0" ]
permissive
//! Contains types corresponding Tissue service. use crate::{checkin::Checkin, TissueRequester}; use std::{collections::HashMap, error::Error}; use chrono::prelude::*; use serde::Deserialize; use serde_json::{from_value, to_value, Value}; /// Returned checkin data for successful checkim request. #[derive(Debug, Clon...
true
6fc11ee22da4756cb437f2ba851b4a053d80c285
Rust
isgasho/mimicaw
/src/printer.rs
UTF-8
5,010
2.78125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::{ args::{Args, ColorConfig, OutputFormat}, test::{Outcome, OutcomeKind, TestDesc, TestKind}, }; use console::{Style, StyledObject, Term}; use std::io::Write; pub(crate) struct Printer { term: Term, format: OutputFormat, style: Style, } impl Printer { pub(crate) fn new(args: &Args) -...
true
caa14fbe30ebd780a3d657da6b33fe493e09c1c6
Rust
mikelloc/radare2-r2pipe-api
/rust/src/api_trait.rs
UTF-8
1,419
2.515625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use structs::*; use serde_json::Error; // Maybe have r2api-rs' own error type? pub trait R2Api { /// Initialize r2 instance with some basic configurations fn init(&mut self); /// Run r2-based analysis on the file to extract information fn analyze(&mut self); /// Detect a function at a particular...
true
bc52a4b0eb2f8ae04bbc6fa978af1c3c341599e0
Rust
Mrmaxmeier/lua-interpreter
/src/instructions/closures.rs
UTF-8
630
2.6875
3
[]
no_license
use instruction::*; use function::*; // 44: CLOSURE A Bx R(A) := closure(KPROTO[Bx]) #[derive(Debug, Clone, Copy, PartialEq)] pub struct Closure { pub a: Reg, pub b: Reg } impl LoadInstruction for Closure { fn load(d: u32) -> Self { let (a, b) = parse_A_Bx(d); Closure { a: a, ...
true
5963432f66e15c47a75af2a0af7170cb314d8712
Rust
pojienie/ray-tracing-in-a-weekend
/src/vec3.rs
UTF-8
3,306
3.40625
3
[]
no_license
use rand::prelude::*; #[derive(Clone, Copy)] pub struct Vec3 { pub v0: f64, // R or X pub v1: f64, // G or Y pub v2: f64, // B or Z } impl Vec3 { pub fn new(v0: f64, v1: f64, v2: f64) -> Vec3 { Vec3 { v0: v0, v1: v1, v2: v2, } } pub fn rando...
true