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
10f1c7c8000497aa2b0514dfd13eca7702d0163f
Rust
Srynetix/gdpm
/crates/gdpm-downloader/src/download.rs
UTF-8
3,159
3.015625
3
[]
no_license
//! Download module. use reqwest::Url; use crate::{error::DownloadError, DownloadAdapter}; use gdpm_types::{GodotVersion, GodotVersionKind, SystemVersion}; /// Downloader. pub struct Downloader; impl Downloader { /// Get URL for version from a mirror URL. pub fn get_official_url_for_version( version...
true
6cf451676f527cf2e23ec1b01813fca99d49685b
Rust
sadernalwis/hash-shader
/vulkan/src/main.rs
UTF-8
2,614
3.09375
3
[ "Apache-2.0", "MIT" ]
permissive
mod runner; use std::env; /// Prepare the text data for GPU by padding the bits to multiples of 512 /// - Append 1 as a delimiter /// - Append 0s /// - The last 64 bits denote the size of original message fn prepare_for_gpu(word: String) -> (Vec<u32>, u32) { let mut init: Vec<u8> = word.into_bytes(); let msg...
true
b17c42048e0de6cdb01cc26587d4f28ea0943989
Rust
CampoDiFiori/sdltablesrust
/src/shapes/impls.rs
UTF-8
1,415
3.109375
3
[]
no_license
use super::clickable::Clickable; use super::into_sdl_rect::IntoSdlRect; impl Clickable for sdl2::rect::Point { fn is_hovered (&self, clicked_point: &sdl2::rect::Point) -> bool { return clicked_point.x <= self.x + 5 && clicked_point.x >= self.x - 5 && clicked_point.y <= self.y + 5 &&...
true
c23aa78d8eca696a8acbfe56ec4fe1181d6bac9f
Rust
Kejuntrap/traQbot
/src/router/functions.rs
UTF-8
5,471
2.984375
3
[ "Apache-2.0" ]
permissive
use super::super::database::Database; use super::receiver::*; #[derive(PartialEq,Debug)] // for debug/test pub enum Command { Help, Random(Vec<String>), } // コマンドがあればそれを↑のEnum形式で、なければNoneを返す pub fn parse_command(plain_text: &str) -> Option<Command> { use Command::*; let mut terms = plain_text.split_wh...
true
bfdf8f1ff964f144261b7ed3cea7bd5a50fbe284
Rust
luqmana/rust-opencl
/examples/demo/main.rs
UTF-8
1,624
2.578125
3
[ "MIT", "Apache-2.0" ]
permissive
extern crate opencl; use opencl::mem::CLBuffer; use std::fmt; fn main() { let ker = include_str!("demo.ocl"); println!("ker {}", ker); let vec_a = vec![0isize, 1, 2, -3, 4, 5, 6, 7]; let vec_b = vec![-7isize, -6, 5, -4, 0, -1, 2, 3]; let (device, ctx, queue) = opencl::util::create_compute_contex...
true
5a3789036bb3d9390d205b9dfed529863598bd7a
Rust
acburigo/rust-bgapi
/src/flash/rsp.rs
UTF-8
2,519
2.625
3
[ "MIT" ]
permissive
use bytes::{Buf, BufMut}; use error::Error; use num_traits::FromPrimitive; use std::io::{Cursor, Read}; #[allow(non_camel_case_types)] #[derive(Debug, Clone, PartialEq, PartialOrd)] pub struct ps_erase { pub result: Error, } impl From<&[u8]> for ps_erase { fn from(data: &[u8]) -> ps_erase { let mut cu...
true
6320aa0ac2fe0d6b4d30cd115c03382ae808754e
Rust
cambricorp/perspective-rs
/src/row_aggregator.rs
UTF-8
1,286
3.078125
3
[ "Apache-2.0", "MIT" ]
permissive
use super::accumulator::Accumulator; use super::cell_value::CellValue; pub struct RowAggregator { row: Vec<CellAccumulator>, } struct CellAccumulator { value: CellValue, accumulator: Accumulator, } impl CellAccumulator { fn accumulate(&self, acc: &CellValue) -> CellAccumulator { CellAccumulat...
true
4805c484e07ecfc1897ef984f0b4aca1000afe95
Rust
Swatinem/aoc2016
/src/day2a.rs
UTF-8
1,534
3.828125
4
[]
no_license
use std::fmt::Write; use self::Direction::*; pub enum Direction { Up, Right, Down, Left, } pub fn parse_direction(i: char) -> Direction { println!("{:#?}", i); match i { 'U' => Up, 'R' => Right, 'D' => Down, 'L' => Left, _ => unreachable!(), } } //...
true
224493f9dfb5d02980cf64f2e82e0391e7cfb0ca
Rust
jimenezrick/katas
/rust/iters2.rs
UTF-8
338
3.0625
3
[]
no_license
fn main() { let mut v = vec![1, 2, 3]; println!("v = {:?}", v); for e in &mut v { *e += 1; } println!("v = {:?}", v); let v2: Vec<_> = v.into_iter().filter(|&x| x >= 3).collect(); println!("v = {:?}", v2); for i in (1..10).rev().filter(|x| x % 2 == 0) { println!("i = {...
true
736cc4638775e5928d5d79883700081aea1f3f8d
Rust
fluent/fluent-bit
/examples/filter_rust_clib/src/lib.rs
UTF-8
1,177
2.53125
3
[ "Apache-2.0" ]
permissive
// Import pure and fast JSON library written in Rust use serde_json::json; use serde_json::Value; // Import chrono library to handle time related operation conveniently use chrono::{Utc, TimeZone}; use std::slice; use std::str; use std::os::raw::c_char; use std::io::Write; #[no_mangle] pub extern "C" fn rust_filter(ta...
true
22f600b2d5e916726e664907c5145e618729d9d8
Rust
AndreasOM/omt
/src/packer/command_packer_list.rs
UTF-8
1,442
2.8125
3
[ "MIT" ]
permissive
use std::fs; use crate::name_map::NameMap; use crate::packer::command_packer::CommandPacker; use crate::packer::packer::Archive; #[derive(Debug, Default)] pub struct CommandPackerList { input: Option<String>, name_map: Option<String>, } impl CommandPackerList { pub fn new() -> Self { Self { ..Default::def...
true
7d2d0d0da6d62222c10204573c0dc4e216b1cc1c
Rust
lytharn/ants
/client/src/parser.rs
UTF-8
17,831
3.015625
3
[ "Unlicense" ]
permissive
use ai::Config; use ai::EndInfo; use ai::PlayerEntity; use ai::Position; use ai::TurnInfo; #[derive(Debug, PartialEq)] pub enum Error { CannotParseGameConfig, CannotParseTurnInfo, CannotParseEndInfo, } #[derive(Debug)] pub enum Turn { Normal(Result<TurnInfo, Error>), End(Result<EndInfo, Error>), }...
true
c8265bc1c200d28b675684be9d895744904a1d7a
Rust
lawliet89/nomad_drain
/nomad_drain/src/vault.rs
UTF-8
13,082
2.9375
3
[ "Apache-2.0" ]
permissive
// ENV: https://www.vaultproject.io/docs/commands/#environment-variables use std::borrow::Cow; use std::collections::HashMap; use std::fmt::Debug; use log::{debug, info, warn}; use reqwest::{Client as HttpClient, ClientBuilder}; use serde::{Deserialize, Serialize}; /// Vault API Client #[derive(Clone, Debug)] pub str...
true
99e56bb844888d1cca97376c67b33c3f6ba25c4c
Rust
analogrelay/crustyclr
/ecma355metadata/src/cli/metadata_sizes.rs
UTF-8
2,675
2.75
3
[]
no_license
use std::io::Read; use byteorder::{LittleEndian, ReadBytesExt}; use cli::tables::{TableIndex, TableMask}; use error::Error; pub const SMALL_TABLE_MAX_SIZE: usize = 0xFFFF; pub const SMALL_INDEX_SIZE: usize = 2; pub const LARGE_INDEX_SIZE: usize = 4; bitflags! { pub struct HeapSizes: u8 { const LARGE_STR...
true
f5ae4974933fb82cb9592ac228f46a35d0615f2e
Rust
cginternals/yage
/yage-core/src/core/gpu_object.rs
UTF-8
2,440
3.6875
4
[ "Apache-2.0", "MIT" ]
permissive
use crate::Context; /// /// A `GpuObject` represents or owns data on the GPU. /// /// In a complex application architecture, it cannot be guaranteed that /// an OpenGL [`Context`] is active at the time an object is created or /// deleted. Therefore, OpenGL objects and functions must only be accessed /// when a [`Conte...
true
376e0924d025e54dad4710fa9af340f8d8de737e
Rust
tianhuil/prisma
/server/prisma-rs/query-engine/connectors/sql-connector/src/transactional/mutaction_executor/update_many.rs
UTF-8
2,052
2.515625
3
[ "Apache-2.0" ]
permissive
use super::update; use crate::{mutaction::MutationBuilder, SqlResult, Transaction}; use connector::filter::Filter; use prisma_models::{GraphqlId, ModelRef, PrismaArgs, PrismaListValue, RelationFieldRef}; use std::sync::Arc; /// Updates every record and any associated list records in the database /// matching the `Filt...
true
cf32c52c5e64646a11900d401b01022c175b034c
Rust
safeforge/artichoke
/mezzaluna-feature-loader/src/paths/default.rs
UTF-8
4,665
3.15625
3
[ "MIT" ]
permissive
use std::ffi::OsStr; use std::path; #[allow(dead_code)] pub fn is_explicit_relative<P: AsRef<OsStr>>(path: P) -> bool { let path = path.as_ref(); let bytes = if let Some(path) = path.to_str() { path.as_bytes() } else { return false; }; is_explicit_relative_bytes(bytes) } #[allow(de...
true
1399e31de983b1ee1322cede384f5cbf16fd71e3
Rust
victor-zapselsky/algorithms-and-data-structures
/Rust/src/main.rs
UTF-8
1,106
2.71875
3
[]
no_license
use std::io; fn main() { let mut numbers = String::new(); let mut tuple = String::new(); io::stdin() .read_line(&mut tuple) .ok() .expect("read error"); let _ln: Vec<i32> = tuple .split_whitespace() .map(|s| s.parse().unwrap()) .collect(); let N : i...
true
f60cd8d6c37807006e4ea117ad8d4bf17e58b58f
Rust
askoufis/advent-of-code-2020
/src/day6.rs
UTF-8
1,626
3.328125
3
[]
no_license
use std::collections::HashMap; #[aoc_generator(day6)] fn input_generator(input: &str) -> Vec<(HashMap<char, usize>, usize)> { input .split("\n\n") .map(|group_answers| { let mut answers = HashMap::new(); let mut count = 0; group_answers.trim().lines().for_each(|l...
true
7b5ed123594b1636f49aed5037cf9b9a9c282017
Rust
niconii/crayonforth-snes
/tools/checksum.rs
UTF-8
925
2.921875
3
[]
no_license
use std::io::prelude::*; use std::fs::OpenOptions; use std::io::SeekFrom; fn main() { let filename = std::env::args().nth(1).expect("No filename given"); let mut f = OpenOptions::new() .read(true).write(true).append(false).truncate(false) .open(filename).expect("Failed to open file"); f.s...
true
bfcb4c9582045dce7dccf7ff23edd82191a61a16
Rust
ngobach/ggez-2048
/src/game/layout.rs
UTF-8
4,523
2.65625
3
[ "MIT" ]
permissive
use ggez::graphics::Rect; use stretch::geometry::Size; use stretch::node::{Node, Stretch}; use stretch::number::Number; use stretch::result::Layout; use stretch::style::{AlignItems, AlignSelf, Dimension, FlexDirection, JustifyContent, Style}; pub struct GameLayout { root: Stretch, title: Node, score: Node,...
true
7fbb37d0f334f2acbe376bd53c8a1b650dd7fac7
Rust
IThawk/rust-project
/rust-master/src/test/run-pass/issues/issue-13264.rs
UTF-8
1,057
2.84375
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// run-pass #![allow(non_camel_case_types)] #![allow(non_snake_case)] use std::ops::Deref; struct Root { jsref: JSRef } impl Deref for Root { type Target = JSRef; fn deref<'a>(&'a self) -> &'a JSRef { &self.jsref } } #[derive(Copy, Clone)] struct JSRef { node: *const Node } impl Deref ...
true
8d16b4a32be064435aa1cec8bf6a525f34ebe324
Rust
imskyer/rust-blog-series-conspiracies-api
/src/actors/tags.rs
UTF-8
851
2.71875
3
[]
no_license
use actix::prelude::*; use db; use models::{NewTag, Tag}; use super::db_executor::{DbExecutor}; pub struct AddTag { pub tag: NewTag } impl Message for AddTag { type Result = Result<usize, String>; } impl Handler<AddTag> for DbExecutor { type Result = Result<usize, String>; fn handle(&mut self, msg: Ad...
true
98ec165cecdbac2281c66d3595480384c35db38d
Rust
bvbasavaraju/rust
/practice/src/main.rs
UTF-8
1,418
3.78125
4
[]
no_license
use std::io; use std::cmp::Ordering; use rand::Rng; fn guess_game() { loop { println!("\n\nEnter your guess between 1 to 10:"); let mut input = String::new(); io::stdin().read_line(&mut input) .expect("Error reading the given input"); let input_: u32 = match input.trim().parse() ...
true
b94c6f479a9fb044cc49a22eaf754bc41f782eea
Rust
Nemo157/cbor-diag-rs
/tests/comments.rs
UTF-8
2,303
2.546875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use cbor_diag::{ByteString, DataItem, IntegerWidth, TextString}; use data_encoding_macro::hexlower as hex; #[macro_use] mod utils; // RFC 8610 Appendix G.6 testcases! { rfc_example(diag2value) { DataItem::Array { data: vec![ DataItem::Integer { value: 1, ...
true
3e150d201c2a0bc3a404e7ce4a5a7dbbe74af42b
Rust
nightkr/id1212_bytebarrage
/src/fs_walker.rs
UTF-8
429
2.828125
3
[]
no_license
use std::path::PathBuf; use std::fs::{metadata, read_dir}; use std::io::Error as IOError; pub fn walk_dir_files<Error, F>(path: PathBuf, f: &mut F) -> Result<(), Error> where Error: From<IOError>, F: FnMut(PathBuf) -> Result<(), Error>, { if metadata(&path)?.is_dir() { for entry in read_dir(path)? ...
true
82fef28baf9c32aa6916ed8f644e06d8a9a14f87
Rust
OhBonsai/rust-leetcode
/src/array/q209.rs
UTF-8
1,382
3.875
4
[]
no_license
//! 给定一个含有n个正整数的数组和一个正整数 target 。 //! //! 找出该数组中满足其和 ≥ target 的长度最小的 连续子数组[numsl, numsl+1, ..., numsr-1, numsr] ,并返回其长度。如果不存在符合条件的子数组,返回 0 。 //! //! //! 示例 1: //! ``` //! 输入:target = 7, nums = [2,3,1,2,4,3] //! 输出:2 //! 解释:子数组[4,3]是该条件下的长度最小的子数组。 //! ``` //! 示例 2: //! ``` //! 输入:target = 4, nums = [1,4,4] //! 输出:1 //! ...
true
1bb9cfc1c43482691f5151bc60f2c99b13915d42
Rust
jffjs/cavers
/src/geom/mod.rs
UTF-8
2,026
3.421875
3
[]
no_license
use geom::Contains::{DoesContain, DoesNotContain}; use core::num::Float; #[derive(Copy, Clone)] pub struct Point { pub x: i32, pub y: i32 } impl Point { pub fn new(x: i32, y: i32) -> Point { Point {x: x, y: y } } pub fn distance_to(&self, p: Point) -> f32 { let x1 = self.x as f32;...
true
0f7e235dfb44b9045334f7f238385e494b8ec77b
Rust
NorabX/rustils
/src/impls/parse/byte_impl.rs
UTF-8
13,088
3.03125
3
[ "MIT" ]
permissive
use parse::byte::*; use RoundingMode; impl ToI8 for bool { /// Parse [`bool`](https://doc.rust-lang.org/std/primitive.bool.html) to /// [`i8`](https://doc.rust-lang.org/std/primitive.i8.html) /// (see more: [`bool_to_i8_res`](../../parse/byte/fn.bool_to_i8_res.html)) /// /// # Examples /// ...
true
73b2b264647a0f8135fd1312895bf6ef3d16f274
Rust
byronwasti/movine
/src/errors.rs
UTF-8
4,842
2.609375
3
[ "MIT" ]
permissive
use libsqlite3_sys::Error as SqliteLibError; use libsqlite3_sys::ErrorCode as SqliteLibErrorCode; use postgres::error::Error as PostgresError; use rusqlite::Error as SqliteError; use std::error::Error as StdError; use std::fmt; use std::io; use toml::de::Error as TomlError; pub type Result<T> = std::result::Result<T, ...
true
d5903a51a63fa0f20d5a9127e7a82d0ed8efa1ef
Rust
dtolnay/reflect
/tests/test_field_access.rs
UTF-8
2,073
2.609375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
#![allow(non_upper_case_globals)] // rustc bug: https://github.com/rust-lang/rust/issues/110573 #![allow(clippy::wildcard_imports)] use quote::quote; use reflect::*; fn derive(ex: Execution) { // Checks from #[trivial(skip)] attribute on a field fn should_skip(field: &Field<Value>) -> bool { field.get...
true
e032fa56bd57b0824638202aaeb7e28fe3fb3d67
Rust
simonjiao/rust-algorithm
/src/bin/longest_substring_without_repeating_characters.rs
UTF-8
1,234
3.53125
4
[ "BSD-2-Clause" ]
permissive
use std::collections::HashSet; #[allow(dead_code)] fn length_of_longest_substring1(s: String)-> i32 { let mut set = HashSet::new(); let mut len = 0; let mut r = 0; let mut i = 0; let size = s.len(); let c_char = s.as_bytes(); while i < size { if i != 0 { set.remove(&c_c...
true
86d712cb8cc408c8bca263751056df9031ea8702
Rust
barodeur/aoc2020
/day_01/src/main.rs
UTF-8
1,013
3.21875
3
[]
no_license
use std::fs::File; use std::io::prelude::*; fn main() -> std::io::Result<()> { let mut input_file = File::open("input.txt")?; let mut contents = String::new(); input_file.read_to_string(&mut contents)?; let numbers: Vec<i32> = contents .split('\n') .filter_map(|s| s.parse().ok()) ...
true
a400094d5757dae2daba72587a8e5bd95a962536
Rust
elsuizo/document-distance-rust
/src/main.rs
UTF-8
4,954
2.75
3
[]
no_license
//------------------------------------------------------------------------- // @file main.rs // // @date 07/10/20 11:35:41 // @author Martin Noblia // @email mnoblia@disroot.org // // @brief // // @detail // // Licence MIT: // Copyright <year> <Martin Noblia> // // Permission is hereby granted, free of charge, to any p...
true
9b68af1d1c5690919237fe44e391c6ae9a0d0b55
Rust
icorderi/rust-jconfig
/examples/basic.rs
UTF-8
597
3.25
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[macro_use] extern crate jconfig; use jconfig::Config; fn main() { let raw = r#"{"port":12345,"name":"test"}"#; // Create from raw JSON, you can also do Config::load("my-config.json") let config = Config::from_str(raw).unwrap(); // Try to get the field of type `Port` println!("{}", config.get::...
true
cc7eed2c4ad97ac1b54c34a8d9b368c1f6a56721
Rust
qrider71/tacho
/tacho/src/help.rs
UTF-8
1,086
2.765625
3
[ "Apache-2.0" ]
permissive
pub fn display_help() -> Result<(), String> { let help = " PerfTacho V 0.4.0 (c)2020 by Markus Reith PerfTacho executes a command and measures the elapsed time in milliseconds. Usage: perftacho [-tachoOptions] <command> [params] Available options: -tachoRepeat=<n>...
true
80b5642016060d979edf5b0c5dcff9b7970b03f8
Rust
julianpoma/rust-playground
/modules/src/main.rs
UTF-8
387
2.6875
3
[]
no_license
mod util; mod helper; use helper::helper_utils; // If we use this, we can call helper utils functions like this // helper_utils::helper_caller(); fn main() { util::util_caller(); // Two ways of calling the helper_utils functions helper::helper_utils::helper_caller(); // We need the use above to d...
true
79bd638e9418aa0a2c1177256163b302374b5950
Rust
drogue-iot/drogue-ffi-compat
/src/strlen.rs
UTF-8
595
2.65625
3
[]
no_license
/// Exported strlen(const char *s) #[allow(clippy::not_unsafe_ptr_arg_deref)] #[no_mangle] pub extern "C" fn strlen(s: *const u8) -> usize { let mut n = 0; unsafe { while *s.add(n) != 0 { n += 1; } } n } /// Exported strnlen(const char *s, size_t maxlen) #[allow(clippy::no...
true
2cca90b0a9827109dc98c37ab89fd36f5543c19e
Rust
thea0032/discordapp
/src/input/servers.rs
UTF-8
1,779
2.5625
3
[]
no_license
use crossterm::event::{KeyCode, KeyEvent}; use super::State; impl super::Parser { pub fn parse_none_server(&mut self, input: KeyEvent) { let KeyEvent { code, modifiers: _ } = input; match code { KeyCode::Right => { self.int.grid.context = super::Context::Category; ...
true
47f7785a11c3aa988c6734b182454bd07812c609
Rust
harcomaase/aoc
/rs-22/src/bin/day11.rs
UTF-8
3,323
3.234375
3
[]
no_license
use std::fs; struct Monkey { items: Vec<i64>, operation: char, operation_value: Option<i64>, test_divisible_by: i64, test_true_target: usize, test_false_target: usize, inspections: usize, } fn main() { let input = fs::read_to_string("../input/22/day11.txt").unwrap(); // parse inpu...
true
0ab7c45d248452f999425a0510a535ec9d701a30
Rust
shaneutt/wasm-pack
/src/install/arch.rs
UTF-8
871
3.1875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown" ]
permissive
use anyhow::{bail, Result}; use std::fmt; use crate::target; /// An enum representing supported architectures #[derive(Clone, PartialEq, Eq)] pub enum Arch { /// x86 64-bit X86_64, /// x86 32-bit X86, /// ARM 64-bit AArch64, } impl Arch { /// Gets the current architecture pub fn get()...
true
1efd223c6b3d1e97156281f779a39d1e696ec82f
Rust
manisenkov/advent-of-code
/rust/src/bin/2022_01.rs
UTF-8
1,352
3.15625
3
[]
no_license
use aoc::solution::Solution; struct Day2022_01 { elf_loads: Vec<Vec<u32>>, } impl Solution<u32> for Day2022_01 { fn new() -> Day2022_01 { Day2022_01 { elf_loads: Vec::new(), } } fn init(&mut self, input: &str) { let mut cur_load = Vec::<u32>::new(); for lin...
true
e8f352fe343afe1c105b63e70161676b6726669d
Rust
AndikaRizary/juneau_wasm
/packages/juneau/src/building/jasm_llvm/visiting/value.rs
UTF-8
1,299
2.515625
3
[]
no_license
use crate::core::Visitor; use crate::semantic::jasm::{JasmType, JasmValue}; use crate::target::llvm::{self, ArrayType, Linkage, Constant}; use crate::building::jasm_llvm::JasmModuleBuildVisitor; impl<'l> Visitor<&JasmValue, &'l llvm::Value> for JasmModuleBuildVisitor<'l> { fn visit(&mut self, value:&JasmValue) ->...
true
b783039fa08b6b83b1dd005191e3a4648184ef64
Rust
Altair-Bueno/fuzzy-disco
/disco-core/src/api/sessions/post.rs
UTF-8
1,011
3
3
[]
no_license
use mongodb::Collection; use rocket::State; use crate::api::result::ApiResult; use crate::api::sessions::delete_all_sessions_from; use crate::api::users::auth::claims::TokenClaims; use crate::mongo::session::Session; /// # AUTH! `POST /api/sessions/delete` /// /// Deletes all sessions from the current user, included ...
true
468222af17b0d940ca81ecf000726d9257f9739f
Rust
EFanZh/LeetCode
/src/problem_0134_gas_station/greedy.rs
UTF-8
1,307
2.859375
3
[]
no_license
pub struct Solution; // ------------------------------------------------------ snip ------------------------------------------------------ // impl Solution { pub fn can_complete_circuit(gas: Vec<i32>, cost: Vec<i32>) -> i32 { // https://leetcode.com/problems/gas-station/discuss/42572/Proof-of-%22if-total-...
true
8ea1070216908dd900f0e67f38d2ee583b0abbca
Rust
Zuchis/genetic-algorithm-rust
/src/selection.rs
UTF-8
1,543
2.921875
3
[]
no_license
#![allow(unused_imports)] #![allow(unused_variables)] #![allow(unused_mut)] extern crate rand; use std::process; use self::rand::Rng; use self::rand::thread_rng; use self::rand::distributions::{IndependentSample, Range}; use population::Population; #[allow(dead_code)] pub fn wheel<T>(pop: &mut Population<T>) -> us...
true
07b83e1ea5bb2000b8ff813b300c9575e7dc555d
Rust
bosley/OPAS
/Rust/DC/nexus/src/common.rs
UTF-8
5,473
3.015625
3
[ "MIT" ]
permissive
extern crate uuid; use uuid::Uuid; extern crate serde; use serde::{Deserialize, Serialize}; use std::fs::File; use std::path::Path; use std::io::{Read, Write}; /// Generate a unique id pub fn generate_id() -> String { let uuid = Uuid::new_v4().to_hyphenated_ref().to_string(); match uuid.split("-").nex...
true
2e6724e2c8d40d2c29034f04bacee1bad5e09e02
Rust
revsolid/polyminis-core
/src/sensors.rs
UTF-8
2,449
3.140625
3
[]
no_license
use ::serialization::*; use std::collections::HashMap; use std::fmt; pub type SensoryPayload = HashMap<SensorTag, f32>; #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum SensorTag { // Default Sensors Not Evolvable // -- Movement PositionX, PositionY, Orientation, LastMoveSucceded, ...
true
54d97d0f5dd255cd1cb0fbcbeb88609bbad520d7
Rust
Koalapvh13/reading_time_estimator
/src/lib.rs
UTF-8
562
3.1875
3
[]
no_license
pub fn reading_time_in_minutes(text: &str) -> i32{ let words_counted: i32 = words_count(text); let calc: f32 = (words_counted as f32)/(160 as f32); calc as i32 } pub fn reading_time_in_seconds(text: &str) -> i32{ let words_counted: i32 = words_count(text); let calc: f32 = (words_counted as f32)/(16...
true
e255f48884a61066923b983aa343c33a7c6b8830
Rust
songyzh/leetcode-rust
/src/solution/s0443_string_compression.rs
UTF-8
2,710
3.3125
3
[ "Apache-2.0" ]
permissive
/** * [443] String Compression * * Given an array of characters, compress it <a href="https://en.wikipedia.org/wiki/In-place_algorithm" target="_blank">in-place</a>. * * The length after compression must always be smaller than or equal to the original array. * * Every element of the array should be a char...
true
b3405c45e2f3915061a9adafe6795ae4cf34f19a
Rust
Veetaha/migrate
/migrate/examples/basic.rs
UTF-8
6,862
3.046875
3
[ "Apache-2.0", "MIT" ]
permissive
//! Example migrating a json file that contains an array of user entities //! //! The first migration fills the json file with some example user entities //! of the initial version (they contain only `name` field). //! //! The second migration adds the `surname` field to each user. use std::path::PathBuf; use async_t...
true
13ae52e5cfd4259b51a21e6e0a49f78c49020f08
Rust
ldm0/wasm_nn
/src/lib.rs
UTF-8
10,179
2.609375
3
[ "WTFPL" ]
permissive
mod data; mod nn; use std::mem; use std::slice; //use std::os::raw::{/*c_double, c_int, */c_void}; // for js functions imports use once_cell::sync::Lazy; use std::sync::Mutex; // for lazy_static // for global variables use ndarray::prelude::*; use ndarray::{array, Array, Array1, Array3, Axis, Zip}; use data::Data...
true
8457e46fe34d1030332a359f02de9f6ae9d21ce7
Rust
skyzh/raytracer.rs
/raytracer/src/tracer/pdf/rect.rs
UTF-8
1,671
2.921875
3
[ "MIT" ]
permissive
use crate::tracer::{Ray, Vec3}; use rand::rngs::SmallRng; use rand::Rng; use std::f32::consts::PI; #[derive(Clone)] pub struct RectXZArea { pub x0: f32, pub x1: f32, pub z0: f32, pub z1: f32, pub k: f32, mu_x: f32, mu_z: f32, s_x: f32, s_z: f32, } fn normal_distribution(rng: &mut S...
true
438a572b2472c5d96f48c6076cdd051c56ab4128
Rust
skycandyzhe/rustStudy
/src/DPProgram/longest_substring_characters0003/long_substr.rs
UTF-8
1,168
3.5625
4
[ "Apache-2.0" ]
permissive
// trait Solution{ // fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> ; // } // use std::collections::HashMap; // 调试宏 之后在 println 和 print 宏中就可以用 {:?} 占位符输出一整个结构体 use std::cmp; pub struct Solution{} impl Solution{ pub fn length_of_longest_substring(s: String) -> i32 { let mut char_vec:[i32; 128]...
true
7e6141a0cd176f2d1a4796caeca76d20045c8d32
Rust
ajkachnic/bliss
/src/file.rs
UTF-8
1,221
2.859375
3
[ "MIT" ]
permissive
use std::fs; use std::io; use std::path; use std::cell::RefCell; use std::rc::Rc; use lib::evaluation; use lib::lexer::Lexer; use lib::parser::error::ParseError; use lib::parser::Parser; use lib::style; use path::Path; /// Executes a file /// The file should already be stat-ed to ensure we can access it pub fn exec_...
true
9f824c340feaa41351131e9e6edd07cc332fd1ca
Rust
saiumesh-apty/birtday-reminder
/src/controllers/auth/login.rs
UTF-8
3,098
2.859375
3
[]
no_license
use actix_web::{ HttpResponse }; use actix_web::web::{Data, Json}; // use chrono::{NaiveDate}; use crate::types::user::{ Login, Response, UpdatePassword, LoginResponse }; use crate::types::postgres_types::{ Postgres }; use crate::helpers::bcrypt_helper::{verify_password, hash_password}; pub fn login(login: Json<Login>...
true
950d516283f3eaa61618ce8f022903364614c3d3
Rust
tupshin/hash_cache
/src/hash_cache.rs
UTF-8
2,278
3.40625
3
[]
no_license
use crate::api::{KVError, KVStore}; use std::collections::HashMap; use std::fmt::Debug; use std::hash::Hash; use std::sync::{Arc, Mutex}; use std::time::Duration; use std::time::SystemTime; ///This is a simple wrapper around HashMap<K,V> that adds thread safety and optional expiration #[derive(Default, Debug, Clone)] ...
true
fc71a62c5356048fd6c451cfe2c49e14d6265aa9
Rust
t-matsudate/sheave
/sheave-core/src/messages/headers/basic/mod.rs
UTF-8
1,318
3.390625
3
[ "MIT" ]
permissive
mod message_format; pub use self::message_format::MessageFormat; /// Indicates the chunk stream and message header's format. /// This header has 3 types. /// /// |Total Length|Message Header Format|Chunk ID|Chunk ID Range| /// | ---------: | ------------------: | -----: | -----------: | /// |8 |2 ...
true
336d429e0a630f1dfd93916385dfbcaa22a0914c
Rust
nicoaudy/rust-todo-cli
/src/main.rs
UTF-8
2,024
3.859375
4
[]
no_license
use std::env; struct TodoItem { name: String, completed: char } impl TodoItem { fn new(name: String) -> TodoItem { return TodoItem{ name: name, completed: ' ' } } } struct TodoList { list: Vec<TodoItem> } impl TodoList { fn all() -> TodoList { ...
true
07433f43a40c5b4e89eccaddd35c8f1b5f4ad4f7
Rust
hgzimmerman/BucketQuestions
/yew_frontend/src/pages/create_bucket.rs
UTF-8
3,902
2.640625
3
[ "MIT" ]
permissive
use yew::{Component, ComponentLink, html}; use yew::virtual_dom::VNode; use yewtil::NeqAssign; use yewtil::fetch::{FetchState, fetch_to_state_msg}; use wire::bucket::{Bucket, NewBucketRequest}; use crate::requests::bucket::CreateBucket; use crate::pages::create_bucket::Msg::FetchedCreateBucket; use yew_router::unit_sta...
true
bb8898c104d0c116a1e4d2227d08f320f0411394
Rust
linebender/norad
/src/kerning.rs
UTF-8
2,871
3.265625
3
[ "MIT", "Apache-2.0" ]
permissive
use std::collections::BTreeMap; use serde::ser::{SerializeMap, Serializer}; use serde::Serialize; use crate::Name; /// A map of kerning pairs. /// /// This is represented as a map of first half of a kerning pair (glyph name or group name) /// to the second half of a pair (glyph name or group name), which maps to the...
true
cecefca9ade06bf77826652ed6a79506cec83621
Rust
Siprj/lords-of-the-realm-2-parser
/rust/src/main.rs
UTF-8
3,156
2.921875
3
[ "MIT" ]
permissive
// For reading and opening files use rayon::prelude::*; use std::convert::TryInto; use std::fs::File; use std::io::{BufWriter, Write}; use std::path::Path; mod pallet; use pallet::*; mod pl8; use pl8::*; mod duo; use duo::*; pub struct Image { height: u32, width: u32, data: Vec<u8>, } fn pl8_to_image(pl8...
true
f65ed7d990f1f890d2a73f86cc4bdfcf51351f0b
Rust
ruoshui-git/mks66-w9_lighting
/src/graphics/drawer.rs
UTF-8
5,064
2.828125
3
[]
no_license
use crate::graphics::{Canvas, Matrix, RGB}; use std::io; use super::lights::LightConfig; /// A procedural interface to simplfy drawing pub struct Drawer<T: Canvas> { stack: Vec<Matrix>, canvas: T, pub fg_color: RGB, pub bg_color: RGB, pub light: LightConfig, } pub struct DrawerBuilder<T: Canvas> ...
true
926a477c86be3ba51d20d381e8ecc15c3655ad4a
Rust
panzi/rust-bfc
/src/brainfuck/codegen/generate_asm_str.rs
UTF-8
2,336
2.671875
3
[ "BSD-3-Clause" ]
permissive
use std::io::Write; pub fn generate_asm_str(out: &mut Write, name: &str, data: &[u8]) -> std::io::Result<()> { write!(out, "{:-8}db ", format!("{}:", name))?; if data.len() > 0 { let indent = " ".to_string() .repeat(std::cmp::max(name.len() + 1, 8) + 3) .into_bytes(); le...
true
b64fa489413233596d839ca31d069f9e639be6df
Rust
kateinoigakukun/wasminspect
/crates/swift-runtime/src/lib.rs
UTF-8
1,335
3.03125
3
[ "MIT" ]
permissive
use std::ffi; extern "C" { fn swift_demangle( mangledName: *const u8, mangledNameLength: usize, outputBuffer: *mut u8, outputBufferSize: *mut usize, flags: u32, ) -> *const i8; } #[derive(Debug)] pub enum DemangleError { Utf8Error(std::str::Utf8Error), Null, } ...
true
ace04207a5d6cf074502db11277f13b59e2c9c20
Rust
bevyengine/bevy
/examples/tools/gamepad_viewer.rs
UTF-8
16,243
2.671875
3
[ "Apache-2.0", "MIT", "Zlib", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive" ]
permissive
//! Shows a visualization of gamepad buttons, sticks, and triggers use std::f32::consts::PI; use bevy::{ input::gamepad::{ GamepadAxisChangedEvent, GamepadButton, GamepadButtonChangedEvent, GamepadSettings, }, prelude::*, sprite::{Anchor, MaterialMesh2dBundle, Mesh2dHandle}, }; const BUTTON_R...
true
4fdc5f32616f150c12dce936b5ab8be7f5de682d
Rust
chrisduerr/bar-helpers
/bar_control/src/config.rs
UTF-8
1,246
2.734375
3
[]
no_license
use std::io::prelude::*; use std::env::home_dir; use std::fs::File; use toml; #[derive(Deserialize)] pub struct Config { pub colors: Colors, pub exec: Executables, pub general: General, pub placeholders: Placeholders, } #[derive(Deserialize)] pub struct General { pub height: i64, pub font: Str...
true
9e485d2c7fce51209bae887fc765fa1e9524e662
Rust
RustyYato/storage
/storage/src/imp/rc.rs
UTF-8
7,000
2.609375
3
[]
no_license
use crate::{ rc::{Counter, DynamicCounter, RefCounted, StrongKind}, Flush, FromPtr, MultiStorage, OffsetHandle, ResizableStorage, SharedFlush, SharedGetMut, SharedOffsetHandle, SharedResizableStorage, SharedStorage, Storage, }; use core::{alloc::Layout, ptr::NonNull}; impl<T: SharedFlush + SharedStorage + ...
true
ee1f3db74a86d42ab19e1e5677cdf89ac215fe3d
Rust
njeisecke/umya-spreadsheet
/src/structs/drawing/run.rs
UTF-8
2,608
2.78125
3
[ "MIT" ]
permissive
use super::run_properties::RunProperties; use writer::driver::*; use quick_xml::Reader; use quick_xml::events::{Event, BytesStart}; use quick_xml::Writer; use std::io::Cursor; #[derive(Default, Debug)] pub struct Run { text: String, run_properties: RunProperties, } impl Run { pub fn get_text(&self) -> &str...
true
155e5676c3cdcc2121b3658501f3da2e311c786d
Rust
ipetkov/conch-runtime
/conch-runtime-tests/src/bin/pwd.rs
UTF-8
193
2.828125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! A utility that will print out the current working directory use std::env; fn main() { println!( "{}", env::current_dir().expect("failed to get cwd").display() ); }
true
8463afa1fa25e8d9ea0c81984b8346c31d8452ce
Rust
sreeise/ProgrammingSnippets
/Rust/rust_defined/src/json_write/mod.rs
UTF-8
658
3.546875
4
[ "MIT" ]
permissive
extern crate serde; extern crate serde_json; /* Serde is a crate that can store data structures as Json. */ #[derive(Serialize, Deserialize, Debug)] struct Point { x: i32, y: i32, } #[cfg(test)] mod test_json_write { use super::*; #[test] fn test_print_serde() { let point = Point { x: 1,...
true
e3f65529458ca026ca77da759cf29b1f67264041
Rust
agatan/nsh
/src/prompt.rs
UTF-8
20,879
2.578125
3
[ "CC0-1.0" ]
permissive
use crate::completion::CompletionSelector; use crate::exec::Isolate; use crate::syntax_highlighting::highlight; use crate::context_parser::InputContext; use pest::Parser; use pest::iterators::{Pairs, Pair}; use std::fmt::Write; use std::path::Path; use termion; use nix::unistd; use libc; #[derive(Debug, PartialEq, Eq)...
true
d92feccd7b343de414fec914cb688ced813e485f
Rust
qeedquan/challenges
/codegolf/integer-logarithms.rs
UTF-8
904
3.234375
3
[ "MIT" ]
permissive
/* Given integers N , P > 1 , find the largest integer M such that P ^ M ≤ N. I/O: Input is given as 2 integers N and P. The output will be the integer M. Examples: 4, 5 -> 0 33, 5 -> 2 40, 20 -> 1 242, 3 -> 4 243, 3 -> 5 400, 2 -> 8 1000, 10 -> 3 Notes: The input will always be valid, i.e. it will always be in...
true
a68447da98f9cdaa03cd1e22724391a16edb87c9
Rust
nhatquangsin/steit
/steit/src/impls/varint.rs
UTF-8
7,882
2.640625
3
[]
no_license
macro_rules! impl_unsigned_varint { (u64, $dummy:ident, "UInt64") => { impl_unsigned_varint!(@impl u64, $dummy, size_64, i64, "UInt64"); }; ($type:ty, $dummy:ident, $csharp_name:literal) => { impl_unsigned_varint!(@impl $type, $dummy, size_32, i32, $csharp_name); }; (@impl $type:ty...
true
6366d33ad99495a2109ee97f5b02149fce0120e9
Rust
antonylsg/ray-tracing-rs
/in-one-weekend/src/hit.rs
UTF-8
1,605
3.140625
3
[]
no_license
use derive_new::new; use crate::material::Material; use crate::material::Scattered; use crate::ray::Ray; use crate::Vec3; use std::cmp::Ordering; trait InspectOption<T> { fn _inspect<F>(self, f: F) -> Option<T> where F: FnMut(&T); } impl<T> InspectOption<T> for Option<T> { fn _inspect<F>(self, m...
true
d5e91f163c3018091abf590ea6ed4f0f4aa59207
Rust
maxjacobson/advent-of-code-2019
/day-03/src/main.rs
UTF-8
4,167
3.609375
4
[]
no_license
use std::collections::HashMap; #[derive(Debug)] enum Movement { Right(i32), Left(i32), Up(i32), Down(i32), } impl Movement { fn from_str(s: &str) -> Self { let dir = s.chars().nth(0); let amount: i32 = s .chars() .skip(1) .collect::<String>() ...
true
e8cbd380d233431b8c950925e0f894262f56b51e
Rust
dbr/vidl-rs
/src/libmig.rs
UTF-8
7,153
2.9375
3
[ "Unlicense" ]
permissive
//! A greatly simplified migration system. //! //! Only supports upgrading schema versions - downgrades are expected to be //! handled by reverting to a backup. Reasons being: //! - VIDL isn't exactly critical infrastructure. Almost all info can be //! recreated from scratch (except the video status). //! - Migration...
true
a81c3fe705688e2f4db1d2f8b7c0100a000b5e37
Rust
thepacketgeek/talent-plan
/courses/rust/exercises/mini-redis-server/src/main.rs
UTF-8
2,028
2.8125
3
[ "MIT", "CC-BY-4.0" ]
permissive
use anyhow::{anyhow, Result}; use futures::stream::StreamExt; use mini_redis_proto::{Request, Response}; use tokio::net::TcpListener; use tokio::prelude::*; async fn handle_request(buf: &[u8]) -> Result<Option<Response>> { let raw_data = std::str::from_utf8(&buf)?; match serde_json::from_str(raw_data)? { ...
true
71dc5af3e649d5c4c618a3b27e5f4cc959c0f109
Rust
jakeburden/random-access-disk
/tests/test.rs
UTF-8
1,034
2.875
3
[ "MIT", "Apache-2.0" ]
permissive
extern crate random_access_disk as rad; extern crate tempdir; use self::tempdir::TempDir; #[test] fn can_call_new() { let dir = TempDir::new("random-access-disk").unwrap(); let _file = rad::RandomAccessDisk::new(dir.path().join("1.db")); } #[test] fn can_open_buffer() { let dir = TempDir::new("random-access-di...
true
cdda4bad5ebb12dd503c0496c96a88b30fac9fd2
Rust
gengteng/silkroad
/src/command/execute.rs
UTF-8
315
2.5625
3
[ "MIT" ]
permissive
use std::path::PathBuf; use structopt::StructOpt; #[derive(Debug, StructOpt)] #[structopt(name = "exec")] pub struct Execute { #[structopt( long = "toml", short = "f", help = "Set the TOML file path", value_name = "PATH", parse(try_from_str) )] toml: PathBuf, }
true
1e444ffbe595ce9d13151bb9e7c822a8572b1d6c
Rust
richwandell/rustjs
/src/parser/create/block_statement.rs
UTF-8
2,029
3.125
3
[]
no_license
use crate::parser::symbols::JSItem; use crate::lexer::js_token::Tok; use crate::parser::create::comma_separate_tokens; use crate::parser::parser::{Parser, SyntaxError}; use std::collections::HashMap; use crate::parser::parser::SyntaxError::UnexpectedToken; pub(crate) fn create_object_expression(mut tokens: Vec<Tok>) -...
true
fb4adba55048ab0c07908b11385dc4aedf182dae
Rust
Roguelazer/rust-rdkafka
/src/message.rs
UTF-8
3,801
3.1875
3
[ "MIT" ]
permissive
//! Store and manipulate Kafka messages. extern crate rdkafka_sys as rdkafka; use self::rdkafka::types::*; use std::slice; use std::str; /// A native librdkafka message. #[derive(Debug)] pub struct Message { ptr: *mut RDKafkaMessage, } unsafe impl Send for Message {} impl<'a> Message { /// Creates a new Me...
true
22d2c6cc4cdf26c1d117f169caf7a6af05805252
Rust
mzabaluev/tower-h2
/src/buf.rs
UTF-8
721
3.109375
3
[ "MIT" ]
permissive
use bytes::Buf; pub struct SendBuf<T> { inner: Option<T>, } impl<T: Buf> SendBuf<T> { pub fn new(buf: T) -> SendBuf<T> { SendBuf { inner: Some(buf) } } pub fn none() -> SendBuf<T> { SendBuf { inner: None } } } impl<T: Buf> Buf for SendBuf<T> { fn remaining(&self) -> usize { ...
true
cb16c19d43f1511a1ab1e5b78adf8264503a061c
Rust
collinpeters/rust-clippy
/tests/ui/drop_forget_ref.rs
UTF-8
1,355
3.109375
3
[ "Apache-2.0", "MIT" ]
permissive
#![warn(clippy::drop_ref, clippy::forget_ref)] #![allow(clippy::toplevel_ref_arg, clippy::similar_names, clippy::needless_pass_by_value)] use std::mem::{drop, forget}; struct SomeStruct; fn main() { drop(&SomeStruct); forget(&SomeStruct); let mut owned1 = SomeStruct; drop(&owned1); drop(&&owned1...
true
f3d1cba21c6d4b6ac7ae2a09e72b5dd43dfd05d5
Rust
jkbstrmen/snark-tool
/src/procedure/error/mod.rs
UTF-8
1,616
2.640625
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::service::io::error::{ReadError, WriteError}; use std::fmt; pub mod chromatic_properties_procedure_error; pub mod construction_procedure_error; #[derive(Debug)] pub enum Error { ReadError(ReadError), WriteError(WriteError), ProcedureError(ProcedureError), ConfigError(String), } impl fmt::Di...
true
aeefd81a47040199f6b09d10e5ec6d845fb47782
Rust
philphilphil/adventofcode
/2022/src/main.rs
UTF-8
1,676
2.96875
3
[]
no_license
mod base; mod day01; mod day02; mod day03; mod day04; mod day05; mod day06; mod day07; mod day08; mod day09; mod day10; mod day11; use base::Problem; use day01::Day1; use day02::Day2; use day03::Day3; use day04::Day4; use day05::Day5; use day06::Day6; use day07::Day7; use day08::Day8; use day09::Day9; use day10::Day10...
true
4f254f6741c419322b8eb4f2eab38d9313266724
Rust
pandaa880/codeforces_practice_rust
/Educational_Roud_109/potion_making/src/main.rs
UTF-8
1,063
3.421875
3
[]
no_license
use std::io; use std::process; fn main() { let essence_values = read_input(); let result = min_steps(essence_values); for r in result { println!("{}", r); } } // TODO: fix this solution (wrong answer) fn min_steps(values: Vec<u32>) -> Vec<u32> { let mut result = Vec::new(); for i in ...
true
d9c51981fee89a51b78c50a2416f615d40368cb6
Rust
CCS-1L-F19/dbgm
/src/gui/modals/rebuild_success.rs
UTF-8
1,820
2.765625
3
[ "MIT" ]
permissive
use super::ModalInterface; use crate::gui::prelude::*; use crate::background::SkipReason; pub struct RebuildSuccess { skipped: Vec<(usize, SkipReason)>, } impl ModalInterface for RebuildSuccess { fn id(&self) -> &str { "rebuildsuccess" } fn title(&self) -> &str { "Image folder successfully rebuilt." } ...
true
a2a590245a70ea293e776478dedd8e19c7204de3
Rust
Kixunil/rust-niceware
/src/error.rs
UTF-8
523
3.046875
3
[ "LicenseRef-scancode-warranty-disclaimer", "MIT" ]
permissive
use std::{error::Error, fmt}; #[derive(Debug)] pub struct UnknownWordError { pub(crate) details: String, } impl UnknownWordError { pub(crate) fn new(msg: &str) -> UnknownWordError { UnknownWordError { details: msg.to_string(), } } } impl fmt::Display for UnknownWordError { ...
true
4b28ed7d6c47d7cc29aaf358ab6c1a59c0a58c23
Rust
ThatNerdyPikachu/rust-rpg
/src/game/utils.rs
UTF-8
1,063
3.171875
3
[]
no_license
use std::{io, time, thread}; use std::io::Write; pub fn question(prompt: &str, valid: &Option<&[&str]>) -> String { loop { print!("{}", prompt); if valid.is_some() { print!(" ({}): ", valid.as_ref().unwrap().join(", ")); } else { print!(": "); } io::stdout().flush().expect("Failed to flush stdout!")...
true
75fe5a2175dc3f88279d4e7e861416feaebd8a2b
Rust
reb/advent_of_code_2017
/day-15/src/main.rs
UTF-8
1,353
3.375
3
[]
no_license
fn generate(start: u64, multiplication_factor: u64, modulo_criteria: u64) -> u64 { let mut new = start; loop { new = (new * multiplication_factor) % 2147483647; if new % modulo_criteria == 0 { return new } } } fn judge_generators(a_start: u64, b_start: u64, a_factor: u64...
true
e3bdefdba44bac7a1d2ff33d56a382924bc4380a
Rust
azdavis/advent-of-code
/years/y2017/src/d02.rs
UTF-8
688
3.28125
3
[ "MIT" ]
permissive
fn run(s: &str, f: fn(Vec<u32>) -> u32) -> u32 { s.lines() .map(|line| { let ns: Vec<u32> = line .split_ascii_whitespace() .map(|it| it.parse().unwrap()) .collect(); f(ns) }) .sum() } pub fn p1(s: &str) -> u32 { run(s, |ns| ns.iter().max().unwrap() - ns.iter().min()....
true
a2fc68bb4b89ae7b3278d60ca894beb431608af3
Rust
dvc94ch/linux-toolkit
/src/wayland/pointer.rs
UTF-8
5,708
3.03125
3
[ "ISC" ]
permissive
//! Pointer handling use crate::wayland::cursor::Cursor; use crate::wayland::seat::SeatEventSource; use std::sync::Mutex; use wayland_client::protocol::wl_pointer::Event; pub use wayland_client::protocol::wl_pointer::RequestsTrait as PointerRequests; pub use wayland_client::protocol::wl_pointer::WlPointer; pub use wayl...
true
f1498e6ea77f942b9533e7017847a992ab7f6cd1
Rust
kalyan63/Rust-shell
/src/cd/src/main.rs
UTF-8
608
3.21875
3
[]
no_license
use std::env; use std::path::{PathBuf,Path}; fn main() { let args: Vec<String> = env::args().collect(); cd(args); } fn cd(args: Vec<String>, crr_dir: &PathBuf) { if args.len()==1 { let dir = &crr_dir; assert!(env::set_current_dir(&dir).is_ok()); } else if args.len()==2 { le...
true
e943a854e3387b47b29893f83159725f320b7023
Rust
topecongiro/reversi
/benches/test_ai.rs
UTF-8
9,807
2.90625
3
[ "MIT" ]
permissive
//! AI tests #![feature(test)] /// Simple AIs to test the library's performances. extern crate rand; extern crate test; extern crate reversi; use reversi::board::*; use reversi::turn::*; use reversi::game::*; use reversi::{Result, ReversiError, Side}; use rand::{Rng}; use rand::distributions::{IndependentSample}; u...
true
bfb040c7a19e6dad247746558d7ec5a7cae111a6
Rust
imos/icfpc2017
/wata/src/lib/mod.rs
UTF-8
384
2.703125
3
[ "MIT" ]
permissive
pub mod unionfind; pub mod dijkstra; pub fn bfs(g: &Vec<Vec<usize>>, s: usize) -> Vec<usize> { let n = g.len(); let mut dist = vec![n + 1; n]; let mut que = ::std::collections::VecDeque::new(); dist[s] = 0; que.push_back(s); while let Some(u) = que.pop_front() { for &v in &g[u] { if dist[v] == n + 1 { d...
true
cad5e3a0fa6e727ab20f78563bda47285a927e58
Rust
csnover/ritual
/cpp_core/src/ptr.rs
UTF-8
9,514
3.53125
4
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use crate::ops::{Begin, BeginMut, End, EndMut, Increment, Indirection}; use crate::vector_ops::{Data, DataMut, Size}; use crate::{ cpp_iter, CppBox, CppDeletable, CppIterator, DynamicCast, Ref, StaticDowncast, StaticUpcast, }; use std::ops::Deref; use std::{fmt, slice}; /// A pointer to a C++ object (similar to a ...
true
d565784d3802a24150876c483bcfc0eb6e4f1d79
Rust
colin-kiegel/rust-derive-builder
/derive_builder_core/src/macro_options/mod.rs
UTF-8
774
2.578125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Types and functions for parsing attribute options. //! //! Attribute parsing occurs in multiple stages: //! //! 1. Builder options on the struct are parsed into `OptionsBuilder<StructMode>`. //! 1. The `OptionsBuilder<StructMode>` instance is converted into a starting point for the //! per-field options (`Option...
true
f49510485829ec587220c34b8f3c5b4482e69217
Rust
marc47marc47/leetcode-cn
/234isPalindrome/ispalindrome/src/main.rs
UTF-8
2,503
3.578125
4
[]
no_license
// Definition for singly-linked list. #[derive(PartialEq, Eq, Clone, Debug)] pub struct ListNode { pub val: i32, pub next: Option<Box<ListNode>> } impl ListNode { #[inline] fn new(val: i32) -> Self { ListNode { next: None, val } } } fn main() { let a =Some( Box::new(ListNode{...
true
f49a0044f60a2f4e1dd3052570709c5a557de150
Rust
pankdm/adventofcode-2019
/src/bin/day19.rs
UTF-8
10,044
2.9375
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::collections::{HashSet, VecDeque}; use std::fs::File; use std::io::{self, Write}; use std::io::{BufRead, BufReader}; use std::process; extern crate adventofcode; use adventofcode::*; use std::time::{Duration, Instant}; fn get_value(ops: &Vec<i64>, value: i64, mode: i64, base: i...
true