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
e9795b276e6cd2bd5d9cdd95011aa79f175bdd17
Rust
ehennes775/bbcmd
/src/cfg/config_args.rs
UTF-8
1,239
2.890625
3
[]
no_license
use crate::cfg::config; use crate::cfg::config::Config; use structopt::StructOpt; use std::path::PathBuf; use std::env; /// Command line arguments for setting up the configuration #[derive(Debug, StructOpt)] pub struct ConfigArgs { #[structopt(long="config", short="c")] /// An optional alternate configuration...
true
a612bff85ef4e0c7dd1151f64dc29e9479bce9b4
Rust
rust-rosetta/rust-rosetta
/tasks/_99-bottles-of-beer/src/main.rs
UTF-8
931
3.765625
4
[ "Unlicense" ]
permissive
use std::string::String; fn main() { for num_bottles in (1u32..100).rev() { println!("{}", bottles_line(num_bottles, true)); println!("{}", bottles_line(num_bottles, false)); println!("Take one down, pass it around..."); println!("{}", bottles_line(num_bottles - 1, true)); p...
true
8b6556752923f93ef1998aacf4168b2a9f343878
Rust
mdsteele/rust-ar
/examples/extract.rs
UTF-8
1,342
3.25
3
[ "MIT" ]
permissive
//! Extracts files from an archive. //! //! To extract all files from an archive into the current directory, run: //! //! ```shell //! cargo run --example extract <path/to/archive.a> //! ``` //! //! This is roughly equivalent to running: //! //! ```shell //! ar -x <path/to/archive.a> //! ``` extern crate ar; use std:...
true
6786def77216f44597f972b47041fbb56a20ee0b
Rust
skade/surf
/tests/test.rs
UTF-8
672
2.78125
3
[ "Apache-2.0", "MIT" ]
permissive
#[runtime::test] async fn post_json() -> Result<(), surf::Exception> { #[derive(serde::Deserialize, serde::Serialize)] struct Cat { name: String, } let cat = Cat { name: "Chashu".to_string(), }; let res = surf::post("https://httpbin.org/post") .body_json(&cat)? ...
true
41cfa86a7c503f12483b7adf624fb9a2924a2ab7
Rust
PierceyOwen/SocialLink
/src/accounts.rs
UTF-8
199
2.59375
3
[]
no_license
/* Contains the functions to gather data from social media accounts linked to the current User */ pub fn get_active_accounts() -> String{ let test = String::from("test me"); return test; }
true
8c5d4656411d8206a40ee49c55304639cde310bf
Rust
Tarrask/tarengine.rs
/level_1_hexagonal/src/hexagonal/coord.rs
UTF-8
6,473
3.25
3
[]
no_license
use std::fmt; use std::ops; #[derive(Debug, Clone, Copy, Hash)] pub struct BaseCoord<T> (T, T, T); pub type Coord = BaseCoord<i32>; pub type FCoord = BaseCoord<f32>; #[allow(dead_code)] impl Coord { pub const ZERO: Coord = BaseCoord::<i32>(0, 0, 0); pub const NEIGHBOURS : [Coord; 6] = [ BaseCoord::<...
true
c11333b35191bccd24cf520b9474055b4d46f2eb
Rust
tansly/euler
/prob_102/src/main.rs
UTF-8
1,025
3.15625
3
[ "MIT" ]
permissive
use std::env; use std::fs; struct Point(i32, i32); fn cross_product_z(a: &Point, b: &Point) -> i32 { a.0 * b.1 - a.1 * b.0 } fn main() { let args: Vec<String> = env::args().collect(); if args.len() < 2 { panic!("give input filename"); } let filename = &args[1]; let contents = fs::read...
true
8b306e4e2f8a7827b923749af29642b9fc5396fb
Rust
iqlusioninc/usbarmory.rs
/firmware/usbarmory/src/fs.rs
UTF-8
12,513
2.90625
3
[ "Apache-2.0", "MIT" ]
permissive
//! File system access. use core::cell::RefCell; use crate::storage::{Block, ManagedBlockDevice, BLOCK_SIZE}; use littlefs2::{ consts, driver::Storage, fs::{self, FileAllocation, FileType, Filesystem, FilesystemAllocation, Metadata, SeekFrom}, io::{self, Read, Seek, Write}, path::Filename, }; use ...
true
4ad70514020f51f2e6adc919b0f9765958ec3b24
Rust
loganek/hawktracer-converter
/src/converter_manager.rs
UTF-8
4,055
3.015625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::converters::Converter; use crate::converters::ConverterFactory; use crate::LabelGetter; pub struct ConverterManager { factories: std::vec::Vec<Box<dyn ConverterFactory>>, } impl Default for ConverterManager { fn default() -> ConverterManager { ConverterManager::new() } } impl Converter...
true
a75840d64913a212f7f18eec4c6e4480ddf9cab4
Rust
goldenMetteyya/microsalt
/src/secretbox/mod.rs
UTF-8
7,538
3.140625
3
[ "LicenseRef-scancode-public-domain" ]
permissive
//! Secret-key authenticated encryption /* -->http://nacl.cr.yp.to/secretbox.html Similarly, ciphertexts in the C NaCl API are 0-padded versions of messages in the C++ NaCl API. Specifically: The crypto_secretbox function ensures that the first crypto_secretbox_BOXZEROBYTES bytes of the ciphertext c are all 0. Th...
true
fccd3d70df546ecbc027308d685da0a46b0d7564
Rust
jsonnull/valor
/src/valor/src/simple/vertex.rs
UTF-8
533
3.359375
3
[ "MIT" ]
permissive
use glium::implement_vertex; #[derive(Copy, Clone)] /// Simple implementation for a vertex used by our material. /// /// Has attributes `position` and `color` pub struct Vertex { position: [f32; 4], // = "a_Pos", color: [f32; 3], // = "a_Color", } implement_vertex!(Vertex, position, color); impl Vertex {...
true
e8af02b10a1024a07834dabd9dc79c4167ceffd7
Rust
wfraser/unicoder
/src/encodings/cp437.rs
UTF-8
6,223
2.609375
3
[]
no_license
use crate::encoding::*; use crate::encodings::utils; const REPLACEMENT: u8 = b'?'; const SAME: u32 = 0; const MAPPING: [u32; 256] = [ 0x0000, 0x263A, 0x263B, 0x2665, 0x2666, 0x2663, 0x2660, 0x2022, // 0 0x25D8, 0x25CB, 0x25D9, 0x2642, 0x2640, 0x266A, 0x266B, 0x263C, // 0 0x25BA, 0x25C4, 0x2195, 0x203C, 0x...
true
8aa13c2d42447a85c28bacb9d3d9b2d5a4285e7e
Rust
darthsteedious/heroes-api
/src/domain/hero/errors.rs
UTF-8
1,054
2.9375
3
[]
no_license
use std::error::Error; use std::fmt; use serde::export::Formatter; #[derive(Debug)] pub struct AlreadyAssignedError(String); impl AlreadyAssignedError { pub fn new(msg: &str) -> AlreadyAssignedError { AlreadyAssignedError(String::from(msg)) } pub fn boxed(msg: &str) -> Box<dyn Error> { Bo...
true
20e40f76b9f0cc0c70c64f59b94e202ec2749b7b
Rust
marco-c/gecko-dev-wordified
/third_party/rust/memmap2/src/advice.rs
UTF-8
12,195
2.5625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/ / The use statement is needed for the cargo docs # [ allow ( unused_imports ) ] use crate : : { Mmap MmapMut } ; / / / Values supported by [ Mmap : : advise ] and [ MmapMut : : advise ] functions . / / / See [ madvise ( ) ] ( https : / / man7 . org / linux / man - pages / man2 / madvise . 2 . html ) map page . # [ re...
true
38179647e271ce05cb130c203d68418ac5767989
Rust
huggingface/tokenizers
/tokenizers/src/tokenizer/encoding.rs
UTF-8
31,474
3.109375
3
[ "Apache-2.0" ]
permissive
use crate::parallelism::*; use crate::tokenizer::{Offsets, Token}; use crate::utils::padding::PaddingDirection; use crate::utils::truncation::TruncationDirection; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::ops::Range; /// Represents the output of a `Tokenizer`. #[derive(Default, Parti...
true
666fde37c923b5aebf0afdc33b77f5d9605d7d75
Rust
obs145628/cl-book
/libs/asmparser/src/parser.rs
UTF-8
5,652
3.390625
3
[]
no_license
use crate::lexer::{Lexer, Token}; /// Parsed argument of an instruction #[derive(Debug)] pub enum InsArg { Const(u64), // <uint> Name(String), // <str> IdInt(u64), // %<uint> IdName(String), // %<str> } /// Parsed label of an instruction #[derive(Debug)] pub enum InsLabel { IdInt(u64), ...
true
131ec95d94c700c43b302a1f77106fdbb4052ed2
Rust
Pranz/Emperust
/src/history_gen.rs
UTF-8
1,261
2.953125
3
[]
no_license
use map::Map; use settings::Settings; use biome::{Biome, BiomeType}; use rand::{sample, thread_rng}; use std::collections::{HashMap}; pub struct Language(pub usize); pub struct City { pub language: Language, pub population: u32, } pub fn place_initial_cities(settings: &Settings, map: &Map) -> HashMap<(usiz...
true
b28a11654e4ddc47e3ee9f5499772356b975d9bc
Rust
mbccrack/monoxide
/src/find_one_and_delete.rs
UTF-8
979
2.75
3
[]
no_license
use bson::Document; use mongodb::options::FindOneAndDeleteOptions; use mongodb::Collection; impl super::Database { pub async fn find_one_and_delete<R>( &self, collection: &str, filter: Document, options: Option<FindOneAndDeleteOptions>, ) -> Result<R, String> where f...
true
d48055b842cd1a33356399c4fabc5a9e2572b335
Rust
mopemope-LeaF/calladdress
/flipper/lib.rs
UTF-8
1,289
2.515625
3
[]
no_license
// Copyright 2018-2021 Parity Technologies (UK) Ltd. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicab...
true
6448d53f3c5712723538ff12a4dbe46b2ec13f8f
Rust
Lutetium-Vanadium/viu-rs
/src/png/parse_image.rs
UTF-8
13,410
2.84375
3
[]
no_license
use super::chunks::ancillary; use crate::common::*; use std::io::{Error, ErrorKind, Result}; pub fn parse_image(mut image_data: Vec<u8>, metadata: &Metadata) -> Result<Image<RGBColor>> { let mut image: Image<RGBColor> = Vec::new(); // Make sure px_size isnt zero from truncation let px_size = metadata.pixe...
true
32db86cf2c42d68ef663e76ae4a8c267507f1273
Rust
Pajn/wlral
/wlral/src/config.rs
UTF-8
962
2.859375
3
[]
no_license
use crate::{event::Event, input::keyboard::KeyboardConfig}; use log::debug; use serde::{Deserialize, Serialize}; use std::{cell::RefCell, rc::Rc}; #[derive(Default, Debug, PartialEq, Clone, Serialize, Deserialize)] #[serde(default)] pub struct Config { pub keyboard: KeyboardConfig, pub background_color: [f32; 3], ...
true
ea51ff2d73bf0e3fe4b40169ebb925aca79f929c
Rust
Bergmann89/asparit
/src/iter/for_each.rs
UTF-8
1,903
2.96875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{core::Driver, Consumer, Executor, Folder, ParallelIterator, WithSetup}; use super::noop::NoOpReducer; pub struct ForEach<X, O> { iterator: X, operation: O, } impl<X, O> ForEach<X, O> { pub fn new(iterator: X, operation: O) -> Self { Self { iterator, operation, ...
true
0b01a210cbac53c9bc6cae929690f91da360c1d3
Rust
silverweed/ecsde
/inle/inle_audio_backend/src/sound/null.rs
UTF-8
760
2.75
3
[]
no_license
use std::marker::PhantomData; pub struct Sound<'a>(PhantomData<&'a ()>); pub struct Sound_Buffer<'a>(PhantomData<&'a ()>); static mut INSTANCE: () = (); impl Sound_Buffer<'_> { pub fn from_file(_fname: &str) -> Option<Self> { Some(Self(PhantomData)) } } impl std::ops::Deref for Sound_Buffer<'_> { ...
true
088180c7737d41b74f2c3e7dea6dfa79d7ad5b95
Rust
snorrwe/doodle-rs
/doodle_example/src/main.rs
UTF-8
545
2.515625
3
[ "MIT" ]
permissive
extern crate doodle; #[macro_use] extern crate serde_json; use doodle::*; #[derive(Schema)] struct Woods { pub id: i32, pub epic: Vec<Tale>, } #[derive(Schema)] struct Tale { pub name: Option<String>, } fn main() { // Initialize an empty dict let mut schema = json! {{}}; let map = schema.as_...
true
71fcb6ee931194114d6d4e8812cbe4abe4523ea3
Rust
svirmi/rust-camera-effect
/src/lib.rs
UTF-8
10,596
2.578125
3
[ "MIT" ]
permissive
mod utils; use std::cell::RefCell; use std::rc::Rc; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use web_sys::{ImageData, WebGlProgram, WebGlRenderingContext, WebGlShader}; const WIDTH: i32 = 128; const HEIGHT: i32 = 128; const CHANNELS: i32 = 4; const BUFFER_SIZE: usize = ((WIDTH * HEIGHT) * CHANNELS) as ...
true
424a07b432e7d6cb199af2b4e17bf7cee57496e4
Rust
CenterDevice/ceres-lambda
/aws-watchtower/src/bin/validate-config.rs
UTF-8
1,084
2.6875
3
[ "MIT" ]
permissive
use aws_watchtower::config::EncryptedFunctionConfig; use aws::AwsClientConfig; use clams::config::Config; use lambda::config::EncryptedConfig; use std::path::PathBuf; use structopt::StructOpt; /// A basic example #[derive(StructOpt, Debug)] #[structopt(name = "basic")] struct Opt { /// Verbose mode (-v, -vv, -vvv...
true
359ab457b0ac45e6dc909509b8b1ed1bc430e8d5
Rust
YaronWittenstein/unsafe-rust-examples
/src/vec_examples.rs
UTF-8
734
3.265625
3
[]
no_license
#[test] fn vec_as_ptr() { let vec: Vec<u8> = vec![10, 20, 30]; let ptr = vec.as_ptr(); let first_ptr: *const u8 = ptr; let second_ptr: *const u8 = unsafe { ptr.offset(1) }; let third_ptr: *const u8 = unsafe { ptr.offset(2) }; assert_eq!(10, unsafe { *first_ptr }); assert_eq!(20, unsafe { ...
true
6280361e098df896d30ed87c94aa6d199b388579
Rust
PartialDragster/lastfm-rs
/src/user/loved_tracks.rs
UTF-8
3,357
2.921875
3
[ "MIT" ]
permissive
use serde::Deserialize; use std::marker::PhantomData; use crate::{ error::{Error, LastFMError}, model::{Attributes, Image, TrackDate}, user::User, Client, RequestBuilder, }; /// The main loved tracks structure. /// /// This is splitted off into two areas: One, the attributes (used /// for displaying v...
true
9d93621a6eda0678ad6ee6cde1cd1efd27bbe292
Rust
rbatis/rbatis
/rbdc-sqlite/src/row.rs
UTF-8
2,745
2.71875
3
[ "Apache-2.0" ]
permissive
#![allow(clippy::rc_buffer)] use crate::decode::Decode; use crate::statement::StatementHandle; use crate::{SqliteColumn, SqliteValue, SqliteValueRef}; use rbdc::db::{MetaData, Row}; use rbdc::error::Error; use rbdc::ext::ustr::UStr; use rbs::Value; use std::collections::HashMap; use std::fmt::Debug; use std::sync::Arc...
true
bb97a636972ab001ea4b4deed484213cac411095
Rust
jiangzhe/mybin
/mybin-core/src/error.rs
UTF-8
2,004
2.796875
3
[]
no_license
use crate::col::BinaryColumnValue; use thiserror::*; pub type Result<T> = std::result::Result<T, Error>; #[derive(Debug, Error)] pub enum Error { #[error("invalid command code: {0}")] InvalidCommandCode(u8), #[error("invalid column type code: {0}")] InvalidColumnTypeCode(u32), #[error("invalid bin...
true
16dc07176ce17dc370d5bf1f6bdfa5ba8238be7c
Rust
steadylearner/Rust-Full-Stack
/yew/server_and_frontend/src/ws_rs.rs
UTF-8
1,041
2.921875
3
[ "MIT" ]
permissive
use yew::services::websocket::{WebSocketService, WebSocketTask}; use yew::services::Task; use yew::format::{Json}; use super::{ http_model::{ websocket_json::{ WebSocketRequest, } }, }; pub struct WebSocket { pub ws_service: WebSocketService, pub ws: Option<WebSocketTask>, ...
true
e21e6cb8a2c8a7b44eb257e38838abc25189d47e
Rust
EIVentures/solana-program-library
/libraries/math/src/approximations.rs
UTF-8
1,735
3.4375
3
[ "Apache-2.0" ]
permissive
//! Approximation calculations use { num_traits::{CheckedAdd, CheckedDiv, One, Zero}, std::cmp::Eq, }; const SQRT_ITERATIONS: u8 = 50; /// Perform square root pub fn sqrt<T: CheckedAdd + CheckedDiv + One + Zero + Eq + Copy>(radicand: T) -> Option<T> { if radicand == T::zero() { return Some(T::zer...
true
e25a33f55ea996a8dea13d712839f256e6edd732
Rust
Lehona/Parsiphae
/src/types/exp/unary_operator.rs
UTF-8
772
3.765625
4
[ "MIT" ]
permissive
#[derive(Clone, Debug, PartialEq)] pub enum UnaryOperator { Plus, Minus, Flip, Negate, } impl UnaryOperator { pub fn from_ascii(op: u8) -> Self { match op { b'+' => UnaryOperator::Plus, b'-' => UnaryOperator::Minus, b'!' => UnaryOperator::Negate, ...
true
9b6dcfe99132579eabd7263427d2504164b352d5
Rust
dwango/fibers-rs
/src/fiber/schedule.rs
UTF-8
10,599
2.5625
3
[ "MIT" ]
permissive
// Copyright (c) 2016 DWANGO Co., Ltd. All Rights Reserved. // See the LICENSE file at the top-level directory of this distribution. use futures::{Async, Future, Poll}; use std::cell::RefCell; use std::collections::{HashMap, VecDeque}; use std::sync::atomic; use std::sync::mpsc as std_mpsc; use super::{FiberState, Sp...
true
675a52b44ecfef0a263383db53f5dd9938fdd2dd
Rust
makeapp007/OS2
/hw1/src/main.rs
UTF-8
33,467
2.75
3
[]
no_license
use std::io; use std::io::Write; extern crate libc; use libc::{system,fork,execvp,waitpid,wait,kill,pipe,dup2,close,open}; use libc::{O_RDONLY,O_WRONLY,O_CREAT,S_IRWXU,O_TRUNC}; use libc::c_char; use std::ffi::{CStr,CString}; use std::str; use std::env; use std::path::Path; use std::{thread, time}; //d #[derive(Deb...
true
3a29bd94b5baaf1850072b9cb6aff3ea394e95f3
Rust
dmvict/wTools
/rust/impl/proc_macro/generic_analyze.rs
UTF-8
1,718
2.75
3
[ "MIT" ]
permissive
//! //! Analyze generic to provide more information than trivial syntax node. //! /// Internal namespace. pub( crate ) mod private { /// Result of generics analyze. #[ derive( Debug ) ] pub struct GenericsAnalysis { /// Original generics. pub generics : syn::Generics, /// Array of names. pub n...
true
aab98b4b1f751f72a273581d28402fd618ce9c5c
Rust
roSievers/pacosako-rust
/src/lib.rs
UTF-8
55,173
3.046875
3
[ "MIT" ]
permissive
pub mod parser; pub mod types; use colored::*; use rand::distributions::{Distribution, Standard}; use rand::seq::SliceRandom; use rand::Rng; use serde::{Deserialize, Serialize}; use std::collections::hash_map::Entry; use std::collections::HashMap; use std::collections::HashSet; use std::collections::VecDeque; use std:...
true
a728189f9d6da7fbccbf56b36cb10ee6e7db05b3
Rust
eduidl/rust-group-theory
/src/examples/finite_uint.rs
UTF-8
1,145
2.984375
3
[ "Apache-2.0" ]
permissive
use crate::traits::{AbelianGroup, Group, Monoid}; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct FiniteUint(u8); pub struct FiniteUintAdd; impl Monoid for FiniteUintAdd { type Element = FiniteUint; fn call(a: FiniteUint, b: FiniteUint) -> FiniteUint { FiniteUint(a.0.wrapping_add(b.0)) }...
true
409278d5f9c964a2821be98f2215e96f0c37675e
Rust
ClubRobotInsat/librobot
/src/navigation/motor.rs
UTF-8
5,819
3.4375
3
[]
no_license
use core::fmt::{Debug, Display, Formatter, Result}; use embedded_hal::digital::OutputPin; use embedded_hal::PwmPin; /// Une commande pour un moteur : une direction et une vitesse sur 16 bits (0 : vitesse nulle). #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum Command { /// Le moteur doit avancer à la vitess...
true
4dd3373028bffe8dbe72248481550def7f3b86fd
Rust
c0d3x42/pico-rs
/picolang/src/commands/execution.rs
UTF-8
1,897
2.8125
3
[]
no_license
use std::collections::HashMap; use crate::context::PicoContext; use crate::errors::PicoError; //use crate::state::PicoState; use crate::rules::PicoRules; use crate::runtime::PicoRuntime; //use crate::values::PicoValue; use anyhow::Result as AnyHowResult; use serde_json::Value as PicoValue; #[derive(Clone, Debug)] pub...
true
efde925c2927476a59a727c5e7f2a81e3e11ca45
Rust
Noah2610/hello-specs-physics
/src/components/decrease_velocity.rs
UTF-8
3,208
3.46875
3
[ "Unlicense" ]
permissive
use super::component_prelude::*; /// Entities, which have `Velocity` and `DecreaseVelocity`, will decrease their velocity /// every frame, by a certain amount (`x`, `y`). /// Note that, the given `x` and `y` fields must _always_ be positive. #[derive(Serialize, Deserialize)] pub struct DecreaseVelocity { pub x: f3...
true
6fae70074fab5d7bc35fad580d3576cf7c0afdfd
Rust
romgrk/vim-clap
/crates/matcher/src/algo.rs
UTF-8
4,368
2.84375
3
[ "MIT" ]
permissive
use structopt::clap::arg_enum; use source_item::{MatchTextFor, MatchType}; use crate::MatchResult; // Implement arg_enum for using it in the command line arguments. arg_enum! { /// Supported line oriented String match algorithm. #[derive(Debug, Clone)] pub enum Algo { Skim, Fzy, SubString, ...
true
f1141930b9c9c801f477a5692fea8488c275c2ff
Rust
marcinioski/rust_playground
/matching_enums/src/main.rs
UTF-8
1,084
3.84375
4
[]
no_license
enum EMessage { Wrong, ErrorValue (u32), Message(String) } impl EMessage { fn show(&self) -> Option<u32> { match self { EMessage::Wrong => { println!("Wrong value"); None }, EMessage::ErrorValue(value) => { println!("Got error value: {}", value); Some(1)}, EM...
true
af95fbeff3b49139e245515e22f2f3b448ae4adc
Rust
ValentinoVizner/rust_crash_course_traversy
/src/conditionals.rs
UTF-8
583
4.125
4
[]
no_license
// Conditionals - Used to check the conditons of something and act upon it pub fn run() { let age = 22; let check_id = true; let knows_person = true; // If/Else if age >= 21 && check_id || knows_person { println!("Bartender: What would you like to drink?"); } else if age <= 21 && check...
true
dfc786727ea1c25ac97671662e00b7df85ffd908
Rust
morimolymoly/rust-is-fun
/hash/src/main.rs
UTF-8
251
3.015625
3
[]
no_license
fn main() { use std::collections::HashMap; let mut scores: HashMap<String, u32> = HashMap::new(); scores.insert(String::from("電通大"), 10); scores.insert(String::from("でんとぅー大"), 100); println!("Hello, world!"); }
true
2efa5d6d1ea8c81554b2e4fe1b8c876744fcb80c
Rust
kn-shimada/Whiteye
/src/machine.rs
UTF-8
7,142
3.296875
3
[]
no_license
use core::panic; use std::collections::HashMap; use std::convert::TryInto; use std::error::Error; use crate::ast::{ AssignmentOpKind, Ast, ComparisonOpKind, ExprOpKind, LogicalOpKind, UnaryOpKind, ValueType, }; use crate::{builtin_functions, value::Value}; #[derive(Debug, thiserror::Error)] pub enum MachineError...
true
b9f513d2ce31cf4a832edd83be0b7043d25d454d
Rust
AnvilMC/anvil_bedrock
/raknet/src/protocol/connected_ping.rs
UTF-8
572
2.71875
3
[ "Apache-2.0" ]
permissive
use crate::prelude::{RaknetPacket, RaknetPacketData}; #[derive(Debug)] pub struct ConnectedPing { pub time: u64, } impl RaknetPacketData for ConnectedPing { fn decode(reader: &mut impl crate::prelude::Reader) -> Option<Self> { Some(Self { time: u64::decode(reader)?, }) } f...
true
eaa2c343321971bb76925cea90179ed6527b32e4
Rust
mwilliammyers/async-graphql
/integrations/tide/src/lib.rs
UTF-8
4,755
2.734375
3
[ "MIT", "Apache-2.0" ]
permissive
//! Async-graphql integration with Tide #![warn(missing_docs)] #![allow(clippy::type_complexity)] #![allow(clippy::needless_doctest_main)] #![forbid(unsafe_code)] use async_graphql::http::MultipartOptions; use async_graphql::{resolver_utils::ObjectType, Schema, SubscriptionType}; use async_trait::async_trait; use std...
true
ff2c224b8dbbe6d3e7a3212f6f692b4cf7c813f8
Rust
c86j224s/snippet
/Rust_Winapi_Serde/run/src/app.rs
UTF-8
2,440
2.859375
3
[ "Apache-2.0" ]
permissive
use crate::file_read::read_file_all; use std::io::Result; use std::io::prelude::*; use std::fmt::Debug; use std::process::{Command, Stdio}; use serde_json; use serde::{Serialize, Deserialize}; #[derive(Serialize, Deserialize, Debug)] pub enum BuildConfiguration { Debug, Release, } #[derive(Serialize, Dese...
true
a8b6bbd2b1fc845ab48c596a277a65d993bdc25a
Rust
kalkyl/aoc-2020
/src/bin/6a.rs
UTF-8
355
3.015625
3
[]
no_license
use std::{collections::HashSet, fs::read_to_string, io::Error}; fn unique(s: &str) -> HashSet<char> { s.chars().filter(|&c| c != '\n').collect() } fn main() -> Result<(), Error> { let input = read_to_string("./input/6.txt")?; let result = input.split("\n\n").fold(0, |acc, s| acc + unique(s).len()); pr...
true
7537b519c5b763b79458850ba9e1d881693f992c
Rust
wehjin/smarket
/src/basics.rs
UTF-8
281
2.890625
3
[]
no_license
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd)] pub enum SharePrice { Float(f64) } impl SharePrice { pub fn as_f64(&self) -> f64 { match self { SharePrice::Float(f) => *f, } } } impl From<f64> for SharePrice { fn from(value: f64) -> Self { SharePrice::Float(value) } }
true
39b9ee6d415891a9f4bf16d6ae56989b739fdd9a
Rust
thegedge/fittle
/profile-gen/src/helpers/sorted.rs
UTF-8
3,881
2.828125
3
[ "MIT" ]
permissive
use std::collections::HashMap; use handlebars::{ Context, Handlebars, Helper, HelperResult, Output, PathAndJson, Renderable, RenderContext, RenderError, Template, }; use serde::Serialize; use serde_json::value::{ Value as Json, to_value, }; pub fn sorted(h: &Helper, r...
true
5e643d02d3ee1ea9ae3684ce137c3fd99c7f302a
Rust
wapm-packages/lolcat
/src/main.rs
UTF-8
3,738
2.796875
3
[ "MIT" ]
permissive
extern crate clap; extern crate getrandom; extern crate rand; use clap::{App, Arg}; use rand::Rng; use std::fs::File; use std::io; use std::io::BufRead; use std::io::BufReader; use std::thread::sleep; use std::time::Duration; mod cat; fn main() { let mut filename: String = "".to_string(); let mut c = parse_cl...
true
1c4e8b3ffc5f5a76a34c0f137c154ae68546672b
Rust
sangwon090/loco.rs
/src/internal/xvc_key.rs
UTF-8
477
2.65625
3
[ "Apache-2.0" ]
permissive
use sha2::{Digest, Sha512}; use std::ops::Deref; pub struct XVCKey { key: String, } impl XVCKey { pub fn new(header: &str, email: &str, device_uuid: &str) -> Self { XVCKey { key: hex::encode(Sha512::digest( format!("HEATH|{}|DEMIAN|{}|{}", header, email, device_uuid).as_byt...
true
09d1e760aa499dadee97d51532bc20be15d72d81
Rust
remexre/serde_sexpr
/src/ser.rs
UTF-8
9,333
3.328125
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use crate::{Error, Result, Value}; use serde::ser::{ Serialize, SerializeMap, SerializeSeq, SerializeStruct, SerializeStructVariant, SerializeTuple, SerializeTupleStruct, SerializeTupleVariant, }; use std::{fmt::Display, io::Write, str::from_utf8}; /// Serialize the given data structure as an S-Expression into...
true
5815339618951ae0ec92c25b4c6d081791408fa4
Rust
flier/grpc-rust
/src/method.rs
UTF-8
2,589
3.046875
3
[]
no_license
use marshall::*; pub struct MethodDescriptor<Req, Resp> { pub name: String, pub client_streaming: bool, pub server_streaming: bool, pub req_marshaller: Box<Marshaller<Req> + Sync + Send>, pub resp_marshaller: Box<Marshaller<Resp> + Sync + Send>, } pub trait MethodHandler<Req, Resp> { fn handl...
true
01e85d2b52c48270cfb2006a441e8ffebca4e76c
Rust
Telixia/leetcode-3
/Medium/1138-Alphabet Board Path/Solution.rs
UTF-8
1,140
3.03125
3
[]
no_license
impl Solution { pub fn alphabet_board_path(target: String) -> String { let mut s = (0, 0); let mut ret = String::new(); for c in target.bytes() { let t = ((c - b'a') / 5, (c - b'a') % 5); ret = ret + &Self::path_to(s, t) + "!"; s = t; } r...
true
16cbc20670f736002a3f9fa795779206ec341eb4
Rust
BitpingApp/bping
/src/display/progress_bar.rs
UTF-8
1,290
2.578125
3
[]
no_license
use crate::{app_config, custom_validators}; use super::emojis; pub fn get_progress_bar_text(endpoint: &str, regions: &Vec<String>) -> String { let config = app_config::get_configuration(); let regions_display = match regions.len() { 0 => { let mut world_message = "Worldwide".to_string(); if...
true
3627f577b31d2af3ba978069176e909570a0ebd8
Rust
jeysal/rust-playground
/collections/src/num_stats.rs
UTF-8
1,561
3.5625
4
[]
no_license
use std::collections::HashMap; #[derive(PartialEq, Debug)] pub struct NumStats { avg: f64, med: f64, mode: i32, } pub fn num_stats(numbers: Vec<i32>) -> Option<NumStats> { if numbers.is_empty() { None } else { Some(NumStats { avg: avg(&numbers), med: med(&numbers), mode: mode(&numbe...
true
168814648f976202a8db8e74a2809d3137b02212
Rust
jean553/rust-memo
/closures/src/main.rs
UTF-8
1,503
3.953125
4
[]
no_license
fn main() { /* the current context can be consumed by the closure, "param" is borrowed as immutable (the closure implements "Fn" trait) */ let param = 10; let closure = |p| { p == param }; println!("{}", param); // "param" is still usuable println!("{}", closure(10)); /* the...
true
95ef68a312c4add69dd8c7afe3b715c9546728b7
Rust
elihunter173/yamlisp
/src/ser.rs
UTF-8
2,805
3.09375
3
[]
no_license
use lexpr::Value; use serde::ser::{SerializeSeq, SerializeMap, SerializeTuple}; use serde::{Serialize, Serializer}; use crate::LispIR; fn serialize_special<T, S>(serializer: S, typ: &str, val: T) -> Result<S::Ok, S::Error> where T: Serialize, S: Serializer, { let mut tup = serializer.serialize_map(Some(1...
true
2bd0ff27b14e8de9c977eadb0e1e33b97d5e9163
Rust
shirvan/fastlyzer
/src/errors.rs
UTF-8
403
2.625
3
[ "Unlicense", "MIT" ]
permissive
use failure::Fail; use std::io; /// Error variants. #[derive(Fail, Debug)] pub enum FastlyzerErr { /// IO Errors. #[fail(display = "{}", _0)] Io(#[cause] io::Error), } impl From<io::Error> for FastlyzerErr { fn from(err: io::Error) -> FastlyzerErr { FastlyzerErr::Io(err) } } /// Fastlyzer...
true
8be973b8eab237f34217fff626284e31ab9fe4ba
Rust
tchagnon/raylang-rust
/src/bounding_box.rs
UTF-8
1,823
3.234375
3
[ "MIT" ]
permissive
use math::Vec3f; use ray_tracer::Ray; use std::f32; #[derive(Debug, Clone, Deserialize, PartialEq)] pub struct BoundingBox { pub min: Vec3f, pub max: Vec3f, } impl BoundingBox { /** * Determine if the ray intersects the bounding box. * * For all 3 axes, calculate the intersection distances ...
true
c9f0d7ab692dad0ebc5b39af004e7b6fbfb928fe
Rust
jamie-c-starling/advent-of-code-2020
/src/bin/10_2.rs
UTF-8
1,020
3.171875
3
[]
no_license
use std::collections::HashMap; use std::fs; fn main() { let contents = fs::read_to_string("src/bin/resources/10_input.txt") .expect("Something went wrong reading the file"); let mut lines: Vec<usize> = contents .lines() .map(|x| x.parse::<usize>().unwrap()) .collect(); lin...
true
ccc4eccafd3791389bee2efb70e9e9b128fa6c26
Rust
utilForever/BOJ
/Rust/2873 - LUNAPARK.rs
UTF-8
3,768
2.875
3
[ "MIT" ]
permissive
use io::Write; use std::{io, str}; pub struct UnsafeScanner<R> { reader: R, buf_str: Vec<u8>, buf_iter: str::SplitAsciiWhitespace<'static>, } impl<R: io::BufRead> UnsafeScanner<R> { pub fn new(reader: R) -> Self { Self { reader, buf_str: vec![], buf_iter: ""...
true
562fb711bc19ec3675c733e9954066ef354387c7
Rust
JonathanLorimer/tendermint-rs
/pbt-gen/src/time.rs
UTF-8
5,460
3
3
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
//! Provides [proptest](https://github.com/AltSysrq/proptest) generators for //! time-like objects. use std::convert::TryInto; use chrono::{DateTime, NaiveDate, TimeZone, Timelike, Utc}; use proptest::prelude::*; /// Any higher, and we're at seconds pub const MAX_NANO_SECS: u32 = 999_999_999u32; /// The most distan...
true
feec2d367847d397733d1c5d334d3b8493e63851
Rust
pglizniewicz/advanced-data-streaming-1
/src/main.rs
UTF-8
12,494
2.8125
3
[]
no_license
use async_std::prelude::*; use async_std::stream; use chrono::prelude::*; use clap::Clap; use futures::future; use std::io::{Error, ErrorKind}; use std::time::Duration; use yahoo_finance_api as yahoo; use async_trait::async_trait; use xactor::*; use std::fs::File; use std::io::BufWriter; use std::io::Write; #[derive(C...
true
0ae9a662d4c90e911f1a08e3fd968de8a6f2c5eb
Rust
maxtnuk/My_workspace
/rust/crate_test/rain/src/main.rs
UTF-8
802
3.03125
3
[]
no_license
extern crate rain; use rain::Graph; macro_rules! error { ($x:expr) => {{$x.expect("error graph")}}; } fn main() { // Get a drawing area let mut graph = Graph::new(); // Get some line identifiers let l1 = "Line 1"; let l2 = "Line 2"; let l3 = "Line 3"; // Add some values and print a...
true
c96fef1f83da295d4b3e802db1fd220580059eeb
Rust
szabo137/ptarmigan
/src/field/mod.rs
UTF-8
5,685
2.734375
3
[ "Apache-2.0" ]
permissive
//! Representation of the electromagnetic field in the simulation domain use rand::prelude::*; use crate::geometry::FourVector; mod focused_laser; mod fast_focused_laser; mod plane_wave; mod fast_plane_wave; pub use self::focused_laser::*; pub use self::fast_focused_laser::*; pub use self::plane_wave::*; pub use sel...
true
a61deb08c13c0900a144b1b42147f270bde0d1f0
Rust
E3-NICU/leche.github.io
/code/src/models/future.rs
UTF-8
737
2.59375
3
[ "MIT" ]
permissive
#![allow(unused, unreachable_code, unused_variables)] // When implementing this remove the #[allow(unused, unreachable_code, unused_variables)] line! use std::ops::Range; use crate::models::base::Model; use crate::constants::{BREAK, PARAMS90, PARAMS360, CORRECTION}; #[derive(Default)] pub struct FutureModel; impl ...
true
478d8dfebd646b97b470bab40b8e5db0bc99bbfa
Rust
koompi/koompi-desktop
/desktop/src/desktop_item.rs
UTF-8
7,092
2.53125
3
[ "MIT" ]
permissive
mod desktop_entry; mod desktop_item_error; mod desktop_item_status; mod desktop_item_type; use super::constants::{TYPE, DESKTOP_ENTRY, ICON, NAME, COMMENT, DEFAULT_APPS, MIME_FILE, MIME_INFO_CACHE, MIME_CACHE, INODE_DIR}; use std::path::{PathBuf, Path}; use std::str::FromStr; use std::convert::From; use desktop_item_t...
true
6bfe57c941aa154029f4af67666de777cfd38941
Rust
ahmedwagd/rust
/src/print_fn.rs
UTF-8
627
3.71875
4
[]
no_license
pub fn run() { // Print to Console println!("Hello From Print.rs File"); // Basic formatting println!("Number: {}", 2); println!("{} is here, Iam from {}", "Ahmed", "Egypt"); //Positional Arguments println!("{0} is form {1}, and {0} likes to {2}","Ahmed","Egypt", "code"); // Named Arg...
true
bcf27ad98abac5c84c64f102b50d07ff6f632600
Rust
ZcashFoundation/librustzcash
/zcash_primitives/src/memo.rs
UTF-8
17,742
3.46875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Structs for handling encrypted memos. use std::cmp::Ordering; use std::convert::{TryFrom, TryInto}; use std::error; use std::fmt; use std::ops::Deref; use std::str; /// Format a byte array as a colon-delimited hex string. /// /// - Source: <https://github.com/tendermint/signatory> /// - License: MIT / Apache 2.0 ...
true
6a155741b9600b0233ede43b5f735f6a3faf075b
Rust
ComanAdrian/exercism
/armstrong-numbers/src/lib.rs
UTF-8
219
2.96875
3
[]
no_license
pub fn is_armstrong_number(num: u32) -> bool { let mut result: u32 = 0; for c in num.to_string().chars() { result += c.to_digit(10).unwrap().pow(num.to_string().len() as u32) } result == num }
true
92ea3cbcf51e5b6d5e0fb657497ff4cce0439da3
Rust
mksyposz/aoc2020
/src/day18.rs
UTF-8
4,839
3.703125
4
[]
no_license
pub fn run<R>(input: R) -> (String, String) where R: std::io::BufRead, { let expressions: Vec<String> = input.lines().map(|s| s.unwrap()).collect(); let ans1 = part_one(&expressions); let ans2 = part_two(&expressions); (ans1, ans2) } fn part_one(exps: &Vec<String>) -> String { exps.iter() ...
true
9c8990faac54a524ba453622b4543a39c4e82bf6
Rust
D1plo1d/async-graphql
/src/extensions/analyzer.rs
UTF-8
2,424
3.28125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::extensions::{Extension, ExtensionContext, ExtensionFactory}; use crate::{value, ValidationResult, Value}; /// Analyzer extension /// /// This extension will output the `analyzer` field containing `complexity` and `depth` in the response extension of each query. pub struct Analyzer; impl ExtensionFactory fo...
true
e92a77b91df626cd7b65bd76795bf75c11916594
Rust
sugyan/leetcode
/others/september-leetcoding-challenge/week-2/3456/lib.rs
UTF-8
749
3.328125
3
[]
no_license
pub struct Solution {} impl Solution { pub fn max_product(nums: Vec<i32>) -> i32 { let mut answer = std::i32::MIN; let mut m = (1, 1); for &num in nums.iter() { m = if num > 0 { (std::cmp::min(m.0 * num, num), std::cmp::max(m.1 * num, num)) } else { ...
true
89307f6907e5c9a5a33d4969e393fcb02acad74b
Rust
darkhypervisor/rustos-hv
/kern/src/process/scheduler.rs
UTF-8
5,817
3.03125
3
[]
no_license
use alloc::boxed::Box; use alloc::collections::vec_deque::VecDeque; use core::fmt; use aarch64::*; use crate::mutex::Mutex; use crate::param::{PAGE_MASK, PAGE_SIZE, TICK, USER_IMG_BASE}; use crate::process::{Id, Process, State}; use crate::traps::TrapFrame; use crate::VMM; /// Process scheduler for the entire machin...
true
f92ac3ec0dc000d960295ce162e6a480f1be90cd
Rust
howlowck/learn-ml-in-rust
/src/simple_forward.rs
UTF-8
1,257
2.890625
3
[]
no_license
use crate::colors; pub fn multi_to_multi_no_hidden_layers() { let toes: Vec<f32> = vec![8.5, 9.5, 9.9, 9.0]; let winloss: Vec<f32> = vec![0.65, 0.8, 0.8, 0.9]; let fans: Vec<f32> = vec![1.2, 1.3, 0.5, 1.0]; let weights: Vec<Vec<f32>> = vec![ vec![0.3, 0.1, 0.4], vec![0.1, 0.2, 0.0], ...
true
74e246f004a2a93a573d81323e6518345d7f8f17
Rust
makarski/esurvey
/src/sheets/basic_chart.rs
UTF-8
9,512
3.03125
3
[ "MIT" ]
permissive
use serde_derive::{Deserialize, Serialize}; use super::spreadsheets; #[derive(Deserialize, Serialize, Debug)] #[serde(rename_all = "camelCase")] pub struct BasicChartSpec { pub chart_type: BasicChartType, pub legend_position: BasicChartLegendPosition, pub axis: Vec<BasicChartAxis>, pub domains: Vec<Ba...
true
876a77c673312a8763b7ed7093d8a9359e031772
Rust
davidji/ciborium
/ciborium/src/value/mod.rs
UTF-8
2,671
2.9375
3
[ "Apache-2.0" ]
permissive
// SPDX-License-Identifier: Apache-2.0 //! A dynamic CBOR value mod float; mod integer; mod de; mod error; mod ser; pub use error::Error; pub use float::{Float, TryFromFloatError}; pub use integer::Integer; use alloc::{boxed::Box, string::String, vec::Vec}; use core::convert::TryFrom; /// A representation of a dy...
true
c38a1857b7f4a52b21d20afd07638ac2ad004c01
Rust
tinkerware/graphsurge
/src/query_handler/serde/mod.rs
UTF-8
680
2.671875
3
[ "Apache-2.0" ]
permissive
pub mod executor; #[derive(new)] pub struct Serde { operation: Operation, bin_dir: String, threads: usize, block_size: Option<usize>, } #[derive(Eq, PartialEq)] pub enum Operation { SerializeGraph, DeserializeGraph, SerializeCollection(String), DeserializeCollection, } impl std::fmt::...
true
aedf317edd4a2718dc80286bdf51f1db8e7daa40
Rust
standardgalactic/oak-1
/tests/grammars/stream_span.rs
UTF-8
1,926
2.515625
3
[ "Apache-2.0" ]
permissive
// Copyright 2016 Pierre Talbot (IRCAM) // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to...
true
12d15178809e07ec37461d157dee38adc8a15e05
Rust
southbambird/sandbox
/rust/projects/practice3/src/main.rs
UTF-8
1,050
3.34375
3
[]
no_license
fn main() { print_lyrics(); } fn to_celsius(f: f32) -> f32 { (5.0 / 9.0) * (f - 32.0) } fn to_fahrenheit(c: f32) -> f32 { (c * 1.8) + 32.0 } fn print_lyrics() { let lyrics = [ "A partridge in a pear tree", "Two turtle doves", "Three French hens", "Four calling birds", ...
true
35badf5a6b6946287a259bf0d847f4f6e8f0f913
Rust
StephanBischoff-Digle/adventofcode
/2021/07/07.2/d072/src/main.rs
UTF-8
851
3.234375
3
[]
no_license
use std::fs; fn find_min(lst: &[i32]) -> i32 { let mut start = *lst.iter().min().expect("Find Minimum in lst."); let mut prev = lst .iter() .map(|l| ((start - l).abs() * ((start - l).abs() + 1)) / 2) .sum(); let mut current = prev; while prev >= current { st...
true
2138a8ce92df140e9cabff14a7fc47fa48e6cce2
Rust
siddharthborderwala/vector-space-model-rs
/src/vsm/posting_list.rs
UTF-8
651
2.9375
3
[]
no_license
use std::collections::HashMap; pub type DocId = usize; pub type Frequency = usize; pub type TFWeight = f64; #[derive(Debug)] pub struct PostingList { pub document_frequency: Frequency, pub dimension_map: HashMap<DocId, TFWeight>, } impl PostingList { pub fn new() -> Self { PostingList { ...
true
c55d22b533bb5a5c483c15713d3b103524a95697
Rust
dylanbraithwaite/cubical
/src/ast/terms/functions/pi.rs
UTF-8
1,985
2.9375
3
[]
no_license
use std::fmt::{Display, Formatter, Error as FmtErr}; use crate::ast::traits::*; use crate::ast::{Term, Expr}; use crate::context::Context; use crate::interval::IntervalDnf; #[derive(Clone, Debug, PartialEq, Eq)] pub struct Pi { pub source: Box<Term>, pub target: Box<Term>, } impl Pi { pub fn new(source: ...
true
7ef79256b583fe15636a55c749e0c23985d28788
Rust
rachel-s-c/rust_HeuristicGameTree
/src/general_game.rs
UTF-8
2,519
4.125
4
[]
no_license
use crate::checkers::start_checkers; use crate::connect4::start_con; use crate::tictactoe::start_tic; /// Starts the game after the player runs the program with the selected game. /// /// Available options are Tic-tac-toe, Connect4, and Checkers. /// # Arguments /// * `game` - A usize that holds the number correspondi...
true
b58c9ca598eca7f04e04582b5ff73d1de95fa684
Rust
FyroxEngine/Fyrox
/src/scene/light/point.rs
UTF-8
5,418
2.828125
3
[ "MIT" ]
permissive
//! Point light can be represented as light bulb which hangs on wire - it is //! spherical light source which emits light in all directions. It has single //! parameter - radius at which intensity will be zero. Intensity of light will //! be calculated using inverse square root law. //! //! # Light scattering //! //! P...
true
6e9663e4d8fe75e66b40a15302d4133f93baec82
Rust
slowli/arithmetic-parser
/typing/tests/integration/annotations.rs
UTF-8
19,437
2.796875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Tests with explicit type annotations. use assert_matches::assert_matches; use arithmetic_parser::grammars::Parse; use arithmetic_typing::{ defs::Prelude, error::{ErrorContext, ErrorKind, ErrorLocation}, TupleLen, Type, TypeEnvironment, UnknownLen, }; use crate::{assert_incompatible_types, hash_fn_typ...
true
e6881978af64c2b536c77f4365f1621cd5ade12a
Rust
guyoung/CaptfEncoder
/CaptfEncoder-V3/encoding/src/classical/affine.rs
UTF-8
1,279
2.765625
3
[]
no_license
use std::collections::HashMap; use super::internal::anyhow::Result; use super::internal::anyhow::*; use crate::EncodingResult; use crate::get_option; pub fn encode(input: &str, options: Option<HashMap<String, String>>) -> Result<EncodingResult> { use super::internal::cipher_crypt::{Affine, Cipher}; ...
true
bcfb55fb4a3b2f34052b9f2f87f022c66f4ea9a7
Rust
carlpehrson/coauthor
/src/main.rs
UTF-8
3,836
3
3
[]
no_license
mod cli_input; mod coauthor; mod coauthors_file; mod git_commit_template_file; mod github_api; mod input_command; use coauthor::Coauthor; use exitfailure::ExitFailure; use input_command::{InputCommand, UserType}; use std::env; fn main() -> Result<(), ExitFailure> { let args: Vec<String> = env::args().collect(); ...
true
30b5cabe7f47014f5db8bed0a58188762b509960
Rust
TCherici/rust_base_nn
/src/main.rs
UTF-8
2,363
2.59375
3
[ "MIT" ]
permissive
mod nnet; mod activation; mod layers; mod losses; use ndarray::{array}; use ndarray::prelude::*; use nnet::NNet; use rust_mnist::{print_sample_image, Mnist}; use rand::seq::SliceRandom; use rand::thread_rng; const INPUT_SIZE: u16 = 28 * 28; const OUTPUT_SIZE: u16 = 10; fn main() { let nnet_topology: Array1...
true
101defb91028c10d660835bd1f0b0999b1716eb4
Rust
DrunkFlamingo/kailua
/kailua_check/src/options.rs
UTF-8
6,031
3.03125
3
[ "MIT", "Apache-2.0" ]
permissive
//! The user-configurable portion of the type checker. use std::str; use std::ascii::AsciiExt; use std::path::{Path, PathBuf, MAIN_SEPARATOR}; use kailua_env::{Spanned, WithLoc}; use kailua_diag::{Report, Stop}; use kailua_syntax::Chunk; /// Options for customizing the type checker. /// /// All of those methods retu...
true
bb2d9546980a2e5bef851a3a2386c633a7217e71
Rust
aetherknight/fractal-rs
/fractal-lib/src/chaosgame/barnsleyfern.rs
UTF-8
3,689
2.703125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright (c) 2015-2019 William (B.J.) Snow Orvis // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicab...
true
e43c2b5b73d287f4c7e0ee8a88a03994074e9b20
Rust
rafaelbm9126/rust-crud
/src/models/persons.rs
UTF-8
1,041
2.828125
3
[]
no_license
use mongodb::{ oid::ObjectId, }; #[derive(Serialize, Deserialize, Debug)] pub struct Person { #[serde(rename="_id")] pub id: Option<ObjectId>, pub name: String, pub age: i32, } graphql_object!(Person: () |&self| { field id() -> String { if let Some(ref id) = self.id { id.to_hex() } else...
true
da708b8ab70b88271931a05bad2e618ca0de6725
Rust
zwhitchcox/leetcode_rs
/src/_0530_minimum_absolute_difference_in_bst.rs
UTF-8
1,378
3.609375
4
[ "MIT" ]
permissive
struct Solution; struct TreeNode { val: i32, left: Link, right: Link, } use std::cell::RefCell; use std::i32; use std::rc::Rc; type Link = Option<Rc<RefCell<TreeNode>>>; impl TreeNode { fn branch(val: i32, left: Link, right: Link) -> Link { Some(Rc::new(RefCell::new(TreeNode { val, left, rig...
true
f6f24098a2836c15dc2216345d9040cb279ee079
Rust
tamamu/100-days-of-code
/codes/pascals_triangle2.rs
UTF-8
1,302
2.984375
3
[]
no_license
// static mut MEMO: [[i32; 34]; 34] = [[0; 34]; 34]; struct Solution {} impl Solution { pub fn get_row(row_index: i32) -> Vec<i32> { let row_indexu = row_index as usize; let mut result = vec![1]; if row_index > 0 { result.resize(row_indexu + 1, 0); let upper_row = Sol...
true
1709bd9b929b69399b414c0a20e25b181b8ad311
Rust
pandaman64/RegExpr
/src/automaton.rs
UTF-8
12,183
2.9375
3
[]
no_license
use std::collections::HashSet; use std::collections::HashMap; use std::collections::BTreeSet; use std::io::Write; use parser::RegExpr; pub struct NodeAllocator { nodes: Vec<Node>, } impl NodeAllocator { pub fn new() -> NodeAllocator { NodeAllocator { nodes: vec![] } } } #[derive(PartialEq,Eq,Par...
true
ea2dcfd75ac0beaf5eb57becfe0ed7491fbf1790
Rust
mcasper/dogstatsd-rs
/src/error.rs
UTF-8
1,016
3.1875
3
[ "MIT" ]
permissive
use std::error::Error; use std::{fmt, io}; /// This type represents the possible errors that can occur while /// sending DogstatsD metrics. #[derive(Debug)] pub enum DogstatsdError { /// Chained IO errors. IoError(io::Error), } use self::DogstatsdError::*; impl fmt::Display for DogstatsdError { fn fmt(&s...
true