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
3ef29f72441d020c35099a7f798aabe3d00095f7
Rust
Hirevo/alexandrie
/crates/alexandrie-rendering/src/config.rs
UTF-8
3,160
3.015625
3
[ "Apache-2.0", "MIT" ]
permissive
use std::path::PathBuf; use serde::{Deserialize, Serialize}; use syntect::dumps; use syntect::highlighting::ThemeSet; use syntect::parsing::SyntaxSet; /// The syntax-highlighting themes configuration struct. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(tag = "type", rename_all = "kebab-case")] p...
true
c3b2fb5f5fbf88430379b504a15e2c10922a18a1
Rust
HerringtonDarkholme/leetcode
/src/count_binary_substrings.rs
UTF-8
564
2.796875
3
[]
no_license
pub struct Solution; impl Solution { pub fn count_binary_substrings(s: String) -> i32 { let s = s.as_bytes(); let mut ret = 0; let mut preced = 0; let mut after = 1; let mut last_c = s[0]; for &c in s[1..].iter() { if c == last_c { after +...
true
0c708eea75557fafe3f3515cce1f66e835b57c30
Rust
sile/bytecodec
/src/padding.rs
UTF-8
3,879
3.703125
4
[ "MIT" ]
permissive
//! Encoder and decoder for padding bytes. use crate::{ByteCount, Decode, Encode, Eos, ErrorKind, Result}; /// Decoder for reading padding bytes from input streams. /// /// `PaddingDecoder` discards any bytes in a stream until it reaches EOS. #[derive(Debug, Default)] pub struct PaddingDecoder { expected_byte: Opt...
true
000556ccf27a9f01b6b4cb0c92082019388e4b92
Rust
AnthonyMeehan/CartesianGeneticProgrammingRust
/cgprs/src/dataset.rs
UTF-8
2,804
3.375
3
[]
no_license
extern crate csv; // for CSV parsing use std::fs::File; use std::io::{BufReader, BufRead}; ///A series of input examples matched-up with output examples, for testing CGP genomes pub struct Dataset { pub input_examples: Vec<f64>, pub output_examples: Vec<f64>, } ///Extracts a dataset from a CSV, using a CSV li...
true
26b73fbbddf5c3cf15461f51f7c58c62890173af
Rust
DeTeam/advent-2018
/day2/src/main.rs
UTF-8
1,841
3.609375
4
[]
no_license
use std::collections::HashMap; use std::fs::File; use std::io::prelude::*; fn get_score(s: &str) -> (bool, bool) { let mut letters = HashMap::new(); for c in s.chars() { let counter = letters.entry(c).or_insert(0); *counter += 1; } let collected_values: Vec<_> = letters.values().collec...
true
3c8c3c00b27706b0e3c969d19a0d014a6cc93586
Rust
Ainevsia/Leetcode-Rust
/1044. Longest Duplicate Substring/src/main.rs
UTF-8
3,046
3.625
4
[ "BSD-2-Clause" ]
permissive
fn main() { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).expect("Failed to read line"); buf.pop(); // let buf: Vec<char> = buf.chars().collect(); // println!("buf[0] = {:#?}", buf[0]); // println!("buf[buf.len()-1] = {:#?}", buf[buf.len()-1]); println!("buf.len() = {:#?...
true
cc0cf4f7e203653ff787fcd45c41ac549801f25d
Rust
paulkoerbitz/git-pivot
/src/statistics/punchcard.rs
UTF-8
1,823
2.953125
3
[]
no_license
use chrono::prelude::*; use git2::Commit; use crate::statistics::PerCommitStatistic; pub struct Punchcard { punches: [[u32; 24]; 7], } impl Punchcard { pub fn new() -> Punchcard { Punchcard { punches: [[0; 24]; 7] } } fn commits_for_weekday(&self, weekday: &Weekday) -> &[...
true
19695be3616c7e424fa01f9cc74b2c8e311ecc5d
Rust
moshthepitt/vipers
/src/assert.rs
UTF-8
4,041
3.0625
3
[ "Apache-2.0" ]
permissive
//! Various assertions. /// Asserts that two accounts share the same key. #[macro_export] macro_rules! assert_keys { ($account_a: expr, $account_b: expr $(,)?) => { assert_keys!($account_a, $account_b, "key mismatch") }; ($account_a: expr, $account_b: expr, $msg: expr $(,)?) => { let __acco...
true
98c9856d680690c4d970c5a2c25c99595deb9c98
Rust
EvilSuperstars/terraform-provider-wapc
/examples/rust/src/lib.rs
UTF-8
1,043
2.75
3
[ "Unlicense" ]
permissive
extern crate wapc_guest as guest; use guest::prelude::*; use serde::{Deserialize, Serialize}; use serde_json::json; #[no_mangle] pub extern "C" fn wapc_init() { register_function("hello", hello); } // // Can be specified in HCL as: // input = { // "Name" = "waPC" // "Uppercase" = true // } // #[derive(Ser...
true
8570e6b21dae628e2d26406b3d4a3e41dbdfd21d
Rust
joshuarli/fd
/src/regex_helper.rs
UTF-8
3,498
3.59375
4
[ "MIT", "Apache-2.0" ]
permissive
use regex_syntax::hir::Hir; use regex_syntax::ParserBuilder; /// Determine if a regex pattern contains a literal uppercase character. pub fn pattern_has_uppercase_char(pattern: &str) -> bool { let mut parser = ParserBuilder::new().allow_invalid_utf8(true).build(); parser .parse(pattern) .map(|...
true
63a940f449fc3e6f88b69d59aaf102931f26e6be
Rust
lostatseajoshua/learning_rust
/fibonacci/src/main.rs
UTF-8
690
3.75
4
[]
no_license
use std::io; fn main() { loop { println!("Get fibonacci of:"); let mut input = String::new(); match io::stdin().read_line(&mut input) { Ok(_) => (), Err(err) => { println!("{:?}", err); continue; }, } let...
true
60dca0824205653aa880315006d9f85110c59df5
Rust
ianprice943/rustBook
/chapter9/c9_3_to_panic_or_not_to_panic/src/main.rs
UTF-8
1,387
3.796875
4
[]
no_license
fn main() { use std::net::IpAddr; // since this is a hard coded string it's reasonable to assume it cannot error out. // if this was a user passed string however, you should do proper error handling let home: IpAddr = "127.0.0.1".parse().unwrap(); // creating custom types for validation // sn...
true
b16236cf02c6f16f3bdf541e99e359ae497b56e2
Rust
hellow554/breeze-emu
/src/spc700/lib.rs
UTF-8
39,128
2.6875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Implements the Audio Processing Unit (APU) //! //! The APU consists of 64 KB shared RAM, the SPC700 and the DSP. It is almost fully independent //! from the rest of the SNES. //! //! The SPC700 is an independent audio coprocessor. The main CPU can transmit a program and audio //! data into the shared RAM and then e...
true
9cc1d6d1f3df5834a26ecf483648438b93cc3c52
Rust
jvff/netlink
/rtnetlink/src/lib.rs
UTF-8
5,326
3.484375
3
[ "MITNFA" ]
permissive
//! This crate contains building blocks for the route netlink protocol. //! //! # Messages //! //! This crate provides two representations of most netlink packets: //! //! - **Buffer** types: [`NetlinkBuffer`](struct.NetlinkBuffer.html), //! [`LinkBuffer`](struct.LinkBuffer.html), [`NlaBuffer`](struct.NlaBuffer.html), ...
true
56d8b4864de1c1890f9814fc7f6f075aee490f34
Rust
telumo/rust_design_pattern
/src/builder/mod.rs
UTF-8
2,238
3.59375
4
[]
no_license
// ここから trait Builder { fn make_title(&mut self, title: String); fn make_string(&mut self, str: String); fn make_items(&mut self, items: Vec<String>); fn close(&mut self); fn get_result(&mut self) -> String; } struct Director<T: Builder> { builder: T, } // ここまでフレームワーク impl<T: Builder + Copy> D...
true
cd733061e160715a2e5159bf2d372b0134bcb153
Rust
mechiru/iso-4217
/src/error.rs
UTF-8
542
3.515625
4
[ "Apache-2.0", "MIT" ]
permissive
use std::fmt; /// An error which can be returned when parsing `&str` or `u32`. #[derive(Debug, PartialEq, Clone)] pub enum ParseCodeError { Alpha(String), Num(u32), } impl fmt::Display for ParseCodeError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use ParseCodeError::*; ma...
true
eb095d9db12438244179d77e54033de972526a0d
Rust
urnest/urnest
/ruf/ruf_newtype/test-newtype.rs
UTF-8
7,629
3
3
[ "LicenseRef-scancode-warranty-disclaimer", "MIT" ]
permissive
// Copyright (c) 2021 Trevor Taylor // // Permission to use, copy, modify, distribute and sell this software // and its documentation for any purpose is hereby granted without fee, // provided that the above copyright notice appear in all. // Trevor Taylor makes no representations about the suitability of this // softw...
true
761493a99aee8b13c3c468e6255e6d8e2d1f24a8
Rust
dsherret/swc
/ecmascript/minifier/src/compress/optimize/join_vars.rs
UTF-8
4,682
3
3
[ "MIT", "Apache-2.0" ]
permissive
use super::Optimizer; use crate::{compress::util::is_directive, mode::Mode}; use swc_common::util::take::Take; use swc_ecma_ast::*; use swc_ecma_utils::StmtLike; /// Methods related to option `join_vars`. impl<M> Optimizer<'_, M> where M: Mode, { /// Join variables. /// /// This method may move variabl...
true
5983b336c57b3b72eaaf846c61108a31f4ba065c
Rust
tokio-rs/tokio
/tokio/src/io/util/write_int.rs
UTF-8
4,601
2.59375
3
[ "MIT" ]
permissive
use crate::io::AsyncWrite; use bytes::BufMut; use pin_project_lite::pin_project; use std::future::Future; use std::io; use std::marker::PhantomPinned; use std::mem::size_of; use std::pin::Pin; use std::task::{Context, Poll}; macro_rules! writer { ($name:ident, $ty:ty, $writer:ident) => { writer!($name, $t...
true
536343782279d933282a5455c5d3f92b5c3356a9
Rust
Dooskington/LD46-Lighthouse-Keeper
/src/game/transform.rs
UTF-8
769
2.71875
3
[ "Zlib" ]
permissive
use crate::game::{Point2f, Vector2d, Vector2f}; use specs::prelude::*; #[derive(Debug)] pub struct TransformComponent { pub position: Vector2d, pub last_position: Vector2d, pub scale: Vector2f, } impl Component for TransformComponent { type Storage = FlaggedStorage<Self, VecStorage<Self>>; } impl Tra...
true
df9e84eee25a67f9c1f63a7728093ea681969d8d
Rust
AlexEne/wasm_interp
/wasm/src/core/executor/stack_ops.rs
UTF-8
1,686
2.9375
3
[ "MIT" ]
permissive
use std::convert::{TryFrom, TryInto}; use crate::core::{stack_entry::StackEntry, Stack}; use anyhow::{anyhow, Result}; pub fn get_stack_top(stack: &mut Stack, n: usize) -> Result<&[StackEntry]> { if stack.working_count() < n { Err(anyhow!("Not enough values on stack")) } else { Ok(stack.workin...
true
600f2eb6a45fcd32b51ccc70a80dc305016da376
Rust
Unesty/Doing
/attempts/petgraph5/src/ps_utils.rs
UTF-8
2,576
3.421875
3
[]
no_license
use crate::avr_interpreter::{ProcessorState, execute_instruction}; // Generate all valid states from a list of instructions pub fn generate_states(instructions: &[u8]) -> Vec<ProcessorState> { let mut states = vec![]; for i in 0..256 { let mut state = ProcessorState::new(); state.pc = 0; ...
true
04429e256c0ab92d97c5d0b216d5b635a867d02b
Rust
khollbach/advent
/2019/rust/12/src/lib.rs
UTF-8
4,726
3.625
4
[]
no_license
use lazy_static::lazy_static; use num::integer; use regex::Regex; use std::cmp::Ordering; use std::fmt; use std::io::prelude::*; pub fn read_input<R: BufRead>(input: R) -> Vec<Moon> { const I: &str = r"(-?\d+)"; lazy_static! { static ref RE: Regex = Regex::new(&format!("^<x={}, y={}, z={}>$", I, I, I))...
true
033a752d42e76d44ee4376d243711042d8f7f4f9
Rust
martingallagher/html5minify
/htmlminify_cli/src/main.rs
UTF-8
1,364
2.8125
3
[]
no_license
use std::{fs::File, io, path::PathBuf}; use html5minify::Minifier; use structopt::StructOpt; #[derive(StructOpt)] #[structopt(name = "html5minify", about = "HTML5Minify options")] struct Opt { /// Preserve whitespace #[structopt(short = "w", long = "whitespace")] disable_collapse_whitespace: bool, //...
true
8e7396c8b4e368921ddf4575d40efee570104bf4
Rust
facebookincubator/antlir
/antlir/bzl/shape2/serialize_shape.rs
UTF-8
3,990
2.6875
3
[ "MIT" ]
permissive
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ // TODO(T139523690) this whole binary can be removed when target_tagger is dead, // which will be shortly after buck1 is dead, af...
true
20e939b6222402e07a9421e641f01c382a976f71
Rust
WilliamVenner/rust-analyzer
/xtask/src/codegen/gen_lint_completions.rs
UTF-8
3,802
2.765625
3
[ "MIT", "Apache-2.0" ]
permissive
//! Generates descriptors structure for unstable feature from Unstable Book use std::path::{Path, PathBuf}; use quote::quote; use walkdir::WalkDir; use xshell::{cmd, read_file}; use crate::{ codegen::{project_root, reformat, update, Mode, Result}, run_rustfmt, }; pub fn generate_lint_completions(mode: Mode) ...
true
e2f534fe1a096809ff10da1cf4d35661223210a8
Rust
GuMiner/rust-experiments
/cross/src/cross/analysis.rs
UTF-8
4,249
3.125
3
[ "MIT" ]
permissive
//! Performs separate-threaded analysis of images use crate::egui::ColorImage; use crate::egui::Rgba; use std::sync::mpsc; use clustering; use super::config::Config; // Doc comments: https://doc.rust-lang.org/reference/comments.html#:~:text=Comments%20in%20Rust%20code%20follow%20the%20general%20C%2B%2B,comments%20ar...
true
2031ef28d719f9401ed47a4496e3a899b137e960
Rust
VulkanWorks/korangar
/src/interface/windows/builder.rs
UTF-8
4,053
2.75
3
[]
no_license
use cgmath::Vector2; use graphics::Color; use super::super::*; const FRAME_WIDTH: f32 = 1.0; const TOP_FRAME_HEIGHT: f32 = 22.0; const FRAME_COLOR: Color = Color::new(30, 30, 30); const TITLE_TEXT_COLOR: Color = Color::new(70, 70, 70); const TITLE_TEXT_OFFSET: Vector2<f32> = Vector2::new(10.0, 4.0); const TITLE_TEXT...
true
cfe0bb68aee1e8a18d2015714add70256b555b80
Rust
ViliLipo/mini-pascal-compiler
/src/symboltable.rs
UTF-8
7,162
2.875
3
[]
no_license
use crate::typedast::*; use crate::address::Address; use std::collections::HashMap; #[derive(PartialEq)] pub enum ConstructCategory { SimpleVar, ArrayVar, Function(Vec<NodeType>, NodeType), Procedure(Vec<NodeType>), TypeId, Special, } pub struct Entry { pub name: String, pub category:...
true
e4fdea5be72e7a388ed7737164231efa1be1daa7
Rust
HarrisonMc555/exercism
/rust/high-scores/src/lib.rs
UTF-8
743
3.03125
3
[]
no_license
type Score = u32; #[derive(Debug)] pub struct HighScores { scores: Vec<Score>, sorted_scores: Vec<Score>, } impl HighScores { pub fn new(scores: &[Score]) -> Self { let mut sorted_scores = scores.to_vec(); sorted_scores.sort(); HighScores { scores: scores.to_vec(), ...
true
b0d4c660f26c10391e6de736b933b2661166b5e1
Rust
1ok1/droid-rust
/src/lib.rs
UTF-8
1,942
2.53125
3
[ "Apache-2.0" ]
permissive
use std::os::raw::{c_char}; use std::ffi::{CString, CStr}; /// Expose the JNI interface for android below #[cfg(target_os="android")] #[allow(non_snake_case)] pub mod android { extern crate jni; use super::*; use self::jni::JNIEnv; use self::jni::objects::{JClass, JString}; use self::jni::sys::{j...
true
ff061b5ee54a02f79f53118e072a58432c5287e4
Rust
wehrwein1/advent-of-code
/2016/day01/day01.rs
UTF-8
4,093
3.3125
3
[]
no_license
// https://adventofcode.com/2016/day/1 // First time doing something non-trivial in Rust (won't be pretty) use std::collections::HashSet; use std::option::Option; mod geometry; // include geometry.rs type Point = geometry::Point<i32>; type Vector = geometry::Vector; pub fn main() { println!("part 1: blocks away: ...
true
79f15ce028afe519c1ef82ba0ddb448dfab03560
Rust
danleechina/Leetcode
/Rust_Sol/src/archive0/s263.rs
UTF-8
347
3.015625
3
[]
no_license
impl Solution { pub fn is_ugly(num: i32) -> bool { if num <= 0 { return false; } let mut cp = num; while cp % 2 == 0 { cp /= 2; } while cp % 3 == 0 { cp /= 3; } while cp % 5 == 0 { cp /= 5; } ...
true
1050d0064950f8279d9b0ca58671dad199e51177
Rust
loewenheim/pueue
/daemon/network/message_handler/stash.rs
UTF-8
869
2.703125
3
[ "MIT" ]
permissive
use pueue_lib::network::message::*; use pueue_lib::state::SharedState; use pueue_lib::task::TaskStatus; use crate::network::response_helper::*; /// Invoked when calling `pueue stash`. /// Stash specific queued tasks. /// They won't be executed until they're enqueued or explicitely started. pub fn stash(task_ids: Vec<...
true
6776a0673e386d446eb48fe0fc5ed0e6122b3b9b
Rust
feenkcom/gtoolkit-boxer
/boxer-ffi/array_point_f32.rs
UTF-8
1,753
2.609375
3
[ "MIT" ]
permissive
use boxer::array::BoxerArrayPointF32; use boxer::point::BoxerPointF32; use boxer::{ValueBox, ValueBoxPointer}; #[no_mangle] pub fn boxer_array_point_f32_create() -> *mut ValueBox<BoxerArrayPointF32> { BoxerArrayPointF32::boxer_array_create() } #[no_mangle] pub fn boxer_array_point_f32_create_with( element_ptr...
true
49a6e7757f6cee3f334e88e077881fdf194512b2
Rust
yaowenqiang/cargo_workspace
/network_programming/src/custom-errors.rs
UTF-8
1,119
3.578125
4
[]
no_license
use std::fmt; use std::error::Error; #[derive(Debug)] enum OperationsError { DividedByZeroError, } impl fmt::Display for OperationsError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { OperationsError::DividedByZeroError => f.write_str("Cannot divide by zero"), ...
true
c306f7fff4f2b002e473a9889ab7575c16af56c3
Rust
FortechRomania/ternary-tree-minimization
/src/main.rs
UTF-8
892
2.625
3
[ "BSD-3-Clause" ]
permissive
extern crate linked_hash_map; mod literal_value; mod product_term; mod ternary_node; mod ternary_tree_minimization; use std::collections::HashSet; fn main() { let mut term = product_term::ProductTerm::new(); term.add_literal(String::from("A"), literal_value::LiteralValue::False); term.add_literal(String::from("...
true
fa5f7d9fee50508f574e0e7d2ccc57b215971ad7
Rust
nulldevelopmenthr/rust-eventsourcing-demo
/code/poc/ver1/src/open_bank_account.rs
UTF-8
1,489
2.859375
3
[]
no_license
use super::prelude::*; use std::sync::Arc; pub struct OpenBankAccountHandler<T> where T: BankAccountRepository, { pub repository: Arc<T>, } impl<T: BankAccountRepository> OpenBankAccountHandler<T> { pub fn handle(&self, command: OpenBankAccountPayload) -> Result<(), BankAccountError> { let result:...
true
3b1a75a596844a98e259066bacd421ec63b2b565
Rust
Aaron1011/oauth1-request-rs
/oauth1-request/src/util.rs
UTF-8
8,952
2.84375
3
[ "Apache-2.0", "MIT" ]
permissive
use std::fmt::{self, Display, Formatter, Write}; use std::str; use percent_encoding::AsciiSet; macro_rules! options { ($( $(#[$attr:meta])* pub struct $O:ident<$lifetime:tt> { $(#[$ctor_attr:meta])* $ctor:ident; $($field:tt)* } )*) => {$( $(#[$attr])* ...
true
38f5da435cee0a1f3937ae5def57dd3c99fd3fb9
Rust
aemreaydin/rust-chip8
/src/chip8/cpu.rs
UTF-8
22,201
2.96875
3
[]
no_license
use std::time::Duration; use super::display; use rand::Rng; const FONTS: [u8; 80] = [ 0xF0, 0x90, 0x90, 0x90, 0xF0, // 0 0x20, 0x60, 0x20, 0x20, 0x70, // 1 0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2 0xF0, 0x10, 0xF0, 0x10, 0xF0, // 3 0x90, 0x90, 0xF0, 0x10, 0x10, // 4 0xF0, 0x80, 0xF0, 0x10, 0xF0, // ...
true
e3150ce481cac3f5fab53b3ebab0b80d62000671
Rust
standardgalactic/toornament-rs
/src/opponents.rs
UTF-8
1,242
2.984375
3
[ "MIT" ]
permissive
use crate::common::MatchResultSimple; use crate::participants::Participant; /// An opponent involved in a match. #[derive( Clone, Default, Debug, Eq, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize, )] pub struct Opponent { /// Number of the opponent pub number: i64, /// The participan...
true
bebeba38c99d4c1a9451d56d52c9b13635389488
Rust
rabisg0/rust-clippy
/clippy_lints/src/mem_discriminant.rs
UTF-8
3,255
2.84375
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::utils::{match_def_path, paths, snippet, span_lint_and_then, walk_ptrs_ty_depth}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{BorrowKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use std::iter; decla...
true
ceda5e111548a76b1b5588d404a9262f6bd2e5c6
Rust
Luthaf/vecmap
/src/lib.rs
UTF-8
17,930
3.671875
4
[]
no_license
use std::borrow::Borrow; use std::ops::Index; use std::fmt::Debug; use std::mem; use std::fmt; use std::slice; use std::vec; #[derive(Clone)] pub struct VecMap<K, V> { values: Vec<V>, keys: Vec<K>, } impl<K: Eq, V> VecMap<K, V> { /// Create an empty `VecMap` pub fn new() -> VecMap<K, V> { VecM...
true
a96271ca74d085769e6474b3b29865502551ca0f
Rust
rahulnakre/rust_channels
/src/lib.rs
UTF-8
6,148
3.296875
3
[]
no_license
#![feature(test)] use std::sync::{Arc, Condvar, Mutex}; // Vector with head and tail pointer use std::collections::VecDeque; use std::thread; use std::sync::mpsc; extern crate test; pub struct Sender<T> { shared: Arc<Shared<T>>, } /** * Need to have Sender be cloneable, but #[derive(Clone)] doesn't work, * as i...
true
e3c7588ebe4866064c1a6172aaf2996b9316fe44
Rust
Razaekel/noise-rs
/examples/perlin.rs
UTF-8
1,067
2.625
3
[ "Apache-2.0", "MIT" ]
permissive
//! An example of using perlin noise extern crate noise; use noise::{ core::perlin::{perlin_2d, perlin_3d, perlin_4d}, permutationtable::PermutationTable, utils::*, }; mod utils; fn main() { let hasher = PermutationTable::new(0); utils::write_example_to_file( &PlaneMapBuilder::new_fn(|po...
true
345147513b607baa21473d2312d3013c06417f87
Rust
drhodes/regmach
/regmach/src/dsp/colors.rs
UTF-8
867
2.734375
3
[]
no_license
use crate::dsp::types::*; const fn c(r: u8, g: u8, b: u8) -> Color { Color { r, g, b } } pub const BACKGROUND: Color = c(250, 250, 250); pub const BLACK: Color = c(0, 0, 0); pub const BLUE: Color = c(0, 0, 255); pub const CURSOR_DARK: Color = c(23, 23, 23); pub const CURSOR_LIGHT: Color = c(190, 190, 190); pub co...
true
59392164af2e20f7755c263ade97fcfbd5c69819
Rust
triplef87/advent_of_code_2015
/day_23/src/main.rs
UTF-8
2,503
3
3
[]
no_license
use std::{fs::File, io, path::Path}; use io::BufRead; fn main() { let mut instructions: Vec<String> = Vec::new(); if let Ok(lines) = read_lines("input") { for line in lines { if let Ok(row) = line { instructions.push(row); } } } let mut index = 0...
true
40e59a241326685f4717bf354193dfa13caa5d3b
Rust
Batanick/mmmodel
/src/entities.rs
UTF-8
14,900
3.015625
3
[]
no_license
use rand::{thread_rng, Rng}; use std::f32::consts::PI; use std::cell::Cell; use std::fmt::Debug; pub type UserId = usize; #[derive(Debug)] pub struct UserData { pub id: UserId, pub real_skill: f32, skill: Cell<f32>, join_time: Cell<u32>, use_real_skill: bool, } impl UserData { fn new(id: ...
true
41d33b348b0ca6ec238e2ff7fed48dda8a5b5bd3
Rust
fagossa/introrust_xebia
/workspace/src/test.rs
UTF-8
268
2.859375
3
[ "MIT" ]
permissive
#[cfg(test)] mod test { describe!( before_each { let awesome = true; } it "is awesome" { assert!(awesome); } it "injects before_each into all test cases" { let still_awesome = awesome; assert!(still_awesome); } ) }
true
8c84e4312ac4aa738d6a4243b1080400ffbfc835
Rust
geofmureithi-zz/rethinkdb-rs
/tests/common/mod.rs
UTF-8
1,115
2.6875
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use std::process::Command; // This should stop any current running database, and start a new one // that has the database 'test', containing the table 'test' // and also has a user named 'bob', with password 'secret' pub fn setup() { //setup code specific to your library's tests would go here Command::new("sh"...
true
d7cdf71c9eb26071937618618783cdecb648918c
Rust
jessaimaya/MoonZoon
/crates/zoon/src/style/font.rs
UTF-8
3,799
2.703125
3
[ "MIT" ]
permissive
use crate::*; use std::borrow::Cow; mod font_weight; pub use font_weight::{FontWeight, NamedWeight}; mod font_family; pub use font_family::FontFamily; #[derive(Default)] pub struct Font<'a> { static_css_props: StaticCSSProps<'a>, dynamic_css_props: DynamicCSSProps, } impl<'a> Font<'a> { pub fn weight(mu...
true
78fc14f1f12dbe49260c40e560be10d75d3e8971
Rust
ferrous-systems/imxrt1052
/src/pxp/ctrl_tog/mod.rs
UTF-8
26,467
2.765625
3
[]
no_license
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::CTRL_TOG { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w ...
true
4f8f91f6272df6244e22b2ebd623bbb9e282f89c
Rust
zTgx/rippled-rs
/src/crypto/key_type.rs
UTF-8
503
3.171875
3
[ "Apache-2.0", "MIT" ]
permissive
use serde_json::{Value}; #[derive(Debug)] pub enum KeyType { Secp256k1 = 0, Ed25519 = 1, } pub fn key_type_from_value (s: &Value) -> Option<KeyType> { let mut ret = None; if let Some(x) = s.as_str() { match x { "Secp256k1" => { ret = Some( KeyType::Secp256k1 ); ...
true
730d7f75b45cf45542e1b465e7628f5c9776c802
Rust
danielschemmel/ralik
/ralik/src/value/display.rs
UTF-8
4,064
2.921875
3
[]
no_license
use std::fmt; use crate::types::{TypeKind, Variant}; use super::{Data, Value}; impl fmt::Display for Value { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.r#type.kind() { TypeKind::Bool => match &self.data { Data::Bool(value) => value.fmt(f), _ => panic!("Invalid bool representation...
true
d0501904ce97352cb789fa2482332d7ed11cf340
Rust
feadoor/rustdoku
/src/strategies/hidden_single.rs
UTF-8
2,074
3.40625
3
[]
no_license
//! A definition of the hidden single strategy. use grid::{Grid, GridSize}; use strategies::{Deduction, Step}; use utils::GeneratorAdapter; /// Find the hidden singles that appear in the grid. /// /// A hidden single is when a given region has only one spot for a particular value. Then that /// value can be placed in...
true
7b14e3b9531ee7f8810ca5de2a3e443fb6078ed7
Rust
betabandido/rest-api-perf
/rust/rocket-rest-api/src/main.rs
UTF-8
916
2.578125
3
[]
no_license
#![feature(proc_macro_hygiene, decl_macro)] extern crate parking_lot; #[macro_use] extern crate rocket; extern crate rest_api_common; use parking_lot::RwLock; use rocket::State; use rocket_contrib::json::Json; use rest_api_common::{make_value_repository, Value, ValueRepository}; #[get("/values/<key>")] fn get_value...
true
74c19d4b27739a4e6696519a789be05d9ba61746
Rust
aatxe/dnd
/src/data/game.rs
UTF-8
2,408
3.171875
3
[]
no_license
use std::collections::HashMap; use std::io::Result; use std::io::prelude::*; use data::player::Player; use data::{BotResult, as_io}; use data::BotError::PasswordIncorrect; use openssl::crypto::hash::{Type, Hasher}; use rand::thread_rng; use rand::distributions::{IndependentSample, Range}; use rustc_serialize::hex::ToHe...
true
3554e8c2e499f22b19aebd16be806b77a0e9da42
Rust
pcein/trust-rust
/code/hello-led/a18.rs
UTF-8
172
2.84375
3
[]
no_license
fn main() { let v = vec![1,2,3,4,5,6]; v.iter().for_each(|x| { println!("{}", x); }); } // Try running "rustfmt" on this file to format it in // a better way!
true
aeb86142a94a658a75844dd00b132d121a834a4c
Rust
davefollett/advent-of-code
/2021/src/day_02/mod.rs
UTF-8
2,534
3.796875
4
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader}; enum Direction { Up(i32), Down(i32), Forward(i32) } struct Position { depth: i32, horizontal: i32, aim: i32, } impl Position { fn update(&mut self, delta: &Direction, part_01: bool) { if part_01 { match delta { ...
true
b0c5824fe96fef350b1c36c13b4c15e7499d353f
Rust
handcraftsman/Genetic
/tests/lib_duplicate_string_tests.rs
UTF-8
1,379
3.140625
3
[ "MIT" ]
permissive
extern crate genetic; extern crate time; #[cfg(test)] mod tests { use time::PreciseTime; use genetic::*; #[test] fn test_duplicate_string() { let start = PreciseTime::now(); let gene_set = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!."; let target = "Not all tho...
true
a2d1de0794a2aba130866f460e1c22fa6bb1172b
Rust
hdelva/preprocess_routable_tiles
/src/entities/segment.rs
UTF-8
471
3.109375
3
[ "MIT" ]
permissive
#[derive(Debug)] pub struct Segment<'a> { pub from: &'a str, pub to: &'a str, } #[derive(Debug)] pub struct WeightedSegment<'a> { pub segment: Segment<'a>, pub weight: u64, } impl<'a> Segment<'a> { pub fn new(from: &'a str, to: &'a str) -> Segment<'a> { Segment { from, to } } } impl<'...
true
a3dbcf09b031227d712efb41a1e8bba6ba8e6544
Rust
marco-c/gecko-dev-wordified
/third_party/rust/ringbuf/src/ring_buffer.rs
UTF-8
4,819
2.78125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate : : { consumer : : Consumer producer : : Producer } ; use alloc : : { sync : : Arc vec : : Vec } ; use cache_padded : : CachePadded ; use core : : { cell : : UnsafeCell cmp : : min mem : : MaybeUninit ptr : : { self copy } sync : : atomic : : { AtomicUsize Ordering } } ; pub ( crate ) struct SharedVec < T : S...
true
97002b87fa2f31dbbfa86b73ea1af41ec6d6ef56
Rust
veer66/linq-rust
/src/lib.rs
UTF-8
1,124
2.984375
3
[]
no_license
macro_rules! query { (select $select_expr:expr; from $data_source:ident;) => { $data_source.map($select_expr) }; (select $select_expr:expr; from $data_source:ident; where $where_expr:expr;) => { $data_source.filter($where_expr).map($select_expr) }; } #[cfg(test)] mod tests { #[test...
true
4f1ccebefdb5ab89464dd4b8ea882d4dd2420b50
Rust
AriYoung00/Rust-RSA
/rsa_vis/src/rsa.rs
UTF-8
7,875
3.1875
3
[]
no_license
use num::{BigUint, BigInt, ToPrimitive, FromPrimitive}; use num::traits::{One, Zero}; use crate::rand; use crate::primes; use crate::num::bigint::ToBigInt; const KEY_SIZE: usize = 1024; const BLOCK_SIZE: usize = 4; // Block size in increments of 8 bytes /// Return greatest common divisor of elements a and b as a BigU...
true
c00b88522453ec6aec72cd4468d49df63450e4c7
Rust
drademacher/advent_of_code_2020
/src/day_02.rs
UTF-8
1,728
3.46875
3
[]
no_license
use regex::Regex; pub fn solve() -> String { return format!("First part: {}\nSecond part: {}", part_one(), part_two()); } #[derive(Debug)] struct SingleInput { fst_number: usize, snd_number: usize, character: char, password: &'static str, } fn read_input_file() -> Vec<SingleInput> { let regex...
true
031cad4f1a486b37e51fae32391b73acca2b7da0
Rust
Enity/sudocu-brutforce-rs
/src/main.rs
UTF-8
1,600
2.71875
3
[]
no_license
#![feature(test)] mod random; mod sudocu; use random::Random; use sudocu::Sudocu; use std::env; const INITIAL_BACKTRACK_STEP: usize = 2; fn main() { let args: Vec<String> = env::args().collect(); if args.len() < 2 { println!("Cannot find sudoku in args"); } else { let mut s = Sudocu::ne...
true
1f322b3d0971df48bd379770271feb9161a389cb
Rust
trainman419/msp430fr2433
/src/port_1_2/p2out/mod.rs
UTF-8
18,934
2.734375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u8, } #[doc = r" Value to write to the register"] pub struct W { bits: u8, } impl super::P2OUT { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut W...
true
aedb1f9d8bb6c9339a0da8ec55d37750a39bae8d
Rust
intendednull/yew
/examples/router/src/pages/author_list.rs
UTF-8
2,642
2.9375
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::components::{author_card::AuthorCard, progress_delay::ProgressDelay}; use rand::{distributions, Rng}; use yew::prelude::*; /// Amount of milliseconds to wait before showing the next set of authors. const CAROUSEL_DELAY_MS: u64 = 15000; pub enum Msg { NextAuthors, } pub struct AuthorList { link: Co...
true
4b9415ba34def5035a0e5877df1825c8cbcd9cde
Rust
0xflotus/grapl
/src/rust/graph-descriptions/src/graph.rs
UTF-8
1,961
2.8125
3
[ "Apache-2.0" ]
permissive
use std::collections::HashMap; use crate::graph_description::{Edge, EdgeList, GeneratedSubgraphs, Graph, Node}; use crate::node::NodeT; impl Graph { pub fn new(timestamp: u64) -> Self { Graph { nodes: HashMap::new(), edges: HashMap::new(), timestamp, } } ...
true
04323cb7aeffd2e84435fc99e08753f6ef9f38b7
Rust
benblank/aoc2019-rust
/src/day14.rs
UTF-8
10,259
2.90625
3
[]
no_license
use std::collections::HashMap; use std::fs; use std::io::BufRead; const INPUT_PATH: &str = "day14.input.txt"; const ORE: &str = "ORE"; #[derive(Debug, PartialEq)] struct Ingredient { name: String, count: u64, } impl Ingredient { fn from_string(string: &str) -> Ingredient { let parts = string.spli...
true
dfbc8652b020b227cd14ae74f069620dd20259ab
Rust
seanwallawalla-forks/nushell
/crates/nu-command/src/commands/viewers/autoview/options.rs
UTF-8
1,168
3
3
[ "MIT" ]
permissive
pub use nu_data::config::NuConfig; use std::fmt::Debug; #[derive(PartialEq, Debug)] pub enum AutoPivotMode { Auto, Always, Never, } impl AutoPivotMode { pub fn is_auto(&self) -> bool { matches!(self, AutoPivotMode::Auto) } pub fn is_always(&self) -> bool { matches!(self, AutoP...
true
c43b1cdb611278a2d5a0ff5f9ecf57c64004cad2
Rust
wooddeep/lee
/src/executor/mod.rs
UTF-8
9,631
3
3
[]
no_license
use crate::parser::*; use crate::lexer::*; use crate::tree::*; use std::ops::Deref; use std::borrow::Borrow; use std::collections::HashMap; use std::rc::Rc; use std::cell::RefCell; pub struct Executor<'a> { parser: &'a mut Parser<'a>, para_map: Rc<HashMap<String, HashMap<String, i32>>>, // 记录个函数的参...
true
5988110d9948cadb19e5b2413147fd3ecf742328
Rust
mordet/yabook
/telegram/src/user_message.rs
UTF-8
1,086
3.296875
3
[ "MIT" ]
permissive
use telegram_bot::{MessageEntityKind, MessageEntity}; pub struct UserMessage { pub command: Option<String>, pub mentions: Vec<String> } fn substring(data: &String, offset: i64, length: i64) -> String { data.chars() .skip(offset as usize) .take(length as usize) .collect() } impl Us...
true
d687a247358f2d7d266a6ef14ede696d47eee27b
Rust
freddyDappDev/lazycli
/src/template.rs
UTF-8
1,244
2.890625
3
[ "MIT" ]
permissive
use regex::{Captures, Regex}; use crate::{config::Command, parse::Row}; pub fn resolve_command(command: &dyn Command, row: &Row) -> String { // if keybinding has a regex we need to use that, otherwise we generate the regex ourselves let matches = match &command.regex() { Some(regex) => { let regex = Reg...
true
2ff3cbc4697fe868c9e48136ea18a09ecc2a3f7a
Rust
geom3trik/swash
/src/scale/outline.rs
UTF-8
11,252
3.25
3
[ "Apache-2.0", "MIT" ]
permissive
/*! Glyph outline. */ use zeno::{Bounds, PathData, Point, Transform, Verb}; /// Scaled glyph outline represented as a collection of layers and a sequence /// of points and verbs. #[derive(Clone, Default)] pub struct Outline { layers: Vec<LayerData>, points: Vec<Point>, verbs: Vec<Verb>, is_color: bool...
true
7366dbdc68f6e29c83dfa2d044dc47068fd47e2c
Rust
nilsso/challenge-solutions
/leetcode/problems/redundant-connection/src/main.rs
UTF-8
1,875
3.375
3
[]
no_license
use std::collections::HashMap; #[derive(Debug)] struct DSU { parents: HashMap<usize, usize>, ranks: HashMap<usize, usize>, } impl DSU { fn new() -> Self { DSU { parents: HashMap::new(), ranks: HashMap::new(), } } fn parent(&mut self, x: usize) -> &mut usize...
true
81de8f4ffde9aa8996697076b8661a57e9f4d603
Rust
kumabook/pink-spider
/src/get_env.rs
UTF-8
739
2.921875
3
[ "MIT" ]
permissive
use std::env; use toml::Value; use std::fs::File; use std::io::Read; pub fn var(key: &str) -> Option<String> { match env::var(key) { Ok(value) => Some(value), Err(_) => { let file = File::open("config/env.toml"); if file.is_err() { return None; } ...
true
25dad3fc77f9e9149e33b469019432a8ffd7e1a8
Rust
faustfu/hello_rust
/src/types/option1.rs
UTF-8
1,434
4.125
4
[]
no_license
// 1. Option is generic enum of Some and None. Therefore it could be some value or none. // enum Option<T> { // Some(T), // None, // } // 2. Use method:unwrap to parse a Some result or panic the system. // 3. Use question mark operator to parse a Some result or return None. // 4. Choosing between match and if l...
true
86ae412c7e7705585a4b85ba08cda78d44326cbf
Rust
reitermarkus/vcontrol-rs
/src/types/error.rs
UTF-8
2,599
3.21875
3
[]
no_license
use core::fmt; use arrayref::array_ref; #[cfg(feature = "impl_json_schema")] use schemars::JsonSchema; use serde::{Serialize, Deserialize}; use crate::Device; use super::DateTime; #[cfg_attr(feature = "impl_json_schema", derive(JsonSchema))] #[derive(Clone, PartialEq, Deserialize, Serialize)] pub struct Error { in...
true
e59e8b8ab4aebc1b775eab83e87f768f02115ba8
Rust
pchickey/cap-std
/cap-primitives/src/winx/fs/is_same_file.rs
UTF-8
1,875
2.984375
3
[ "MIT", "LLVM-exception", "Apache-2.0" ]
permissive
use crate::fs::Metadata; use std::{fs, io}; /// Determine if `a` and `b` refer to the same inode on the same device. #[cfg(windows_by_handle)] #[allow(dead_code)] pub(crate) fn is_same_file(a: &fs::File, b: &fs::File) -> io::Result<bool> { let a_metadata = Metadata::from_std(a.metadata()?); let b_metadata = Me...
true
6b84f0e8065e100f19de4949508bc39f5e5c8bda
Rust
input-output-hk/jormungandr
/jcli/src/jcli_lib/transaction/new.rs
UTF-8
947
2.578125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::jcli_lib::transaction::{common, staging::Staging, Error}; use structopt::StructOpt; #[derive(StructOpt)] #[structopt(rename_all = "kebab-case")] pub struct New { #[structopt(flatten)] pub common: common::CommonTransaction, } impl New { pub fn exec(self) -> Result<(), Error> { let stagin...
true
3f1c9c2e8093da05d9f283ca56fedc5dff181ef1
Rust
norse-rs/runic
/src/rasterizer/hati.rs
UTF-8
3,785
2.578125
3
[]
no_license
use crate::{ math::*, rasterize_each_with_bias, Curve, Framebuffer, Rasterizer, Rect, Segment, Filter, }; pub struct HatiRasterizer<F: Filter> { pub filter: F, } impl<F: Filter> Rasterizer for HatiRasterizer<F> { fn name(&self) -> String { format!("HatiRasterizer :: {}", self.filter.name()) ...
true
7d901168167e384ac20d676e665a83427fd14fa6
Rust
tomdewildt/rust-basics
/src/loops.rs
UTF-8
481
4.15625
4
[ "MIT" ]
permissive
// Loops are used to iterate until a condition is met pub fn main() { let mut integer = 0; // Infinite loop loop { integer += 1; println!("Infinite loop: {}", integer); if integer >= 5 { break; } } // While loop while integer <= 10 { printl...
true
a2128f96a24ecab9d6b2aab5284394639b21bb33
Rust
tessi/rpiet
/src/cmd_options.rs
UTF-8
3,552
3.15625
3
[ "MIT" ]
permissive
use clap::{App, Arg, ArgMatches}; pub struct CmdOptions<'a> { pub verbose: bool, pub codel_size: u32, pub max_steps: u128, pub unlimited_steps: bool, pub unknown_white: bool, pub file_path: &'a str, } fn is_valid_file_name(val: String) -> Result<(), String> { if val.ends_with(".png") { ...
true
f7724c2189b7c7166729cb9c845c219aa38fe8a3
Rust
jxnu-liguobin/graphql-ws-client
/src/websockets.rs
UTF-8
1,691
3.0625
3
[ "Apache-2.0" ]
permissive
//! Contains traits to provide support for various underlying websocket clients. /// An abstraction around WebsocketMessages /// /// graphql-ws-client doesn't implement the websocket protocol itself. /// This trait provides part of the integration with websocket client libraries. pub trait WebsocketMessage: std::fmt::...
true
736b79b216a9f316e642ed693c07157177c3ee2a
Rust
HewlettPackard/dockerfile-parser-rs
/src/instructions/misc.rs
UTF-8
1,967
2.71875
3
[ "MIT", "LicenseRef-scancode-dco-1.1" ]
permissive
// (C) Copyright 2019-2020 Hewlett Packard Enterprise Development LP use std::convert::TryFrom; use crate::Span; use crate::dockerfile_parser::Instruction; use crate::error::*; use crate::util::*; use crate::parser::*; /// A miscellaneous (unsupported) Dockerfile instruction. /// /// These are instructions that aren...
true
95b429dee9123775503e1672b69631c277c2825b
Rust
MacTuitui/nannou
/examples/wgpu/wgpu_triangle_raw_frame/wgpu_triangle_raw_frame.rs
UTF-8
2,883
3.078125
3
[]
permissive
//! The same as the `wgpu_triangle` example, but demonstrates how to draw directly to the swap //! chain texture (`RawFrame`) rather than to nannou's intermediary `Frame`. use nannou::prelude::*; struct Model { bind_group: wgpu::BindGroup, render_pipeline: wgpu::RenderPipeline, vertex_buffer: wgpu::Buffer...
true
6c2c9f996468a0eb78e871c81c818aafa08ebede
Rust
minhtriet/rustlings
/exercises/variables/variables2.rs
UTF-8
260
3.15625
3
[ "MIT" ]
permissive
// variables2.rs // Make me compile! Execute the command `rustlings hint variables2` if you want a hint :) fn main() { let x = 0.15 + 0.15 + 0.15; if x == 0.1 + 0.25 + 0.1 { println!("Ten!"); } else { println!("Not ten!"); } }
true
972349dfd09ad02d3fe538a363cda82500217993
Rust
astral-sh/ruff
/crates/ruff/src/rules/pyupgrade/rules/use_pep604_annotation.rs
UTF-8
3,925
3.109375
3
[ "BSD-3-Clause", "0BSD", "LicenseRef-scancode-free-unknown", "GPL-1.0-or-later", "MIT", "Apache-2.0" ]
permissive
use itertools::Either::{Left, Right}; use itertools::Itertools; use ruff_python_ast::{self as ast, Expr, Ranged}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_semantic::analyze::typing::Pep604Operator; use ruff_source_file:...
true
8a5c7a6ab675e107b0bf9a69af92a9333c2afd24
Rust
PacktPublishing/Rust-High-Performance
/Chapter10/example1.rs
UTF-8
213
3.4375
3
[ "MIT" ]
permissive
use std::cell::Cell; fn main() { let my_cell = Cell::new(0); println!("Initial cell value: {}", my_cell.get()); my_cell.set(my_cell.get() + 1); println!("Final cell value: {}", my_cell.get()); }
true
af8d8fc0ee1781e9b1d498e4908553765f90b45f
Rust
vrobweis/genius-rs
/src/album.rs
UTF-8
2,494
2.671875
3
[ "MIT" ]
permissive
use serde::Deserialize; use crate::annotation::Referent; use crate::song::{Artist, SongPerformance}; use crate::user::UserMetadata; #[derive(Deserialize, Debug)] pub struct Album { /// Path of the API. pub api_path: String, /// Number of comments. /// > Only in `get_album` pub comment_count: Optio...
true
0d9b453ccf99da29a3241ba9cb7ff1dd1a1b5a6d
Rust
J0sh0nat0r/rust-aip-filtering
/src/ast.rs
UTF-8
12,523
3.109375
3
[]
no_license
use std::fmt::{self, Display, Formatter}; use std::time::Duration; use chrono::{DateTime, FixedOffset}; use itertools::Itertools; use pest::error::Error; use pest::iterators::{Pair, Pairs}; use pest::Parser; use pest_derive::Parser; #[derive(Parser)] #[grammar = "grammar.pest"] pub struct FilterParser; impl FilterPa...
true
0ab9c7449413e929cdeccd1452a8d5c14bd6887f
Rust
quininer/aes
/src/mode/ecb.rs
UTF-8
1,219
2.890625
3
[]
no_license
use ::AES; use ::utils::padding::Padding; use ::cipher::{ DecryptFail, SingleBlockEncrypt, SingleBlockDecrypt, BlockEncrypt, BlockDecrypt }; #[derive(Clone, Debug)] pub struct Ecb<C> { cipher: C } impl Ecb<AES> { pub fn new(key: &[u8]) -> Ecb<AES> { Ecb { cipher: AES::new(key) } } } ...
true
93ee4d09a663b58577314f57bf319770d0c0de9f
Rust
chikuchikugonzalez/varsun
/src/mswin.rs
UTF-8
3,753
3.234375
3
[ "MIT" ]
permissive
// -*- coding: utf-8 -*- // vi: set sts=4 ts=4 sw=4 et ft=rust: //! Provides MS-Windows style substition. //! //! MS-Winodws style substition is `%var%` format strings. //! You can see on COMMAND PROMPT (not PowerShell). /// Parse src and substitute found variables with result of `mapfn`. /// /// # Examples...
true
0d6e7fa95ae4b163993a546dc830349e529ecf0d
Rust
kaikalii/smore
/src/lib.rs
UTF-8
7,820
2.953125
3
[]
no_license
use std::f32::EPSILON; pub trait Vectorize<const N: usize> { fn vectorize(&self) -> [f32; N]; } pub trait Devectorize<const N: usize>: Vectorize<N> { fn devectorize(vector: [f32; N]) -> Self; } impl Vectorize<1> for f32 { fn vectorize(&self) -> [f32; 1] { [*self] } } impl Devectorize<1> for ...
true
1232d9c02f168950e5e9ed338fc694223f02dfaf
Rust
sepiggy/imooc-517
/ch04/demo09function/src/main.rs
UTF-8
203
3.453125
3
[]
no_license
fn fib(n:u64) -> u64 { match n { 0 => 0, 1 => 1, _ => fib(n-1) + fib(n-2), } } fn main() { println!("fib(5) = {}", fib(5)); println!("fib(10) = {}", fib(10)); }
true
2a685aa3263d3491a1746b5f13e15b87c183707e
Rust
lordy1992/REMulator
/src/cpu.rs
UTF-8
46,049
3.0625
3
[ "MIT" ]
permissive
use std::collections::HashMap; use crate::address_space::AddressSpace; #[derive(Debug)] pub struct StatusRegister { carry_flag: bool, zero_flag: bool, interrupt_disable_flag: bool, decimal_flag: bool, break_flag_1: bool, break_flag_2: bool, overflow_flag: bool, negative_flag: bool } i...
true
35763977358cf7737675618f2e33bd5a39efb7b6
Rust
Greast/r-graph
/src/wrapper/random/edge.rs
UTF-8
6,823
2.578125
3
[ "MIT" ]
permissive
use crate::dev::orientation::AddEdge as EdgeTrait; use crate::dev::{ orientation, AddVertex, Edges, GetEdge, GetEdgeTo, GetVertex, Merge, Neighbours, RemoveEdge, RemoveVertex, Vertices, }; use rand::distributions::{Distribution, Standard}; use rand::random; use std::marker::PhantomData; use std::ops::{Deref, D...
true
fc014f834bf74cbfec692d742819240831dfbc13
Rust
ZakisM/http_lib
/src/header_map.rs
UTF-8
3,633
3.34375
3
[]
no_license
use std::ops::Deref; #[derive(Debug, Default, Clone)] pub struct HeaderMap { pub headers: Vec<(String, String)>, } #[allow(unused)] impl HeaderMap { pub fn new() -> Self { Self::default() } pub fn from_header_lines(header_str_lines: &mut dyn Iterator<Item = &str>) -> Option<Self> { le...
true
5ac255edd131908e2e0d34fdfbc3ef7db87b7ce0
Rust
svmk/fund-watch-bot
/src/telegram/model/message_id.rs
UTF-8
415
2.71875
3
[]
no_license
use crate::prelude::*; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, ValueObject)] #[value_object(error_type = "Failure", load_fn = "MessageId::from_u32")] pub struct MessageId(u32); impl MessageId { pub fn from_u32(value: u32) -> Result<MessageId, Failure> { let value = MessageId(value); ...
true