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
6ef430a8950aad16ec80689d50259603ed704fe4
Rust
nathanjhaveri/advent-of-code-2019
/10/src/polar.rs
UTF-8
319
3.140625
3
[]
no_license
type PPt = f32; pub struct PolarPt { theta: PPt, dist: PPt, } impl PolarPt { pub fn from_coords(x: i32, y: i32) -> PolarPt { let x = x as PPt; let y = y as PPt; let dist = (x.powi(2) + y.powi(2)).sqrt(); let theta = (x / y).atan(); PolarPt { theta, dist } } }
true
c623060dd845b8443e07e2238c41107eff27dc47
Rust
TGElder/rust
/frontier/src/services/clock.rs
UTF-8
4,996
3.359375
3
[ "CC-BY-4.0" ]
permissive
use commons::bincode::{deserialize_from, serialize_into}; use serde::{Deserialize, Serialize}; use std::fs::File; use std::io::{BufReader, BufWriter}; use std::time::Instant; pub struct Clock<T> where T: Now, { baseline_instant: Instant, now: T, default_speed: f32, state: ClockState, } pub trait N...
true
1c20b9699bfa9beac9c61d87275b65d4af18d535
Rust
zrneely/ebml
/ebml_macros/src/parsers/mod.rs
UTF-8
21,394
2.59375
3
[]
no_license
use std::str::{self, FromStr}; use std::num; use chrono::{Duration, NaiveDate, NaiveDateTime, NaiveTime}; use ebml::Id; use nom::{self, types::CompleteByteSlice, AsChar, ErrorKind, Needed}; use {BinaryRange, BinaryRangeItem, Cardinality, DateRange, DateRangeItem, FloatRange, FloatRangeItem, Header, HeaderStatem...
true
0745ee7a4f8bf1944b8a1150a5087f61dc0176ca
Rust
txus/rye
/src/light.rs
UTF-8
5,439
2.90625
3
[]
no_license
use crate::color::Color; use crate::linear::{Point, Vector}; use crate::world::World; use crate::jitter::RandomJitter; use crate::rays::Precomputation; use crate::materials::Material; use std::cell::RefCell; use std::rc::Rc; use std::ops::DerefMut; pub trait Light { fn intensity(&self) -> &Color; fn intensity...
true
0f486b3541b898437774b07530f875926c08a7d3
Rust
aGiant/robust_trading.icml2019
/rsrl/src/core/parameter.rs
UTF-8
8,478
3.265625
3
[ "BSD-3-Clause", "MIT" ]
permissive
//! Variable parameters module. use std::f64; use std::ops::{Add, Div, Mul, Sub}; #[derive(Clone, Copy, Debug, Serialize, Deserialize)] pub enum Parameter { Fixed(f64), Exponential { init: f64, floor: f64, tau: f64, count: u32, }, Polynomial { init: f64, ...
true
a307428536b326927fed1047ed541787817c16b9
Rust
samuelcolvin/pyo3
/src/conversions/indexmap.rs
UTF-8
6,844
3.21875
3
[ "Apache-2.0", "Python-2.0" ]
permissive
#![cfg(feature = "indexmap")] //! Conversions to and from [indexmap](https://docs.rs/indexmap/)’s //! `IndexMap`. //! //! [`indexmap::IndexMap`] is a hash table that is closely compatible with the standard [`std::collections::HashMap`], //! with the difference that it preserves the insertion order when iterating over...
true
177eb6c702afcaf11fa0b3c0dbc56955c5321347
Rust
5l1v3r1/algorithm-1
/src/dp/fib.rs
UTF-8
1,924
3.375
3
[ "MIT" ]
permissive
//! fib use std::cell::RefCell; /// classic impl #[allow(unused)] pub fn fib_classic_recursive(n: usize) -> usize { match n { 0 => 0, 1 | 2 => 1, _ => fib_classic_recursive(n - 1) + fib_classic_recursive(n - 2), } } thread_local!(static MEMO: RefCell<Vec<usize>> = RefCell::new(vec![0;...
true
7c4745c5e7786573049ecb4038763da3bf4c5e88
Rust
sagebind/isahc
/testserver/src/request.rs
UTF-8
1,870
3.234375
3
[ "MIT", "CC-BY-4.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use regex::Regex; #[derive(Clone, Debug, Eq, PartialEq)] pub struct Request { pub(crate) number: u32, pub(crate) method: String, pub(crate) url: String, pub(crate) headers: Vec<(String, String)>, pub(crate) body: Option<Vec<u8>>, } impl Request { pub fn method(&self) -> &str { self.met...
true
2a8f9fb303e8e0defd4ff27f5ce1997f63356536
Rust
actix/actix-web
/actix-web/tests/test_error_propagation.rs
UTF-8
2,686
2.71875
3
[ "MIT", "Apache-2.0" ]
permissive
use std::sync::Arc; use actix_utils::future::{ok, Ready}; use actix_web::{ dev::{forward_ready, Service, ServiceRequest, ServiceResponse, Transform}, get, test::{call_service, init_service, TestRequest}, ResponseError, }; use futures_core::future::LocalBoxFuture; use futures_util::lock::Mutex; #[deriv...
true
701344fe37869a717491c5f8daf77eb746a9806b
Rust
linhbngo/Reference-Solutions
/utils/advanced-ps3-benchmark-framework/src/zhtta-v3/zhtta.rs
UTF-8
9,727
2.515625
3
[ "MIT" ]
permissive
// // zhtta.rs // // Running on Rust 0.8 // // Towards PS3: SPT scheduling // Towards PS3: improving concurrency // Towards PS3: eliminating long-blocked IO // // Note: it would be very unwise to run this server on a machine that is // on the Internet and contains any sensitive files! // // University of Virginia - c...
true
c24a79881187592dd72a937483670146cdc6de2a
Rust
Detegr/readline-sys
/examples/shell.rs
UTF-8
3,049
3.203125
3
[ "MIT" ]
permissive
//! Example of a command line shell with history support //! //! Use the arrow keys to go forwards and backwards through the history. //! //! Currently supported commands: //! //! * `history -c` -> clear the history //! * `history -s n` -> stifle the history to n entries //! * `history -u` -> unstifle the history //! *...
true
46ffc1193e12961c17daac89db7c77f54d88e367
Rust
wangfenjin/advent-of-code
/2018/day20/src/main.rs
UTF-8
3,779
3.03125
3
[ "MIT" ]
permissive
extern crate regex; use regex::Regex; use std::collections::{HashMap, HashSet, VecDeque}; use std::fs::File; use std::io::BufRead; use std::io::BufReader; use std::path::Path; use std::{thread, time}; fn main() { let f = File::open("./src/input.txt").unwrap(); let mut file = BufReader::new(&f); for line i...
true
2742741d29541e71ceea62d5947dadd8630148d8
Rust
skermes/aoc19
/src/days/five.rs
UTF-8
736
2.921875
3
[]
no_license
use itertools::Itertools; use crate::problem::Problem; use crate::intcode::Machine; pub struct DayFive {} impl Problem for DayFive { fn name(&self) -> String { "Sunny With a Chance of Asteroids".to_string() } fn part_one(&self, input: &str) -> String { let mut machine = Machine::from_str...
true
f1e8b05a8117450d39305e218d522796d74a8a76
Rust
AurelienAubry/lc3-vm
/src/instructions/ld.rs
UTF-8
2,445
3.3125
3
[]
no_license
use crate::bus::Bus; use crate::cpu::{register_from_u16, Register, Registers}; use crate::instructions::{sign_extend, two_complement_to_dec, Instruction}; use anyhow::Result; pub struct Ld { dst_reg: Register, pc_offset_9: u16, } impl Ld { pub fn new(instruction: u16) -> Result<Self> { let dst_reg...
true
818aa92673d0e47da1a300a1914c211da656b01f
Rust
stevepryde/rustonator
/src/comms/playercomm.rs
UTF-8
3,632
2.75
3
[ "Apache-2.0" ]
permissive
use crate::{ comms::websocket::WsError, component::action::Action, engine::{ player::{PlayerId, SerPlayer}, worlddata::SerWorldData, }, error::{ZError, ZResult}, }; use serde::{Deserialize, Serialize}; use std::ops::Deref; use tokio::{ sync::mpsc::{error::TryRecvError, Receiver,...
true
1edd432f5c5ceb4d879f109554631d3626af4ac3
Rust
UMR1352/advent-of-code-2020
/src/day5.rs
UTF-8
1,106
3.265625
3
[]
no_license
use std::collections::BTreeSet; #[aoc_generator(day5)] pub fn input_generator(input: &str) -> Vec<usize> { input .lines() .map(|seat| { seat.chars() .map(|c| match c { 'F' => '0', 'B' => '1', 'L' => '0', ...
true
94a59a31abad5b7fc599d3f275723c872644e350
Rust
franziskuskiefer/traits
/cipher/src/block.rs
UTF-8
8,174
3.515625
4
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
//! Traits used to define functionality of [block ciphers][1]. //! //! # About block ciphers //! //! Block ciphers are keyed, deterministic permutations of a fixed-sized input //! "block" providing a reversible transformation to/from an encrypted output. //! They are one of the fundamental structural components of [sym...
true
9a447c7370bb259e0485b09fe73e8221bf2efc84
Rust
waywardmonkeys/elasticsearch-rs
/codegen/src/api/parse.rs
UTF-8
3,691
3.578125
4
[ "Apache-2.0" ]
permissive
//! API Spec Parser //! //! A simple parser that buffers API spec files into memory and uses `serde_json` to deserialise. extern crate serde_json; use std::error; use std::fmt; use std::io::Read; use std::fs::File; use std::fs::read_dir; use serde_json::{ Value, value }; use super::ast::Endpoint; use std::io::Error...
true
77d8970519c64fd830321c9c557913b480454dd0
Rust
lindskogen/gameboy-rust
/src/dmg/cpu/step.rs
UTF-8
32,276
2.640625
3
[]
no_license
use bit_field::BitField; use crate::dmg::debug::lookup_op_code; use crate::dmg::mem::MemoryBus; use super::Flags; use super::ProcessingUnit; impl ProcessingUnit { pub fn next(&mut self, bus: &mut MemoryBus) -> u32 { if self.check_and_execute_interrupts(bus) { return 4; } if s...
true
95065f9c8ca1de4a2696858801d5d3bf682c1b8c
Rust
matter-labs/hodor
/src/fft/radix4_fft/mod.rs
UTF-8
4,926
2.671875
3
[ "MIT", "Apache-2.0" ]
permissive
use ff::PrimeField; use super::multicore::*; pub(crate) fn best_fft<F: PrimeField>(a: &mut [F], worker: &Worker, omega: &F, log_n: u32) { assert!(log_n % 2 == 0); // TODO: For now let mut log_cpus = worker.log_num_cpus(); if (log_cpus % 2 != 0) { log_cpus -= 1; } // we split into radi...
true
c905ca5403b3a33333dede2e05a99279e89d3abc
Rust
albedium/redox
/filesystem/apps/sodium/exec.rs
UTF-8
7,273
2.78125
3
[ "MIT" ]
permissive
use super::*; use redox::*; impl Editor { /// Execute a instruction pub fn exec(&mut self, Inst(para, cmd): Inst) { use super::Key::*; use super::Mode::*; use super::PrimitiveMode::*; use super::CommandMode::*; let n = para.d(); match cmd { Ctrl(b) =...
true
2f49a7aa67c15a23e0be743b0291531b6fec65c0
Rust
RustCrypto/elliptic-curves
/p384/tests/affine.rs
UTF-8
2,450
2.53125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
//! Affine arithmetic tests. // TODO(tarcieri): point compaction support #![cfg(all(feature = "arithmetic", feature = "test-vectors"))] use elliptic_curve::{ group::{prime::PrimeCurveAffine, GroupEncoding}, sec1::{FromEncodedPoint, ToEncodedPoint}, }; use hex_literal::hex; use p384::{AffinePoint, EncodedPoi...
true
fb7e46ec425f0ae3f0179de84bffd6647236dd0f
Rust
JohaoDev/number-to-letter-converter
/src/control/cardinals.rs
UTF-8
3,824
3.390625
3
[]
no_license
fn f_unidades(num: i128) -> String { let mut result = String::from(""); match num { 1 => result = "UNO".to_string(), 2 => result = "DOS".to_string(), 3 => result = "TRES".to_string(), 4 => result = "CUATRO".to_string(), 5 => result = "CINCO".to_string(), 6 => res...
true
bb4f5f2699c96bf41fa784af0d2c1c284ae85479
Rust
divinerapier/ossfs
/tools/md5checker/main.rs
UTF-8
4,146
2.734375
3
[ "Apache-2.0" ]
permissive
use clap::*; fn main() { let matches = App::new("md5checker") .version("1.0") .author("divinerapier") .about("check files' md5") .arg( Arg::with_name("source") .required(true) .short("s") .long("source") .va...
true
c772d192863c2bfba554294e677c7ab5882dec8f
Rust
iwillspeak/ullage
/src/main.rs
UTF-8
8,894
2.9375
3
[ "MIT" ]
permissive
//! Expression tree parsing using Top-Down Operator Precedence //! parsing. #![warn(missing_docs)] pub mod compile; pub mod diag; pub mod low_loader; pub mod meta; pub mod sem; pub mod syntax; use crate::compile::*; use crate::low_loader::targets; use crate::syntax::text::DUMMY_SPAN; use crate::syntax::*; use docopt...
true
0824825aa46f7eeedc2f96290bba27471269a244
Rust
dispanser/codewars-rs
/src/sort_the_odd.rs
UTF-8
946
3.90625
4
[]
no_license
/// sorting only the odd numbers, keeping the even ones in place /// - go over the array once, putting the odds into a separate vec and /// simultaneously marking the odd positions /// - sort the separated odds /// - fill them back in pub fn sort_array(arr: &[i32]) -> Vec<i32> { let mut odds: Vec<i32> = arr.iter(...
true
8de3f641d8aed176f8e7035c9671956ec273aa30
Rust
AnumEssani/Assignment2
/Q4/src/main.rs
UTF-8
556
3.4375
3
[]
no_license
#[derive(Debug)] struct Children { name:String, } pub trait Primary_passed { fn Pp(&self) -> i32 { 1 } } pub trait Bilingual { fn bil(&self) -> i32 { 1 } } impl Primary_passed for Children {} impl Bilingual for Children {} fn main () { let my_children = Children { name...
true
cd9f35808be19641659a4daea6a72847a24e0818
Rust
danielmansson/advent2020
/Rust/advent_2020/src/util.rs
UTF-8
794
2.546875
3
[]
no_license
use reqwest::header::ACCEPT; use reqwest::header::COOKIE; use std::fs; pub fn fetch_input(year: u32, day: u32) -> String { let token = fs::read_to_string("temp/token.txt").unwrap(); let path = format!("temp/input_{}_{}.txt", year, day); let cached = fs::read_to_string(path.to_owned()); if cached.is_ok...
true
fa738e2e82a1bce67e907aa8ac48f767ef59c95f
Rust
bwiklund/rust-formula-parser
/src/lex.rs
UTF-8
2,576
3.546875
4
[]
no_license
use regex; #[derive(Clone, Copy, Debug, PartialEq)] pub enum TokenTy { Whitespace, Ident, Number, LParen, RParen, Comma, Operator, EOF, } #[derive(Clone, Debug)] pub struct Token<'a> { pub text: &'a str, pub ty: TokenTy, } struct Matcher { re: regex::Regex, ty: TokenTy...
true
366e63243322d1bebbac0ee16f68cd36821d69c1
Rust
panda-re/panda-rs-plugins
/panda-il-trace/src/fil/bbl.rs
UTF-8
5,225
2.875
3
[]
no_license
use std::fs; use std::path::Path; use std::collections::BTreeMap; use serde::Serialize; use super::{BasicBlock, Branch}; /// Final trace representation, for serialization. #[derive(Debug, Clone, Serialize)] pub struct BasicBlockList { list: Vec<BasicBlock>, } impl BasicBlockList { /// Constructor, resolves:...
true
3c17e72f9886c582a8e1123bbc82cc76f31d40e4
Rust
deeenclave/rustilicious
/tuples.rs
UTF-8
195
3.125
3
[]
no_license
pub fn run(){ let simple_simon: (&str,&str,bool) = ("simple simon","pieman",false); print!("Says {} to the {} - Do I have any pie's ? {}",simple_simon.0,simple_simon.1,simple_simon.2); }
true
a3feab9b2b5a55b0b0c908ee08bb0a47a6a8a78b
Rust
ytyaru/Rust.Std.Time.Instant.20190726100633
/src/1/std_time_instant/src/main.rs
UTF-8
259
2.734375
3
[ "CC0-1.0" ]
permissive
/* * Rust自習(std::time::Instant) * CreatedAt: 2019-07-26 */ fn main() { let ins = std::time::Instant::now(); println!("{:?}", ins); std::thread::sleep(std::time::Duration::from_secs(1)); println!("{:?}", ins.elapsed().as_secs()); }
true
c6527e8d9c94459315e0c0c59690d7ea980fe6d9
Rust
drconopoima/linked-list-rust
/src/second.rs
UTF-8
6,966
3.625
4
[ "MIT" ]
permissive
type Link<T> = Option<Box<ListNode<T>>>; #[derive(Debug)] pub struct ListNode<T> { value: T, next: Link<T>, } #[derive(Debug)] pub struct LinkedList<T> { // Number of non-empty nodes in list // @field length // @type {usize} pub length: usize, // Pointer to first node in the list. // @...
true
1357d56cc95af96ec7db302b813c6b7beb3c89f3
Rust
joanhey/FrameworkBenchmarks
/frameworks/Rust/viz/src/models_diesel.rs
UTF-8
556
2.65625
3
[ "LicenseRef-scancode-warranty-disclaimer" ]
permissive
use std::borrow::Cow; use diesel::Queryable; use sailfish::TemplateOnce; use serde::Serialize; #[derive(Serialize, Queryable, Debug)] pub struct World { pub id: i32, pub randomnumber: i32, } #[derive(Serialize, Queryable, Debug)] pub struct Fortune { pub id: i32, pub message: Cow<'static, str>, } #[...
true
1788bfb81064abc5f44b965a4e7784bb0fc81d66
Rust
vvbv/abstreet
/editor/src/sandbox/score.rs
UTF-8
4,071
2.84375
3
[ "Apache-2.0" ]
permissive
use crate::ui::UI; use ezgui::{ hotkey, EventCtx, GfxCtx, HorizontalAlignment, Key, ModalMenu, Text, VerticalAlignment, Wizard, WrappedWizard, }; use geom::{Duration, DurationHistogram}; use itertools::Itertools; use sim::{FinishedTrips, TripID, TripMode}; pub enum Scoreboard { Summary(ModalMenu, Text), ...
true
98c9d7ac2033124fea1bd2cd2586ae2cb737fce8
Rust
standardgalactic/oak-1
/src/liboak/middle/typing/surface.rs
UTF-8
6,167
2.578125
3
[ "Apache-2.0" ]
permissive
// Copyright 2014 Pierre Talbot (IRCAM) // 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...
true
6046003555a9f70c9142430a0421981ae14c01d1
Rust
kaikalii/ryvm
/src/app.rs
UTF-8
4,490
2.734375
3
[]
no_license
use std::path::PathBuf; use structopt::StructOpt; use crate::spec::Name; /// A Ryvm CLI command #[derive(Debug, StructOpt)] pub enum RyvmCommand { #[structopt(about = "Quit ryvm", alias = "exit")] Quit, #[structopt(about = "Start recording a loop. Press enter to finish recording.")] Loop { #[...
true
214e8b1638f3daf99abe40407dfe65a14ef8e9bb
Rust
jam1garner/cargo-mextk
/src/run.rs
UTF-8
2,042
2.515625
3
[]
no_license
use crate::paths::{dir_from_id, PathExt}; use crate::manifest::Manifest; use crate::{install, Error}; use std::{io, fs}; use std::path::Path; use std::process::Command; use include_dir::{include_dir, Dir}; #[cfg(windows)] const DOLPHIN_COMMAND: &str = "Dolphin.exe"; #[cfg(not(windows))] const DOLPHIN_COMMAND: &str ...
true
37a083a86e1855a3c9748e8276af246d6fb3dbca
Rust
PacktPublishing/The-Complete-Rust-Programming-Reference-Guide
/Chapter07/block_expr.rs
UTF-8
415
3.125
3
[ "MIT" ]
permissive
// block_expr.rs fn main() { // using bare blocks to do multiple things at once let precompute = { let a = (-34i64).abs(); let b = 345i64.pow(3); let c = 3; a + b + c }; // match expressions let result_msg = match precompute { 42 => "done", a if a % ...
true
ca2647c941a544ba85fc692ed460a80625d689ee
Rust
Pzkgw/CAVI_Transcoding_Server
/CAVI_Transcoding_Main/src/header.rs
UTF-8
2,886
3.71875
4
[]
no_license
use std::string::ToString; use std::collections::BTreeMap; pub type Key = String; pub type Value = String; #[derive(Debug)] pub struct Headers { headers: BTreeMap<Key, Value>, } impl Headers{ pub fn new () -> Headers { Headers { headers: BTreeMap::new() } } pub fn get(&self, key: Key) -> O...
true
1320197473741896d61a70602736d5ab266941cb
Rust
canpok1/atcoder-rust
/contests/abc193/src/bin/b.rs
UTF-8
441
2.734375
3
[]
no_license
use std::cmp::min; use proconio::input; fn main() { input! { n: usize, } let mut min_p = -1; for _i in 0..n { input!{ a: i64, p: i64, x: i64, } let stock = x - a; if stock > 0 { if min_p < 0 { min_p...
true
5e3f0361d06f262a7908f2c24c4c29c4cd1087cf
Rust
djmitche/rerl
/src/vm.rs
UTF-8
9,083
3.03125
3
[]
no_license
//! Stack-based VM use crate::data::{Message, Value}; use crate::program::{Function, Instruction, Module}; use std::collections::HashMap; use std::sync::{Arc, Mutex}; use tokio::sync::{ mpsc::{channel, Receiver, Sender}, Notify, }; #[derive(Clone)] pub struct VM(Arc<Mutex<VMInner>>); pub struct VMInner { ...
true
f0285278c1633eda3f23460cca37f5f31d6966a4
Rust
WillTarte/COMP442-Compiler
/src/lexer/lexer.rs
UTF-8
12,188
3.15625
3
[]
no_license
//! Lexer implementation for the compiler use crate::lexer::token::InvalidTokenType::InvalidCharacter; use crate::lexer::token::{Token, TokenFragment, TokenType}; use crate::lexer::utils::lexer::{ is_valid_character, parse_kw_or_id, parse_number, parse_op_or_punct, parse_string, }; use crate::lexer::utils::LINE_EN...
true
d26ffd351e4d72a5a49286970c4cf6a17b322c46
Rust
vangroan/cave
/build.rs
UTF-8
2,417
3.078125
3
[]
no_license
extern crate fs_extra; extern crate glob; extern crate itertools; use std::env; use std::path::Path; use itertools::concat; /// Copies all resources to the out directory. fn copy_resources() { use fs_extra::dir::{copy, CopyOptions}; let out_dir = env::var("OUT_DIR").unwrap(); let res_dir = "resources"; ...
true
f71cb0073c2da76d644f6e8d8c479f1cd19fa156
Rust
vicentedpsantos/rust-by-example
/src/functions/closures/closures.rs
UTF-8
1,088
3.9375
4
[]
no_license
// Closures in Rust are like Ruby blocks. // The syntax and capabilities of closures make them convenient // for on the fly usage. Calling a closure is exactly like calling // a function. However, both input and return types can be inferred // and input variable names must be specified. fn main() { fn function (i:...
true
a737d144bca391688bbc5256a5104e72cc32a4db
Rust
dvc94ch/crepe
/tests/test_let_bindings.rs
UTF-8
802
3.375
3
[ "MIT", "Apache-2.0" ]
permissive
// This test ensures that variables defined in `let` bindings are registered. use crepe::crepe; struct Wrapper<T> { x: T, } enum Wrapper2<T> { Inner { y: T }, } impl<T> Wrapper2<T> { fn new(y: T) -> Self { Self::Inner { y } } } crepe! { @input struct Input(i32); @output #[d...
true
b721e72e8b0eaca11c8d8ecdf615c1cce8421520
Rust
coreos/zincati
/src/weekly/utils.rs
UTF-8
7,364
3.625
4
[ "Apache-2.0" ]
permissive
//! Utilities for weekly-time related logic. use crate::weekly::{MinuteInWeek, MAX_WEEKLY_MINS, MAX_WEEKLY_SECS}; use anyhow::{anyhow, bail, ensure, Result}; use chrono::{DateTime, TimeZone, Weekday}; use fn_error_context::context; use std::convert::TryInto; use std::time::Duration; /// Convert `MinuteInWeek` to a we...
true
0920d53f8d31d1cbeb4b84aa0330c96a27e87217
Rust
Emilgardis/svd
/svd-rs/src/device.rs
UTF-8
13,976
2.703125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use super::{ BuildError, Cpu, EmptyToNone, Name, Peripheral, RegisterProperties, SvdError, ValidateLevel, }; /// Errors for [`Device::validate`] #[derive(Clone, Debug, PartialEq, Eq, thiserror::Error)] pub enum Error { /// Device has no peripherals #[error("Device must contain at least one peripheral")] ...
true
950f7466826588a53fa9adab0400d72da5fc8aed
Rust
imp/rangetree-rs
/tests/rangetree.rs
UTF-8
2,553
2.859375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Apache License, Version 2.0 // (c) Campbell Barton, 2016 extern crate rangetree; use rangetree::RangeTree; #[test] fn test_basic_take_release() { let mut r: RangeTree<i32> = RangeTree::new([0, 10], false); let i = r.take_any().unwrap(); assert_eq!(i, 0); assert!(!r.has(i)); let i = r.take_an...
true
45f9dd4e673a135e2b16bb9c7e65cff99a952911
Rust
mgacek8/cryptopals-solutions-rust
/src/set2/challenge09.rs
UTF-8
2,146
3.578125
4
[]
no_license
/// Implements PKCS#7 padding. /// /// PKCS#7 padding is defined in [RFC 5652](https://tools.ietf.org/html/rfc5652#section-6.3). pub fn pkcs_7(data: &[u8], padding_size: usize) -> Vec<u8> { let bytes_to_pad = padding_size - (data.len() % padding_size); let mut padded_data = data.to_vec(); for _ in 0..bytes...
true
4e866b6d6b099028461f40014a184c113b3483d9
Rust
stevedonovan/mosquitto-client
/examples/self-publish-receive-many.rs
UTF-8
683
2.65625
3
[ "MIT" ]
permissive
extern crate mosquitto_client as mosq; use mosq::Mosquitto; use std::thread; fn run() -> mosq::Result<()> { let m = Mosquitto::new("test"); m.connect_wait("localhost",1883,300)?; let bilbo = m.subscribe("bilbo/#",1)?; let mt = m.clone(); thread::spawn(move || { for i in 0..5 { ...
true
0730115647ef60d66a77bdba5bdd153f0b3fcbe4
Rust
Earlz/VSTPlugin
/src/lib.rs
UTF-8
4,004
2.703125
3
[]
no_license
#[test] fn it_works() { } #[macro_use] extern crate vst2; use vst2::plugin::{Info, Plugin}; use vst2::buffer::AudioBuffer; use std::collections::vec_deque::VecDeque; use std::vec::Vec; #[derive(Default)] struct BasicPlugin{ history: VecDeque<f64>, accumulator: f64, kickback: f64, //params.. limit_param: f32,...
true
46df83f5f4d751f75501fdaeed5dd1352b0feff8
Rust
yancouto/psycho_rust
/src/systems/gameplay/enemy_spawner.rs
UTF-8
1,989
2.671875
3
[ "MIT" ]
permissive
use amethyst::{ core::math::{Point2, Vector2}, core::timing::Time, derive::SystemDesc, ecs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, SystemData, WriteStorage}, }; use crate::{ components::{EnemySpawner, Triangle}, display::{HEIGHT as H, WIDTH as W}, systems::player::movement:...
true
05cecbf9952a04209391c032ac165c46850a868a
Rust
RustWorks/liquid-rust-templating
/crates/core/src/runtime/stack.rs
UTF-8
6,866
2.8125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::error::Error; use crate::error::Result; use crate::model::{Object, ObjectView, ScalarCow, Value, ValueCow, ValueView}; /// Layer variables on top of the existing runtime pub struct StackFrame<P, O> { parent: P, name: Option<kstring::KString>, data: O, } impl<P: super::Runtime, O: ObjectView> St...
true
2995d7df546a7d8eae908cedfc25724cfe213343
Rust
flxo/rogcat
/src/lossy_lines.rs
UTF-8
7,188
3.28125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright (c) 2018 Tokio Contributors use bytes::{BufMut, BytesMut}; use futures::{Poll, Stream}; use std::{ cmp, io::{self, BufRead}, usize, }; use tokio::{ codec::{Decoder, Encoder}, io::AsyncRead, }; /// Combinator created by the top-level `lossy_lines` method which is a stream over /// the ...
true
715d2546f534ab240a2da314ab4b5d216759d958
Rust
masaxsuzu/calculator
/src/token.rs
UTF-8
174
2.8125
3
[]
no_license
#[derive(Debug, Clone, PartialEq)] pub enum Token { Illegal, Eof, Integer(i64), Plus, Minus, Asterisk, Slash, LeftParen, RightParen, }
true
25805ae6eebe86a90931724c26fa806f8dd6db7f
Rust
ingolia-lab/turbidostat
/mcgeachy-2018/cyh2/src/bc-pileup/trl.rs
UTF-8
2,680
2.78125
3
[]
no_license
struct NtTree<T> { a: T, c: T, g: T, t: T, } impl<T> NtTree<T> { pub fn get(&self, nt: u8) -> Option<&T> { match nt { b'A' => Some(&self.a), b'C' => Some(&self.c), b'G' => Some(&self.g), b'T' => Some(&self.t), _ => None, } ...
true
45ecede9ea8dd6285b66149baba822f43df08b7d
Rust
kevin20200525/curv
/examples/pedersen_commitment.rs
UTF-8
1,162
2.90625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use curv::BigInt; /// Pedesen Commitment: /// compute c = mG + rH /// where m is the commited value, G is the group generator, /// H is a random point and r is a blinding value. /// TO RUN: /// cargo run --example pedersen_commitment --features CURVE_NAME /// CURVE_NAME is any of the supported curves: i.e.: /// cargo ...
true
3116151384ce24ce0d067c0d19a486bbff3122ef
Rust
iCodeIN/patterns_rs
/src/builder/mod.rs
UTF-8
671
3.609375
4
[ "MIT" ]
permissive
//! # 创建者模式 #[derive(Default)] pub struct Foo { result: String } #[derive(Default)] pub struct FooBuilder { foo: Foo } impl FooBuilder { pub fn new() -> Self { Self::default() } pub fn part1(mut self) -> Self { self.foo.result.push_str("part1 "); self } pub fn part...
true
244accbdb7ab97f4683a1ebc292cf750dbf2333c
Rust
Aelto/calco
/src/models/inherited_sheet.rs
UTF-8
3,749
2.875
3
[ "MIT" ]
permissive
use crate::constants::DATABASE_PATH; use rusqlite::{params, Connection, Result}; #[allow(dead_code)] pub struct InheritedSheet { pub parent_sheet_id: i32, pub inherited_sheet_id: i32, pub date: i64 } impl InheritedSheet { #[allow(dead_code)] pub fn new(parent_sheet_id: i32, inherited_sheet_id: i32, date: i6...
true
3774e5714dd11fe3e14c378df02de68277dfda09
Rust
AndreasOM/ggj19
/src/counter.rs
UTF-8
796
2.9375
3
[ "MIT", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
use crate::bobs::bobtype::BobType; use crate::fb::FB; pub struct Counter { } impl Counter { fn offset_for( n: usize ) -> isize { match n { 0 => 0, 1 => 17, 2 => 34, 3 => 51, 4 => 68, 5 => 85, 6 => 102, 7 => 119, 8 => 136, 9 => 153, _ => 0, } } pub fn draw( value: usize, data: ...
true
fb9fcde061c29fb0c49932bc279b004b7461d74f
Rust
Elinvynia/aoc2020
/src/main-2.rs
UTF-8
1,882
3.4375
3
[ "MIT", "Apache-2.0" ]
permissive
use std::{fs::File, io::{BufRead, BufReader}, vec}; struct Password { letter: char, min_amount: u8, max_amount: u8, password: String, } fn main() { let file = File::open("inputs/input-2.txt").unwrap(); let lines = BufReader::new(file).lines(); let mut passwords: Vec<Password> = vec![]; ...
true
45ea9638354af9ee5b5c3880d6e3b4c934f8f4a0
Rust
strangelovephd/minesweeper
/src/minesweeper.rs
UTF-8
2,994
3.71875
4
[]
no_license
//! Gameboard logic. use std::collections::HashSet; /// Sizes of gameboard. const SIZE_BEGINNER: usize = 8; const SIZE_INTERMEDIATE: usize = 16; const SIZE_EXPERT: usize = 24; /// Mine number for different game modes. const MINE_NUMBER_BEGINNER: usize = 10; const MINE_NUMBER_INTERMEDIATE: usize = 40; const MINE_NUMB...
true
11775dd4f4fe8a7e412ada26df2d2d7619e5cb1a
Rust
graycl/rust_turorial
/hw05/src/game/hall.rs
UTF-8
653
3.34375
3
[]
no_license
use std::cell::RefCell; use std::rc::Rc; use super::room::Room; #[derive(Debug)] pub struct Hall { pub left: Rc<RefCell<Room>>, pub right: Rc<RefCell<Room>>, } impl Hall { pub fn new(left: Rc<RefCell<Room>>, right: Rc<RefCell<Room>>) -> Hall { Hall { left: left.clone(), right: right.clone() } } ...
true
7ffa13d788eb93b21a9816735ba632c651ff3ac3
Rust
pnadon/aoc
/y2021/src/helpers.rs
UTF-8
625
3.046875
3
[ "Apache-2.0" ]
permissive
use anyhow::Result; use std::{ fs::File, io::{BufRead, BufReader}, }; pub fn comma_delimited_input(f: File) -> Result<Vec<usize>> { let mut buf = String::new(); BufReader::new(f).read_line(&mut buf)?; let nums = buf .trim() .split(',') .into_iter() .map(|num| Ok(num.parse::<usize>()?)) .c...
true
fbb524048c396d4af15f721fb6bb8e6d9b61905c
Rust
rusterlium/rustler
/rustler_tests/native/rustler_test/src/test_primitives.rs
UTF-8
678
2.828125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use rustler::ErlOption; #[rustler::nif] pub fn add_u32(a: u32, b: u32) -> u32 { a + b } #[rustler::nif] pub fn add_i32(a: i32, b: i32) -> i32 { a + b } #[rustler::nif] pub fn echo_u8(n: u8) -> u8 { n } #[rustler::nif] pub fn option_inc(opt: Option<f64>) -> Option<f64> { opt.map(|num| num + 1.0) } #...
true
5e0351ebba7489f2f6ff0bfb599d796ab503f58d
Rust
skgbanga/AOC
/2017/15/main.rs
UTF-8
715
3.1875
3
[]
no_license
struct Gen { start: i64, mult: i64, mo: i64, } impl Gen { fn next(&mut self) -> u16 { loop { let p = (self.start * self.mult) % 2147483647; self.start = p; if p % self.mo == 0 { return p as u16; } } } } fn main() { ...
true
6aea299b04c20a22884eb799585f39543eca8722
Rust
Lakelezz/serenity
/src/model/gateway.rs
UTF-8
11,461
3.25
3
[ "ISC" ]
permissive
//! Models pertaining to the gateway. use parking_lot::RwLock; use serde::de::Error as DeError; use serde::ser::{SerializeStruct, Serialize, Serializer}; use serde_json; use std::sync::Arc; use super::utils::*; use super::prelude::*; /// A representation of the data retrieved from the bot gateway endpoint. /// /// Th...
true
5ba87b8b777f5c7be3fa5f291f357cfb496e572a
Rust
steveklabnik/simplot.rs
/src/grid.rs
UTF-8
1,336
3.203125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use Script; use axis::Axis; use display::Display; #[deriving(Clone)] pub struct Properties { hidden: bool } // TODO Lots of configuration pending: linetype, linewidth, etc impl Properties { // NB I dislike the visibility rules within the same crate #[doc(hidden)] pub fn _new() -> Properties { ...
true
0f58dcb385f12ac3725015d65cf8d17f557b53a3
Rust
libp2p/rust-libp2p
/protocols/kad/src/query/peers.rs
UTF-8
2,879
2.65625
3
[ "MIT" ]
permissive
// Copyright 2019 Parity Technologies (UK) 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, mer...
true
d4f74c473f5d0b9a5df273423c0151e9650c6686
Rust
sseemayer/aoc2020
/src/bin/day03.rs
UTF-8
2,349
2.953125
3
[]
no_license
use std::fs::File; use snafu::{ResultExt, Snafu}; use aoc2020::map::{Map, MapError, ParseMapTile}; #[derive(Debug, Snafu)] enum Error { #[snafu(display("I/O error on '{}': {}", filename, source))] Io { filename: String, source: std::io::Error, }, #[snafu(display("Map error: {}", sour...
true
e42f2d49a81889a69941cb24cb3cfba9e0b131f8
Rust
Maix0/pixel_engine
/examples/fps_pixel/src/maps.rs
UTF-8
5,802
2.703125
3
[]
no_license
extern crate pixel_engine as engine; extern crate ron; extern crate serde; //use engine::Keycode; use engine::*; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct World { pub map: Map, pub objs: Vec<Objects>, pub tiles: std::collections::HashMap<char...
true
3a3e0449ea37587ed57d9464175e6a6fe3aa5a65
Rust
isgasho/shine
/crates/shine-math/src/trace/tracescope.rs
UTF-8
1,300
2.90625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::ops; pub trait Trace { fn trace_begin(&self); fn trace_end(&self); fn trace_push_group<S: Into<String>>(&self, name: Option<S>); fn trace_pop_group(&self); fn trace_pause(&self); fn trace_document(&self) -> TraceDocument<'_, Self> where Self: Sized, { self.trac...
true
7d247a3d8edb9bae6095d2cac9f93133db5e2a53
Rust
jamwaffles/gmlpa-rs
/src/main.rs
UTF-8
1,132
2.765625
3
[]
no_license
#[macro_use] extern crate nom; use std::error::Error; use std::fs::File; use std::io::prelude::*; use std::path::Path; use std::str; use std::str::FromStr; use nom::{ IResult }; named!(node_field<&[u8], (String, String)>, do_parse!( key: alt!(tag!("id")) >> value: take_until!("\n") >> ((String::from_utf8...
true
182703032a5ca257f3c74a4a966e3715f7de63a2
Rust
mesalock-linux/crates-io
/vendor/stdweb/src/webcore/reference_type.rs
UTF-8
490
3.015625
3
[ "Apache-2.0", "Unlicense", "BSD-3-Clause", "0BSD", "MIT", "CC-BY-SA-3.0" ]
permissive
use webcore::value::{Value, Reference}; use webcore::instance_of::InstanceOf; use webcore::try_from::TryFrom; /// A trait for types which wrap a reference to a JavaScript object. pub trait ReferenceType: AsRef< Reference > + InstanceOf + TryFrom< Value > + TryFrom< Reference > { /// Converts a given reference into...
true
a431d0ea115a36662707063125cf8a3d3af1e7d1
Rust
crudbits/rust
/pluralsight/DataStructure/src/main.rs
UTF-8
2,391
3.328125
3
[]
no_license
#![allow(dead_code)] #![allow(unused_variables)] #![allow(unused_parens)] mod vectors; struct Point { x: f64, y: f64 } enum Color { Black, Green, RGB(u8, u8, u8) } fn main() { tuples(); strings(); enums(); option(); arrays(); vectors::vectors(); } fn tuples() { let mut a:(i32, char) = (1,...
true
c1168f03f4e6f1b471f5edb21af6c114a5e155da
Rust
mdaffin/scribe
/src/menus.rs
UTF-8
2,645
3.015625
3
[ "MIT" ]
permissive
use std::fmt::Display; use std::io::{stdin, stdout, Write}; use termion::event::Key; use termion::input::TermRead; use termion::{self, raw::IntoRawMode}; pub fn select_from<T>(items: &[T]) -> Option<&T> where T: Display, { match items.len() { 0 => { println!("No sutible devices found"); ...
true
54629976c82e9092547bada31e0e43f868c9d761
Rust
baszalmstra/winner
/winner_actor/src/messages.rs
UTF-8
2,246
2.703125
3
[]
no_license
use actix::prelude::*; use std::collections::HashMap; use winner_server::messages::{RoomStateChange, StateChange}; use winner_server::types::{Story, StoryPoints, Winner}; pub type ClientMessages = winner_server::messages::ClientMessages; pub mod client { use super::server; use crate::RoomState; use actix:...
true
523f30542bf5d4530d14b4ad6476dc65296c7d01
Rust
Azure/azure-sdk-for-rust
/services/mgmt/storageimportexport/src/package_2020_08/models.rs
UTF-8
43,594
2.765625
3
[ "LicenseRef-scancode-generic-cla", "MIT", "LGPL-2.1-or-later" ]
permissive
#![allow(non_camel_case_types)] #![allow(unused_imports)] use serde::de::{value, Deserializer, IntoDeserializer}; use serde::{Deserialize, Serialize, Serializer}; use std::str::FromStr; #[doc = "Contains information about the delivery package being shipped by the customer to the Microsoft data center."] #[derive(Clone,...
true
83e6746b3992cdc66de5a606b2ece5b3d8d850ea
Rust
aldrin/advent
/src/y2018/day2.rs
UTF-8
2,809
3.40625
3
[]
no_license
// Copyright 2018 by Aldrin J D'Souza. // Licensed under the MIT License <https://opensource.org/licenses/MIT> //! Inventory Management System ([Statement](https://adventofcode.com/2018/day/2)). use std::collections::HashMap; /// Find the checksum of the input defined as the product of the number of lines in the inpu...
true
301b5b476f5c5af0631094d83dc528fcf7fb9ea2
Rust
Ermiya13277/libra
/language/move-lang/src/cfgir/cfg.rs
UTF-8
3,255
2.6875
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 use super::ast::*; use crate::errors::*; use std::collections::{BTreeMap, BTreeSet, VecDeque}; //************************************************************************************************** // CFG //*****************************...
true
e7972192b0411ac41151c22efe5a8a14da325595
Rust
joshbooks/ginseng_auction-rs
/src/main.rs
UTF-8
10,675
3.125
3
[]
no_license
extern crate ginseng; use ginseng::guest::Guest; use ginseng::guest::Range; use std::cmp::min; use std::cmp::Ordering; use std:collections::HashMap; use std::vec::Vec; fn social_welfare(proposed_allocation: &Vec<(&Guest, u64)>) -> u64 { let mut total_welfare: u64 = 0; for (guest, allocation) in proposed_al...
true
35e90c8a4c72740a1b7966cf8cfdfcc7848c8473
Rust
ThomasZumsteg/project-euler
/problem_0021.rs
UTF-8
1,351
3.359375
3
[]
no_license
#[macro_use] extern crate clap; use common::set_log_level; fn proper_divisors(num: usize) -> Vec<usize> { let mut result = vec![1]; let mut n = 2; while n * n <= num { if num % n == 0 { result.push(n); result.push(num / n); } n += 1; }; return result...
true
c9138da1dde1eee0d3811a485f43992ff211322a
Rust
filiprejmus/algeng
/src/state.rs
UTF-8
3,857
2.765625
3
[]
no_license
use std::iter::repeat; use crate::*; use crate::graph::Graph; #[derive(Clone)] pub struct ExState { pub ideas: Vec<Box<dyn InnerIdea>>, pub state: State, } // Let G be the graph given to ideas[i] on the last .apply() call, // and let G' be the current graph. // Then dirty[i].contains(v) <-> G[N(v, G) + v] !=...
true
4036d7219bdae17ad581843a466fa3bf6b3b1397
Rust
planet0104/w600_rust
/websocket-server/src/main.rs
UTF-8
3,308
2.78125
3
[ "MIT" ]
permissive
use futures_channel::mpsc::{unbounded, UnboundedSender}; use futures_util::{future, pin_mut, stream::TryStreamExt, StreamExt}; use serde_json::Value; use std::{ collections::HashMap, io::Error, sync::{Arc, Mutex}, }; use tokio::net::{TcpListener, TcpStream}; use tokio_tungstenite::tungstenite::Message; #[t...
true
0a626e713ed60f9e21e60e265dff5abef6d87568
Rust
chutchinson/advent-of-code
/src/day7.rs
UTF-8
4,089
3.328125
3
[]
no_license
use crate::intcode::{Intcode, IntcodeBuilder}; pub fn solve() { let input = include_str!("./inputs/7.txt"); { let phases = vec![0, 1, 2, 3, 4]; let max_thruster_signal = permutations(phases) .map(|sequence| amplify_thruster_signal(input, &sequence, false)) .max() ...
true
744c191a078b37fe6f3cf8a8d7cb4c287cc3b6ae
Rust
fivemoreminix/rsc
/src/lib.rs
UTF-8
1,378
3.15625
3
[ "MIT" ]
permissive
mod expr; mod interpreter; mod parser; mod tokenizer; pub use expr::*; pub use interpreter::*; pub use parser::*; pub use tokenizer::*; use std::fmt::Debug; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign}; use std::str::FromStr; pub trait Num: Debug + Clone + Part...
true
1bad239ec2dc684254b807306bf2f9e2ee996700
Rust
marco-c/gecko-dev-wordified-and-comments-removed
/third_party/rust/threadbound/src/lib.rs
UTF-8
1,350
2.65625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# ! [ doc ( html_root_url = " https : / / docs . rs / threadbound / 0 . 1 . 5 " ) ] # ! [ allow ( clippy : : doc_markdown ) ] use std : : fmt : : { self Debug } ; use std : : thread : : { self ThreadId } ; pub struct ThreadBound < T > { value : T thread_id : ThreadId } unsafe impl < T > Sync for ThreadBound < T > { } u...
true
4515f27d3948e3947034a404fa1e1ba57d9e9364
Rust
iCodeIN/reedline
/src/history_search.rs
UTF-8
1,416
3.265625
3
[ "MIT" ]
permissive
use std::collections::VecDeque; pub struct BasicSearch { pub result: Option<(usize, usize)>, pub search_string: String, } pub enum BasicSearchCommand { InsertChar(char), Backspace, Next, } impl BasicSearch { pub fn new(search_string: String) -> Self { Self { result: None, ...
true
798c4d0ca7b710649ac3df401d3a03e3a2189f69
Rust
dupu222/nom-bitvec
/src/lib.rs
UTF-8
808
3.03125
3
[ "MIT" ]
permissive
//! This crate provides input types for [nom parser combinators](https://crates.io/crates/nom) //! using [bitvec](https://crates.io/crates/bitvec). //! With those, you can use common nom combinators directly on streams of bits. //! //! ## Example //! //! ```rust,ignore //! let data = [0xA5u8, 0x69, 0xF0, 0xC3]; //! let...
true
d87f2b4e82f0b9ae955b3bd8fe10af8443d24303
Rust
shino16/cp_rust
/src/tests.rs
UTF-8
6,969
2.859375
3
[ "CC0-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[cfg(test)] mod tests { mod gf { use crate::gf::*; #[test] fn test_pow() { use crate::rand::xorshift::*; let mut rng = Xorshift64::new(); assert_eq!(Gf17::new(2).pow(3), Gf17::new(8)); for _ in 0..100 { let base: Gf17 = rng.nex...
true
94a32dc1e08e285e709358555d4237913e1a57bb
Rust
sunumathewscaria/rust
/aoc4part1/src/main.rs
UTF-8
4,602
3.03125
3
[]
no_license
use array2d::Array2D; use std::env; use std::{ fs::File, io::{prelude::*, BufReader}, path::Path, }; fn lines_from_file(filename: impl AsRef<Path>) -> Vec<String> { //AsRef ? what is the use println!("{:?}", env::current_dir()); let file = File::open(filename).expect("no such file"); let b...
true
d53b9fb2437fa642ec86a239a407403600784ccb
Rust
nervosnetwork/molecule
/tools/codegen/src/ast/raw/mod.rs
UTF-8
3,233
2.796875
3
[ "MIT" ]
permissive
use std::path::PathBuf; #[cfg(feature = "compiler-plugin")] use serde::{Deserialize, Serialize}; use property::Property; mod utils; #[derive(Debug, Default, Property)] pub(crate) struct Ast { syntax_version: Option<SyntaxVersion>, namespace: String, imports: Vec<ImportStmt>, decls: Vec<TopDecl>, } ...
true
131b49825f6bc890cdee90d0b5c6a3ad02ba09ed
Rust
Gogomoe/LeetCodeSolutions
/src/0895.rs
UTF-8
923
3.109375
3
[]
no_license
use std::collections::{HashMap, VecDeque}; use std::cmp::max; struct FreqStack { cnt: HashMap<i32, usize>, stacks: Vec<VecDeque<i32>>, max_cnt: usize, } impl FreqStack { fn new() -> Self { FreqStack { cnt: HashMap::new(), stacks: Vec::new(), max_cnt: 0, ...
true
a32119218ecc45359849c49ff184eb1c7bb7a3ad
Rust
abashurov/event_display
/src/middlewares/role.rs
UTF-8
4,010
2.671875
3
[]
no_license
use actix_web::middleware::session::RequestSession; use actix_web::middleware::{Middleware, Started}; use actix_web::HttpRequest; use futures::future::Future; use std::rc::Rc; use crate::database::users::messages::GetUserInfo; use crate::routes::AppState; const SELF_RO_ACCESS: i16 = 0; const FULL_RO_ACCESS: i16 = 1; ...
true
65c40fa56b7a823e644a86160bc9a2db0dced923
Rust
freestrings/playground
/rust-ds/src/linked_list/raw_linked_list.rs
UTF-8
4,756
3.765625
4
[]
no_license
use std::ptr; type Link<T> = Option<Box<Node<T>>>; /// /// tail은 Box 포인터가 아니라 Node의 mutable 참조를 보관한다. /// Node가 mutable인 이유는 next값을 변경해야 하기 때문. /// struct List<T> { head: Link<T>, tail: *mut Node<T>, } struct Node<T> { data: T, next: Link<T>, } struct Iter<'a, T: 'a> { next: Option<&'a Node<T>>,...
true
aba5e41a5863cf528e620b673bde5f4364a0674d
Rust
GraphiteEditor/Graphite
/document-legacy/src/document.rs
UTF-8
38,395
2.53125
3
[ "MIT", "Apache-2.0", "ISC", "BSL-1.0", "BSD-2-Clause", "MPL-2.0", "Unicode-DFS-2016", "BSD-3-Clause", "CC0-1.0" ]
permissive
use crate::intersection::Quad; use crate::layers::folder_layer::FolderLayer; use crate::layers::layer_info::{Layer, LayerData, LayerDataType, LayerDataTypeDiscriminant}; use crate::layers::layer_layer::{CachedOutputData, LayerLayer}; use crate::layers::shape_layer::ShapeLayer; use crate::layers::style::RenderData; use ...
true
5dc105cd2c4fd19ab66bb6daf3d48aed3b12908f
Rust
lvsoso/learn_rust
/FirstClassOfRust/ownership/src/ownership_error.rs
UTF-8
290
3.3125
3
[]
no_license
fn main(){ let data = vec![1,2,3,4]; //let data1 = data; let data1 = data.clone(); println!("sum of data1: {}", sum(data1.clone())); println!("data1: {:?}", data1); println!("sum of data: {}", sum(data)); } fn sum(data: Vec<u32>) -> u32 { data.iter().sum() }
true
2b225ed3340ac1d8dba0b4a8ce8387b1b9f9e1f5
Rust
johansmitsnl/oxfeed
/api/src/services/source.rs
UTF-8
4,069
2.640625
3
[]
no_license
use actix_web::web::{Data, Json, Path}; use oxfeed_common::item::Model as ItemModel; use oxfeed_common::source::Model; pub(crate) fn scope() -> actix_web::Scope { actix_web::web::scope("/sources") .service(get) .service(delete) .service(update) .service(all) .service(create)...
true
e23e33dc0992bff8f9a4d10e7aad2589e1b02e5f
Rust
cdrappi/rnr
/services/api/src/auth/twilio.rs
UTF-8
1,121
2.609375
3
[ "Apache-2.0" ]
permissive
use reqwest::{Client, Error, Response}; use util::expect_env; fn get_env() -> (String, String, String) { return ( expect_env("TWILIO_SERVICE"), expect_env("TWILIO_ACCOUNT_SID"), expect_env("TWILIO_AUTH_TOKEN"), ); } pub fn post_phone(phone: &str) -> Result<Response, Error> { let cl...
true