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
a0c58a52ae966d570f8e81794366c852308904df
Rust
dtynn/pkg-rs
/src/encoding/varint/tests.rs
UTF-8
2,866
3.4375
3
[]
no_license
use super::{get_i64, get_u64, put_i64, put_u64, ErrorKind, MAX_VARINT_LEN_U64}; use rand::{thread_rng, Rng}; #[test] fn uvarint_test() { let mut rng = thread_rng(); let mut buf = Vec::with_capacity(MAX_VARINT_LEN_U64); let mut nums = vec![0; 10000]; rng.fill(&mut nums[..]); for num in nums { ...
true
c4feb96489cf2428092973ba69a8539605c8db21
Rust
evgenykuzyakov/near-cli
/src/commands/transfer_command/transfer_near_tokens_type/mod.rs
UTF-8
5,289
2.625
3
[]
no_license
use dialoguer::Input; #[derive(Debug, clap::Clap)] pub enum CliTransfer { /// Enter an amount Amount(CliTransferNEARTokensAction), } #[derive(Debug)] pub enum Transfer { Amount(TransferNEARTokensAction), } impl From<CliTransfer> for Transfer { fn from(item: CliTransfer) -> Self { match item {...
true
dc4b5c9062d36038189900c619029d5edfd3ffb5
Rust
lucafanselau/city-builder
/crates/assets/src/assets.rs
UTF-8
3,265
2.5625
3
[]
no_license
use std::{any::type_name, hash::BuildHasherDefault}; use crate::{ asset::Asset, channels::{AssetPipeReceiver, RefEvent, RefReceiver}, handle::{AssetHandle, HandleId}, prelude::AssetEvent, }; use core::anyhow::anyhow; use dashmap::{mapref::one::Ref, DashMap}; use ecs::prelude::{Events, Res, ResMut}; use...
true
879cac4f4ff51ff8e4f94da2abbcbf70356026c5
Rust
ogoodman/rust-table
/src/decode.rs
UTF-8
7,462
2.921875
3
[ "MIT" ]
permissive
use std::io; use std::collections::BTreeMap; use encode::Encode; #[cfg(test)] use encode::encode; #[derive(Debug)] pub enum DecodeError { IOError { err: io::Error }, EOF, Null, PartialRead, } #[derive(Default)] pub struct DecodeStats { read: usize, discarded: usize, } impl DecodeStats { ...
true
c35f5993f12e2f3b3fb79e98637c2107c3bcea53
Rust
lhutyra/rustyhex
/src/creature.rs
UTF-8
8,773
2.671875
3
[ "MIT" ]
permissive
// Copyright 2014 Dawid Ciężarkiewicz // See LICENSE file for more information use ai::{Actor,AIActor}; use game; use game::Action; use game::{Melee,Turn,Move,Run,Wait}; use hex2d; use hex2d::{Left,Right,Forward,Backward}; use hex2d::{Point,Position}; use hex2d::AbsoluteDirection; use map; use map::Map; use map::TileT...
true
b2c17fe0ce0a3e1702966896aba34bb120277017
Rust
flyer5200/reflow
/asocks5/examples/client.rs
UTF-8
1,725
2.71875
3
[]
no_license
use asocks5::connect_socks_socket_addr; use asocks5::socks::SocksError; use futures::compat::Future01CompatExt; use std::net::SocketAddr; use structopt::StructOpt; use tokio::net::TcpStream; use tokio::prelude::*; fn main() { println!("Async socks client"); let opt: Opt = Opt::from_args(); let f = async mo...
true
2c2bc5681dbfefb84242509630d9c13d949d7d04
Rust
zwhitchcox/leetcode_rs
/src/_0020_valid_parentheses.rs
UTF-8
1,113
3.890625
4
[ "MIT" ]
permissive
struct Solution; impl Solution { fn is_valid(s: String) -> bool { let mut stack: Vec<char> = vec![]; for c in s.chars() { match c { '(' | '[' | '{' => stack.push(c), ')' | ']' | '}' => match stack.pop() { Some(t) => { ...
true
13e642d28e1657402495d7cb72270e98ae23a589
Rust
swc-project/swc
/crates/swc_plugin_runner/src/memory_interop.rs
UTF-8
3,531
2.671875
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use swc_common::plugin::serialized::{PluginSerializedBytes, VersionedSerializable}; use swc_plugin_proxy::AllocatedBytesPtr; use wasmer::{Memory, MemoryView, StoreMut, TypedFunction, WasmPtr}; #[tracing::instrument(level = "info", skip_all)] pub fn copy_bytes_into_host(memory: &MemoryView, bytes_ptr: i32, bytes_ptr_le...
true
0998a4be22fb8b0498bf27a4ad76e08799e11535
Rust
magnet/metered-rs
/metered/src/int_counter.rs
UTF-8
1,456
2.90625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A module providing thread-safe and unsynchronized implementations for //! Counters on various unsized integers. use crate::{ atomic::AtomicInt, clear::{Clear, Clearable}, metric::Counter, num_wrapper::NumWrapper, }; use std::cell::Cell; macro_rules! impl_counter_for { ($int:path) => { ...
true
e7d1fc38a3330deb464758757eb293841c650bc3
Rust
jz4o/codingames
/rust/practice/classic_puzzle/easy/addem-up.rs
UTF-8
1,059
3.21875
3
[]
no_license
use std::io; macro_rules! parse_input { ($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap()) } /** * Auto-generated code below aims at helping you parse * the standard input according to the problem statement. **/ fn main() { let mut input_line = String::new(); io::stdin().read_line(&mut input_lin...
true
067ed698765206f2cc2aae00d866cb3f1a7067df
Rust
selevt/AdventOfCode2015
/day2/src/main.rs
UTF-8
1,964
3.421875
3
[ "Unlicense" ]
permissive
use std::env; use std::cmp; #[derive(Debug)] struct Gift { w: i32, l: i32, h: i32, } impl Gift { // Returns the two smaller sides fn smaller_sides(&self) -> Vec<i32> { let mut sorted_sides = vec![self.w, self.l, self.h]; sorted_sides.sort(); let (first_two, _last) = sorted_...
true
bb040592f2489beb7a7b1208ee6a5a9a1ee1b060
Rust
elauffenburger/lyrical
/liblyrical/src/lyrics/caching/mod.rs
UTF-8
3,204
3.25
3
[]
no_license
mod dev_cache; use std::fmt::Debug; use serde::{Deserialize, Serialize}; use super::*; pub use dev_cache::*; #[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] pub enum CacheEntry { Success(String), Failure(String), } pub trait Cache: Debug { fn save(&mut self, song: &SongDescriptor, entry: Cac...
true
8c8d39346bd17e0df95aee1e6bbf9a812d8e2cc2
Rust
FirelightFlagboy/taskmaster
/src/server/state.rs
UTF-8
6,021
2.8125
3
[]
no_license
use std::{ collections::HashMap, convert::TryFrom, marker, sync::{ atomic::{AtomicBool, Ordering}, mpsc::Sender, Arc, Mutex, }, thread::{self, JoinHandle}, time, }; use super::{ communication::Com, formatter::Formatter, inter::Inter, monitor::Monitor,...
true
9b44ae68797e6adb0a884998ca5fbd19d8ca38eb
Rust
urbanslug/wfilter
/src/utils.rs
UTF-8
297
2.859375
3
[]
no_license
pub fn pretty_print_int(i: isize) -> String { let mut s = String::new(); let i_str = i.to_string(); let a = i_str.chars().rev().enumerate(); for (idx, val) in a { if idx != 0 && idx % 3 == 0 { s.insert(0, ','); } s.insert(0, val); } s }
true
0883413294d6ac32d0dc4110abac179f95c4c22b
Rust
hecrj/ggez
/examples/spritebatch.rs
UTF-8
3,771
2.90625
3
[ "MIT" ]
permissive
//! An example of how to use a `SpriteBatch`. //! //! You really want to run this one in release mode. use ggez; use ggez::event; use ggez::graphics; use ggez::nalgebra::{Point2, Vector2}; use ggez::timer; use ggez::{Context, GameResult}; use std::env; use std::path; struct MainState { spritebatch: graphics::spr...
true
ed15e9e05de9fedad089fc820d325bbc1f768407
Rust
rust-lang/chalk
/chalk-solve/src/infer/canonicalize.rs
UTF-8
7,687
2.5625
3
[ "Apache-2.0", "BSD-3-Clause", "bzip2-1.0.6", "LicenseRef-scancode-other-permissive", "NCSA", "MIT", "ISC", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "Unlicense" ]
permissive
use crate::debug_span; use chalk_derive::FallibleTypeFolder; use chalk_ir::fold::shift::Shift; use chalk_ir::fold::{TypeFoldable, TypeFolder}; use chalk_ir::interner::{HasInterner, Interner}; use chalk_ir::*; use std::cmp::max; use tracing::{debug, instrument}; use super::{InferenceTable, ParameterEnaVariable}; impl<...
true
c558081b61b5ded3113527b4e932970be566c8af
Rust
jmgao/pore
/src/update_check.rs
UTF-8
2,394
3.015625
3
[ "Apache-2.0" ]
permissive
use std::path::Path; use std::sync::mpsc; use std::thread; use anyhow::Error; #[derive(Debug, Serialize, Deserialize)] struct VersionFile { versions: Vec<Version>, } #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Version { pub number: String, pub date: String, pub changes: Vec<String>, } pub str...
true
b5e9bede4851188c401300b8958a4a45833b5b98
Rust
pombredanne/crates-1
/zeroize/src/lib.rs
UTF-8
18,288
3.859375
4
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
//! Securely zero memory with a simple trait ([Zeroize]) built on stable Rust //! primitives which guarantee the operation will not be 'optimized away'. //! //! ## Usage //! //! ``` //! use zeroize::Zeroize; //! //! fn main() { //! // Protip: don't embed secrets in your source code. //! // This is just an examp...
true
bea9c293654743f33c311369133ab32475e8eb44
Rust
Elinvynia/bot
/src/utils/macros.rs
UTF-8
641
2.53125
3
[ "Apache-2.0", "MIT" ]
permissive
#[macro_export] macro_rules! error_return { ($e:expr) => { match $e { Ok(o) => o, Err(_) => return, } }; } #[macro_export] macro_rules! none_return { ($e:expr) => { match $e { Some(s) => s, None => return, } }; } #[macro_e...
true
b6fc04014da982edc81dd76d6e312c59eff80581
Rust
brandonkal/dialoguer
/examples/key.rs
UTF-8
575
3.09375
3
[ "MIT" ]
permissive
extern crate dialoguer; use dialoguer::theme::ColoredTheme; use dialoguer::{Input, KeyPrompt}; fn main() { let rv = KeyPrompt::with_theme(&ColoredTheme::default()) .with_text("Do you want to continue?") .items(&['y', 'n', 'p']) .default(1) .interact() .unwrap(); if rv =...
true
085fc4c841f9ff2f8867245c14eca804cb92b648
Rust
saigono/raytrace
/src/random/perlin.rs
UTF-8
3,698
3.046875
3
[]
no_license
use crate::linalg::Vec3; use rand::Rng; const PERLIN_SIZE: usize = 256; const PERLIN_MASK: usize = PERLIN_SIZE - 1; pub struct Perlin { perm_x: [usize; PERLIN_SIZE], perm_y: [usize; PERLIN_SIZE], perm_z: [usize; PERLIN_SIZE], grid: [Vec3; PERLIN_SIZE] } fn smooth(t: f32) -> f32 { 6.0*t.powf(5.0) ...
true
4f571d44535492e975d3471f3ebb371553848762
Rust
sogapalag/contest
/atcoder/past202005-open/g.rs
UTF-8
3,553
2.75
3
[]
no_license
#[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; use std::io::{Write, BufWriter}; // https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 macro_rules! input { ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufRea...
true
83b8a786c0e2100451fd10a3ded8350002da6ca8
Rust
Alpaca-H/rust
/src/tools/miri/test-cargo-miri/tests/test.rs
UTF-8
1,004
2.828125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT", "BSD-3-Clause", "BSD-2-Clause", "LicenseRef-scancode-other-permissive", "NCSA" ]
permissive
use rand::{SeedableRng, Rng, rngs::SmallRng}; // Having more than 1 test does seem to make a difference // (i.e., this calls ptr::swap which having just one test does not). #[test] fn simple1() { assert_eq!(4, 4); } #[test] fn simple2() { assert_ne!(42, 24); } // A test that won't work on miri (tests disabli...
true
732f33797f5fe3feed6c88e93017e6a06011a101
Rust
lambdaxymox/embed
/examples/example.rs
UTF-8
210
3
3
[ "Apache-2.0", "MIT" ]
permissive
use embed::embed; /// Embed a file into the binary as a vector using the `embed` macro and /// then print the result. fn main() { let obj = embed!("../assets/triangle.obj"); println!("{:?}", obj); }
true
6d5bbc1b8fbef71f9984a8d8ad2104443dd1b7e2
Rust
m-kann0/atcoder-rust
/examples/abc138_e.rs
UTF-8
2,187
3.5
4
[]
no_license
use std::io::Read; use std::collections::HashMap; fn main() { let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).unwrap(); let answer = solve(&buf); println!("{}", answer); } fn solve(input: &str) -> String { let mut iterator = input.split_whitespace(); let s: Vec<char> ...
true
ef462c8c1d7a7d1960687673ce79bf9ff5a29124
Rust
cachance7/fuzzy5e
/src/index.rs
UTF-8
954
2.765625
3
[ "MIT" ]
permissive
use std::error::Error; use std::{fmt, fmt::{Display, Formatter}}; #[derive(Debug)] pub enum IndexError { // ConnectionError, ProcessingError, } impl Display for IndexError { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, "{}", self)?; Ok(()) } } impl Error for IndexEr...
true
208ff442928043ccc07bc69c2f8fde92fc23065e
Rust
Poddster/ggez
/src/game.rs
UTF-8
6,429
3.28125
3
[ "MIT" ]
permissive
//! The `game` module contains traits and structs to actually run your game mainloop //! and handle top-level state. use context::Context; use GameResult; use timer; use std::time::Duration; use super::event as gevent; use sdl2::event::Event::*; use sdl2::event; use sdl2::mouse; use sdl2::keyboard; /// A trait de...
true
bcbf44cb0046f5f6cfdd797b77052b46b0997d9c
Rust
pola-rs/polars
/crates/polars/tests/it/lazy/aggregation.rs
UTF-8
2,454
2.703125
3
[ "MIT" ]
permissive
use super::*; #[test] fn test_lazy_df_aggregations() { let df = load_df(); assert!(df .clone() .lazy() .min() .collect() .unwrap() .frame_equal_missing(&df.min())); assert!(df .clone() .lazy() .median() .collect() .unw...
true
70b6c2eea174a9e8ff06a2a0389d9aaa16ca40b5
Rust
jakub-valenta/aoc2017
/src/aoc18.rs
UTF-8
8,763
3.015625
3
[]
no_license
use std::collections::{HashMap, LinkedList}; use std::ops::{Add, Mul, Rem}; use std::str::FromStr; use utils; pub fn recover_frequency(program: &str) -> Option<i64> { let mut sound_processor = SoundProcessor::new(parse_program(program)?); Some(sound_processor.run()) } pub fn count_sends(program: &str) -> Opti...
true
7f4be743adc32defa5135f31e7df7d9a22a0fe4a
Rust
timsar2/Rust
/ownership/src/main.rs
UTF-8
2,442
3.828125
4
[]
no_license
fn main() { struct_define(); slice_string(); refrence(); ownership(); } fn build_user(email: String, username: String) -> User { User { email, username, active: true, sign_in_count: 1, } } struct User { username: String, email: Stri...
true
e304378236155f5f0e45e528b0f77af4ffbdb943
Rust
magic003/http-parser-rs
/tests/test_long_body.rs
UTF-8
1,168
2.515625
3
[ "MIT" ]
permissive
extern crate http_parser; use http_parser::{HttpParserType, HttpParser}; pub mod helper; #[test] fn test_no_overflow_long_body_request() { test_no_overflow_long_body(HttpParserType::Request, 1000); test_no_overflow_long_body(HttpParserType::Request, 100000); } #[test] fn test_no_overflow_long_body_response(...
true
0f9d7bb450fb52ab5c29a3e4a59ce90ac805cbdb
Rust
holmgr/rymdbiljard
/src/goalzone.rs
UTF-8
1,867
3.203125
3
[ "MIT" ]
permissive
use na::Point2; use piston::input::RenderArgs; use opengl_graphics::GlGraphics; use graphics::Transformed; use graphics::ellipse; use na::FloatPoint; use poolball; /** * Implements a basic goalzone to be used in each corner of the playing field. */ pub struct Goalzone { position: Point2<f64>, radius: f64, } ...
true
426b7f9a9a89ac7fe00031cf2c87be680285bc9b
Rust
osobo/appcryp-cryptopals
/src/code/aes128.rs
UTF-8
5,252
2.71875
3
[]
no_license
mod ffiaes { #[link(name = "appcrypaes", kind = "static")] extern "C" { pub fn key_sched(roundkeys: *mut u8, key: *const u8); pub fn encrypt_block(block: *mut u8, roundkeys: *const u8); pub fn decrypt_block(block: *mut u8, roundkeys: *const u8); } } pub const BLOCKSIZE: usize = 16...
true
70009f429b63278f0045435840bf7482478f523f
Rust
rusticata/pcap-analyzer
/pcap-rewrite/src/lib.rs
UTF-8
3,242
2.59375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
extern crate lz4; use std::fs::File; use std::io::{self, Read}; use std::path::Path; use flate2::read::GzDecoder; use libpcap_tools::{Config, PcapDataEngine, PcapEngine}; use log::{error, info}; use xz2::read::XzDecoder; mod container; pub mod filters; mod pcap; mod pcapng; pub mod rewriter; mod traits; use rewrite...
true
848a24cc770fc9883bd65168f42ec2dce4b014f5
Rust
danalex97/rust-examples
/timely_tutorial/src/examples/core/dataflow.rs
UTF-8
1,281
2.625
3
[]
no_license
#![allow(unused_variables)] extern crate timely; use timely::dataflow::InputHandle; use timely::dataflow::operators::{Input, Exchange, Inspect, Probe}; pub fn run() { timely::execute_from_args(std::env::args(), |worker| { let index = worker.index(); let mut input = InputHandle::new(); // ...
true
c1ead5cf4fd238006af96c07a0c914384d5c12db
Rust
kana/shards
/rust/traits.rs
UTF-8
2,421
3.671875
4
[]
no_license
trait Shape { fn area(&self) -> f64; } struct Rectangle { x: f64, y: f64, width: f64, height: f64, } impl Shape for Rectangle { fn area(&self) -> f64 { self.width * self.height } } struct Circle { x: f64, y: f64, radius: f64, } impl Shape for Circle { fn area(&sel...
true
c0de1a1933fd31fad0a669126a231f11824bc979
Rust
Kuniwak/study-rust-with-digest
/src/digest.rs
UTF-8
921
3.3125
3
[]
no_license
use std::option::Option; use std::io::{Read, Write}; use std::process::{Command, Stdio}; fn main() { let str = "abcd"; match digest(&str) { Some(hash) => println!("HASH: {}", hash), None => println!("HASH: NONE"), } } fn digest(src: &str) -> Option<String> { let mut out = String::ne...
true
651409a4f341b6fa18eb4314534b108794971e92
Rust
cbreeden/qp-trie-rs
/src/lib.rs
UTF-8
8,699
3.109375
3
[]
no_license
#[macro_use] extern crate debug_unreachable; use std::cmp; use std::mem; fn nybble<K: AsRef<[u8]>>(idx: usize, key: K) -> u8 { let byte = key.as_ref()[idx >> 1]; if idx & 1 == 0 { byte & 0x0F } else { byte >> 4 } } pub struct Sparse<T> { index: u32, data: Vec<T>, } impl<T> Sparse<T> { pub f...
true
5b74ed50e8a54a23d1278df77cba24366b402a51
Rust
ahouts/aoc-2019
/day5/src/main.rs
UTF-8
4,862
3.375
3
[]
no_license
use std::io::stdin; use std::ops::{Index, IndexMut}; use FetchMode::*; use OpcodeInstruction::*; #[derive(Copy, Clone, Debug)] struct Opcode { instruction: OpcodeInstruction, mode1: FetchMode, mode2: FetchMode, mode3: FetchMode, } impl From<i32> for Opcode { fn from(n: i32) -> Self { let s...
true
8d427359fd9ce485eac6ae7ac91f6407a7360e23
Rust
ric2b/Vivaldi-browser
/chromium/third_party/rust/prettyplease/v0_1/crate/src/attr.rs
UTF-8
7,576
2.75
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT", "BSD-3-Clause", "LGPL-2.0-or-later", "GPL-1.0-or-later" ]
permissive
use crate::algorithm::Printer; use crate::INDENT; use proc_macro2::{Delimiter, TokenStream, TokenTree}; use syn::{AttrStyle, Attribute, Lit, PathArguments}; impl Printer { pub fn outer_attrs(&mut self, attrs: &[Attribute]) { for attr in attrs { if let AttrStyle::Outer = attr.style { ...
true
921dff6b634cc6ad8f46ae2d96956dca94de4224
Rust
x1957/tide
/src/head.rs
UTF-8
4,729
3.484375
3
[ "Apache-2.0", "MIT" ]
permissive
//! Types related to the headers (and metadata) of a request. //! //! This module includes extractors like `Path` that endpoints can use to //! automatically parse out information from a request. use futures::future; use std::ops::{Deref, DerefMut}; use std::sync::Arc; use crate::{Extract, IntoResponse, Request, Resp...
true
7358fdca97336801cba893611981367c1ace9104
Rust
zshehov/tui-tetris
/src/piece.rs
UTF-8
6,842
3.359375
3
[]
no_license
use crate::matrix::Matrix; use rand::Rng; #[derive(Clone)] pub enum PieceType { Square, L, Straight, ReverseL, T, Worm, ReverseWorm } #[derive(Clone)] pub enum PieceColor { Red, Blue, LightBlue, Yellow, LightYellow, Green, Magenta, } pub fn get_piece_color(piec...
true
b3c52c71e16eadfb1273c209396a9a969c537fde
Rust
mjpcollins/haskell-sandbox
/rust/compare.rs
UTF-8
2,471
3.078125
3
[]
no_license
fn main() { let features: &[u16] = &[1, 2]; let families: &[u16] = &[0, 1]; let constraint_a: &[[u16; 3]] = &[[0, 1, 0], [1, 0, 1], [1, 2, 0]]; let constraint_b: &[[u16; 3]] = &[[0, 1, 1], [1, 0, 1], [1, 2, 0]]; let constraint_c: &[[u16; 3]] = &[[2, 3, 0], [2, 4, 1], [3, 5, 0], [1, 2, 0]]; let...
true
30185fc67a52da2dc99f0aa2ea3ebeb72e75836b
Rust
tschneidereit/wasmtime
/crates/api/examples/hello.rs
UTF-8
1,940
2.890625
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
//! Translation of hello example extern crate alloc; use alloc::rc::Rc; use anyhow::{ensure, format_err, Context as _, Result}; use core::cell::Ref; use std::fs::read; use wasmtime_api::*; struct HelloCallback; impl Callable for HelloCallback { fn call(&self, _params: &[Val], _results: &mut [Val]) -> Result<(),...
true
3ed863551b5c56435cebaa9c6419508812de4c00
Rust
tmcw/argonautica
/argonautica-rs/examples/example_custom.rs
UTF-8
1,796
2.703125
3
[ "MIT", "Apache-2.0" ]
permissive
extern crate argonautica; extern crate dotenv; #[macro_use] extern crate failure; use std::collections::HashMap; use std::env; use argonautica::config::{Variant, Version}; use argonautica::input::{Salt, SecretKey}; use argonautica::{Hasher, Verifier}; // Helper method to load the secret key from a .env file. Used in...
true
be6d7ffbb4c3730510a3f3c0290b02bf1e9f505f
Rust
jashanj0tsingh/card_game_engine
/src/engine/builder.rs
UTF-8
1,075
3.4375
3
[ "MIT" ]
permissive
/// This trait builds an initial game state pub trait GameBuilder { /// Error type type E; /// Game State type type S: Clone; /// This function initializes the game with an initial state fn initialize_game() -> Result<Self::S, Self::E>; } pub struct DefaultBuilder; impl GameBuilder for Default...
true
3427b5f3827d0d59e2d5f663baa90a71e9511a88
Rust
ng3rdstmadgke/dary
/src/trie.rs
UTF-8
13,706
3.296875
3
[]
no_license
use std::fmt::Debug; use super::bit_cache::BitCache; use crate::double_array::DoubleArray; use bincode; use serde::Serialize; use serde::de::DeserializeOwned; struct Node<T> { key : u8, values: Vec<T>, nexts : Vec<Node<T>>, } /// トライ木の実装。 /// ダブル配列は直接構築することはできないので、トライ木を構築してから変換することで構築する。 /// /// # Exa...
true
3416fe5d0ad89c79825a74eb342c3721e2b5b08d
Rust
isabelgk/median
/median/src/builder.rs
UTF-8
13,233
2.65625
3
[ "MIT" ]
permissive
//! Utilities for building objects. use crate::{ atom::Atom, buffer::{BufferRef, BufferReference}, clock::ClockHandle, inlet::{MSPInlet, MaxInlet, Proxy}, notify::{Attachment, AttachmentError, Registration, RegistrationError, Subscription}, outlet::{OutAnything, OutBang, OutFloat, OutInt, OutLis...
true
d295bcb6a54a9c0798818d2e529cd8445255a9f5
Rust
terrorizer1980/oqs-rs
/mullvad-wg-establish-psk/src/server/wg.rs
UTF-8
3,288
3.234375
3
[ "Apache-2.0", "MIT" ]
permissive
use std::process::Command; use std::net::IpAddr; use std::str::{self, FromStr}; error_chain! { errors { WgProcessError { description("Unable to run the wg command") } WgMalformedOutput { description("Invalid output from wg") } } } /// Metadata about a wireguard peer #[derive(Debug, Clone, Eq, ...
true
7806b813cb063f238d13e123a8b0b0acdd48de9d
Rust
alakahakai/vector
/src/kafka.rs
UTF-8
2,944
2.75
3
[ "Apache-2.0" ]
permissive
use crate::tls::TlsOptions; use rdkafka::ClientConfig; use serde::{Deserialize, Serialize}; use snafu::Snafu; use std::path::PathBuf; #[derive(Debug, Snafu)] enum KafkaError { #[snafu(display("invalid path: {:?}", path))] InvalidPath { path: PathBuf }, } #[derive(Clone, Copy, Debug, Derivative, Deserialize, S...
true
a1b7c8a90f02a8120cd002faf70b7c12b665f0be
Rust
ethereum-mousse/mousse
/simulator/src/simulator.rs
UTF-8
6,872
3.03125
3
[ "Apache-2.0" ]
permissive
use crate::*; use beacon_chain::*; pub use errors::*; use simulation_params::*; /// Eth2 simulator. pub struct Simulator { // The slot to be processed. // Note: The last processed slot is `self.slot - 1`. pub slot: Slot, pub beacon_chain: BeaconChain, pub shards: Vec<shard::Shard>, // Settings ...
true
f0eedbdce47facb81164df11c05ae77d541c1a25
Rust
iCodeIN/fs-utils-rs
/src/read.rs
UTF-8
2,212
3.53125
4
[ "MIT", "Apache-2.0" ]
permissive
//! Functions to read from files. use std::{ self, fs, io::{self, Read}, path::Path, }; /// Reads the first N bytes from a file. /// /// It is equivalent to `head -c limit` *nix utility. pub fn head(path: impl AsRef<Path>, limit: usize) -> io::Result<Vec<u8>> { let file_size = fs::metadata(&path)?.len(...
true
2181e8c5510b9bef67f56757a24769e7daa8bb52
Rust
frol/kmod
/src/print.rs
UTF-8
353
2.515625
3
[ "MIT" ]
permissive
//! Common kernel debug print support extern "C" { pub fn printk(fmt: *const u8, ...) -> i32; } // Common printing macro macro_rules! print { ($e:expr) => ( unsafe { ::print::printk(concat!($e, "\0").as_ptr()); } ) } // Common printing macro including newline macro_rules! println { ($e:expr) ...
true
31f418574760ee30aed60a18b41d5ccedad05029
Rust
GameRuiner/Uniwersytet
/VII semestr/Rust/lista6/src/zadanie2.rs
UTF-8
2,453
3.53125
4
[]
no_license
mod solution { #[allow(dead_code)] pub fn range_extraction(a: &[i32]) -> String { // Your solution here let mut res = "".to_string(); let mut last_number = a[0]; let mut second_of_sequence_num = a[0]; let mut first = true; let mut first_of_sequence = true; ...
true
c2922b064d01d05a2aefd220834bf294eb41ed0d
Rust
athorwall/vulkan-project
/src/obj.rs
UTF-8
12,390
3.234375
3
[]
no_license
use std::fs::File; use std::io::prelude::*; use cgmath::*; use geometry::*; #[derive(PartialEq, Debug)] pub struct ObjModel { /// Vertex coordinates. pub v: Vec<(f32, f32, f32, f32)>, /// Vertex texture coordinates. pub vt: Vec<(f32, f32)>, /// Vertex normals. pub vn: Vec<(f32, f32, f32)>, ...
true
8690f037bd66444d6ef50ed522df29e47b3a63dc
Rust
hrishisd/aoc2018
/aoc05/src/main.rs
UTF-8
1,882
3.265625
3
[]
no_license
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; fn main() -> Result<()> { let polymer: Vec<char> = std::fs::read_to_string("input")?.trim().chars().collect(); let reduced_polymer = reduce(polymer)?; println!("Part1: {}", reduced_polymer.len()); println!("Part2: {}", part2(reduced_p...
true
41dcc81b10d30d8e3e41dd979f809ae159717e15
Rust
Ruin0x11/sabi
/src/renderer/ui/elements/mod.rs
UTF-8
4,479
2.734375
3
[]
no_license
use renderer::ui::*; use renderer::ui::renderer::*; mod bar; mod message; pub use self::message::UiMessageLog; pub use self::bar::UiBar; pub trait UiElement { fn draw(&self, renderer: &mut UiRenderer); } impl UiElement for UiWindow { fn draw(&self, renderer: &mut UiRenderer) { let (x, y) = self.pos;...
true
baa2a997dc6ca597f5ba42029b16238080660764
Rust
coderedtails/tic_tac_toe_rust
/tests/tests.rs
UTF-8
1,265
2.734375
3
[]
no_license
extern crate tic_tac_toe; use tic_tac_toe::core::board; use tic_tac_toe::core::board::Board; use tic_tac_toe::core::marker::Marker; use tic_tac_toe::io::cli_spy; use tic_tac_toe::io::cli_spy::CliSpy; use tic_tac_toe::io::display::Display; use tic_tac_toe::players::human; use tic_tac_toe::players::human::Human; pub mo...
true
f25193f56e5eb664c78be1f1a2cbf4882e754a55
Rust
marco-c/gecko-dev-comments-removed
/third_party/rust/darling_core/src/codegen/attr_extractor.rs
UTF-8
3,744
2.71875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use proc_macro2::TokenStream; use quote::quote; use crate::options::ForwardAttrs; use crate::util::PathList; pub trait ExtractAttribute { fn local_declarations(&self) -> TokenStream; fn attr_names(&self) -> &PathList; fn forwarded_attrs(&self) -> Option<&ForwardAttrs>; fn param_name...
true
225ec4f2508a39f7630b0380930d449030372a2e
Rust
apognu/defcon
/src/model/specs/ping.rs
UTF-8
1,375
2.71875
3
[ "MIT" ]
permissive
use anyhow::Result; use sqlx::{FromRow, MySqlConnection}; use crate::model::{specs::SpecMeta, Check}; #[derive(Debug, FromRow, Clone, Serialize, Deserialize)] pub struct Ping { #[serde(skip)] pub id: u64, #[serde(skip)] pub check_id: u64, pub host: String, } impl SpecMeta for Ping { fn name(&self) -> &'s...
true
2343b5048fb1421ee79f8b19a6a92de296e31013
Rust
emanuelpalm/arspec
/arspec_doc/src/html/mod.rs
UTF-8
1,619
2.96875
3
[]
no_license
pub mod system; use std::{fmt, io}; use std::path::Path; pub trait Encode { fn encode<W>(&self, w: &mut W) -> io::Result<()> where W: io::Write; fn name(&self) -> &str; } /// Creates HTML documentation file for given `element`. pub fn render<E, W>( element: &E, scripts: &[&'_ Path], styl...
true
e5cd02b11c47a0edb86f90dc7a952820b3aea31d
Rust
idanarye/aoc-2020
/src/day20.rs
UTF-8
11,831
3.046875
3
[]
no_license
use core::fmt::Debug; use core::ops::Index; use hashbrown::{HashMap, HashSet}; const SIDE: usize = 10; const SEA_MONSTER_PATTERN: &[&str] = &[ " # ", "# ## ## ###", " # # # # # # ", ]; #[derive(Debug, Clone)] pub struct Tile { bitmap: Vec<bool>, } type Input = HashM...
true
c07d4a80c0e20f9f59ef9d6eba4320a7d667ea25
Rust
ademcaglin/learn-algorithms
/rust/src/find_anagrams.rs
UTF-8
1,068
3.078125
3
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader}; use std::time::{Duration, Instant}; fn diff(a: &String, b: &String) -> String{ let mut a_arr : Vec<char> = a.chars().collect(); let mut b_arr : Vec<char> = b.chars().collect(); for a_c in a.chars(){ if b_arr.iter().any(|&x| x == a_c){ a_arr.iter()...
true
1a109577dead6151ba1776604a418b0abbb56ed4
Rust
matsadler/quack
/src/commands/update.rs
UTF-8
4,711
2.59375
3
[]
no_license
use std::{ error::Error as StdError, fmt, net::{IpAddr, Ipv4Addr, Ipv6Addr}, time::Duration, }; use duck_dns::{Client, UpdateOptions}; use log::{debug, error, info}; use structopt::StructOpt; use crate::{check_ip_opts::CheckIpOpts, opts::Account, parse_duration::parse_duration}; #[derive(Debug)] stru...
true
48e2ac8880f15146ae27c2504bf20a2ff845505c
Rust
doytsujin/rust-advanced-collections
/src/disjoint_set/disjoint_set.rs
UTF-8
11,452
3.453125
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::collections::hash_map::Entry; use std::collections::hash_map::RandomState; use std::hash::{BuildHasher, Hash}; use std::iter::{Extend, FromIterator}; use std::default::Default; use std::iter::Iterator; use std::collections::hash_map::IntoIter; #[derive(Debug, Clone, Copy)] struc...
true
96c53c0e5ed671816df8dee4b4282a6f06fe8191
Rust
ml47-srl/b.3-linbot
/src/spec/lpath.rs
UTF-8
2,765
2.890625
3
[]
no_license
use libsrl::db::Database; use libsrl::cell::Cell; use libsrl::navi::{CellID, CellPath}; use libsrl::error::SRLError; use super::super::cond::Condition; #[derive(PartialEq)] #[derive(Clone)] pub enum Location { Target, Rule { rule_index : usize } } #[derive(PartialEq)] #[derive(Clone)] pub struct LocatedCellPath { ...
true
8b2ba214c185603bb046b816e9040a10f2ec2dad
Rust
fukatani/rust-ant-book
/lib/kruskal.rs
UTF-8
2,633
3.125
3
[]
no_license
// https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_A #[derive(Debug, Clone)] struct UnionFindTree { parent: Vec<isize>, size: Vec<usize>, height: Vec<u64>, } impl UnionFindTree { fn new(n: usize) -> UnionFindTree { UnionFindTree { parent: vec![-1; n], siz...
true
90eb5b13105fac45230b08ef3f6948eebda16c18
Rust
PacktPublishing/Rust-Programming-Cookbook
/Chapter05/resilient-programming/src/main.rs
UTF-8
523
2.9375
3
[ "MIT" ]
permissive
use std::fs; use std::io; fn print_file_contents_qm(filename: &str) -> Result<(), io::Error> { let contents = fs::read_to_string(filename)?; println!("File contents, external fn: {:?}", contents); Ok(()) } fn main() -> Result<(), std::io::Error> { println!("Ok: {:?}", print_file_contents_qm("testfile....
true
fd46ab335c28c9a857a5849be7d0d2d5db914939
Rust
pontem-network/move-language-server
/crates/move_language_server/src/config.rs
UTF-8
2,288
2.5625
3
[]
no_license
use crate::line_index::OffsetEncoding; use crate::lsp_ext::supports_utf8; use project_model::ProjectManifest; use vfs::AbsPathBuf; #[derive(Debug, Clone)] pub struct FilesConfig { pub exclude: Vec<AbsPathBuf>, } #[derive(Debug, Clone)] pub struct Config { pub caps: lsp_types::ClientCapabilities, pub disco...
true
6785c4a24b1b91ad328f0762ac94f64f5714c0ae
Rust
coriolinus/adventofcode-2019
/src/day02.rs
UTF-8
1,214
3.109375
3
[]
no_license
use crate::{ intcode::{compute_intcode, IntcodeMemory, Word}, parse, CommaSep, Exercise, }; use std::path::Path; pub struct Day02; impl Exercise for Day02 { fn part1(&self, path: &Path) { let mut memory: IntcodeMemory = parse::<CommaSep<Word>>(path).unwrap().flatten().collect(); // commen...
true
e59520d4f9159a190709e4152a0ad0af6748aac7
Rust
zhengminlai/Rust
/toy_problems/fibonacci.rs
UTF-8
1,135
3.921875
4
[]
no_license
fn main() { let max = 25; let results = fibonacci(max, []); // pass in max as arg1 and an empty, dynamically-sized vector as arg2 println!("{:?}", results); // print the results as a string using '{:?}' } // @param uint - max - an unsigned integer, the number of Fibonacci numbers to generate // @param vector...
true
9326fbd93375a83b5aaa69cf326a5e6e3acc9acd
Rust
YusukeHosonuma/workspace
/Rust/tutorial/tutorial_4_19/src/main.rs
UTF-8
6,634
4
4
[]
no_license
// トレイトの宣言(型シグネチャだけ定義) trait HasArea { fn area(&self) -> f64; } struct Circle { x: f64, y: f64, radius: f64, } // トレイトを実装 // `impl {トレイト} for 型 {` impl HasArea for Circle { fn area(&self) -> f64 { std::f64::consts::PI * (self.radius * self.radius) } } struct Square { x: f64, ...
true
e98a6019cd543cd17268dc8d3155362e4b22c1e5
Rust
probe-rs/probe-rs
/probe-rs/src/architecture/arm/ap/mod.rs
UTF-8
8,097
2.796875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Types and functions for interacting with access ports. #[macro_use] pub mod register_generation; pub(crate) mod generic_ap; pub(crate) mod memory_ap; use crate::architecture::arm::dp::DebugPortError; use crate::DebugProbeError; pub use generic_ap::{ApClass, ApType, GenericAp, IDR}; pub use memory_ap::{ Addre...
true
c46989a848b2731a46630f1b065a81c7fed9aa35
Rust
deckarep/rust-lifetimes
/src/toolbelt.rs
UTF-8
530
3.125
3
[ "MIT" ]
permissive
use std::vec::Vec; use std::fmt; pub struct Toolbelt<'a> { pub tools: Vec<&'a Item>, } impl<'a> Toolbelt<'a> { pub fn empty(&mut self) { self.tools.clear(); } } impl<'a> fmt::Display for Toolbelt<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut tools = String::new(...
true
23a6b26b8cb67d45000036017f345f1945f84cbe
Rust
mcapell/aoc2020
/src/day_02.rs
UTF-8
3,813
3.28125
3
[]
no_license
use std::fs::File; use std::io::{prelude::*, BufReader}; use lazy_static::lazy_static; use regex::Regex; const FILEPATH: &str = "data/02/input.txt"; lazy_static! { static ref RE: Regex = Regex::new(r"^(\d+)\-(\d+) (\w): (\w+)$").expect("Invalid regex"); } pub fn first_solution() { let file = File::open(FILEP...
true
641f0d570240e6b8e9a6434840edd96249ea942c
Rust
markhildreth/space-trouble
/st_core/src/actors/directives/controls.rs
UTF-8
6,147
3.390625
3
[]
no_license
use crate::common::*; use core::fmt::Debug; use heapless::consts::*; use rand::Rng; pub(super) trait Control<T> { fn perform(&mut self, option: T); fn clear(&mut self, option: T); fn actions_available(&self) -> bool; fn generate(&mut self, rng: &mut impl Rng) -> T; } #[derive(Debug)] pub(super) struct...
true
99bfe024a5097511b16aa0f1c1a8bb5ed91aacaa
Rust
zaclummys/cache-implementation-rust
/src/cache/line/regular.rs
UTF-8
456
2.78125
3
[]
no_license
pub struct RegularCacheLine { valid: bool, tag: usize, } impl RegularCacheLine { pub fn invalid () -> RegularCacheLine { RegularCacheLine { tag: 0, valid: false, } } pub fn valid (tag: usize) -> RegularCacheLine { RegularCacheLine { tag, ...
true
a40b4e837cdd64744d049d946f4233ce1a26104b
Rust
vtselfa/gps-server
/src/action.rs
UTF-8
3,640
2.640625
3
[]
no_license
use crate::types; pub trait Action { fn new(action_name: &str, contents: &str) -> Result<Self, types::GpsError> where Self: Sized; fn execute(&self, state: &types::State) -> Result<String, types::GpsError>; fn report_not_successful(&self, error: &types::GpsError) -> Result<String, types::GpsE...
true
0e0c229742c8f528647ac442bc80016ec9cb5de7
Rust
bentekkie/advent_of_code_2020
/day5/rust/src/main.rs
UTF-8
1,842
2.96875
3
[]
no_license
extern crate snafu; use snafu::{OptionExt, ResultExt, Snafu}; use std::fs::File; use std::io::{self, BufRead}; use std::num::ParseIntError; use std::path::{Path, PathBuf}; fn main() { println!("Part1: {:?}", part1()); println!("Part2: {:?}", part2()); } fn part1() -> Result<usize> { read_lines("../i")? ...
true
ae7e8708d216f56a11f549d8f7a7f996239c923a
Rust
Ryan1729/rote
/libs/platform_layer/libs/window_layer/gl_layer/gl_layer_types/src/gl_layer_types.rs
UTF-8
5,152
3.03125
3
[ "Apache-2.0", "MIT" ]
permissive
use platform_types::{ScreenSpaceRect, ScrollXY}; use macros::{d}; mod u24; pub use u24::U24; /// `(width, height)` pub type Dimensions = (U24, U24); use std::borrow::Cow; pub type Res<T> = Result<T, Box<dyn std::error::Error>>; #[derive(Clone, Copy, Debug, Default)] pub struct Point { pub x: f32, pub y: f3...
true
5dcc209dfc8bf0520201981eac2d0b91993ccec9
Rust
marco-c/gecko-dev-wordified
/third_party/rust/wast/src/component/item_ref.rs
UTF-8
4,129
3.046875
3
[ "LicenseRef-scancode-unknown-license-reference", "LLVM-exception", "Apache-2.0" ]
permissive
use crate : : parser : : { Cursor Parse Parser Peek Result } ; use crate : : token : : Index ; fn peek < K : Peek > ( cursor : Cursor ) - > Result < bool > { / / This is a little fancy because when parsing something like : / / / / ( type ( component ( type foo ) ) ) / / / / we need to disambiguate that from / / / / ( t...
true
4a4e15f2c059cb0c6204134e3c5bebe64b20aa83
Rust
oxidecomputer/third-party-api-clients
/stripe/src/tokens.rs
UTF-8
1,999
2.953125
3
[ "MIT" ]
permissive
use crate::Client; use crate::ClientResult; pub struct Tokens { pub client: Client, } impl Tokens { #[doc(hidden)] pub fn new(client: Client) -> Self { Tokens { client } } /** * This function performs a `POST` to the `/v1/tokens` endpoint. * * <p>Creates a single-use token ...
true
7f03bc6f600d89479f77fbe7172ec43ea1c8e11b
Rust
blackblood/kv-lake
/src/stores/lru/my_list.rs
UTF-8
3,408
3.0625
3
[ "MIT" ]
permissive
use std::sync::{ Arc, RwLock }; use super::my_node; pub struct List<T: std::fmt::Display + std::clone::Clone> { pub head: Option<Arc<RwLock<my_node::Node<T>>>>, pub end: Option<Arc<RwLock<my_node::Node<T>>>>, pub size: u32 } pub struct ListIterator<T: std::fmt::Display + std::clone::Clone> { ptr: Opti...
true
81745a4ee5437869ac847b4d6ee11f2ab03a013d
Rust
ymgyt/kvsd
/src/error/internal.rs
UTF-8
4,612
2.5625
3
[ "MIT" ]
permissive
use std::error; use std::fmt; use std::io; use backtrace::Backtrace; use tokio::sync::mpsc::error::SendError; use tokio::sync::oneshot::error::RecvError as OneshotRecvError; use tokio::time::error::Elapsed; use crate::common::KvsdError; use crate::protocol::message::{FrameError, ParseError}; #[derive(Debug)] pub(cra...
true
4e4afec383c3dd6616e8ac743831445688c0dc21
Rust
lewisdiamond/rms
/termui/src/terminal/store/tags.rs
UTF-8
460
3.03125
3
[]
no_license
use crate::message::Message; use crate::stores::MessageStore; pub struct TagsStore<'a> { pub message_store: &'a dyn MessageStore, pub message: Option<Message>, } impl<'a> TagsStore<'a> { pub fn new(msg_store: &'a dyn MessageStore) -> TagsStore<'a> { TagsStore { message: None, ...
true
668a577c2be13ea40c31366a10d3b504483bfa43
Rust
Hades785/jp-quiz
/src/main.rs
UTF-8
2,070
2.984375
3
[ "MIT" ]
permissive
use rand::prelude::IteratorRandom; use std::env; const HIRA: &str = "あいうえおかきくけこがぎぐげごさしすせそざじずぜぞたちつてとだぢづでどなにぬねのはひふへほばびぶべぼぱぴぷぺぽまみむめもやゆよらりるれろわをん"; const HIRA_GOJUU: &str = "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをん"; const KATA: &str = "アイウエオカキクケコガギグゲゴサシスセソザジズゼゾタチツテトダヂヅデドナニヌネノハヒフヘホバビブベボパピプペポマミムメモヤユヨラリルレロワヲン"; c...
true
6146e3e388b990b5bb09e97326cb3178cbf3c028
Rust
Koka/odbc-rs
/tests/libs.rs
UTF-8
11,747
2.78125
3
[ "MIT" ]
permissive
extern crate odbc; extern crate odbc_safe; use odbc::*; use odbc_safe::AutocommitOn; #[test] fn list_tables() { let env = create_environment_v3().unwrap(); let ds = env.connect("TestDataSource", "", "").unwrap(); // scope is required (for now) to close statement before disconnecting { let sta...
true
4c29672354e6fac63bf82c0faaaa669194ee24e1
Rust
Stratus51/rust_dash7_alp
/src/test_tools.rs
UTF-8
410
2.640625
3
[ "MIT" ]
permissive
#[cfg(test)] use crate::codec::{Codec, WithSize}; #[cfg(test)] pub fn test_item<T: Codec + std::fmt::Debug + std::cmp::PartialEq>(item: T, data: &[u8]) where T::Error: std::fmt::Debug, { assert_eq!(item.encode()[..], *data); assert_eq!( T::decode(&data).expect("should be parsed without error"), ...
true
b8a7002e42188de212ab8899fa2c4dffb97c5ea5
Rust
kakira9618/algorithm-problem-client
/src/atcoder/client.rs
UTF-8
2,590
3.171875
3
[ "MIT" ]
permissive
use crate::util::HttpClient; use crate::Result; use super::*; const ATCODER_PREFIX: &str = "https://atcoder.jp"; pub struct AtCoderClient { http_client: HttpClient, } impl Default for AtCoderClient { fn default() -> Self { Self { http_client: HttpClient::default(), } } } imp...
true
45ed5ccce48fe82eb1753ccc3cbc264d321c6ae9
Rust
johannesvollmer/iris
/src/bxdf/specular_reflection.rs
UTF-8
1,005
2.640625
3
[ "MIT" ]
permissive
use crate::bxdf::fresnel::Fresnel; use crate::bxdf::BxDF; use crate::bxdf::BxDFType; use crate::film::spectrum::Spectrum; use crate::math::*; #[derive(new)] pub struct SpecularReflection<'a> { pub r: Spectrum, pub fresnel: &'a dyn Fresnel, } impl BxDF for SpecularReflection<'_> { fn get_type(&self) -> BxD...
true
95401020d4373e4bad7dbbc911456ff370f382f7
Rust
Zorakinezear/stormy-fire
/src/map.rs
UTF-8
6,888
2.9375
3
[ "Apache-2.0", "MIT" ]
permissive
use amethyst::{ core::transform::Transform, ecs::{Component, DenseVecStorage, Entity, FlaggedStorage}, }; extern crate tiled; use std::{fs::File, io::BufReader, path::Path}; // note:(future implmentation of Monster) use crate::components::{Monster, Orientation}; use crate::constants; use log::info; /// Make ...
true
fb77ad5c98fa165eef5775d4ca5a6d593ba21ab0
Rust
sarsko/CreuSAT
/JigSAT/src/util.rs
UTF-8
333
2.53125
3
[ "MIT" ]
permissive
pub fn sort_reverse(v: &mut Vec<(usize, usize)>) { let mut i: usize = 0; while i < v.len() { let mut max = i; let mut j = i + 1; while j < v.len() { if v[j].0 > v[max].0 { max = j; } j += 1; } v.swap(i, max); i +...
true
15bdec0b8da22d6d3ec65a933ea76921dc91ff96
Rust
veeso/chess-engine-harmon
/src/board/mod.rs
UTF-8
70,623
3.390625
3
[ "MIT" ]
permissive
//! # Board //! //! This module contains the data types to work with the chess board. //! The two most important struct are the `Board` which contains the "game" itself and the //! `BoardBuilder` which is an helper to build different kind of "games". //! //! The board, instead, already provides constructor for: //! //!...
true
51f61d176d825891b1987a6081555cac4df8008c
Rust
JetHalo/ShamirSecret_Share
/src/lib.rs
UTF-8
2,646
3.09375
3
[]
no_license
//! ShamirSecret_Share is a Rust libary for secret sharing //! #[cfg(test)] extern crate quickcheck; extern crate rand; extern crate subtle; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}; /// gf256 is a module for field elements over the field GF(2^8) with irreducible polynomi...
true
1ace4b8726ba40d3ade492b9fb0ad61353854967
Rust
LucasGobbs/Aim-Training
/src/main.rs
UTF-8
4,186
2.59375
3
[]
no_license
mod target; use target::Target; mod game; use game::Game; use std::fs; use tetra::graphics::text::{Font, Text}; use tetra::graphics::{self, Color, Texture}; use tetra::math::Vec2; use tetra::{Context, ContextBuilder, Event, State, time, window, input}; use rlua::{ Lua, Function, }; use rand::Rng; struct...
true
41cbabf777dd400e20fd31e3a381ac2ce1bdf971
Rust
tomaka/futures-diagnose
/src/absolute_time.rs
UTF-8
2,338
3.046875
3
[ "MIT" ]
permissive
// Copyright 2020 Pierre Krieger // // 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, di...
true
032abdee0d6435d00a84066a3179bbb4b35c09c1
Rust
rick68/rust-trace
/libcore/convert/T/from.rs
UTF-8
359
3.125
3
[ "MIT" ]
permissive
#![feature(core)] extern crate core; #[cfg(test)] mod tests { struct A<T> { value: T } // impl<T> From<T> for T { // fn from(t: T) -> T { t } // } type T = i32; #[test] fn into_test1() { let value: T = 68; let a: A<T> = A { value: value }; let from: A<T> = A::<T>::from(a); ...
true
80caaa8bf428ae1234d2f983af61dd31be3b15ac
Rust
ChewyGumball/advent_of_code_2020
/5/b/src/main.rs
UTF-8
2,893
3.359375
3
[ "MIT" ]
permissive
use std::env; use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; struct BoardingPass { seat: String } fn parse_line(line: std::io::Result<String>, file_name: String) -> BoardingPass { let value = match line { Err(why) => panic!("Couldn't read line from {}: {}", file_name, why), ...
true
6ce9378e8494e22007071d0f126227c865c47980
Rust
ennocramer/lucifer
/src/geometry/disc.rs
UTF-8
1,812
3.5625
4
[]
no_license
use cgmath::prelude::*; use geometry::{Geometry, Intersection, Point, Ray, Vector}; /// A two-dimensional disc. #[derive(Clone, Debug)] pub struct Disc { /// The disc's center point. pub center: Point, /// The disc's normal. pub normal: Vector, /// The disc's radius. pub radius: f32, } impl D...
true
e3a5714dba259287614d936bf3788a36fbf966ae
Rust
DeTeam/advent-2018
/day9/src/main.rs
UTF-8
867
2.859375
3
[]
no_license
fn solve(players: usize, last_marble: u32) -> u32 { let mut scores: Vec<u32> = vec![0; players]; let mut circle: Vec<u32> = vec![0]; let marbles = 1..=last_marble; let players_iter = (0..players).into_iter().cycle(); for (marble, player) in marbles.zip(players_iter) { if marble % 23 =...
true