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
f6f970202412aada6a7b66035946c5ff8847cda8
Rust
yuki-uchida/Competitive_programming
/AtcoderBeginnerContest/abc287/src/bin/a.rs
UTF-8
383
3.03125
3
[]
no_license
use proconio::{input}; fn main() { input! { n: usize, mut answers: [String; n], } let count:usize = answers.iter().filter(|&ans| ans == "For").count(); // println!("{}", count); let div: usize = ((n as f32 / 2.0)).ceil() as usize; // println!("{}", div); if count >= div { ...
true
14ad7bac4cf0c72bdc3cdef157893d7e11b71d6a
Rust
blindley/multitext
/src/lib.rs
UTF-8
6,263
3.5625
4
[]
no_license
/*! ```text This project contains a parser for a format I call Multitext. Multitext is a simple text file format that allows you to store multiple text files in one. Its original purpose was to allow all of the shader stages for an OpenGL shader program to be stored in a single file, for easily switching between them a...
true
7cc1c6ae918c0ba8b0f67ee88031d8dd9de7cb3e
Rust
ChrisWhealy/pig_latin
/src/main.rs
UTF-8
1,481
3.796875
4
[]
no_license
fn main() { let plain_text = String::from("This is a Rust training exercise on how to transform the words in an English UTF-8 string into pig latin"); let mut result = String::new(); for word in plain_text.split_whitespace() { result = format!("{} {}", result, pigify(&word)); } println!("\"{}\" in pig l...
true
37d94e8356c8ea740d8203351115e9780a90fd51
Rust
0b01/DIRTY
/src/audio/types.rs
UTF-8
462
3.0625
3
[ "Zlib" ]
permissive
// wengwengweng #[derive(Clone, Copy, Debug, PartialEq)] pub enum Channel { Left, Right, } impl Channel { fn as_usize(&self) -> usize { return match self { Channel::Left => 0, Channel::Right => 1, }; } } #[derive(Clone, Copy, Debug, PartialEq)] pub enum ChannelCount { One, Two, } impl ChannelCount {...
true
57b0aba885de2004345a204c0a2da8265fbe70e5
Rust
Ninjani/advent-of-code-2018
/src/day2.rs
UTF-8
1,582
3.296875
3
[]
no_license
#[aoc(day2, part1)] pub fn solve_day2_part1(input: &str) -> usize { let box_ids: Vec<_> = input.split('\n').collect(); let alphabet: Vec<_> = (b'a'..b'z').map(|x| x as char).collect(); let letter_counts: Vec<_> = box_ids .into_iter() .map(|w| { ( is_letter_count(w...
true
bdb8a205108de4e59996cb66244c4c0a5848442f
Rust
davidspies/dc2
/src/convenience_operators/joins.rs
UTF-8
3,230
2.84375
3
[]
no_license
use crate::key::Key; use crate::monoid::Monoid; use crate::tuple::{fst, snd, swap}; use crate::{Op, Relation}; use std::ops::Mul; impl<'a, C: Op> Relation<'a, C> { pub fn semijoin_on<F: Fn(&C::D) -> C2::D + 'static, C2: Op, R3: Monoid>( self, other: Relation<'a, C2>, f: F, ) -> Relation...
true
33a0f117e7ff3ae376e6b05f4e41fe9b0beb086b
Rust
sudormrfbin/pac
/src/git.rs
UTF-8
3,306
2.96875
3
[ "MIT" ]
permissive
use crate::{Error, Result}; use git2::{self, Repository}; use std::fs; use std::path::PathBuf; /// Fetch from a remote repo (branches and tags). Does not change working tree. /// Returns the default remote branch. fn fetch(repo: &Repository, remote: &str) -> Result<String> { let mut opts = git2::FetchOptions::new...
true
67b62b6c44ceebcb2e08030144b9d446bd0ee68c
Rust
npip99/poker-rust
/src/deck.rs
UTF-8
1,889
3.625
4
[]
no_license
use std::fmt; #[derive(Clone, Copy, PartialEq, Eq, Hash)] pub enum Suit { Clubs, Diamonds, Hearts, Spades } pub type Rank = usize; #[derive(Clone, PartialEq, Eq)] pub struct Card { pub rank: Rank, pub suit: Suit, } impl fmt::Display for Card { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {...
true
2c2dfdddbd596d41919d07391d17a5426c072d53
Rust
DataTriny/Fortuna
/src/utils.rs
UTF-8
312
2.734375
3
[]
no_license
pub fn compare_words(s: &str, against: &str) -> usize { let mut against_chars = against.chars(); for (i, c) in s.chars().enumerate() { let against_char = against_chars.next(); if i >= against.len() || c != against_char.unwrap() { if i == 0 || c != ' ' { return 0; } return i; } } s.len() }
true
137f542e294a11ec8a672b24a40c1cb964006a8a
Rust
jfarrell468/rlox
/src/vm/compiler.rs
UTF-8
21,387
2.90625
3
[ "MIT" ]
permissive
use num_enum::TryFromPrimitive; use std::convert::TryFrom; use std::ops::Sub; use strum_macros::Display; use super::super::scanner; use super::super::token::{Token, TokenType}; use super::chunk::Chunk; use super::opcode::OpCode; use super::value::Value; pub enum InterpretResult { Ok, CompileError, Runtime...
true
f76dc612473dca5862ebec42d7e0840a28f0576c
Rust
rj00a/sandbox
/leetcode/plus-one.rs
UTF-8
325
3.1875
3
[ "Unlicense" ]
permissive
fn main() { println!("{:?}", plus_one(vec![9, 9, 9])); } fn plus_one(mut digits: Vec<i32>) -> Vec<i32> { for i in digits.iter_mut().rev() { if *i == 9 { *i = 0; } else { *i += 1; return digits; } } digits[0] = 1; digits.push(0); digi...
true
0fd14c562b0bc5e39e44ddab1b706d0528cc242c
Rust
TheWestDevop/zaryn_peer_2_peer_crypto_wallet
/src/controllers/stake.rs
UTF-8
9,830
2.609375
3
[]
no_license
use crate::actors::db::DBActor; use crate::actors::stake::*; use crate::actors::transaction::{CreateTransaction, UpdateTransaction}; use crate::actors::wallet::GetByWallet; use crate::controllers::wallet::{update_wallet,transfer}; use crate::models::stake::{StakeInfo, WithdrawStake}; use crate::utils::{crypto::encode, ...
true
7ea60307a2fc92146e6fe05d32aca94613ef5e59
Rust
ariefrahmansyah/learn-rust
/borrowing/functions-references.rs
UTF-8
365
4.03125
4
[]
no_license
fn print_greeting(message: &String) { println!("Greeting: {}", message); } fn main() { let greeting = String::from("Hello"); print_greeting(&greeting); // `print_greeting` takes a `&String` not an owned `String` so we borrow `greeting` with `&` print_greeting(&greeting); // Since `greeting` didn't move...
true
5b9fedfbbda18c227d27b96d30514e1ada6cf179
Rust
tx991020/rust-exercise
/a34/src/main.rs
UTF-8
655
2.890625
3
[]
no_license
use clap::{load_yaml, App}; fn main() { // The YAML file is found relative to the current file, similar to how modules are found let yaml = load_yaml!("cli.yml"); let matches = App::from(yaml).get_matches(); // Same as previous examples... match matches.subcommand_name() { Some("test") => ...
true
9a1e3c0678cea0decefe43d73346c80ed70ccaae
Rust
maxtnuk/wasm_cluster
/src/ml/activation/softplus.rs
UTF-8
711
3.046875
3
[]
no_license
use std::f64; use super::{Activation, CalcMod}; #[derive(Copy, Clone)] pub struct SoftPlus; impl SoftPlus { pub fn new() -> SoftPlus { return SoftPlus; } } impl Activation for SoftPlus { /// Calculates the SoftPlus of input `x` fn calc(&self, x: Vec<f64>,calc_mode: &CalcMod) -> Vec<f64> { ...
true
b121d3826d41ea161e6eb1c669ed6ed3cd36f4d7
Rust
Teln0/SolidPython
/src/main.rs
UTF-8
2,477
2.5625
3
[]
no_license
use solid_python::lexer::{lex, Token}; use solid_python::parser::{Parser}; use solid_python::span::SessionGlobals; use solid_python::target::tree_walk_interpreter::TreeWalkInterpreter; use solid_python::target::tree_walk_interpreter::val::{ptr, TWIVal, TWIValKind, FnTWIVal, TyTWIVal, mk_type, FnTWIValCode, mk_none}; f...
true
423ba1d09f53ac03281604d80c28514f21a1056a
Rust
malramsay64/crystal-packing
/crystal-packing/src/wallpaper.rs
UTF-8
5,781
3.0625
3
[ "MIT" ]
permissive
// // wallpaper.rs // Copyright (C) 2019 Malcolm Ramsay <malramsay64@gmail.com> // Distributed under terms of the MIT license. // use anyhow::{anyhow, Error}; use serde::{Deserialize, Serialize}; use std::convert::TryFrom; use crate::{CrystalFamily, Transform2}; #[derive(Clone, Serialize, Deserialize)] pub struct Wa...
true
3e3fbc8324d3eb4c11d8c048ee56609c55afa377
Rust
sonro/Ellie
/src/commands/extra/weather.rs
UTF-8
6,481
2.84375
3
[ "MIT", "GPL-3.0-only" ]
permissive
use crate::utilities::database::get_user_location; use crate::utilities::geo_utils::get_coordinates; use chrono::prelude::*; use itertools::Itertools; use log::error; use reqwest::blocking::Client; use reqwest::Url; use serde::Deserialize; use serenity::client::Context; use serenity::framework::standard::macros:...
true
fdbbb0b22d561081306339c20c40e10bd50d94d1
Rust
bitkis/ruspiro-brain
/src/mpmc/mod.rs
UTF-8
2,146
3.03125
3
[ "Apache-2.0" ]
permissive
/*************************************************************************************************** * Copyright (c) 2019 by the authors * * Author: André Borrmann * License: Apache License 2.0 **************************************************************************************************/ //! # Multi Producer...
true
5eec6791c7930d149b353a23d09c00f5e5c446bb
Rust
rust-lang/rust-bindgen
/bindgen/ir/ty.rs
UTF-8
47,947
2.921875
3
[ "BSD-3-Clause" ]
permissive
//! Everything related to types in our intermediate representation. use super::comp::CompInfo; use super::context::{BindgenContext, ItemId, TypeId}; use super::dot::DotAttributes; use super::enum_ty::Enum; use super::function::FunctionSig; use super::item::{IsOpaque, Item}; use super::layout::{Layout, Opaque}; use sup...
true
f7236d5edb6bdd99fff711ec73824c8645b7117f
Rust
miguch/crupter
/src/hashes/hasher.rs
UTF-8
1,361
3.109375
3
[ "MIT" ]
permissive
use digest::Digest; use generic_array::GenericArray; use std::io::Read; pub trait Hasher { type OutputArray; /// Produce a hash result from a reader(stdin, file, ...) fn from_reader<R: Read>(self, reader: R) -> Result<Self::OutputArray, failure::Error>; } impl<D: Digest> Hasher for D { type OutputArra...
true
f4664bf163cc97f23431a99d1844e414f4660f4c
Rust
quirinux/rust-core-utils
/src/bin/head.rs
UTF-8
2,554
3.03125
3
[]
no_license
#[macro_use] extern crate log; extern crate env_logger; #[macro_use] mod util; use std::io::{self, Write}; use structopt::StructOpt; #[derive(StructOpt, Debug)] #[structopt(name = "head", about = "output the first part of files")] struct Opt { /// print the first K bytes of each file; with the leading '-', prin...
true
7ae00c370b172f1d9674970bc064a8aebd3061cd
Rust
sclolus/Raymarcher
/src/camera.rs
UTF-8
2,672
3.359375
3
[]
no_license
//! The camera component of the View component of the system. use cgmath::{Vector3, Point3, Rotation, Rotation3, Matrix4, PerspectiveFov, InnerSpace, Rad, Deg, Quaternion}; pub struct Camera { position: Point3<f32>, dir: Vector3<f32>, up: Vector3<f32>, aspect: f32, fovy: Rad<f32>, near_distance: f32, far_dista...
true
407a285d102f13114fdd08264f93deea532dd6e7
Rust
yasinkacmaz/Rusty
/src/main.rs
UTF-8
2,177
3.234375
3
[]
no_license
#![allow(dead_code)] #![allow(unused_variables)] #![allow(unused_imports)] #![allow(non_snake_case)] mod stackheap; mod statements; mod loops; use std::mem; use std::ops::Deref; use crate::stackheap::stack_and_heap; fn main() { //types() //operators() //scopes() //constants() stack_and_heap() } ...
true
4e19a45da3b20bc0169b73807ef764d48c599bde
Rust
azriel91/autexousious
/crate/sprite_model/src/loaded/sprite_render_sequence_handles.rs
UTF-8
1,282
2.515625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use amethyst::{ ecs::{storage::DenseVecStorage, Component, Entity, World, WriteStorage}, renderer::Transparent, shred::{ResourceId, SystemData}, }; use asset_model::ItemComponent; use derivative::Derivative; use sequence_model_derive::sequence_component_data; use crate::loaded::SpriteRenderSequenceHandle; ...
true
200bbb17b80e46c03328880ead2dc90a52e8878e
Rust
makepad/glui
/src/text.rs
UTF-8
4,334
2.625
3
[ "MIT" ]
permissive
use crate::math::*; use crate::shader::*; use crate::cx::*; use crate::cxdrawing::*; pub struct Text{ pub font_id:usize, pub shader_id:usize, pub text:String, pub color: Vec4, pub font_size:f32, pub x: f32, pub y: f32 } impl Style for Text{ fn style(cx:&mut Cx)->Self{ let mut s...
true
ce6023b655dd8c2b8dcc5dd9b2812922c44a7a62
Rust
AlexanderJohnston/JavaScript.Eval
/src/native/JavaScript_Eval_Native/src/v8facade.rs
UTF-8
19,210
2.515625
3
[ "MIT" ]
permissive
use std::{convert::TryFrom, sync::mpsc::RecvError, thread::JoinHandle}; use std::sync::{mpsc, Once}; use rusty_v8 as v8; use crate::{function_parameter::FunctionParameter, V8HeapStatistics}; static INIT_PLATFORM: Once = Once::new(); fn init_platform() { let platform = v8::new_default_platform(0, false).make_sh...
true
c8118fe8549c92ec26c471ee5b4a2937225dcd76
Rust
inversion-engine/inversion-api-rust
/crates/broker/src/inv_uniq.rs
UTF-8
5,013
3.0625
3
[ "Apache-2.0" ]
permissive
//! InvUniq uuid-like identifier, using base58 alphabet. use once_cell::sync::Lazy; use std::sync::Arc; /// InvUniq uuid-like identifier, using base58 alphabet. #[derive( Clone, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Serialize, serde::Deserialize, )] pub struct InvUniq(Arc<str>);...
true
a030967095319d4d2588c91b0087a100ae4794e1
Rust
gabbhack/tgbot
/src/types/dice.rs
UTF-8
4,158
3.65625
4
[ "MIT" ]
permissive
use crate::types::primitive::Integer; use serde::{ de::{Deserializer, Error as _}, Deserialize, }; use std::{error::Error, fmt}; /// Represents a dice with random value #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] pub struct Dice { kind: DiceKind, value: Integer, } impl Dice { ...
true
589ca1428de2d77cfd62bb280b629775e6bc7e29
Rust
tjheslin1/irc-rust
/tests/server_tests.rs
UTF-8
535
2.953125
3
[]
no_license
use irc_rust::server::Server; #[test] fn test_server_creation_name_too_long() { let server_creation_error = Server::new("Areallylongnameforaserverthatjustoverexceedsthesixtyhreecharacterlimit") .expect_err("Expected Err because Server name is too long."); let expected_message = "Error crea...
true
13fdfb98764a8e646383b961691cbf12f7052911
Rust
rectinajh/rust-leetcode
/src/l287_find_the_duplicate_number.rs
UTF-8
1,669
3.59375
4
[]
no_license
/* 287. 寻找重复数 给定一个包含 n + 1 个整数的数组 nums,其数字都在 1 到 n 之间(包括 1 和 n),可知至少存在一个重复的整数。假设只有一个重复的整数,找出这个重复的数。 示例 1: 输入: [1,3,4,2,2] 输出: 2 示例 2: 输入: [3,1,3,4,2] 输出: 3 说明: 不能更改原数组(假设数组是只读的)。 只能使用额外的 O(1) 的空间。 时间复杂度小于 O(n2) 。 数组中只有一个重复的数字,但它可能不止重复出现一次。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/find-the-duplicate-numb...
true
4b11848b023183d3690a2c2fb719bd355c04b286
Rust
ugnom/programming_competition_archive
/abc/abc028/b.rs
UTF-8
948
3.421875
3
[]
no_license
use std::str::FromStr; use std::collections::HashMap; fn get_one<T : FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); return s.trim().parse().ok().unwrap(); } fn get_vec<T : FromStr>() -> Vec<T> { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok...
true
43371b3459c538b8c9a5e952b3e35c869a8bafba
Rust
digitalbitbox/bitbox02-firmware
/src/rust/vendor/num-bigint/src/bigint/shift.rs
UTF-8
3,428
2.90625
3
[ "Apache-2.0", "MIT", "LGPL-3.0-or-later", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::BigInt; use super::Sign::NoSign; use core::ops::{Shl, ShlAssign, Shr, ShrAssign}; use num_traits::{PrimInt, Signed, Zero}; macro_rules! impl_shift { (@ref $Shx:ident :: $shx:ident, $ShxAssign:ident :: $shx_assign:ident, $rhs:ty) => { impl<'b> $Shx<&'b $rhs> for BigInt { type Output ...
true
8eb0cfb3ab81e0f168e09e6de4f4874b8909718b
Rust
simonbrahan/rustbook
/enums/src/main.rs
UTF-8
1,153
3.484375
3
[]
no_license
#[derive(Debug)] enum IpAddr { V4(u8, u8, u8, u8), V6(String), } enum Message { Quit, Move { x: i32, y: i32 }, Write(String), ChangeColour(i32, i32, i32), } impl Message { fn call(&self) -> String { match &self { Message::Quit => "Quit".to_string(), Message:...
true
77d9ec70cf94b169dc219505dda615eb8f9bedfc
Rust
BITICPC/WaveJudge
/judge/src/engine/mod.rs
UTF-8
24,706
2.578125
3
[]
no_license
//! This module implements the very core logic of the judge, or the engine's //! logic. The judge engine performs judge task described in //! `JudgeTaskDescriptor` values and produce judge result in `JudgeResult` //! values. //! mod checkers; mod io; use std::fs::File; use std::io::{Read, Seek, SeekFrom}; use std::pa...
true
1e9748559ce3f1d13ae41039fee13e88b3a29836
Rust
danieleades/tree-buf
/tree-buf/src/internal/types/array.rs
UTF-8
5,705
2.921875
3
[ "LicenseRef-scancode-free-unknown", "MIT" ]
permissive
use crate::prelude::*; use std::vec::IntoIter; #[cfg(feature = "encode")] impl<T: Encodable> Encodable for Vec<T> { type EncoderArray = VecArrayEncoder<T::EncoderArray>; fn encode_root<O: EncodeOptions>(&self, stream: &mut EncoderStream<'_, O>) -> RootTypeId { profile_method!(encode_root); matc...
true
a79962ce378730231fc026879024f45c59920b7d
Rust
d3v3l0/delta
/src/cli.rs
UTF-8
20,042
3.125
3
[ "MIT" ]
permissive
use std::path::PathBuf; use structopt::clap::AppSettings::{ColorAlways, ColoredHelp, DeriveDisplayOrder}; use structopt::StructOpt; #[derive(StructOpt, Clone, Debug, PartialEq)] #[structopt( name = "delta", about = "A syntax-highlighter for git and diff output", setting(ColorAlways), setting(ColoredHe...
true
152d3e418b34da1183600cc66e52d0bbbfdfa367
Rust
storyfeet/shoehorn_circle
/examples/hello.rs
UTF-8
5,099
2.6875
3
[]
no_license
extern crate shoehorn_circle as shoehorn; extern crate bracket_parse; use shoehorn::{Game,ScErr,card_set}; use shoehorn::card::{CardType,CardKey}; use shoehorn::action::{Action,Request}; use shoehorn::supply::Supply; //use shoehorn::player::Player; use bracket_parse::Bracket; use std::io; use std::str::FromStr; use s...
true
0d37aa4fcf7b135428ae79bd8ab6019433205459
Rust
jlgerber/pkmake
/src/targets/test.rs
UTF-8
15,769
3.140625
3
[]
no_license
//! Test //! //! This module contains the Test struct, which models the parameters for the //! pk test command. //! //! Like other targets, it provides individual methods which follow the builder pattern. //! That is, each setter method takes `self` by mutable reference, and returns a mutable //! reference to `self` as...
true
beb6ece9af5dfab6e2489bb3eed75b2c924cfac6
Rust
zmird/muscovite
/src/rules.rs
UTF-8
21,972
3.28125
3
[]
no_license
use crate::game::{Move, Position, Status, State, Board}; use crate::constants::*; // use log::debug; // Returns the opposite color #[allow(dead_code)] pub fn get_opposite_color(color: &String) -> String { if color == WHITE { BLACK.to_string() } else { WHITE.to_string() } } // Returns a cel...
true
4a8ac0f1dd3542fc98dc42b6474359dc6624508f
Rust
kenkoooo/programming-contest-solutions
/rust/src/bin/ddcc2017_qual_c.rs
UTF-8
977
3.171875
3
[]
no_license
use std::io; use std::str; use std::usize; use std::cmp; fn main() { let (n, c) = { let v = read_values::<usize>(); (v[0], v[1]) }; let mut v = (0..n).map(|_| { read_values::<usize>()[0] }).collect::<Vec<_>>(); v.sort(); let mut ans = 0; let mut head = 0; let mut tail = n ...
true
d42e45a2c9c7b8c6280a6f42d41f0d0d67cafdd2
Rust
vegayours/aoc-2020
/src/aoc_16.rs
UTF-8
4,471
3.109375
3
[ "MIT" ]
permissive
use std::{collections::HashMap, ops::RangeInclusive}; struct Rule { name: String, first: RangeInclusive<i64>, second: RangeInclusive<i64>, } impl Rule { fn matches(&self, num: &i64) -> bool { self.first.contains(num) || self.second.contains(num) } fn parse(line: &str) -> Rule { ...
true
dc342b32d585fd9e3d28c15394f03b475e12028e
Rust
K-JBoon/bawk
/src/ast.rs
UTF-8
698
2.71875
3
[]
no_license
use crate::lexer::Span; #[derive(Debug)] pub struct Program { pub rules: Vec<Rule>, } #[derive(Debug)] pub enum RuleType { BeginRule, DefaultRule, EndRule } #[derive(Debug)] pub struct Rule { pub rule_type: RuleType, pub statements: Vec<Statement> } #[derive(Debug)] pub struct Statement { ...
true
28dfc769ee2a24fc0df48508a899ebc40c42d14a
Rust
bubble-07/FETISH-RS
/src/compressed_inv_schmear.rs
UTF-8
1,071
2.546875
3
[ "MIT" ]
permissive
use ndarray::*; use crate::term_pointer::*; use crate::term_reference::*; use crate::type_id::*; use crate::sampled_embedder_state::*; use crate::inverse_schmear::*; #[derive(Clone)] ///An [`InverseSchmear`] which has been compressed relative to some expansion matrix. ///When an inverse schmear is compressed, it may ...
true
8ee6f9bb023c30bf0e283c96ad6f22a82851e38b
Rust
FujiHaruka/renvsubst
/src/main.rs
UTF-8
2,381
3.234375
3
[ "MIT" ]
permissive
extern crate regex; extern crate uuid; use std::io::{self, Read}; use std::env; use uuid::Uuid; use regex::Regex; use std::collections::HashSet; fn main() { let mut input = String::new(); io::stdin().read_to_string(&mut input).unwrap(); let mut output = input.clone(); let var_names = get_subst_names(...
true
eb6d0a87b3204e54bfdf6d88db74129b87ffaf7b
Rust
OneebMalik/rusty-chip8
/src/main.rs
UTF-8
393
2.515625
3
[]
no_license
use std::env; //use std::fs::File; //use std::path::Path; //use std::io::Read; mod chip8; mod cpu; mod display; mod sprite; use chip8::Chip8; fn main() { if env::args().nth(1) == None { panic!("No ROM filepath provided"); } let rom_file_path = env::args().nth(1).unwrap(); let mut chip8 ...
true
bcd5041565321e4bb993274976e42db000f99bac
Rust
huggingface/tokenizers
/tokenizers/src/decoders/sequence.rs
UTF-8
1,281
2.96875
3
[ "Apache-2.0" ]
permissive
use crate::decoders::DecoderWrapper; use crate::tokenizer::{Decoder, Result}; use crate::utils::macro_rules_attribute; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug)] #[macro_rules_attribute(impl_serde_type!)] pub struct Sequence { decoders: Vec<DecoderWrapper>, } impl Sequence { pub fn new(decod...
true
a7706f29479429ba1f7c95e743cdf20c2ee75fda
Rust
tech-paws/vm_memory
/public/rust/vm_memory/src/lib.rs
UTF-8
4,393
3.4375
3
[]
no_license
#[allow(warnings)] #[allow(clippy::all)] mod c_api; use c_api::*; use std::mem; /// Accessing to allocated buffer pub trait BufferAccessor { fn get_buffer_ptr(&self) -> *mut u8; fn get_buffer_size(&self) -> u64; } /// Simple region based allocator. /// /// Allocates continuous chunk of memory with a specifi...
true
52c7b4d54eb49ddee014e7d324469332fe33248a
Rust
pola-rs/polars
/crates/polars-lazy/src/physical_plan/file_cache.rs
UTF-8
2,040
2.546875
3
[ "MIT" ]
permissive
use std::sync::Mutex; use polars_core::prelude::*; #[cfg(any(feature = "parquet", feature = "csv", feature = "ipc"))] use polars_plan::logical_plan::FileFingerPrint; use crate::prelude::*; #[derive(Clone)] pub(crate) struct FileCache { // (path, predicate) -> (read_count, df) inner: Arc<PlHashMap<FileFingerP...
true
23f406214e3cd80119201d5c9579cf22c706ad68
Rust
Eosis/AoC2020
/src/main.rs
UTF-8
3,974
2.734375
3
[]
no_license
mod day_1; mod day_10; mod day_11; mod day_12; mod day_13; mod day_14; mod day_15; mod day_16; mod day_17; mod day_18; mod day_19; mod day_2; mod day_20; mod day_21; mod day_22; mod day_23; mod day_24; mod day_25; mod day_3; mod day_4; mod day_5; mod day_6; mod day_7; mod day_8; mod day_9; use argh::FromArgs; #[deriv...
true
c9ae0985c89dfeaa1c43e73574dee957714e893c
Rust
stepancheg/absh
/src/maybe_strip_csi_writer.rs
UTF-8
473
2.796875
3
[]
no_license
use std::fmt; use std::fmt::Write; use std::io; use crate::ansi::strip_csi; pub struct MaybeStripCsiWriter<W: io::Write> { pub inner: W, pub strip: bool, } impl<W: io::Write> Write for MaybeStripCsiWriter<W> { fn write_str(&mut self, s: &str) -> fmt::Result { if self.strip { write!(se...
true
3cd29356f3ad71b5dcd819c053d8f1a938191176
Rust
montaglue/Fifteen-Game
/src/position.rs
UTF-8
5,944
3.15625
3
[]
no_license
use std::fmt; use std::fmt::Display; use rand::Rng; #[derive(Hash, Eq, PartialEq, Debug, PartialOrd, Ord, Clone, Copy)] pub struct Pos(pub u64); pub const START: Pos = Pos(0xfedcba9876543210); impl Pos { pub fn hole_index(&self) -> usize { for i in 0..16 { if (self.0 >> (4 * i)) & 15 == 15 {...
true
031cf4423d1140c875971166bfabef779905a80c
Rust
ackxolotl/rambleed-rs
/src/architecture.rs
UTF-8
732
2.84375
3
[]
no_license
pub(crate) type PhysAddr = usize; #[derive(Clone)] #[derive(Debug)] pub struct DramAddr { pub chan: u8, pub dimm: u8, pub rank: u8, pub bank: u8, pub row: u16, pub col: u16, } impl DramAddr { pub(crate) fn new() -> DramAddr { DramAddr { chan : 0, dimm : 0, ...
true
ae48ee7ac36012f209284aa7ed0777b8b2cfc79d
Rust
davidli2010/ethnum-rs
/src/fmt.rs
UTF-8
9,573
3.25
3
[ "Apache-2.0", "MIT" ]
permissive
//! Module implementing formatting for `U256` type. //! //! Most of these implementations were ported from the Rust standard library's //! implementation for primitive integer types: //! https://doc.rust-lang.org/src/core/fmt/num.rs.html use crate::{AsU256, U256}; use core::fmt; use core::mem::{self, MaybeUninit}; use...
true
de7ada24ea59f014c8d6d35e5e7720e40f999a0a
Rust
roy-ganz/toql
/crates/core/src/sql_expr/resolver_error.rs
UTF-8
983
2.875
3
[ "MIT", "Apache-2.0" ]
permissive
//! Errors from [Resolver](crate::sql_expr::resolver::Resolver) use thiserror::Error; /// Represents all errors from the Resolver #[derive(Error, Debug)] pub enum ResolverError { /// Aux param can't be resolved, because it's missing. #[error("aux param `{0}` is missing")] AuxParamMissing(String), /// A...
true
2a21b816b47a6042c3d56d52197c16b72c60a3e5
Rust
ry/tokio
/src/runtime/mod.rs
UTF-8
14,989
4
4
[ "MIT" ]
permissive
//! A batteries included runtime for applications using Tokio. //! //! Applications using Tokio require some runtime support in order to work: //! //! * A [reactor] to drive I/O resources. //! * An [executor] to execute tasks that use these I/O resources. //! * A [timer] for scheduling work to run after a set period of...
true
13b0f72438b3a6f2b0a8417aecc72662225501f2
Rust
fvhockney/here-boy
/src/errors.rs
UTF-8
2,988
2.953125
3
[ "MIT" ]
permissive
use std::error::Error; use std::fmt; use std::path::PathBuf; pub enum MockError { UnparsableUri(String), UnableToGet, UnableToCreateFile(PathBuf), UnableToWriteToFile(PathBuf), NoChunk, RequestFailed(String, String), NoConfigFound(PathBuf), CantCreatePaths(PathBuf), MalformedConfig(...
true
e7237b8b09cc2b60277b1575e8a0db5e07c00cb0
Rust
charredlot/cryptopals-rust
/src/base64.rs
UTF-8
4,764
2.890625
3
[]
no_license
use std::fs::File; use std::io::BufReader; use std::io::prelude::*; use std::vec::Vec; use hex::bytes_to_hex; const BASE64_VAL_CHAR: [char; 64] = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',...
true
8757a93e842633b229c759eb3b9baa6261581de0
Rust
youxkei/fermat
/src/layout_fun.rs
UTF-8
26,956
2.703125
3
[]
no_license
use std::cmp::max; use std::collections::{BTreeSet, HashSet}; use std::rc::Rc; use itertools::Itertools; use crate::avltree::AvlTree; use crate::layout_expr::LayoutExpr; #[derive(Clone, Copy, Debug)] pub struct Config { pub right_margin: i32, pub newline_cost: i32, pub beyond_right_margin_cost: i32, ...
true
90257055e5333d3585197cc3714b331132a55dc6
Rust
togdon/adventofcode_2020
/src/bin/day02-1.rs
UTF-8
677
3.03125
3
[]
no_license
use std::fs; fn main() { let data = fs::read_to_string("data/day-02.txt").expect("Unable to read file"); let lines: Vec<&str> = data.split('\n').collect(); let mut answer = lines.len() - 1; // println!("{:?} lines", lines.len() - 1); for line_num in 0..lines.len() - 1 { let line: Vec<&str...
true
8a78f791e1710bdb31458e3cb2616116048c24f2
Rust
ekirshey/rusty_rogue
/src/world/world.rs
UTF-8
3,349
3.1875
3
[]
no_license
use utils::{Vec2, Graph}; use entity::{EntityMap, CorpseMap}; use world::Dungeon; use player::Player; use log::Log; pub enum WorldNode { DungeonNode(Dungeon) } pub struct World { active_node : usize, world_map : Graph<WorldNode> } impl World { pub fn new() -> World { let mut world_map = Graph...
true
6b0bb14950d4a4e998f204fc69e2176f064e78be
Rust
KULeuven-COSIC/SCALE-MAMBA
/WebAssembly/scale_std/src/secret_ieee.rs
UTF-8
4,631
2.9375
3
[ "BSD-2-Clause", "MIT", "Apache-2.0" ]
permissive
use crate::circuits::*; use core::mem; use core::ops::{Add, Div, Mul, Neg, Sub}; use scale::*; // The secure IEEE Type #[derive(Copy, Clone)] pub struct SecretIEEE { val: SecretI64, } // The holding "insecure" IEEE Type // - This variant allows no arithmetic just // allows parsing and printing #[derive(Copy...
true
3835c6848a8e2f208750acfa925984e08a0f8377
Rust
quezlatch/Dining_Philosophers
/src/dining_philosophers/resource_hierarchy_impl/thinking.rs
UTF-8
2,081
3.09375
3
[]
no_license
use crate::dining_philosophers::fork::Fork; use crate::dining_philosophers::philosopher::state_machine::{State, StateMachine}; use crate::dining_philosophers::resource_hierarchy_impl::left_thinking::LeftThinking; use crate::dining_philosophers::resource_hierarchy_impl::right_thinking::RightThinking; use crate::dining_p...
true
56dd3e7aa2589d180771e6a763d4d21d7526e590
Rust
NotErnWong/crystalorb
/examples/standalone.rs
UTF-8
6,505
2.84375
3
[ "Apache-2.0" ]
permissive
#![feature(generic_associated_types)] use crystalorb::{ client::{stage::StageMut, Client}, command::Command, fixed_timestepper::Stepper, server::Server, world::{DisplayState, World}, Config, TweeningMethod, }; use crystalorb_mock_network::MockNetwork; use serde::{Deserialize, Serialize}; use st...
true
6a5ba3c49ee70c50687619371006845fe15c3452
Rust
jaq-the-cat/gAyPI
/src/errors.rs
UTF-8
138
2.5625
3
[ "MIT" ]
permissive
use serde::Serialize; #[derive(Serialize)] pub enum Errors { GenderNotFound, SexualityNotFound, GenderOrSexualityNotFound, }
true
6c83fedcab2ecfa3a18765ec3a2f3ded904b950f
Rust
varunsrin/rusty_money
/src/format.rs
UTF-8
9,089
3.8125
4
[ "MIT" ]
permissive
use crate::currency::FormattableCurrency; use crate::{Money, Round}; use std::cmp::Ordering; /// Converts Money objects into human readable strings. pub struct Formatter; impl<'a> Formatter { /// Returns a formatted Money String given parameters and a Money object. pub fn money<T: FormattableCurrency>(money: ...
true
f29b1bb3eb3cf058d2a8272f635b5f2f4b9f04e8
Rust
jakobbotsch/exp-epa
/src/lang/parser_tests.rs
UTF-8
4,076
3.015625
3
[]
no_license
use super::parser::*; use super::ast::*; macro_rules! assert_parse { ($parse:expr, $expected:expr) => { match $parse { Ok(result) => assert_eq!(result, $expected), Err(err) => panic!("{}", err), } } } fn id(name: &str) -> Expr { Expr::App(name.to_string(), vec![]) }...
true
5398c1d4da5da8d071fe0414c60359c7822bd054
Rust
aldhsu/adventofcode2019
/day16/src/main.rs
UTF-8
4,594
3.578125
4
[]
no_license
use ndarray::arr1; use std::fs; struct Pattern { position: usize, } impl Pattern { const BASE_PATTERN: [isize; 4] = [0, 1, 0, -1]; fn new(position: usize) -> Self { Self { position } } fn to_vec(&self, len: usize) -> Vec<isize> { Self::BASE_PATTERN .iter() ...
true
fb7ba984ba7a772a69dabb992aaa00d3e2db9bef
Rust
oberien/dotfiles
/i3/bar/src/sysfs.rs
UTF-8
2,214
2.546875
3
[]
no_license
use std::io::{self, Read, Seek, SeekFrom}; use std::fs::{self, File}; use std::path::{Path, PathBuf}; use std::os::unix::io::{FromRawFd, AsRawFd}; use std::mem; use tokio_core::reactor::{PollEvented, Handle}; use futures::{Stream, Async, Poll}; use tokio_file_unix::File as AsyncFile; pub struct Sysfs { buf: Strin...
true
e7fbe8a07764c9c96787cfe3bb3aae67c28d702f
Rust
scirner22/stockcli-rs
/src/iex.rs
UTF-8
1,601
2.671875
3
[]
no_license
use std::rc::Rc; use hyper::rt::{Future, Stream}; use hyper::{self, client::HttpConnector}; use hyper_tls::HttpsConnector; use serde_json; const BASE_URL: &str = "https://api.iextrading.com/1.0"; #[derive(Deserialize, Debug)] #[serde(rename_all = "camelCase")] pub struct IexResponse { symbol: String, pub del...
true
fddb3523f7d53c8b932deb24f61173c17b486b21
Rust
KarelPeeters/SuperTTTApi-rs
/src/util/bits.rs
UTF-8
931
3.234375
3
[]
no_license
use num::{PrimInt, Unsigned}; use num::traits::WrappingSub; #[derive(Debug)] pub struct BitIter<N: PrimInt + Unsigned> { left: N, } impl<N: PrimInt + Unsigned> BitIter<N> { pub fn new(left: N) -> Self { BitIter { left } } } impl<N: PrimInt + Unsigned> Iterator for BitIter<N> { type Item = u8;...
true
87c18d9714521d58d24f9f3d0ce2c5b0e5e2ed81
Rust
Keats/tera
/src/builtins/filters/number.rs
UTF-8
8,422
3.21875
3
[ "MIT" ]
permissive
/// Filters operating on numbers use std::collections::HashMap; #[cfg(feature = "builtins")] use humansize::format_size; use serde_json::value::{to_value, Value}; use crate::errors::{Error, Result}; /// Returns the absolute value of the argument. pub fn abs(value: &Value, _: &HashMap<String, Value>) -> Result<Value>...
true
3609c9c8cad56007cf80be79dcafd82131444ada
Rust
hmarthinsen/rustbeam
/src/lights.rs
UTF-8
554
3.671875
4
[ "MIT" ]
permissive
//! Module containing different light sources. use crate::math::Vector3; /// A light source emitting parallel light rays from a specified direction. pub struct Sun { /// The color of the light rays, in linear RGB. pub color: Vector3, /// The direction the rays point in. Must be a unit vector. pub dire...
true
80b51eb8b66020bfc0691ce5a4e1d0734f4ca034
Rust
Thomasdezeeuw/mio-pipe
/src/lib.rs
UTF-8
9,786
2.84375
3
[ "MIT" ]
permissive
//! Unix pipe for use with Mio. //! //! See the [`new_pipe`] documentation. //! //! ## Supported platforms //! //! Currently supported platforms: //! //! * Android //! * DragonFly BSD //! * FreeBSD //! * Linux //! * NetBSD //! * OpenBSD //! * iOS //! * macOS //! //! The most notable exception in the list is Windows. If...
true
0e866011f3ebfe94a975259dd070a32a342e618d
Rust
hydro-project/hydroflow
/hydroflow_lang/src/graph/ops/reduce.rs
UTF-8
6,198
2.796875
3
[ "Apache-2.0" ]
permissive
use quote::quote_spanned; use super::{ DelayType, FlowProperties, FlowPropertyVal, OperatorCategory, OperatorConstraints, OperatorWriteOutput, Persistence, WriteContextArgs, RANGE_0, RANGE_1, }; use crate::diagnostic::{Diagnostic, Level}; use crate::graph::{OpInstGenerics, OperatorInstance}; /// > 1 input str...
true
7a6b3686a0a21f1d81a65bf0d90666959affb26c
Rust
oxidecomputer/third-party-api-clients
/sendgrid/src/contacts.rs
UTF-8
19,649
3.078125
3
[ "MIT" ]
permissive
use crate::Client; use crate::ClientResult; pub struct Contacts { pub client: Client, } impl Contacts { #[doc(hidden)] pub fn new(client: Client) -> Self { Contacts { client } } /** * Get Sample Contacts. * * This function performs a `GET` to the `/marketing/contacts` endpo...
true
535f9a99a17ed0de7478e2631d35f203b9d66c3a
Rust
sindreij/advent-of-code-2019
/intcode/src/lib.rs
UTF-8
386
2.984375
3
[]
no_license
pub mod computer; pub use computer::{Computer, IO}; use anyhow::Result; pub fn parse_program(program: &str) -> Result<Vec<i64>> { Ok(program .split(",") .filter(|s| !s.is_empty()) .map(|val| Ok(val.trim().parse()?)) .collect::<Result<Vec<i64>>>()?) } #[cfg(test)] mod tests { ...
true
0eb0e0600037a88c6d66cdcaa63f72725aee6ca3
Rust
K0R0VA/portal-chat
/src/graphql/models/room.rs
UTF-8
1,399
2.734375
3
[]
no_license
use async_graphql::{Object, Context, Result}; use serde::Deserialize; use crate::graphql::models::user::User; use async_graphql::dataloader::DataLoader; use crate::graphql::models::room_message::RoomMessage; use crate::graphql::loaders::participants_loader::ParticipantsLoader; use crate::graphql::loaders::room_message...
true
092383f258cbfca7893a852aac0db61dd07026e3
Rust
CatpainBlack/FantASM
/src/assembler/get_token.rs
UTF-8
2,675
2.96875
3
[ "BSD-2-Clause" ]
permissive
use std::ops::Range; use crate::assembler::Assembler; use crate::assembler::error::Error; use crate::assembler::error_type::ErrorType; use crate::assembler::tokens::Token; pub trait GetToken { fn relative(&mut self) -> Result<u8, Error>; fn expect_byte(&mut self, instr_size: isize) -> Result<isize, E...
true
d6cf03dcd3a55b1c469d4e78d063b38bdfab001d
Rust
hunterlester/rusting_leetcode
/src/recursion.rs
UTF-8
9,065
3.53125
4
[]
no_license
#![allow(dead_code)] use std::cell::RefCell; use std::rc::Rc; use std::collections::HashMap; use std::cmp::max; #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } impl TreeNode { fn new(val: i32) -> Self {...
true
e0bc52044e7f32a347f2088ec0fd04415e63c121
Rust
bcopp/retox
/src/main.rs
UTF-8
3,475
2.828125
3
[ "MIT" ]
permissive
use std::env; use std::path::PathBuf; // CMD Parser #[macro_use] extern crate clap; // Logging #[macro_use] extern crate log; extern crate stderrlog; use clap::{App, Arg}; mod run; fn main() { info!("Starting Program"); let opts = App::new("Retox") .version("1.0") .author("Brendan C. <bcop...
true
c041c311ba1637b0ef9c2498aa4699e26e82e6b2
Rust
mgaudet/icu4x
/components/datetime/src/provider/helpers.rs
UTF-8
8,849
2.578125
3
[ "Apache-2.0", "ICU", "MIT", "LicenseRef-scancode-unicode" ]
permissive
// This file is part of ICU4X. For terms of use, please see the file // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). use crate::date; use crate::error::DateTimeFormatError; use crate::fields; use crate::options::{components, length, D...
true
5471c3d901fb2bb00dcd311d7fd1d3956e7f4352
Rust
jxnu-liguobin/cs-summary-reflection
/rust-leetcode/src/interview_24.rs
UTF-8
540
2.9375
3
[ "Apache-2.0" ]
permissive
use crate::pre_structs::{ListNode, Solution}; ///反转链表 leetcode 206 impl Solution { pub fn reverse_list(head: Option<Box<ListNode>>) -> Option<Box<ListNode>> { let mut pre = None; let mut tmp = head; loop { //每次让head指向的节点指向pre指向的节点 if let Some(mut head) = tmp { ...
true
f8cf51d1934452f03ed592dca38159ea5a28cff0
Rust
quietlychris/Rust_RL
/src/examples/fortress.rs
UTF-8
2,804
2.9375
3
[]
no_license
use crate::game::fortress; use std::io; fn parse_train_num() -> u64 { let mut training_games = String::new(); println!("please insert the number of training games."); io::stdin() .read_line(&mut training_games) .expect("Failed to read number of games"); let training_games: u64 = training_games.trim...
true
5cbf1285ae2e126789187d60c7f7f3c1d23a66fc
Rust
thea0032/discordapp
/src/textbox.rs
UTF-8
6,478
3.015625
3
[]
no_license
use std::{io::Stdout, mem::replace}; use crossterm::{cursor::MoveTo, queue, style}; pub struct Textbox { text: Vec<Vec<char>>, cursor_line: usize, cursor_pos: usize, pub flag: bool, length: usize, } impl Textbox { pub fn new(length: usize) -> Textbox { Textbox { text: vec![...
true
6c3c4b6b389773803a5ee2c30940df913d583550
Rust
yzhong52/AdventOfCode
/2019/src/y2019/day1.rs
UTF-8
778
3.203125
3
[]
no_license
use super::super::helpers::parser::*; use super::super::helpers::puzzle::Puzzle; pub struct Day1 {} impl Day1 { fn get_fuel(number: &i32) -> i32 { number / 3 - 2 } fn get_fuel_recursive(number: &i32) -> i32 { let fuel = Day1::get_fuel(number); if fuel <= 0 { 0 ...
true
b87f6ed4d02c4d2be5bb9fe47a64bbfabb8e5e5b
Rust
luccasmmg/noodles
/noodles-bam/src/bai/index.rs
UTF-8
1,994
3.328125
3
[ "MIT" ]
permissive
//! BAM index and fields. mod builder; pub mod reference_sequence; pub use self::{builder::Builder, reference_sequence::ReferenceSequence}; /// A BAM index. #[derive(Clone, Debug, Default, Eq, PartialEq)] pub struct Index { reference_sequences: Vec<ReferenceSequence>, n_no_coor: Option<u64>, } impl Index { ...
true
aa2b031aee09b5885c4a52a24c207f85f633847a
Rust
tylerwhall/advent-of-code-2019
/2019/src/bin/03.rs
UTF-8
5,079
3.421875
3
[]
no_license
#[derive(Debug, PartialEq, Eq, Clone)] enum Move { X(i32), Y(i32), } use Move::*; type Point = (i32, i32); type Vector = (Point, Move); type VectorDist = (Vector, u32); /* fn swap(p: Point) -> Point { (p.1, p.0) } */ fn sort(a: i32, b: i32) -> (i32, i32) { if a > b { (b, a) } else { ...
true
9baf5d8f5589781b5b9af2c6b91ff52b355f0e65
Rust
dermesser/localmr
/src/input_cache.rs
UTF-8
2,446
3.1875
3
[ "MIT" ]
permissive
use std::collections::linked_list; use std::collections::LinkedList; use std::vec; use record_types::Record; /// Holds inputs, e.g. to the Map phase, in memory. /// Specialty: Holding large amounts in memory in a way that is both efficient to store and /// efficient to iterate. pub struct InputCache { chunks_iter...
true
85f62e0043cacb5b172199e7a17807a9af0a6763
Rust
willcrichton/salva
/src/kernel/viscosity_kernel.rs
UTF-8
1,570
2.71875
3
[ "BSD-2-Clause" ]
permissive
use crate::kernel::Kernel; use na::RealField; /// The Viscosity smoothing kernel. /// /// Refer to "Particle-Based Fluid Simulation for Interactive Applications", Müller et al.pub struct ViscosityKernel; #[derive(Copy, Clone, Debug)] pub struct ViscosityKernel; impl Kernel for ViscosityKernel { fn scalar_apply<N:...
true
76c8b02f48d849e68b61c4e44b5ee2bf0cd671a4
Rust
jmou/aoc2018
/d15/src/main.rs
UTF-8
8,442
3.125
3
[]
no_license
use std::collections::{BTreeMap, VecDeque}; use std::error::Error; use std::fmt; use std::io::{self, Read}; use std::result; use std::usize; type Result<T> = result::Result<T, Box<dyn Error>>; #[derive(Clone, PartialEq)] enum Tile { Wall, Open, Unit, } #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord...
true
16a8ba391a57e086d18ae41d1acee49a558078cb
Rust
quarterblue/bloomy
/src/portfolio.rs
UTF-8
2,613
3.671875
4
[ "MIT" ]
permissive
use crate::equity::Equity; pub enum Presult { ADDED, REMOVED, EXISTS, DNE, } pub struct PortList { pub portfolio_list: Vec<Portfolio>, } impl PortList { // Creates a new empty List of Portfolios pub fn empty_new() -> Self { PortList { portfolio_list: Vec::new(), ...
true
3e8c36170c98b0341d5811685b7444ffb000aa6e
Rust
vemoo/rowan
/examples/s_expressions.rs
UTF-8
11,705
3.578125
4
[ "Apache-2.0", "MIT" ]
permissive
//! In this tutorial, we will write parser //! and evaluator of arithmetic S-expressions, //! which look like this: //! ``` //! (+ (* 15 2) 62) //! ``` /// Currently, rowan doesn't have a hook to add your own interner, /// but `SmolStr` should be a "good enough" type for representing /// tokens. /// Additionally, rowa...
true
44ad7fa96fbfef5b4be7b708a0edadf08ed5075a
Rust
vitocchi/ghost
/src/lib.rs
UTF-8
2,322
2.640625
3
[]
no_license
#![no_std] extern crate eng_wasm; extern crate eng_wasm_derive; extern crate hex; extern crate serde; mod account; mod error; mod ghost_core; pub use account::Account; use eng_wasm::*; pub use error::Error; use ghost_core::{AccountRepositoryInterface, GhostCore}; // Public struct Contract which will consist of private...
true
cd120d3abe16c9feb66ddbf103dec58d68640e12
Rust
wavejumper/opm
/src/http.rs
UTF-8
5,840
2.640625
3
[]
no_license
use crate::errors::{IronConfigurationError, ResourceNotFound}; use crate::manifest::{Db, Kit, Kits, Manifest, Sample}; use iron::error::IronError; use iron::mime; use iron::prelude::*; use router::Router; use std::fs::File; use std::io::prelude::*; pub fn extract_query(req: &Request, query: &str) -> IronResult<String>...
true
b4c852dae3e55c79dcdf9020c675522f85f71836
Rust
kshkss/easyopt
/table-dump/src/lib.rs
UTF-8
2,148
3.234375
3
[ "MIT" ]
permissive
use serde::ser; use thiserror::Error; #[derive(Error, Debug)] pub enum Error { //#[error("Too complicated data structure to dump as a table. Try a flattened structure.")] #[error("Map and variant is not acceptable except unit-variant pattern.")] TooComplicated, #[error("failed with serializing data: {0...
true
50111771e444f49ddfb01ab3903bdc1da42ff34c
Rust
e-ivkov/ursa_key_utils
/src/lib.rs
UTF-8
4,186
3
3
[ "Apache-2.0" ]
permissive
use std::{ convert::{TryFrom, TryInto}, fmt, fmt::{Display, Error, Formatter}, }; use ursa::{ keys::{KeyGenOption, PrivateKey}, signatures::{ed25519::Ed25519Sha512, SignatureScheme}, }; pub const PUBLIC_KEY_LENGTH: usize = 32; pub const PRIVATE_KEY_LENGTH: usize = 64; #[derive(Clone)] pub struct S...
true
97e064a76fa33a1d3e1247a80a8e28303f9d765c
Rust
wezm/Quotes
/src/auth.rs
UTF-8
4,474
2.609375
3
[ "Apache-2.0", "MIT" ]
permissive
//! User authentication. // TODO: Refresh session cookie on new requests use std::collections::HashMap; use rocket::form::Form; use rocket::http::{Cookie, CookieJar}; use rocket::outcome::{try_outcome, IntoOutcome}; use rocket::request::{FlashMessage, FromRequest, Outcome, Request}; use rocket::response::{Debug, Flas...
true
64ded1c367fc6da5df13942b7990c90c9b2a783c
Rust
curest0x1021/terra-rust
/src/staking.rs
UTF-8
11,975
2.546875
3
[ "Apache-2.0" ]
permissive
use anyhow::Result; use structopt::StructOpt; use terra_rust_api::Terra; //use crate::errors::Result; use crate::{NAME, VERSION}; use bitcoin::secp256k1::Secp256k1; use rust_decimal::Decimal; use terra_rust_api::core_types::Coin; use terra_rust_api::messages::staking::{ MsgBeginRedelegate, MsgCreateValidator, MsgDe...
true
5ebcbb944311d2aaf8ebd516dcde59b4ac80cb33
Rust
achillesss/dragonex.io
/rust/calculator/src/main.rs
UTF-8
2,356
3.296875
3
[]
no_license
// 输入平均交易量和开始的天数,计算成本和分红 const BASE_RELEASE: f32 = 51200.0; const BASE_DAMPING: f32 = 0.5; const CHARGE: f32 = 2e-3; fn period(day: u32) -> u32 { (day-1)/365+1 } fn period_day_release(period: u32) -> f32 { BASE_RELEASE*(BASE_DAMPING.powf((period -1)as f32)) } fn daily_release(day: u32) -> f32 { let perio...
true