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
8d772e6588eaf7fbaa3012e3bfefce62f6255328
Rust
yatender-oktalk/fun-rust
/play_with_vectors/src/main.rs
UTF-8
1,025
3.921875
4
[]
no_license
//! #[derive(Debug)] struct Human { name: String, age: Option<u16>, } impl Human { pub fn new(n: String, a: Option<u16>) -> Self { Self { name: n, age: a } } } fn main() { let mut v: Vec<i32> = Vec::new(); push_in_list(&mut v, 23); push_in_list(&mut v, 33); push_in_list(&mut v...
true
9918bc0a073d3851844300ad32d5ef2e83dd93a8
Rust
kklibo/panorama-explorer
/src/photo.rs
UTF-8
5,720
3.109375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use std::rc::Rc; use std::fmt::{Display,Formatter}; use three_d::{Mat4,Texture,InnerSpace}; use serde::{Serialize, Deserialize, Serializer}; use serde::ser::SerializeStruct; pub use crate::entities::LoadedImageMesh; use crate::viewport_geometry::{WorldCoords, PixelCoords}; use crate::world_rectangle::{WorldRectangle...
true
2d434de272daa220cf3cf98bbd35ad2d1b81d34e
Rust
joephon/PoloDB
/src/polodb_core/meta_doc_helper.rs
UTF-8
3,245
2.6875
3
[ "MIT" ]
permissive
use polodb_bson::{Document, Value, mk_document}; use std::rc::Rc; use crate::DbResult; use crate::error::DbErr; /// root_btree schema /// { /// _id: String, /// name: String, /// root_pid: Int, /// flags: Int, /// } /// /// flags indicates: /// key_ty: 1byte /// ... /// pub(crate) struct MetaDocEntry { nam...
true
a9723ebc52864227a7fde3e20647415f5ab8ffa0
Rust
davidpdrsn/oops-lang
/src/prep/mod.rs
UTF-8
9,760
2.703125
3
[]
no_license
use crate::ast::{visit_ast, Ast, Visitor}; use crate::{ ast::{self, Ident}, error::{Error, Result}, interpret::{ClassVTable, VTable}, Span, }; use std::{collections::HashMap, rc::Rc}; pub type Classes<'a> = VTable<'a, Rc<Class<'a>>>; pub fn find_classes_and_methods<'a>( ast: &'a Ast<'a>, built...
true
611cb8859515989e081216c117599e4bbeb2b45f
Rust
Alligator/advent-of-code-2019
/day-3/src/main.rs
UTF-8
4,923
3.390625
3
[]
no_license
use std::fs; use std::collections::{HashSet, HashMap}; type Point = (i64, i64); fn get_points(path: &[&str]) -> (HashSet<Point>, HashMap<Point, i64>) { let mut current_point: Point = (0, 0); let mut points = HashSet::<Point>::new(); let mut steps = HashMap::new(); let mut total_steps = 0; points....
true
067ed15e7ce5e7faef7377ca7365d5e219952858
Rust
tatamiya/actix-web-tutorial
/application/src/main.rs
UTF-8
1,897
2.890625
3
[]
no_license
use actix_web::{get, web, App, HttpServer, HttpResponse, Responder}; use std::sync::Mutex; async fn index() -> impl Responder { "Hello world!" } struct AppState { app_name: String, } #[get("/")] async fn state(data: web::Data<AppState>) -> String { let app_name = &data.app_name; format!("Hello {}!", ...
true
6e2ddde408de01c3b7658bb7f51fd7d02461260d
Rust
greendwin/rust_ray
/src/world/scene.rs
UTF-8
1,026
2.953125
3
[]
no_license
use crate::math::*; pub trait LightDecl { fn orig(&self) -> Vec3; fn radius(&self) -> f64; fn color_at(&self, pt: Vec3) -> Vec3; } pub trait Scene { type Mat: Material; type Obj: HitRay<Self::Mat>; type Light: LightDecl; fn objs(&self) -> &[Self::Obj]; fn lights(&self) -> &[Self::Ligh...
true
88b5dc70fbe177e0ddcaf20e7e09dbffb4d5971f
Rust
KanchiShimono/rust-rocket-juniper-graphql-example
/src/db/repository.rs
UTF-8
3,012
2.96875
3
[]
no_license
use crate::db::{ models::{Person, PersonWithPosts, Post}, Db, }; use crate::graphql::schema::{CreatePersonInput, CreatePostInput}; use chrono::Utc; use diesel::result::Error; use uuid::Uuid; pub trait PersonRepository { fn find_all(&self) -> Result<Vec<Person>, Error>; fn find_by_id(&self, id: Uuid) ->...
true
064df29d49d4b6c65284677b2f90fad30d23de45
Rust
lovoror/ruffle
/core/src/avm1/globals/color.rs
UTF-8
7,142
2.765625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Color object //! //! TODO: This should change when `ColorTransform` changes to match Flash's representation //! (See GitHub #193) use crate::avm1::property::Attribute::*; use crate::avm1::return_value::ReturnValue; use crate::avm1::{Avm1, Error, Object, ScriptObject, TObject, UpdateContext, Value}; use crate::disp...
true
1ff027f567eab8468cc0b753954b9ce6074aa5e1
Rust
oli-obk/regex
/src/input.rs
UTF-8
3,213
3.0625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
true
920e392cc3bce508f48a5c9d863fe40c23fa0cd6
Rust
mrsekut/rytl
/src/lexer/lexer.rs
UTF-8
3,770
3.40625
3
[]
no_license
use crate::lexer::{LexerError, Loc, Token}; // fn recognize_many(input: &[u8], mut pos: usize, mut f: impl FnMut(u8) -> bool) -> usize { // while pos < input.len() && f(input[pos]) { // println!("pos: {:?}", pos); // println!("len: {:?}", input.len()); // pos += 1; // } // pos // } ...
true
d895644361ccf54127a89cc741d41f70e7bd15c7
Rust
18616378431/myCode
/rust/test8-39/src/main.rs
UTF-8
458
3.34375
3
[]
no_license
//字符串回顾 fn main() { let s = r"1234 5678 9876 4321"; let (mut x, mut y) = (0, 0); for (idx, val) in s.lines().enumerate() { let val = val.trim(); let left = val.get(idx..idx+1).unwrap().parse::<u32>().unwrap(); let right = val.get((3 - i...
true
2e70401732620bdd078944c51688846ee5ce0c5c
Rust
mattmahn/rosetta-code
/tasks/cum-stdev/rust/src/main.rs
UTF-8
673
3.6875
4
[ "Unlicense" ]
permissive
pub struct CumulativeStandardDeviation { n: f64, sum: f64, sum_sq: f64 } impl CumulativeStandardDeviation { pub fn new() -> Self { CumulativeStandardDeviation { n: 0., sum: 0., sum_sq: 0. } } fn push(&mut self, x: f64) -> f64 { self.n...
true
7f22d79324bc0b01611a15a97f1b7d6345cd459d
Rust
Farooq-azam-khan/rust-practice
/borrow2.rs
UTF-8
230
3.546875
4
[]
no_license
fn main() { let mut s1 = String::from("Hello"); let len = string_len(&mut s1); println!("{} has {} chars", s1, len); } fn string_len(word: &mut String) -> usize { word.push_str(", world"); word.len() }
true
31e5c200fdaa6adf66b9dde168b61241044651cd
Rust
silverweed/ecsde
/ecs_game/src/spatial.rs
UTF-8
13,139
2.546875
3
[]
no_license
use inle_alloc::temp::*; use inle_app::app::Engine_State; use inle_ecs::ecs_world::{Ecs_World, Entity, Evt_Entity_Destroyed}; use inle_events::evt_register::{with_cb_data, wrap_cb_data, Event_Callback_Data}; use inle_math::vector::Vec2f; use inle_physics::collider::C_Collider; use inle_physics::phys_world::{Collider_Ha...
true
a9a5c4c9549a95c9da984863b8cf7e28092d624e
Rust
baitcenter/sled
/crates/sled/src/node.rs
UTF-8
7,492
2.859375
3
[ "Apache-2.0", "MIT" ]
permissive
use std::{fmt, mem::size_of}; use super::*; #[derive(Clone, PartialEq, Serialize, Deserialize)] pub(crate) struct Node { pub(crate) data: Data, pub(crate) next: Option<PageId>, pub(crate) lo: IVec, pub(crate) hi: IVec, pub(crate) merging_child: Option<PageId>, pub(crate) merging: bool, } impl...
true
f90234ba82ae6210d218545be97354487e2a964a
Rust
lianhuiwang/tokamak
/src/parser2/error_handler.rs
UTF-8
3,425
3.046875
3
[ "Apache-2.0" ]
permissive
extern crate term; pub use self::Level::*; use std::cell::Cell; use std::fmt; use codemap::{MultiSpan}; #[derive(Copy, PartialEq, Clone, Debug)] pub enum Level { Bug, Fatal, // An error which while not immediately fatal, should stop the compiler // progressing beyond the current phase. PhaseFatal, Error...
true
93f7788948110b906462bcc5836954c931544ec6
Rust
thomashk0/chip8-rs
/packages/chip8/src/screen.rs
UTF-8
1,604
2.96875
3
[ "MIT" ]
permissive
type Point2i = (i32, i32); pub const CHIP8_FB_W: usize = 64; pub const CHIP8_FB_H: usize = 32; pub type Chip8Fb = [u32; CHIP8_FB_W * CHIP8_FB_H]; #[derive(Clone)] pub struct Screen { inverted_y: bool, fb: Chip8Fb, width: u32, height: u32, } impl Screen { pub fn new() -> Self { Screen { ...
true
08582e72c9372fcf9c746d54461d48e31f4f26ce
Rust
Rantanen/intercom
/intercom-common/src/idents.rs
UTF-8
1,586
2.53125
3
[ "MIT" ]
permissive
use crate::prelude::*; use crate::tyhandlers::ModelTypeSystem; use syn::{Ident, Path}; pub trait SomeIdent { fn get_some_ident(&self) -> Option<Ident>; } impl SomeIdent for Path { fn get_some_ident(&self) -> Option<Ident> { self.get_ident() .cloned() .or_else(|| self.segmen...
true
2b1ec48934f11906d2a70c25108b5d203b2d566c
Rust
media-io/rs_mpegts
/src/mpegts/packet.rs
UTF-8
1,784
2.65625
3
[ "MIT" ]
permissive
use std::fmt; use mpegts::adaptation_field::AdaptationField; use mpegts::payload::Payload; use mpegts::program_association::*; use mpegts::program_map::*; #[derive(Debug, Clone)] pub struct Packet { pub transport_error_indicator: bool, pub transport_priority: bool, pub program_id: u16, pub transport_scrambli...
true
243e5b5dc8a7c1e8c4264239519675eecbe1de69
Rust
l4l/whos-online
/src/whosb.rs
UTF-8
1,289
2.640625
3
[ "MIT" ]
permissive
use telebot::bot; use telebot::functions::*; use reqwest::get; use serde_json::from_str; use tokio_core::reactor::Core; use futures::stream::Stream; use status::Map; const NO_USERS: &'static str = "No users found"; const FETCH_ERROR: &'static str = "Nothing found"; fn fetch(host: &str) -> Option<Map> { get(host...
true
9630129249a991ab73ddf3c7036ef4f26756f1f8
Rust
yujie21ic/datacannon-rs-core
/src/message_structure/kafka_queue.rs
UTF-8
342
2.59375
3
[ "Apache-2.0" ]
permissive
//! Structure and functions storing data for when kafka acts as a queue //! //! --- //! author: Andrew Evans //! --- /// Creates a kafka structure /// /// # Arguments /// * `queue` - Name of the queue /// * `default_exchange` - Exchange for te pub struct KafkaQueue{ queue: String, default_exchange: String, ...
true
1e325050de63d568e99722f04c3a955399bd8841
Rust
lilydjwg/chinese-num
/src/lib.rs
UTF-8
4,224
3.375
3
[]
no_license
//! Convert a decimal number to its Chinese form. //! //! [![Build Status](https://travis-ci.org/lilydjwg/chinese-num.svg)](https://travis-ci.org/lilydjwg/chinese-num) //! [![Crates.io Version](https://img.shields.io/crates/v/chinese-num.svg)](https://crates.io/crates/chinese-num) //! [![GitHub stars](https://img.shiel...
true
eeb9102e847eb34d29fdf87b2edbff4521ebf08e
Rust
synecdoche/pelikan
/src/rust/core/server/src/process/mod.rs
UTF-8
1,943
2.921875
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2021 Twitter, Inc. // Licensed under the Apache License, Version 2.0 // http://www.apache.org/licenses/LICENSE-2.0 mod builder; mod worker_builder; pub use builder::ProcessBuilder; pub use worker_builder::WorkerBuilder; use common::signal::Signal; use queues::QueuePairs; use std::thread::JoinHandle; //...
true
7e165052c93b69c07fdd2bf4aa9ae7fd1c954796
Rust
bytebuddha/bevy_tiled_world
/examples/utils/colliders.rs
UTF-8
4,980
2.765625
3
[]
no_license
use bevy::prelude::*; use bevy_rapier2d::prelude::*; pub fn draw_colliders( mut lines: ResMut<bevy_prototype_debug_lines::DebugLines>, query: Query<(&ColliderShape, &ColliderPosition)>, ) { for (shape, position) in query.iter() { match shape.0.as_typed_shape() { TypedShape::Cuboid(cuboi...
true
25e954ff01d7d287a2e4baab75193f236fb3e22e
Rust
whitfin/efflux
/src/lib.rs
UTF-8
1,737
2.734375
3
[ "MIT" ]
permissive
//! Efflux is a set of Rust interfaces for MapReduce and Hadoop Streaming. //! //! This crate provides easy interfaces for working with MapReduce, whether //! or not you're running on the Hadoop platform. Usage is as simple as a //! struct which implements either the `Mapper` or `Reducer` trait, as all //! other intera...
true
429d6d641cbe8615aef22571401e5314aa4970b6
Rust
Woyten/fileserver
/src/main.rs
UTF-8
1,701
2.6875
3
[ "MIT" ]
permissive
use iron::middleware::Handler; use iron::mime::Mime; use iron::prelude::*; use iron::status::Status; use staticfile::Static; use std::fs; use std::fs::ReadDir; use std::path::Path; use std::path::PathBuf; static FILE_FOLDER: &str = "www"; fn main() { let static_file_handler = Static::new(Path::new(FILE_FOLDER)); ...
true
1b11341c511b87dd9b770d99be27b805aaba22e9
Rust
nikolabr/base64rs
/src/lib.rs
UTF-8
3,224
3.375
3
[]
no_license
pub mod base64 { static BASE64_TABLE: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; fn get_ascii(ch: u8) -> u8 { match BASE64_TABLE.chars().position(|x| x == ch as char) { None => 0, Some(n) => n as u8 } } fn get_b64_char(val: u8) -...
true
810107b60d4368049d58d73dd702c5b8dc9f4921
Rust
arothstein/sandbox-rust
/the-book/03/shadowing/src/main.rs
UTF-8
798
4.375
4
[]
no_license
fn main() { let x = 5; // We can shadow a variable by using the same variable’s name and repeating the use of the let keyword as follows: let x = x + 1; let x = x * 2; println!("The value of x is: {}", x); // Shadowing is different from marking a variable as mut, because we’ll get a compile-...
true
14e00dc3fb6c55fcec1bb334ebc82ba020b5af9b
Rust
EFanZh/n-body
/src/basic_renderer.rs
UTF-8
1,785
2.8125
3
[ "MIT" ]
permissive
use crate::configuration::Color; use crate::renderer::Renderer; use cgmath::Vector2; use itertools::izip; use wasm_bindgen::JsValue; use web_sys::CanvasRenderingContext2d; pub struct BasicRenderer { canvas_context: CanvasRenderingContext2d, body_colors: Vec<String>, trail_widths: Vec<f64>, } impl BasicRen...
true
e23266534b9a41311fe49104eec99a6650a9eaea
Rust
Vicfred/codeforces-rust
/insomnia_cure_148A.rs
UTF-8
1,055
2.828125
3
[ "BSD-3-Clause" ]
permissive
// https://codeforces.com/problemset/problem/148/A // implementation, simulation, simple math use std::io; fn main() { let mut k = String::new(); io::stdin() .read_line(&mut k) .unwrap(); let k: i64 = k.trim().parse().unwrap(); let mut l = String::new(); io::stdin() .rea...
true
b31eb9662d953601504e039d375052a60afc0190
Rust
geom3trik/fft_resample
/examples/demo.rs
UTF-8
1,768
2.703125
3
[ "MIT" ]
permissive
use std::{error::Error, fs::File, io::BufReader, usize}; use fft_resample::fft_upsample; use hound::{WavReader, WavSpec, SampleFormat, WavWriter}; fn main() -> Result<(), hound::Error> { // Replace with path to test file let path = "C:/Users/Setup/Music/file_example_WAV_5MG.wav"; let mut reader = WavRead...
true
4c05ac454e5ce39285e5543013d9bd27fae4b091
Rust
SeijiEmery/subliminal
/structural_parser/src/text_style.rs
UTF-8
641
3.5
4
[ "MIT" ]
permissive
pub struct TextStyle { font: Option<String>, color: Option<Color>, size: Option<f32>, italic: Option<bool>, bold: Option<bool>, } impl Default for TextStyle { fn default () -> TextStyle { TextStyle { font: None, color: None, size: None, italic: false, bold: false } } } impl BitO...
true
77058d7ec4c60610a551e6b77abc64b8a98b6227
Rust
mchesser/platformer
/src/map.rs
UTF-8
2,903
3.078125
3
[ "MIT" ]
permissive
use std::{fs::File, io::Read, path::Path}; use anyhow::Context; use macroquad::prelude::{Rect, Vec2}; use crate::tiles::{TileInfo, TileSet}; pub struct Map { pub width: usize, pub height: usize, tiles: Vec<u16>, tileset: TileSet, } impl Map { /// Loads a map from a file pub fn load_map(path:...
true
84b82fbb5622e37e3ebdfbf0163a4f74cbfcf4b0
Rust
HappyCodingRust/async_executors
/src/tokio_ct.rs
UTF-8
5,475
2.84375
3
[ "Unlicense" ]
permissive
use { crate :: { SpawnHandle, LocalSpawnHandle, JoinHandle, join_handle::InnerJh } , std :: { sync::Arc, future::Future, sync::atomic::AtomicBool } , tokio :: { task::LocalSet, runtime::{ Runtime } } , futures_task :: { FutureObj, LocalFutureObj, Spawn, ...
true
7e852c5803efe0d60fab202ff6f01b44360f7835
Rust
rovangju/vacuum-robot-simulator
/src/geometry/vector.rs
UTF-8
1,738
3.796875
4
[]
no_license
use std::cmp; use std::fmt; use std::ops; use math::{Angle, Scalar}; #[derive(Debug, Clone, Copy)] pub struct Vector { pub x: Scalar, pub y: Scalar, } impl fmt::Display for Vector { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "({}, {})", self.x, self.y) } } impl ops::Add...
true
d36dd1e963fe5fee1c70aba9b5486e97a945cf83
Rust
Vanille-N/rask
/src/parse/mod.rs
UTF-8
2,833
2.671875
3
[ "MIT" ]
permissive
mod build; mod lex; mod split; mod util; pub use build::build; pub use lex::distribute_lex as lex; pub use split::split; use std::rc::Rc; pub use util::*; pub fn parse(src: &str) -> Vec<Result<Rc<Expr>, ParseErr>> { let symbols = split(src); if let Err(e) = symbols { return vec![Err(e)]; } let...
true
2b1e6aba5adabab5c7179b13fd62d2395bc06ca0
Rust
rust-lang/rust-analyzer
/crates/ide-assists/src/handlers/generate_default_from_enum_variant.rs
UTF-8
3,765
2.859375
3
[ "Apache-2.0", "MIT" ]
permissive
use ide_db::{famous_defs::FamousDefs, RootDatabase}; use syntax::ast::{self, AstNode, HasName}; use crate::{AssistContext, AssistId, AssistKind, Assists}; // Assist: generate_default_from_enum_variant // // Adds a Default impl for an enum using a variant. // // ``` // enum Version { // Undefined, // Minor$0, // Ma...
true
b06e4f1d03551cd08f93419ec93a7285cf13e6e8
Rust
xgillard/ddo
/ddo/examples/max2sat/errors.rs
UTF-8
1,981
2.6875
3
[ "MIT" ]
permissive
// Copyright 2020 Xavier Gillard // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, di...
true
27cbbbb07c1dc63f818962407e4be6ed5ab15d49
Rust
CryZe/livesplit-lite-core
/src/segment.rs
UTF-8
309
3.09375
3
[ "MIT" ]
permissive
use std::fmt; #[derive(Clone)] pub struct Segment { pub name: String, } impl fmt::Display for Segment { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.name) } } impl Segment { pub fn new(name: String) -> Segment { Segment { name: name } } }
true
6121cd16bfb95c5752f517480a371dfc984682df
Rust
alexbispo/rust_the_book
/cap03/temperatures_converter/src/main.rs
UTF-8
1,664
3.75
4
[]
no_license
use std::io; fn main() { println!("Temperature converter!"); println!("==============================================================="); loop { println!("Quit: q <enter>"); println!("Fahrenheit to Celsius: f <temperature_number> <enter>"); println!("Celsius to Fahrenheit: c <tempe...
true
70d343ea2276c78f5e6b20ef9090473d65964fd8
Rust
cbrewster/alcova
/alcova/src/live_view.rs
UTF-8
5,393
2.578125
3
[ "MIT" ]
permissive
use crate::{ live_socket::{ClientMessage, LiveSocketContext, SocketViewMessage}, LiveSocket, LiveTemplate, }; use actix::{Actor, ActorContext, Addr, Context, Handler, Message}; use actix_web::{HttpRequest, HttpResponse, Responder}; use jsonwebtoken::{encode, EncodingKey, Header}; use serde::{de::DeserializeOwne...
true
ebedcc11fadf54c9cb0f39de30e39b06574346c1
Rust
ypoluektovich/tmux-interface-rs
/src/commands/windows_and_panes/select_pane.rs
UTF-8
4,684
2.953125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::commands::constants::*; use crate::{Error, TmuxCommand, TmuxOutput}; use std::borrow::Cow; /// Make pane `target-pane` the active pane in window `target-window` /// /// # Manual /// /// tmux ^3.1: /// ```text /// tmux select-pane [-DdeLlMmRUZ] [-T title] [-t target-pane] /// (alias: selectp) /// ``` /// ///...
true
1b436e87e29d2332e959e3d751d15137af83a859
Rust
Ryan1729/rote
/libs/move_mod/src/move_mod.rs
UTF-8
1,600
3.09375
3
[ "Apache-2.0", "MIT" ]
permissive
use macros::{fmt_display, ord}; #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum Move { Up, Down, Left, Right, ToLineStart, ToLineEnd, ToBufferStart, ToBufferEnd, ToPreviousLikelyEditLocation, ToNextLikelyEditLocation, } use Move::*; fmt_display!(for Move: r#move in ...
true
c8d35e534af7e67f65945615931fceb055007d00
Rust
mishaszu/RUST-INTRO
/src/ex1/match_statement/src/basic_matching.rs
UTF-8
328
3.15625
3
[]
no_license
fn match_test() { let country_code = 1000; let country = match country_code { 44 => "UK", 46 => "Sweden", 1...999 => "unknown", _ => "invalid", }; println!("the country for this code is: {}", country); } pub fn run() { println!("Running basic maching"); match_te...
true
40d6a584f86d61530d0458014433319562701614
Rust
rust-lang/crates.io
/src/email.rs
UTF-8
9,186
2.796875
3
[ "MIT", "Apache-2.0" ]
permissive
use std::path::PathBuf; use std::sync::Mutex; use crate::util::errors::{server_error, AppResult}; use crate::config; use crate::Env; use lettre::message::header::ContentType; use lettre::transport::file::FileTransport; use lettre::transport::smtp::authentication::{Credentials, Mechanism}; use lettre::transport::smtp:...
true
0264df150e0ef52391e318759d05ad4079086336
Rust
michaelherger/librespot
/core/src/util.rs
UTF-8
589
3.09375
3
[ "LicenseRef-scancode-warranty-disclaimer", "MIT" ]
permissive
use std::mem; pub trait Seq { fn next(&self) -> Self; } macro_rules! impl_seq { ($($ty:ty)*) => { $( impl Seq for $ty { fn next(&self) -> Self { (*self).wrapping_add(1) } } )* } } impl_seq!(u8 u16 u32 u64 usize); #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, O...
true
3e59f3b73d6bfb037621cc2624509352efe28e92
Rust
aheart/hearth
/src/metrics/mod.rs
UTF-8
1,523
2.671875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
pub mod aggregator; mod cpu; mod disk; pub mod hub; mod la; mod metric_buffer; mod network; mod ram; mod space; use std::time::SystemTime; #[derive(PartialEq, Debug)] pub enum Metrics { Cpu(cpu::CpuMetrics), Disk(disk::DiskMetrics), La(la::LaMetrics), Net(network::NetMetrics), Ram(ram::RamMetrics)...
true
81754a6d5d7adb8cc231319c4b1e3c1837370eda
Rust
lorenzoditucci/calyx
/calyx/src/passes/group_to_invoke.rs
UTF-8
4,197
2.828125
3
[ "MIT" ]
permissive
use std::rc::Rc; use itertools::Itertools; use crate::analysis::ReadWriteSet; use crate::ir::RRC; use crate::ir::{ self, traversal::{Action, Named, VisResult, Visitor}, }; /// Transform groups that are structurally invoking components into equivalent /// [ir::Invoke] statements. /// /// For a group to meet t...
true
b93dae2a656f75b8afab53af8cbad710419bc1ae
Rust
Sophie-Williams/GameRoom-Bot
/src/command.rs
UTF-8
836
3.09375
3
[]
no_license
use std::string::String; use discord::model::{Message, ChannelId, User}; #[derive(Debug)] pub struct Command { user: User, channel_id: ChannelId, command: String, args: Vec<String>, } impl Command { pub fn parse(message: &Message) -> Command { let mut args: Vec<String> = message.content.s...
true
4177bdbb65c162c1eac67135c784f12bd836fda9
Rust
tinaun/playbot_ng_serenity
/src/context.rs
UTF-8
3,842
3.046875
3
[]
no_license
use serenity; use serenity::model::{ channel::Message, id::{ChannelId, UserId}, }; use threadpool::ThreadPool; use regex::Regex; use std::rc::Rc; type SendFn = fn(&ThreadPool, ChannelId, &str) -> serenity::Result<()>; #[derive(Clone)] pub struct Context<'a> { body: &'a str, is_directly_addressed: bo...
true
dee11345a693a0d28811763657a85ef4b000e0b2
Rust
Larusso/unity-version-manager
/uvm_core/src/unity/version/mod.rs
UTF-8
24,312
2.59375
3
[ "Apache-2.0" ]
permissive
use crate::unity::Installation; use log::{debug, info}; use regex::Regex; use semver; use serde::{self, Deserialize, Deserializer, Serialize, Serializer}; use std::cmp::Ordering; use std::convert::{AsMut, AsRef, From, TryFrom}; use std::fmt; use std::path::{Path, PathBuf}; use std::result; use std::str::FromStr; mod er...
true
3a3e6db3ec6b081684634f6365f9e1bffc59153d
Rust
thchittenden/rust-kernel
/src/interrupt/timer.rs
UTF-8
1,688
2.9375
3
[]
no_license
#![allow(dead_code)] // Constants. use util::asm; const TIMER_CHAN0: u16 = 0x0040; const TIMER_CHAN1: u16 = 0x0041; const TIMER_CHAN2: u16 = 0x0042; const TIMER_COMM: u16 = 0x0043; /// The timer frequency in hertz. const TIMER_FREQ: u32 = 1_193_182; /// The desired interrupt frequency in hertz. const INT_FREQ: u32 =...
true
991a1ed94869dde2f068b53d42c6ba8b34ee28c3
Rust
sirxyzzy/ilbm
/src/lib.rs
UTF-8
4,464
2.84375
3
[]
no_license
#[macro_use] extern crate log; pub mod iff; mod bytes; mod compression; mod read; use iff::ChunkId; use thiserror::Error; use std::path::Path; /// Global settings when reading image files pub struct ReadOptions { pub read_pixels: bool, pub page_scale: bool, } /// Main entry point pub fn read_from_file<P: AsR...
true
98e4d999ddc132ac5e4863dcddad3bb61ae8a932
Rust
crlf0710/modern-web
/mweb/src/classical/lexer.rs
UTF-8
61,619
3.234375
3
[]
no_license
use crate::utils::U8SpanRef; use thiserror::Error; pub mod ascii_char { #[derive(Copy, Clone, PartialEq)] enum AsciiCharCategory { Alphabetic, Digit, Symbol, InlineWhitespace, LineFeedWhitespace, Invalid, } fn ascii_char_category(ch: u8) -> AsciiCharCate...
true
24ec11896677f646b439567f03f5daa166f81c60
Rust
unovor/frame
/asn1_der-0.6.3/src/types/boolean.rs
UTF-8
702
2.671875
3
[ "BSD-2-Clause", "MIT" ]
permissive
use ::{ Asn1DerError, types::{ FromDerObject, IntoDerObject }, der::{ DerObject, DerTag} }; impl FromDerObject for bool { fn from_der_object(der_object: DerObject) -> Result<Self, Asn1DerError> { if der_object.tag != DerTag::Boolean { return Err(Asn1DerError::InvalidTag) } match der_object.value.data.as_slice...
true
88d58e93555a8aad6ff888974be5d5196671451d
Rust
esavier/keynesis
/src/passport/block/content.rs
UTF-8
7,809
2.828125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::passport::block::{EntryError, EntrySlice, EntryType, Hash, Hasher}; use std::{ convert::TryInto as _, fmt::{self, Formatter}, iter::FusedIterator, ops::Deref, }; use thiserror::Error; #[derive(Ord, PartialOrd, Eq, PartialEq, Clone, Hash)] pub struct Content(Box<[u8]>); #[derive(Ord, Partial...
true
fe2b27935168a910385475d8c99f7a74ebb18257
Rust
kyle-rader/advent_of_code
/src/rust/aoc/src/auth.rs
UTF-8
2,264
2.875
3
[]
no_license
use std::fs::{self, File}; use std::io::Write; use std::path::PathBuf; use crate::aoc_client::AocClient; use crate::cookies::aoc_session_token_first; use anyhow::anyhow; use directories::ProjectDirs; pub fn login(token: Option<String>) -> anyhow::Result<()> { // Get let token = match token { ...
true
e84f63686921b6e2c38786095c792e852a256097
Rust
nparthas/project_euler
/src/q1_50/q16.rs
UTF-8
458
2.953125
3
[]
no_license
extern crate num; extern crate num_bigint; use self::num_bigint::{BigInt, ToBigInt}; use std::ops::Mul; pub fn q16() -> i64 { let num_str: String = { let mut num: BigInt = 2.to_bigint().unwrap(); for _ in 1..1000 { num = num.mul(2); } num.to_str_radix(10) }; ...
true
da72f242775804c301adbff5e55ce4d923f6a425
Rust
adjivas/vt100-rust
/tests/csi.rs
UTF-8
13,668
2.703125
3
[ "MIT" ]
permissive
extern crate vt100; mod support; use support::TestHelpers; #[test] fn absolute_movement() { let mut screen = vt100::Screen::new(24, 80); assert_eq!(screen.cursor_position(), (0, 0)); screen.assert_process(b"\x1b[10;10H"); assert_eq!(screen.cursor_position(), (9, 9)); screen.assert_process(b"\x1b...
true
9aa78b2edba994bb6f3f7e5fdf7b37e563bdb3d7
Rust
dermesser/leveldb-rs
/src/asyncdb.rs
UTF-8
9,918
3.046875
3
[ "MIT" ]
permissive
use std::collections::hash_map::HashMap; use std::path::Path; use crate::{Options, Result, Status, StatusCode, WriteBatch, DB}; use tokio::sync::mpsc; use tokio::sync::oneshot; use tokio::task::{spawn_blocking, JoinHandle}; const CHANNEL_BUFFER_SIZE: usize = 32; #[derive(Clone, Copy)] pub struct SnapshotRef(usize);...
true
35e0b54b4037574ec6d98644f5f8c7d0568c401c
Rust
Joxx0r/RustRevEngine
/src/misc/input.rs
UTF-8
2,512
3.078125
3
[]
no_license
use crate::math::vec::Vec2; use glfw::{Key, Action, MouseButton}; use crate::misc::camera::Camera; use crate::misc::camera::Camera_Movement::*; pub struct input_state { pub left_mouse_button_down: bool, pub mouse_position: Vec2, pub forward_key_down: bool, pub back_key_down: bool, pub left_key_down...
true
dca7e0facdb300a9c8f85b455b55f5bd534dd19a
Rust
hubris-lang/hubris
/src/hubris_rt/src/lib.rs
UTF-8
493
3.125
3
[ "MIT" ]
permissive
use std::rc::Rc; use std::mem::transmute; struct ObjValue { ptr: *mut usize, } pub struct Obj(Rc<ObjValue>); impl Obj { pub fn from<T>(t: T) -> Obj { unsafe { let boxed_val = Box::new(t); let val = ObjValue { ptr: transmute(Box::into_raw(boxed_val)), ...
true
00c5e51dfc68f6afdf5222d95fb4ccfe2d728d48
Rust
bollo35/cryptopals
/src/bin/p040.rs
UTF-8
3,181
3.09375
3
[]
no_license
extern crate ooga; use ooga::rsa::Rsa; extern crate openssl; use openssl::bn::{BigNum, BigNumContext}; use std::ops::{Add, Div, Mul, Sub}; fn main() { let rsa0 = Rsa::new(); let rsa1 = Rsa::new(); let rsa2 = Rsa::new(); let msg = "Never gonna give you up! Never gonna let you down!".to_string(); let ct0 = BigNu...
true
9bd1c7e7f17365d5f76e9cea6cf3c85305130196
Rust
ushkarev/rusty-kms
/src/key_store/key/tags.rs
UTF-8
942
3.125
3
[ "MIT" ]
permissive
use crate::key_store::errors::*; use crate::key_store::tag::Tag; use crate::key_store::key::{Key, State}; impl Key { pub fn add_tag(&mut self, tag: Tag) -> Result<(), AddTagError> { if let State::PendingDeletion(_) = self.state { return Err(AddTagError::InvalidState); } if let S...
true
9294846647301ee2e68c1e8190d55b981ccf53fd
Rust
leptonyu/salak.rs
/src/lib.rs
UTF-8
10,594
3.671875
4
[ "MIT" ]
permissive
//! Salak is a multi layered configuration loader and zero-boilerplate configuration parser, with many predefined sources. //! //! 1. [About](#about) //! 2. [Quick Start](#quick-start) //! 3. [Features](#features) //! * [Predefined Sources](#predefined-sources) //! * [Key Convention](#key-convention) //! * [Va...
true
803d47198803d026358b00492feed23c3c720724
Rust
trevershick/uni
/src/main.rs
UTF-8
1,356
3.03125
3
[]
no_license
#[macro_use] extern crate simple_error; #[macro_use] extern crate clap; use std::error::Error; use std::process::exit; use std::result::Result; use clap::App; use hex; fn utf8_to_utf16(unicode_bytes: Vec<u8>) -> Result<String, Box<dyn Error>> { if unicode_bytes.len() != 2 { bail!("only handle arrays of 2...
true
9f50f066cda213a8677e45e00a4d365757896afe
Rust
embed-rs/stm32f7x6
/src/ethernet_mmc/mmccr/mod.rs
UTF-8
19,766
2.921875
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::MMCCR { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut...
true
e293abe837acee93c3c204016fac4b18bdcef1cf
Rust
astro/rust-lpc43xx
/src/scu/pintsel0/mod.rs
UTF-8
30,148
2.53125
3
[ "Apache-2.0" ]
permissive
#[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::PINTSEL0 { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w ...
true
161a56edb3db6f76bd0d42056e768fd9b162ee5d
Rust
zfzackfrost/string_studio
/src/generate/regex_gen.rs
UTF-8
6,496
2.609375
3
[ "MIT" ]
permissive
use rand::distributions::{Distribution, Uniform}; use rand::prelude::*; use regex_syntax::hir::{self, Hir, HirKind}; use regex_syntax::Parser; use std::iter::FromIterator; use encoding::all::UTF_8; use encoding::{DecoderTrap, EncoderTrap, Encoding}; const MAX_REPEAT: u32 = 100; struct RandomizeState<'a, R: Rng> { ...
true
17931b343d778a5308fb58c83b860016ccc33223
Rust
garciparedes/google-hashcode-2021
/src/main.rs
UTF-8
6,015
3.28125
3
[]
no_license
use std::io::prelude::*; use std::io; use std::collections::{HashMap, HashSet}; fn main() -> io::Result<()> { let input = read_input()?; let mut solver = Solver::from_str(&input); // println!("{:?}", solver); let solution = solver.solve(); write_output(solution); return Ok(()); } #[derive(D...
true
b97dde5b6f15364dbfc9169474aebd1212babb74
Rust
k124k3n/competitive-programming-answer
/codesignal/largestNumber.rs
UTF-8
167
3.1875
3
[ "MIT" ]
permissive
fn largestNumber(n: i32) -> i32 { if n == 0 { return n; } let mut out = 9; for i in 1..n { out *= 10; out += 9; } out }
true
62aa2389e4b844e79b836993fb75f28eab00910d
Rust
mateuszptr/rust_dhcp
/src/main.rs
UTF-8
3,138
2.515625
3
[]
no_license
#![feature(int_to_from_bytes)] extern crate byteorder; extern crate bytes; extern crate serde; extern crate serde_json; #[macro_use] extern crate serde_derive; extern crate actix; #[macro_use] extern crate actix_derive; extern crate libc; extern crate hwaddr; mod dhcp_frames; mod dhcp_options; mod config; mod ser...
true
dbe93392a7856f3749ee596cdc81e6a796745de4
Rust
prisma/prisma-engines
/query-engine/prisma-models/src/selection_result.rs
UTF-8
5,231
3.203125
3
[ "Apache-2.0" ]
permissive
use crate::{DomainError, FieldSelection, PrismaValue, ScalarFieldRef, SelectedField}; use itertools::Itertools; use std::convert::TryFrom; /// Represents a set of results. #[derive(Default, Clone, PartialEq, Eq, Hash)] pub struct SelectionResult { pub pairs: Vec<(SelectedField, PrismaValue)>, } impl std::fmt::Deb...
true
e399c03576c227ce4347ada70b8fb4314f443680
Rust
wa7sa34cx/WhyDoYou-bot
/src/utils/locale.rs
UTF-8
4,945
3.046875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! Localization helper use crate::models::error::HandlerError; use include_dir::{include_dir, Dir, File}; use lazy_static::lazy_static; use log::{error, info, warn}; use regex::{Captures, Regex}; use std::collections::HashMap; lazy_static! { /// Shared instance of Locale pub static ref TEXTS: Locale = Locale...
true
6dd8177bfc0f4b5bf78e749af2e13ba80cebe258
Rust
russelltg/srt-rs
/srt-protocol/src/packet/msg_number.rs
UTF-8
229
2.625
3
[ "Apache-2.0" ]
permissive
use super::modular_num::modular_num; modular_num! { pub MsgNumber(u32, 26) } impl MsgNumber { #[must_use] pub fn increment(&mut self) -> Self { let result = *self; *self += 1; result } }
true
bbca1674e59b8a03bc3683d625ef4f58f01db247
Rust
ajm188/advent_of_code
/2015/day01/main.rs
UTF-8
1,158
3.359375
3
[ "MIT" ]
permissive
use std::env::args; struct Santa { position: i32, first_time_in_basement: i32, num_movements: i32, } impl Santa { fn has_been_in_basement(&self) -> bool { self.first_time_in_basement >= 0 } fn from_santa(santa: Santa, movement: i32) -> Santa { let pos = santa.position + moveme...
true
16e7f44ffefec6125de2b0621a53a7dd1e33864a
Rust
flanfly/rust-pottcpp
/numortxt.rs
UTF-8
480
3.953125
4
[ "MIT" ]
permissive
enum NumberOrText { Number(i32), Text(String) } fn print_number_or_text(nt: NumberOrText) { match nt { NumberOrText::Number(i) => println!("Number: {}",i), NumberOrText::Text(t) => println!("Text: {}",t) } } fn main() { let a: NumberOrText = NumberOrText::Number(42); let b: NumberOrText = NumberOrText...
true
ef3cdeae12f65e6bfe91cbba96412998279f48d7
Rust
AurelienAubry/lc3-vm
/src/instructions/not.rs
UTF-8
2,267
3.5
4
[]
no_license
use crate::bus::Bus; use crate::cpu::{register_from_u16, Register, Registers}; use crate::instructions::Instruction; use anyhow::Result; pub struct Not { dst_reg: Register, src_reg: Register, } impl Not { pub fn new(instruction: u16) -> Result<Self> { let dst_reg = register_from_u16(instruction >>...
true
6ae9a645c26ac86e6b447a7bedc95240071b3be4
Rust
rjloura/proxy-rs
/src/utils.rs
UTF-8
1,207
3.3125
3
[ "MIT" ]
permissive
use chrono::prelude::*; const DEFAULT_UNIT: f64 = 1024_f64; const SUFFIX: &[&str] = &["k", "M", "G", "T", "P", "E"]; /// Takes the number of bytes and converts it to a human readable string pub fn pretty_bytes(b: u64) -> String { let b = b as f64; if b < DEFAULT_UNIT { return format!("{:.0} B", b); ...
true
d796f16109e37e30ecb4c6dd6bc3dbc71133b2d3
Rust
BurntSushi/rust-sorts
/src/lib.rs
UTF-8
9,148
2.90625
3
[ "Unlicense" ]
permissive
#![crate_id = "sorts#0.1.0"] #![crate_type = "lib"] #![license = "UNLICENSE"] #![doc(html_root_url = "http://burntsushi.net/rustdoc/rust-sorts")] #![feature(phase)] #![feature(macro_rules)] //! A collection of sorting algorithms with tests and benchmarks. #[phase(syntax, link)] extern crate log; extern crate stdtest...
true
69824be9d4a6657364d2f9835d88edf36306243b
Rust
dalance/nom-greedyerror
/examples/nom7.rs
UTF-8
1,122
2.8125
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use nom7::branch::alt; use nom7::character::complete::{alpha1, digit1}; use nom7::error::{ErrorKind, ParseError, VerboseError}; use nom7::sequence::tuple; use nom7::Err::Error; use nom7::IResult; use nom_greedyerror::{error_position, GreedyError, Position}; use nom_locate4::LocatedSpan; type Span<'a> = LocatedSpan<&'a...
true
a96a37f9547b1bf69e973f22f148f22517062db9
Rust
Tyler-Zhang/words-with-coworkers
/words-game/src/error.rs
UTF-8
1,025
3.1875
3
[ "Apache-2.0" ]
permissive
use std::error; use std::fmt; #[derive(Debug)] pub enum Error { BadAction(String), NotEnoughTiles, InvalidWord(String), StartingTileNotCovered, WordDoesNotIntersect, NoLettersUsed, } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { ...
true
f991c37a6fb8194d58418eae04de737454fc9698
Rust
tiredhaydn/project_euler
/src/bin/problem009/main.rs
UTF-8
343
2.953125
3
[]
no_license
fn main() { let mut answer = 0; for a in 3..=998 { for b in 4..=997 { let c = 1000 - a - b; if a * a + b * b == c * c { let abc = a * b * c; if abc > answer { answer = abc; } } } } pri...
true
132a4d55730bbebc5b9c22282d60101b60f86f0c
Rust
liang610/flux
/libflux/src/flux/semantic/convert.rs
UTF-8
118,059
2.828125
3
[ "MIT" ]
permissive
use crate::ast; use crate::semantic::fresh::Fresher; use crate::semantic::nodes::*; use crate::semantic::types::MonoType; use std::result; pub type SemanticError = String; pub type Result<T> = result::Result<T, SemanticError>; /// convert_with converts an AST package node to its semantic representation using /// the ...
true
12e6e4ad88859f08e5b01b898b0ec9d33a62cb58
Rust
Vechro/roman
/src/lib.rs
UTF-8
3,082
3.578125
4
[]
no_license
mod test; const fn roman_lut(numeral: &char) -> Option<usize> { match numeral { 'I' => Some(1), 'V' => Some(5), 'X' => Some(10), 'L' => Some(50), 'C' => Some(100), 'D' => Some(500), 'M' => Some(1000), _ => None, } } const fn arabic_lut(digit: &us...
true
eeafdd246e46748861c9efec9a4ce1d0f6e81ccd
Rust
bouzuya/rust-atcoder
/cargo-atcoder/contests/abc296/src/bin/b.rs
UTF-8
312
2.640625
3
[]
no_license
use proconio::{input, marker::Chars}; fn main() { input! { s: [Chars; 8], }; for i in 0..8 { let n = 8 - i; for j in 0..8 { let a = (b'a' + j as u8) as char; if s[i][j] == '*' { println!("{}{}", a, n); } } } }
true
81318dce492702fd85da4204de7e836ba3beca28
Rust
kakoc/leetcode
/src/except_self.rs
UTF-8
779
3.21875
3
[]
no_license
pub fn product_except_self(nums: Vec<i32>) -> Vec<i32> { let mut res = vec![0; nums.len()]; let mut p = 1; for (i, v) in nums.iter().rev().enumerate() { if i == 0 { res[nums.len() - 1 - i] = 1; p = *v; continue; } res[nums.len() - 1 - i] = p; ...
true
507353e2300b9ffbfd7a5507ffdbdb51ce737fde
Rust
ebsnet/blockchain
/lib/data/src/tx.rs
UTF-8
2,121
3.140625
3
[]
no_license
//! This module contains transaction specific data. use hack::BigArray; use bincode::serialize; use failure::Error; /// Size of a Ed25519 signature in bytes. pub const SIG_SIZE: usize = 64; /// Convenience type for a signature. pub type Signature = [u8; SIG_SIZE]; /// Convenience type for signed data inside a blo...
true
c8a539fe0e2a23380ab156c99430c4099d68e83c
Rust
arashout/cover-letter-generator
/src/blurb.rs
UTF-8
1,322
2.96875
3
[]
no_license
use crate::rules::{Rule, apply_rules}; use crate::types::TokenizedDescription; #[derive(Default)] pub struct Blurb<'a> { pub precendence: u8, pub long_description: &'a str, pub short_description: &'a str, pub name: &'a str, rules: Vec<Box<Rule>>, } impl<'a> Blurb<'a> { pub fn new(name: &'a str...
true
4ce7f85b9bc8f8e8ddf7a5c2bb82447b83da7e83
Rust
richarddowner/Rust
/rust-by-example/modules/modules.rs
UTF-8
975
3.734375
4
[]
no_license
// Rust provides a powerful module system that can be used to hierarchically // split code in logical units (modules), and manage visibility (public/priv) // between them. // A module is a collection of items like: functions, structs, traits, impl blocks, // and even other modules. fn function() { println!("called `...
true
b8f9029ec2b77aa4922952530b4ef8e23da04d25
Rust
davideGiovannini/rust_sdl2_engine
/leek/src/lib.rs
UTF-8
3,592
2.78125
3
[]
no_license
//! The following code creates an empty window: //! ``` //! fn main() { //! Engine::new("Title").start::<Game>(); //! } //! //! //! struct Game; //! //! impl GameScene for Game { //! fn set_up(&mut self) {} //! //! fn logic(&mut self, context: &EngineContext, engine: &mut Engine, ui: &Ui) -> EngineAction { //! ...
true
8f22063d9137e61e624b12972c7fa844563d77e2
Rust
zargony/advent-of-code-2016
/src/day20.rs
UTF-8
1,553
3.359375
3
[]
no_license
use std::num; /// Parse multiline-text of ranges into a vector of tuples pub fn parse(s: &str) -> Result<Vec<(u32, u32)>, num::ParseIntError> { s.lines().map(|line| { let mut nums = line.split('-').map(|s| s.parse::<u32>().unwrap()); Ok((nums.next().unwrap(), nums.next().unwrap())) }).collect(...
true
ee0dd34daf298b6848c5a9ed8498979928af2d71
Rust
m1el/refterm-hash-break
/main.rs
UTF-8
12,123
2.609375
3
[]
no_license
#![allow(clippy::needless_return)] #![feature(portable_simd)] use core_simd::Simd; use core::convert::TryInto; use srng::SRng; use simd_aes::SimdAes; const DEFAULT_SEED: Simd<u8, 16> = Simd::from_array([ 178, 201, 95, 240, 40, 41, 143, 216, 2, 209, 178, 114, 232, 4, 176, 188, ]); #[allow(non_snake_case)] fn ...
true
cced4a2da2d263cc5d424bf18d58bfc715bb4de4
Rust
neosmart/securestore-rs
/securestore/src/tests/secrets.rs
UTF-8
4,788
3.59375
4
[ "Apache-2.0", "MIT" ]
permissive
//! Highest-level tests for the secure store use crate::errors::ErrorKind; use crate::{KeySource, SecretsManager}; use tempfile::NamedTempFile; /// Verify that basic storage and retrieval of secrets functions correctly. #[test] fn basic_store_get() { // Create a new secrets manager with a known secret so we don't...
true
68d081dfc8abf1dcb438287b74bb54f66deef276
Rust
jneem/rust-playground
/src/skyline.rs
UTF-8
9,228
3.28125
3
[]
no_license
#[deriving(Clone, Show)] struct Building { m: f64, b: f64, end: f64 } // To prevent numerical instability, we don't allow large slopes. static MAX_SLOPE: f64 = 1e3; impl Building { fn from_points(x1: f64, y1: f64, x2: f64, y2: f64) -> Building { // To avoid NaNs, we deal with vertical line seg...
true
fcb01a63ca183f09223a866c6536afe442a45c51
Rust
yoav-steinberg/jsonpath
/tests/filter.rs
UTF-8
6,059
2.671875
3
[ "MIT" ]
permissive
#[macro_use] extern crate serde_json; use common::{read_json, select_and_then_compare, setup}; mod common; #[test] fn quote() { setup(); select_and_then_compare( r#"$['single\'quote']"#, json!({"single'quote":"value"}), json!(["value"]), ); select_and_then_compare( r#...
true
582843f9fd9e5b818bade37d0bf1ab284e8d4432
Rust
JiahaiHu/kv-server
/src/store/mod.rs
UTF-8
417
2.71875
3
[]
no_license
use std::collections::HashMap; pub mod engine; pub type Key = String; pub type Value = String; pub trait Engine { fn get(&self, key: &Key) -> Result<Option<Value>, ()>; fn put(&mut self, key: &Key, value: &Value) -> Result<Option<Value>, ()>; fn delete(&mut self, key: &Key) -> Result<Option<Value>, ()>; ...
true
f3729e4c24aac1e3e0c3c89a1e7c07b2a18a1a5c
Rust
Lakelezz/white_rabbit
/src/lib.rs
UTF-8
10,550
3.53125
4
[ "ISC" ]
permissive
//! *“I'm late! I'm late! For a very important date!”* //! *by “The White Rabbit”* 『Alice's Adventures in Wonderland』 //! //! `white_rabbit` schedules your tasks and can repeat them! //! //! One funny use case are chat bot commands: Imagine a *remind me*-command, //! the command gets executed and you simply create a on...
true
faa3c8a3555c2ab38c745576140f3d8811832fd9
Rust
neont21/pjos-rust-programming
/chapter11/assert_format/src/lib.rs
UTF-8
341
3.390625
3
[ "Apache-2.0" ]
permissive
pub fn greeting(name: &str) -> String { String::from("Hello?") } #[cfg(test)] mod tests { use super::*; #[test] fn greeting_contains_name() { let result = greeting("Peter"); assert!(result.contains("Peter"), "Greeting did not contain name, value was '{}'", resul...
true