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
f308fde85293b173feed8c4897978e4f64dfeee8
Rust
hrvojep/snatch
/src/write.rs
UTF-8
619
3.359375
3
[ "MIT" ]
permissive
use SChunks; use std::fs::File; use std::io::{Error, Write}; /// This function fills the buffer of a given local file, with the content of chunks. pub fn write_file(local_file_buf: &mut File, chunks: &SChunks) -> Result<(), Error> { // Get the access to the chunks let chunks_m = chunks.lock().unwrap(); /...
true
8b502252a3415a98b406b53dbc531b17ff9c3c94
Rust
lemunozm/ruscii
/examples/roguelike.rs
UTF-8
2,211
2.890625
3
[ "Apache-2.0" ]
permissive
use ruscii::app::{App, Config, State}; use ruscii::drawing::{Pencil, RectCharset}; use ruscii::gui::FPSCounter; use ruscii::keyboard::{Key, KeyEvent}; use ruscii::spatial::Vec2; use ruscii::terminal::{Color, Window}; struct GameState { player_pos: Vec2, player_move: Vec2, map_dim: Vec2, } impl GameState {...
true
90876cbcd6aaf2560c4282c792e93277276f9aa5
Rust
ldfallas/rgwbasic
/rgwbasic/src/eval/while_instr.rs
UTF-8
5,783
3.15625
3
[ "MIT" ]
permissive
use std::rc::Rc; use super::{ GwExpression, GwInstruction, InstructionResult, EvaluationContext, LineExecutionArgument, GwProgram }; pub struct GwWhile { pub condition : Box<dyn GwExpression>, } impl GwInstruction for GwWhile { fn eval (&self, ...
true
ef59c63dcda35c32b87bb74b54dc062235273f03
Rust
DelSkayn/RustEngine3d
/tungsten/tungsten_core/src/io/mod.rs
UTF-8
8,557
3.125
3
[]
no_license
//! Streaming io module. //! //! Tungsten use streaming io for its loading of resources. //! This module specifies the types nessecary for stream io. //! //! All operations are pushed to a thread wich will execute them. //! Allowing to do io while being able to keep running. //! //! I honestly have no idea if this is e...
true
37d557994c6f4a7c8ded065f9205471713230188
Rust
pindaroso/MarketSim
/src/simulation/config_parser.rs
UTF-8
1,425
2.9375
3
[]
no_license
use crate::simulation::simulation_config::{DistType, DistReason, Distributions, Constants}; use std::error::Error; use serde::Deserialize; use csv; #[derive(Debug, Deserialize)] struct TempDist{ reason: DistReason, v1: f64, v2: f64, scalar: f64, dist_type: DistType, } impl TempDist { pub fn unpack(&mut self) ...
true
d1c6a8995c9b0100ac08bbb69dfad75bbb4335d0
Rust
sangwon090/loco.rs
/src/protocol/header.rs
UTF-8
749
3.109375
3
[ "Apache-2.0" ]
permissive
use serde::{Deserialize, Serialize}; use std::string::FromUtf8Error; #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)] pub struct LocoHeader { pub id: u32, pub status: i16, pub name: [u8; 11], pub data_type: u8, pub data_size: u32, } impl LocoHeader { /// Extract String from name ...
true
58b685423241e06645b02c7e8309ae805baa68fa
Rust
puhtaytow/sampler
/src/mode.rs
UTF-8
6,383
2.859375
3
[ "MIT", "Apache-2.0" ]
permissive
use audio::Audio; use instrument; use map::Map; use pitch; use sampler::PlayingSample; use std; use Velocity; pub use instrument::mode::{Mono, MonoKind, Poly, Dynamic}; /// The "mode" with which the Sampler will handle notes. pub trait Mode { /// Handle a `note_on` event. /// /// Is called immediately fo...
true
dcda8b3e2d344b84f911891cb6a4639647e20cfe
Rust
vulkano-rs/vulkano
/vulkano/src/pipeline/cache.rs
UTF-8
20,591
2.734375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright (c) 2016 The vulkano developers // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT // license <LICENSE-MIT or https://opensource.org/licenses/MIT>, // at your option. All files in the project carrying such // notice may not be ...
true
b4148ec37e3173ca4ce6e366b9a827becb5754be
Rust
ShabbirHasan1/bowot-rs
/src/commands/economy.rs
UTF-8
6,071
3
3
[]
no_license
use std::ops::Sub; use crate::{ constants::{DAILY_AMOUNT, GAMBLE_MULTIPLIERS, GAMBLE_WEIGHTS}, data::PgPoolContainer, database::Guild, utils::basic_functions::format_seconds, }; use chrono::prelude::*; use rand::distributions::WeightedIndex; use comfy_table::{Cell, CellAlignment::Center, ContentArrang...
true
4c18b9b785e16d25535da67b025e96a82ad05073
Rust
raviqqe/futures-black-hole
/src/black_hole.rs
UTF-8
3,881
2.921875
3
[ "MIT" ]
permissive
use std::error::Error; use std::fmt::{self, Display, Formatter}; use std::sync::{Mutex, PoisonError}; use futures::Poll; use futures::Async::{NotReady, Ready}; use futures::prelude::Future; use futures::task::{self, Task}; use self::Inner::*; #[derive(Debug)] pub struct BlackHole(Mutex<Inner>); impl BlackHole { ...
true
ad5b3d50f44e753bc7296d229b53c28f065f71f5
Rust
aptend/rlox
/src/interpreter/lox_class.rs
UTF-8
3,294
2.9375
3
[]
no_license
use super::{Interpreter, LoxCallable, LoxFunction, RuntimeResult, Value}; use std::cell::RefCell; use std::collections::HashMap; use std::fmt; use std::rc::Rc; pub struct ClassInner { name: String, superclass: Option<LoxClass>, methods: HashMap<String, LoxFunction>, } #[derive(Clone)] pub struct LoxClass ...
true
dd19ecf9a52840901b84499b0b4fdfff1fec2d0c
Rust
lux01/advent-of-code-2017
/src/day_03/mod.rs
UTF-8
1,368
3.53125
4
[]
no_license
pub use super::Day; mod spiral_iter; use self::spiral_iter::SpiralIterator; mod cached_summed_spiral_iter; use self::cached_summed_spiral_iter::CachedSummedSpiralIterator; /// [Day 3](https://adventofcode.com/2017/day/3). Calculate the Manhatten distance of a number from /// the centre of number spirals. pub struct ...
true
565cfbfef6639302b8da4eb3a20c4294814e415f
Rust
mhackersu/bookmark
/src/bin/interactive/interface.rs
UTF-8
26,399
2.546875
3
[ "MIT" ]
permissive
use crate::interactive::bookmarks_table::BookmarksTable; use crate::interactive::event::{Event, Signal}; use crate::interactive::helpers::to_string; use crate::interactive::modules::command::Command; use crate::interactive::modules::delete::Delete; use crate::interactive::modules::help::HelpPanel; use crate::interactiv...
true
30524572eb4c5178eec1432bef94dd13ebaa6469
Rust
AdamKinnell/AdventOfCode2018
/src/bin/day11_part1_v3.rs
UTF-8
3,195
3.140625
3
[]
no_license
#[macro_use] mod common; use self::common::*; // Types ////////////////////////////////////////////////////////////////////// #[derive(Copy, Clone, PartialEq)] struct Vec2D { x: i32, y: i32, } // Functions ////////////////////////////////////////////////////////////////// /* Find the power level of the fue...
true
204d2d6600fa9ce73dc6fec34088dbaa4cb32ebb
Rust
derlaft/ppkui_bar
/src/config.rs
UTF-8
1,389
3
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use serde_derive::Deserialize; use std::str::FromStr; use css_color::Rgba; #[derive(Deserialize, Clone)] pub struct Config { button_color: String, button_hover_color: String, text_color: String, pub bar: Option<BarConfig>, pub launcher: Option<LauncherConfig>, } #[derive(Deserialize, Clone)] pub...
true
bf86c22902f1060f01a73875ba70a55419d427e3
Rust
iCodeIN/css-1
/src/main.rs
UTF-8
1,309
3.25
3
[ "Apache-2.0" ]
permissive
use std::env; use std::process; mod css; mod optimize; fn main() { let args: Vec<String> = env::args().collect(); // Display the help if args.len() < 2 { println!("minify"); println!("Quickly minimize CSS files\n"); println!("Specify one or more CSS files"); println!("Ex...
true
6aa70f3e28e7424f11ac0ad432b25b0c0cb489bd
Rust
sybrenw/rapid-rust
/src/lexer.rs
UTF-8
4,794
3.640625
4
[]
no_license
use std::vec; #[derive(Debug, Clone)] pub enum TokenType { // Brackets LeftPar, RightPar, LeftBrace, RightBrace, LeftBrack, RightBrack, // Terminators Semicolon, Comma, Whitespace, Newline, // Operators Add, Minus, Multiply, Divide, // Assign Assign, // Multi-char token Equa...
true
f1fac98e48d088bdd2a9a40efe0d62e3b1a9a1d1
Rust
Axect/Natural_Unit
/src/bin/example.rs
UTF-8
771
2.53125
3
[]
no_license
extern crate natural_unit; use natural_unit::*; fn main() { let cgs_to_geom = ConversionFactor::new( CONSTANT_CGS.G / (CONSTANT_CGS.c.powi(2) * CONSTANT_CGS.r_solar), // Mass conversion factor 1f64 / CONSTANT_CGS.r_solar, // Length conversion factor ...
true
e2875ce6161186d8a07cba999753a5a0a452d23e
Rust
mesalock-linux/rust-protobuf-sgx
/protobuf/src/reflect/transmute_eq.rs
UTF-8
1,930
3.0625
3
[ "MIT" ]
permissive
#[cfg(not(rustc_nightly))] mod transmute_eq_impl { use std::any::Any; use std::mem; #[inline(always)] pub fn transmute_eq<F: 'static, T: 'static>(mut from: F) -> Result<T, F> { // call downcast twice to work around borrow checked if (&mut from as &mut Any).downcast_mut::<T>().is_none() ...
true
4432d16982a9f8f6f4be5a1ffd98ade7a71ed353
Rust
des256/classic-e
/try/previous2/engine/channel.rs
UTF-8
622
2.625
3
[ "MIT" ]
permissive
// e::engine::Channel // by Desmond Germans, 2019 //use audio::Frame; use crate::Bunch; use crate::Synth; /// Note. #[derive(Clone)] pub struct Note { note: u8, // 0 = C0, ..., 95 = B7 velocity: f32, // 0.0 = none, ..., 1.0 = full length: u64, } /// Channel. #[derive(Clone)] pub struct Channel { synt...
true
3a6335bf3e07c603b7b83978958b6491e0903a96
Rust
kayleg/cloud-pubsub
/examples/serde.rs
UTF-8
1,869
2.796875
3
[ "MIT" ]
permissive
use cloud_pubsub::error; use cloud_pubsub::{Client, EncodedMessage, FromPubSubMessage}; use serde_derive::Deserialize; use std::sync::Arc; use tokio::task; #[derive(Deserialize)] struct Config { pubsub_subscription: String, google_application_credentials: String, } #[derive(Debug, Deserialize)] struct UpdateP...
true
90c71d2a466899888bf48616de06dd2415d0fb6b
Rust
dvc94ch/disco-rs
/src/patterns.rs
UTF-8
10,156
3.421875
3
[ "MIT", "Apache-2.0" ]
permissive
//! This module contains the data pertaining to Noise handshake patterns. For more information on //! these patterns, consult the //! [Noise specification](https://noiseprotocol.org/noise.html#handshake-patterns). use failure::Fail; use std::str::FromStr; use HandshakePattern::*; /// Role in the handshake process. #[d...
true
2673ce1e315e445e8b91d5b77c5c0d4084fe765f
Rust
vpatryshev/haskell_bits
/src/impls/vec.rs
UTF-8
1,895
2.921875
3
[]
no_license
use crate::*; pub struct TypeCon; impl<T> TypeAppParam for Vec<T> { type Param = T; } impl<T> TypeApp<TypeCon, T> for Vec<T> {} impl<T> WithTypeArg<T> for TypeCon { type Type = Vec<T>; } impl Functor for TypeCon { fn fmap<TIn, TOut, F>( f: F, x: &<TypeCon as WithTypeArg<TIn>>::Type, ...
true
87521afdea2bf4d4341ab987d5899bf7bf72ac46
Rust
jmccrae/yarem
/src/lib.rs
UTF-8
4,477
4.03125
4
[ "Apache-2.0" ]
permissive
//! Yet Another Rust Error Macro //! ============================ //! //! A simple but relatively easy to use Rust error macro. New errors can be //! defined using the `error!` macro as follows //! //! ``` //! #[macro_use] extern crate yarem; //! /// A comment for this error that will be visible in the docs //! error!...
true
2f4dc0266a8c42fc0a75980f40955523996a67c6
Rust
martijnjanssen/pheromones
/src/lib.rs
UTF-8
6,846
3.03125
3
[ "Apache-2.0", "MIT" ]
permissive
mod utils; use wasm_bindgen::prelude::*; // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global allocator. #[cfg(feature = "wee_alloc")] #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; const MAX_ANT_STEPS: u32 = 200; #[wasm_bindgen] #[repr(u8)] #[derive(Clone, C...
true
2a3c5158416795b45ba03053af3383058867d398
Rust
trcm/erode
/src/main.rs
UTF-8
5,419
3.0625
3
[]
no_license
extern crate getopts; extern crate httparse; extern crate bufstream; extern crate time; use std::net::{TcpListener, TcpStream}; use std::io::{Read, Write}; use std::fs::File; use std::thread; use std::process; use std::env; use bufstream::BufStream; use getopts::Options; /// Erode /// /// Erode is a Toy http server ...
true
7a6eefca27ae51da01811c1852505146cba8e524
Rust
tempbottle/timely-dataflow
/src/progress/notificator.rs
UTF-8
3,769
2.9375
3
[ "MIT" ]
permissive
//! A Notificator manages outstanding capabilities on several inputs as well as notification //! requests that may be blocked by them. use std::collections::VecDeque; use progress::Timestamp; use progress::frontier::MutableAntichain; use progress::count_map::CountMap; /// Tracks requests for notification and deliver...
true
abefab3760312dba3e704054a203f21f9689eeeb
Rust
SiegeEngine/siege-mesh
/src/mesh.rs
UTF-8
4,840
2.96875
3
[ "MIT" ]
permissive
use errors::*; use math::{Point3, Vec4}; use std::path::Path; use vertex::*; pub const MAGIC1: u8 = 238; pub const MAGIC2: u8 = 91; pub const MAGIC3: u8 = 131; // In order to deserialize a Mesh, we first need to know its vertex type. // So we have a header, which helps us deserialize the rest. // Since we have a head...
true
0d79d4885e029eebe1871211af36821ae461d44a
Rust
philmein23/lox-interpreter
/src/environment.rs
UTF-8
1,449
3.40625
3
[]
no_license
use std::collections::HashMap; use crate::object::Object; #[derive(Clone, Debug, PartialEq)] pub struct Environment { values: HashMap<String, Object>, pub enclosing: Option<Box<Environment>>, } impl Environment { pub fn new() -> Environment { Environment { values: HashMap::new(), ...
true
7e22618889119a537895a51eb75ce9019f67ac3f
Rust
virgesmith/rust101
/number/src/lib.rs
UTF-8
6,435
3.53125
4
[ "MIT" ]
permissive
extern crate num; use num::traits::{One, Zero}; use num::{Bounded, Float, Integer, Signed}; use core::ops::Add; #[derive(Debug, PartialEq)] // PartialEq required to test error values pub enum NumericalError { // hardware FP exceptions DivZero, Overflow, InvalidOp, // software exceptions NotRealNumber, I...
true
38c2f677993f31f85ca0b890ed7ac7f08af11e96
Rust
richerarc/saphir
/saphir/src/macros.rs
UTF-8
9,479
3.609375
4
[]
permissive
//! Saphir provides a proc_macro attribute and multiple function attributes. //! //! # The `#[controller]` Macro //! //! This macro is an attribute macro that need to be place on the `impl block` //! of a Saphir controller. It has 3 optionnal parameters: //! - `prefix="<pre>"` : This will prefix any controller route by...
true
b9cc2d642d72fbad77adc0d1fab6c79d00a688d8
Rust
mich2000/smartapp
/backend/xam-xam-dal/src/enums/product_kind.rs
UTF-8
1,020
3.171875
3
[]
no_license
use diesel_derive_enum::DbEnum; use serde::{Deserialize, Serialize}; use std::fmt; /** * Enumeration containing all the kind of food a product can be. */ #[derive(DbEnum, Debug, Clone, Deserialize, Serialize)] #[DieselType = "Product_Kind"] pub enum ProductKind { Other, Vegetables, Fruit, Grain, ...
true
10c32f2d0a3704f22ce94a509cd0e52aa2c3daaf
Rust
bertptrs/adventofcode
/2022/src/main.rs
UTF-8
1,265
2.96875
3
[ "MIT" ]
permissive
use std::fs::File; use std::io::Read; use std::num::NonZeroU8; use std::path::PathBuf; use std::time::Instant; use anyhow::Result; use clap::Parser; use aoc_2022::get_implementation; /// Advent of Code 2022 runner #[derive(Parser)] struct Opts { /// Which day to run day: NonZeroU8, /// Print time taken ...
true
8ba4f95aec8072f330a4b82351e49cdd56b703d8
Rust
TedDriggs/faux
/faux_macros/src/self_type.rs
UTF-8
1,203
3.296875
3
[ "MIT" ]
permissive
use darling::FromMeta; #[derive(PartialEq, Eq)] pub enum SelfType { Rc, Owned, Arc, Box, } impl FromMeta for SelfType { fn from_string(value: &str) -> darling::Result<Self> { match value { "owned" => Ok(SelfType::Owned), "Rc" => Ok(SelfType::Rc), "Arc" =...
true
e7bca4afe5a4ee10f65914975da79c67ae1827fa
Rust
jbiason/random
/tokiocommandtimeouttest/src/main.rs
UTF-8
1,200
2.984375
3
[]
no_license
use std::ffi::OsString; use std::path::PathBuf; use std::time::Duration; use tokio::process::Command; use tokio::time::timeout; /// Special script that looks for some file in $PATH. fn search_in_path(name: &str) -> Option<PathBuf> { let path = std::env::var_os("PATH").unwrap_or_else(OsString::new); std::env::...
true
947fa9e9c315fd61bb47dd5bfb0cc5e385fd7c81
Rust
RustCrypto/stream-ciphers
/chacha20/src/backends/soft.rs
UTF-8
2,171
2.78125
3
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0", "MIT" ]
permissive
//! Portable implementation which does not rely on architecture-specific //! intrinsics. use crate::{Block, ChaChaCore, Unsigned, STATE_WORDS}; use cipher::{ consts::{U1, U64}, BlockSizeUser, ParBlocksSizeUser, StreamBackend, }; pub(crate) struct Backend<'a, R: Unsigned>(pub(crate) &'a mut ChaChaCore<R>); im...
true
473cb91b77a12399484bd9530de695ef3b172a08
Rust
jt-l/kv
/src/bin/pkvstore.rs
UTF-8
2,545
2.6875
3
[ "MIT" ]
permissive
extern crate clap; use clap::{App, Arg, SubCommand}; use std::process; use std::env::current_dir; use pkvstore::{Result, PkvStore}; //use tempfile::TempDir; fn main() -> Result<()> { let matches = App::new("pkvstore") .version(env!("CARGO_PKG_VERSION")) .author(env!("CARGO_PKG_AUTHORS")) ...
true
4018000eef1a3d7c9644ea74d30238f00566f501
Rust
raccog/gitrs
/src/utils/fileio.rs
UTF-8
3,570
3.28125
3
[]
no_license
use std::fs::{self, OpenOptions}; use std::io::{self, ErrorKind, Read, Write}; use std::path::Path; use crate::{self as gitrs, GitResult}; /// Shorthand for creating a new directory. /// /// Returns [Ok] if the directory already exists. /// /// # Errors /// /// This function returns some errors from [ErrorKind] wrapp...
true
a52f37eba537698634bc71af9db9720da33c3656
Rust
andygrove/tmp102-rs
/src/lib.rs
UTF-8
1,330
3.109375
3
[]
no_license
extern crate i2cdev; use i2cdev::core::*; use i2cdev::linux::*; pub enum TempScale { Fahrenheit, Celcius } pub struct TMP102 { dev: Box<LinuxI2CDevice>, buf: Vec<u8> } impl TMP102 { pub fn new(filename: &'static str, address: u16) -> Result<Self, Box<LinuxI2CError>> { let dev = try!(Lin...
true
cf2ae9609730d0302c5752ded8acd1eb049619cb
Rust
petrSchreiber/thinclippy
/src/rules/compiled/mod.rs
UTF-8
4,539
2.78125
3
[ "MIT" ]
permissive
use crate::thinbasic_script::{Code, IssueSummary}; use crate::tokenizer; use crate::tokenizer::TokenType; pub fn section_definition(code: &mut Code) -> Vec<IssueSummary> { let mut issues_found: Vec<IssueSummary> = vec![]; let tokens = code.get_tokens(); let mut token_iter = tokens.iter().peekable(...
true
03be81579c97a15d0a81c85d27513c0a0f149067
Rust
unfuse/aoc2015
/src/bin/day05.rs
UTF-8
3,050
3.328125
3
[]
no_license
use std::fs; use std::collections::HashSet; use std::collections::HashMap; fn main() { let input: String = fs::read_to_string("src/bin/input05.txt").expect("Could not read file"); let mut counter: usize = 0; // println!("{}", is_nice_part2("qjhvhtzxzqqjkmpb")); // for part 1, swap to is_nice_part1(li...
true
caf0f3202b2e6fe06f757e92c7fa58cee3addaf0
Rust
dimdark/neon
/src/types/internal.rs
UTF-8
2,948
2.84375
3
[ "MIT", "Apache-2.0" ]
permissive
use std::mem; use std::os::raw::c_void; use neon_runtime; use neon_runtime::raw; use context::{CallbackInfo, FunctionContext}; use context::internal::Env; use types::error::convert_panics; use types::{JsObject, Handle, Managed}; use result::JsResult; use object::class::Callback; use super::Value; pub trait ValueIntern...
true
76011602c5865b77078d8d9c2d194158de5907e1
Rust
commandblockguy/rust-hangman
/src/main.rs
UTF-8
2,960
3.375
3
[ "MIT" ]
permissive
extern crate rand; use rand::seq::SliceRandom; use std::io::{self, BufRead}; include!(concat!(env!("OUT_DIR"), "/words.rs")); fn main() { let stdin = io::stdin(); let mut progress: u8 = 0; let word = get_random_word(); let mut display = "_".repeat(word.len()); let mut letters: [bool; 26] = [false; 26]; printl...
true
e9edfd3d104169fc62c115812ac99089f87f4bb3
Rust
alex-700/exercism-rust-solutions
/say/src/lib.rs
UTF-8
1,969
3.359375
3
[]
no_license
use std::iter::from_fn; const FROM_0_TO_9: [&str; 10] = [ "", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", ]; const FROM_10_TO_19: [&str; 10] = [ "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nin...
true
15643bb5911b1bb328f6b2663e57d22c5a3e27bb
Rust
7e4/himalaya
/src/domain/msg/parts_entity.rs
UTF-8
3,404
2.828125
3
[]
no_license
use mailparse::MailHeaderMap; use serde::Serialize; use std::ops::{Deref, DerefMut}; #[derive(Debug, Clone, Default, Serialize)] pub struct TextPlainPart { pub content: String, } #[derive(Debug, Clone, Default, Serialize)] pub struct TextHtmlPart { pub content: String, } #[derive(Debug, Clone, Default, Seria...
true
59ef9a6e733be77fa8f89d9d62dc53b585e7f608
Rust
fredyw/leetcode
/src/main/rust/src/bin/problem2614.rs
UTF-8
1,197
3.46875
3
[ "MIT" ]
permissive
// https://leetcode.com/problems/prime-in-diagonal/ pub fn diagonal_prime(nums: Vec<Vec<i32>>) -> i32 { fn is_prime(n: i32) -> bool { if n == 1 { return false; } if n == 2 { return true; } for i in 2..=(n as f64).sqrt() as i32 { if n % i as...
true
b26a9fad8c9b6fdb8c90b5e436ee1b0f350b25b8
Rust
peacekeeper/sovrin-client-rust
/tests/utils/wallet.rs
UTF-8
3,253
2.625
3
[ "Apache-2.0" ]
permissive
use sovrin::api::ErrorCode; use sovrin::api::wallet::{ sovrin_create_wallet, sovrin_open_wallet, sovrin_wallet_set_seq_no_for_value }; use utils::callback::CallbackUtils; use utils::timeout::TimeoutUtils; use std::ffi::CString; use std::ptr::null; use std::sync::mpsc::channel; pub struct WalletUtils {} ...
true
1df6f446ad8bea0f8b54fc351e3199c7ec731e14
Rust
trip-flip/sample-engine
/sample-core/src/assets.rs
UTF-8
714
2.8125
3
[]
no_license
use std::rc::Rc; use std::collections::HashMap; use std::path::Path; use crate::{ mesh::Mesh, shader::Shader, texture::Texture, }; pub struct Assets { meshes: HashMap<String, Rc<Mesh>>, shaders: HashMap<String, Rc<Shader>>, textures: HashMap<String, Rc<Texture>>, //materials: Vec<Rc<Material...
true
ff593ed8d3b8e7d040c9c69cd3598ac6d1a199e4
Rust
rymdhund/adventofcode
/6/src/main.rs
UTF-8
3,796
3.265625
3
[]
no_license
use std::io::BufReader; use std::io::BufRead; use std::fs::File; #[derive(Debug)] enum Command { On, Off, Toggle } #[derive(Debug)] struct Instruction { command: Command, x1: usize, y1: usize, x2: usize, y2: usize } fn light(instructions: &[Instruction]) -> usize { let mut lights...
true
a88b20710fa70463aaef4ee9c64672a176cf575a
Rust
obsgolem/rusty-radar
/src/radar.rs
UTF-8
4,068
2.625
3
[]
no_license
use std::f32::consts::PI; use nalgebra::{UnitQuaternion, Vector3}; use ndarray::{Array1, Axis}; use num::traits::float::FloatCore; use crate::{ helper::{vec_to_aspect, wavelength}, helper_traits::SphericalFunction, scene::PointTarget, signal::{scalar::Scalar, Pulse}, }; const c: f32 = 299_792_458.0; ...
true
04cfda7d43cd1b9d5c207ece6483052a6b4b36fd
Rust
ruoshui-git/stuy-graphics
/src/mdl/result.rs
UTF-8
1,609
2.890625
3
[]
no_license
use std::io; use thiserror::Error; use super::types::Kind; /// Result to wrap EngineError pub type EngineResult<T> = Result<T, EngineError>; #[derive(Error, Debug)] pub enum EngineError { #[error("io error: {0}")] Io(#[from] io::Error), #[error("syntax error on line {line}: input: {input}, type: {kind:?...
true
fbf938b01499bd3f723be1bfa671422fe9199b25
Rust
m-bra/swirl
/src/types/rulepart.rs
UTF-8
8,563
3.09375
3
[]
no_license
use std::collections::{BTreeMap, HashMap}; use std::cell::UnsafeCell; use crate::*; #[derive(Debug)] pub struct RulePart<Invocation: Clone> { text: String, /// each usize, an index in .text, is associated with all the rule invocations that appear (in the given order) right before the index /// it is assume...
true
4535a8a9e3dc45df3cc35bbe3386b29ffa074782
Rust
djdisodo/chipcalc_native_rust
/src/vector2.rs
UTF-8
149
2.9375
3
[]
no_license
#[derive(Clone)] pub struct Vector2<T> { pub x: T, pub y: T } impl <T> Vector2<T> { pub fn new(x: T, y: T) -> Self { Self { x, y } } }
true
1c433d028e9562817fa055c171716f7199e98b78
Rust
remysucre/fgh
/eqsat/src/lang.rs
UTF-8
2,066
3.1875
3
[]
no_license
use egg::*; define_language! { pub enum Semiring { // A bare number is a literal Num(i32), // All variables are tagged with var // to distinguish from relations // e.g. (var x) // "var" = Var(Id), // Relations are tagged with rel // e.g. (rel R (var...
true
a0b7c7e7c534a11508b7330ee38251265ddc7257
Rust
Azure/azure-sdk-for-rust
/sdk/data_cosmos/src/clients/trigger.rs
UTF-8
3,216
2.734375
3
[ "MIT", "LicenseRef-scancode-generic-cla", "LGPL-2.1-or-later" ]
permissive
use crate::clients::*; use crate::operations::*; use crate::resources::trigger::{TriggerOperation, TriggerType}; use crate::ReadonlyString; use azure_core::{Pipeline, Request}; /// A client for Cosmos trigger resources. #[derive(Debug, Clone)] pub struct TriggerClient { collection: CollectionClient, trigger_na...
true
50110e40330f95e3fa1f3044b40fef7839ba573f
Rust
maufl/notrust
/src/index.rs
UTF-8
2,991
2.5625
3
[]
no_license
use clap::{ArgMatches}; use maildir::{Maildir}; use mailparse::{ParsedMail, MailHeader}; use tantivy::schema::*; use tantivy::{doc,Index,directory::MmapDirectory}; use chrono::{DateTime,offset::Utc}; pub fn run_index(matches: &ArgMatches) { let dir = matches.value_of("DIR").unwrap(); let index = matches.value_...
true
0b13d6292bfc8a7cf1089b119a65c976f766d205
Rust
ShigekiKarita/rust_nlp100
/src/bin/nlp12.rs
UTF-8
2,166
3.21875
3
[ "BSL-1.0" ]
permissive
/// Ex. 12 cut N-th column of /data/hightemp.txt, Ch. 2 UNIX command basics #[derive(Debug)] struct Config { filename: String, delim: char, ncol: usize } impl Config { fn new() -> Self { Self { filename: String::new(), delim: '\t', ncol: 0 } } fn parse(&mut self, it: &mut impl Iterato...
true
07fd2776b9078bf7ae8cc95b5459bda3a80c6062
Rust
pashadia/bridge-stack-backend
/src/auction/tests.rs
UTF-8
10,971
3.046875
3
[]
no_license
use crate::auction::constants::*; use crate::auction::Error::InsufficientBid; use crate::auction::{Auction, Error}; use crate::contract::Contract::PassedOut; use crate::contract::{ContractLevel, Strain}; use crate::BridgeDirection; #[test] fn can_pass_out() -> Result<(), Error> { let mut auction = Auction::new(Bri...
true
5eaa7e436072522ba2279d64a5d2cf48cfe24b43
Rust
konradsz/adventofcode2016
/day21/src/main.rs
UTF-8
7,070
3.328125
3
[]
no_license
#[macro_use] extern crate lazy_static; use regex::Regex; use std::fs; fn swap_position(password: &str, position_1: usize, position_2: usize) -> String { let letter_1 = password.chars().nth(position_1).unwrap(); let letter_2 = password.chars().nth(position_2).unwrap(); let mut new_password = String::from(...
true
21c04401b8d04dd3684e1001f62576eb110ccce0
Rust
MDeiml/attomath
/src/serialization/command.rs
UTF-8
17,159
2.875
3
[ "MIT" ]
permissive
use std::fmt::Write; use nom::{ branch::alt, bytes::complete::{is_not, tag, take_till1, take_until}, character::complete::{char, digit1}, combinator::{all_consuming, eof, map, map_opt, map_parser, rest}, error::context, sequence::{terminated, tuple}, IResult, }; use crate::Theorem; use su...
true
f91aa3c3a6c779a8537edb4d1103ef4b6c1c4c09
Rust
kennytm/async-ctrlc
/src/lib.rs
UTF-8
2,598
2.5625
3
[ "MIT", "Apache-2.0" ]
permissive
// Copyright 2019 kennytm. Licensed under MIT OR Apache-2.0. //! `async-ctrlc` is an async wrapper of the `ctrlc` crate. use ctrlc::set_handler; pub use ctrlc::Error; #[cfg(feature = "stream")] use futures_core::stream::Stream; use std::{ future::Future, pin::Pin, ptr::null_mut, sync::atomic::{AtomicB...
true
bb0ea047ba723d6fd405162ad8d0b021936e671d
Rust
emschwartz/async-cache-rs
/src/main.rs
UTF-8
1,003
3.046875
3
[]
no_license
mod async_cache; mod sync_cache; use async_cache::AsyncCache; use chrono::Duration; use serde::Deserialize; #[derive(Deserialize, Debug)] #[serde(untagged)] enum Response { Square { msg: u32, #[serde(alias = "ttl(ms)")] ttl: u32, }, Error { error: String, }, } #[tokio:...
true
786fd8a363b506fdb9edc22abf25d934506426ea
Rust
DaTa-/advent-of-code-2020
/src/bin/day16_part2.rs
UTF-8
4,365
2.828125
3
[ "MIT" ]
permissive
use std::{collections::HashSet, ops::RangeInclusive}; fn main() { let input = String::from_utf8(std::fs::read("input/day16").unwrap()).unwrap(); let mut input = input.split("\n\n"); let fields: Vec<(String, Vec<RangeInclusive<u16>>)> = input .next() .unwrap() .split_terminator('\n'...
true
2eee2b4000a42831aeb1f0a0b81d134dd86c0592
Rust
blguru20/RustBasics
/rust/loops/src/main.rs
UTF-8
644
3.53125
4
[]
no_license
fn main() { println!("calling for loop "); let mut flag : bool = true; while(flag){ flag = false; println!("inside while loop "); } println!("calling for loop "); for x in 0..10{ println!("value : {}", x); } //infinite loop let mut count = 0; ...
true
36f9918a7945a6ad1cc50b6adacc8a9688814b06
Rust
lilac/rust-projects
/sorting/bubble-sort.rs
UTF-8
778
2.84375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/* Sample bubble sort program in Rust. Tested to compile with rust-0.6. */ extern mod extra; extern mod benchmark; use benchmark::Benchmark; fn bubble_sort<T:Ord+Clone>(arr: ~[T]) -> ~[T] { let mut result = arr.clone(); let mut left: uint; let mut right: uint = arr.len() - 1; let mut swap_occurred ...
true
9cbc33deda2f65df664097d89e4e470db86fda90
Rust
C-Saunders/days_between
/src/inputs/date_string_parser.rs
UTF-8
2,032
3.578125
4
[ "MIT" ]
permissive
use regex::{Captures, Regex}; use DateFormat; pub struct ParsedDateString { pub year: i32, pub month: u32, pub day: u32, pub format_type: DateFormat, } impl ParsedDateString { pub fn new(input: &str) -> Result<ParsedDateString, &'static str> { let re = Regex::new(r"^(?P<year>\d{4})-?(?P<mo...
true
d4159f7b0b6297b569f6f9467d07d71dec6688a7
Rust
ipetkov/conch-runtime
/conch-runtime/src/spawn.rs
UTF-8
5,687
2.5625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Defines methods for spawning commands into futures. use crate::ExitStatus; use async_trait::async_trait; use futures_core::future::BoxFuture; mod and_or; mod case; mod for_cmd; mod func_exec; mod if_cmd; mod local_redirections; mod loop_cmd; mod pipeline; mod sequence; mod simple; mod subshell; mod substitution; ...
true
78515bffb7fec3a74c877bf3112644968aef45de
Rust
AnOrdinaryUsername/show-waifu
/src/api/mod.rs
UTF-8
432
2.578125
3
[]
no_license
pub mod danbooru; pub mod safebooru; use regex::Regex; pub fn reformat_search_tags(tags: String) -> String { let extra_spaces = Regex::new(r"\s{2,}").unwrap(); let delimiters = Regex::new(r"[,\s]").unwrap(); // Remove excess spaces (2 or more) extra_spaces.replace_all(&tags, ""); // Replace commas...
true
7b97b4180953bb3d37b1a021a289b9ed86644d27
Rust
AlexanderEkdahl/pbr
/src/camera.rs
UTF-8
2,773
3.125
3
[]
no_license
use rand::{random, Rand, Rng, ThreadRng}; use cgmath::{Point3, Vector3, Matrix4, BaseNum, ApproxEq, BaseFloat}; use cgmath::{ElementWise, InnerSpace}; use num::traits::{zero, Zero, one, One, FloatConst, FromPrimitive}; use ray::Ray; #[derive(Debug)] pub struct Camera<T> { pub width: usize, pub height: usize, ...
true
dcb7dedf3c297e1e774bfa9c6a74e89340a5ea7d
Rust
danielSanchezQ/rich
/text/src/lib.rs
UTF-8
2,751
3.71875
4
[ "MIT" ]
permissive
use style::Style; #[derive(Clone, Eq, PartialEq, Debug)] pub struct Span { start: usize, end: usize, style: Style, } #[derive(Clone)] pub struct Text {} impl Span { pub fn new(start: usize, end: usize, style: Style) -> Self { Self { start, end, style } } pub fn as_tuple(&self) -> (us...
true
5a0a94be940e4e33c1aaccbb8306b1f0e0927cbc
Rust
stormgbs/cron-rs
/src/error.rs
UTF-8
967
3.03125
3
[ "MIT" ]
permissive
use std::num::ParseIntError; use std::fmt; #[derive(Debug)] pub enum Error { ErrCronFormat(String), ErrParseTask(String), ErrParseInt(ParseIntError), ErrRunCommand(String), ErrKillProcess(String), ErrRead(String), } impl From<ParseIntError> for Error { fn from(err: ParseIntError) -> Error ...
true
3b8a7033fc37e434f51131881828c2300755b977
Rust
spitfire05/dfconfig-rs
/src/lib.rs
UTF-8
12,270
3.875
4
[ "MIT" ]
permissive
//! dfconfig is a lib for parsing and manipulating Dwarf Fortress' `init.txt` and `d_init.txt` config files (and possibly many others using the same format). //! This lib's functionality has been specifically tailored to behave similar as DF internal parser, which implies: //! //! * [`Config::get`] returns the last occ...
true
e23c97c5f63440f0514e844c73ff51b274ca316c
Rust
isgasho/dotter
/src/main.rs
UTF-8
2,373
2.578125
3
[ "Unlicense" ]
permissive
#[cfg(windows)] extern crate dunce; #[macro_use] extern crate anyhow; extern crate clap; extern crate env_logger; extern crate handlebars; #[macro_use] extern crate log; extern crate meval; #[macro_use] extern crate serde; extern crate shellexpand; extern crate structopt; #[macro_use] extern crate thiserror; extern cr...
true
99a5b55ed97bcb5463721fea0df5e2fabeb7704e
Rust
nabijaczleweli/quirc-rs-impl
/src/util/decode/err_corr.rs
UTF-8
2,815
2.703125
3
[ "MIT" ]
permissive
//! Code stream error correction //! //! Generator polynomial for `GF(2^8)` is `x^8 + x^4 + x^3 + x^2 + 1` use self::super::{GF256_EXP, GF256_LOG, MAX_POLY, GF256, berlekamp_massey, poly_eval}; use self::super::super::super::ops::version_db::QuircRsParams; use self::super::super::super::ffi::QuircDecodeError; pub f...
true
8ed4a3588def1e8027f4ea884b8734ff1eb844d4
Rust
johannesegger/AdventOfCode
/2022/Day01/Rust/src/main.rs
UTF-8
988
3.109375
3
[]
no_license
use std::fs::File; use std::io; use std::io::BufRead; use std::io::BufReader; fn main() -> Result<(), io::Error> { let file_name = "input.txt"; let file = File::open(file_name)?; let reader = BufReader::new(file); let mut sums = reader.lines() .filter_map(|line| line.ok()) .fold(Vec::ne...
true
06821116ebfb15ef2066825b5d76d58bcc3052cc
Rust
ergoplatform/sigma-rust
/ergoscript-compiler/src/parser/grammar.rs
UTF-8
601
2.703125
3
[ "CC0-1.0" ]
permissive
mod expr; mod stmt; use crate::lexer::TokenKind; use crate::parser::Parser; use crate::syntax::SyntaxKind; use super::marker::CompletedMarker; pub fn root(p: &mut Parser) -> CompletedMarker { let m = p.start(); while !p.at_end() { stmt::stmt(p); } m.complete(p, SyntaxKind::Root) } #[cfg(te...
true
12618ae4da0e8f288f616a64de5b058b2a6e2905
Rust
dtolnay/serde-yaml
/tests/test_value.rs
UTF-8
3,788
3.03125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![allow( clippy::derive_partial_eq_without_eq, clippy::eq_op, clippy::uninlined_format_args )] use indoc::indoc; use serde::de::IntoDeserializer; use serde::Deserialize; use serde_derive::{Deserialize, Serialize}; use serde_yaml::{Number, Value}; #[test] fn test_nan() { let pos_nan = serde_yaml::from...
true
8223e86b3190785ba7ddd9619c2fbc158108f772
Rust
far-rainbow/AntidetectFirefox
/third_party/rust/target_build_utils/src/changelog.rs
UTF-8
1,785
2.609375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Project Changelog /// Release 0.3.0 (2017-02-10) /// /// # Breaking changes /// /// * The `Error` enumeration gained a new variant `CustomTargetsUnsupported` to signify the fact /// this particular build of the crate does not support custom JSON targets. /// /// # Other changes /// /// * `serde_json` is now an e...
true
5cc6a1717fce79173c2dc55c11eda86771c611d0
Rust
cnutshell/rust-ucx
/workspace/ucx/src/configuration/values/TagSenderMask.rs
UTF-8
2,926
2.828125
3
[ "MIT", "Apache-2.0" ]
permissive
// This file is part of ucx. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/ucx/master/COPYRIGHT. No part of predicator, including this file, may be copied, modified, propagated, or distributed except acco...
true
46cea0ef69221ae29cd5eea40c0e44c63269fef4
Rust
karimElmougi/Simumo
/simulator/src/components/types/agents.rs
UTF-8
1,863
2.59375
3
[ "BSD-2-Clause" ]
permissive
use crate::commons::LogDataEntry; use crate::commons::Percentage; use crate::ressources::lane_graph::EdgeId; use crate::ressources::lane_graph::NodeId; use serde::ser::Serialize; use serde::ser::SerializeSeq; use serde::ser::Serializer; use simumo_derive::{simucomponent_base, simucomponent_data, SimumoSerialize}; use s...
true
6fd1f051a138ee1ac8042f960080b5149450da09
Rust
alileino/turtlers
/src/run_history.rs
UTF-8
1,199
3.109375
3
[]
no_license
use std::time::{SystemTime, UNIX_EPOCH}; use crate::turtle_state::{TurtleState}; use crate::turtle_action::{TurtleAction}; pub fn create_run_id(id: &str) -> String { let now = SystemTime::now(); let duration = now.duration_since(UNIX_EPOCH).unwrap(); format!("{}_{}", id, duration.as_millis()) } pub struc...
true
3af681f7ee86944a4ec891a113392a08328a95b0
Rust
u1roh/dxf2svg
/src/geom2d.rs
UTF-8
3,604
3.421875
3
[]
no_license
#[derive(Debug, Clone, Copy, PartialEq, Default)] pub struct Pos { pub x: f64, pub y: f64, } impl From<&dxf::Point> for Pos { fn from(src: &dxf::Point) -> Self { Self { x: src.x, y: src.y } } } impl From<Pos> for dxf::Point { fn from(src: Pos) -> dxf::Point { dxf::Point { ...
true
9b5362775db14bca41d2b4e1c6727c7e30e9d422
Rust
wasmerio/cranelift
/cranelift-codegen/src/abi.rs
UTF-8
8,007
3.484375
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
//! Common helper code for ABI lowering. //! //! This module provides functions and data structures that are useful for implementing the //! `TargetIsa::legalize_signature()` method. use crate::ir::{AbiParam, ArgumentExtension, ArgumentLoc, Type}; use core::cmp::Ordering; use std::vec::Vec; /// Legalization action to...
true
6f925ba5dfc7026df09bfc5e39e8a7cfa6e03c96
Rust
PhylumChordata/space-invade.rs
/emulator/src/test2.rs
UTF-8
126
2.75
3
[]
no_license
struct Foo {} fn main() { let foo = Foo{}; thread::spawn(move || { println!("Here is foo {}", foo); }) }
true
3a9103d86b9caaa97c7fbe576a75c03cb756bd85
Rust
pola-rs/polars
/crates/polars-utils/src/contention_pool.rs
UTF-8
1,015
3.265625
3
[ "MIT" ]
permissive
use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Mutex; pub struct LowContentionPool<T> { stack: Vec<Mutex<T>>, size: AtomicUsize, } impl<T: Default> LowContentionPool<T> { pub fn new(size: usize) -> Self { let mut stack = Vec::with_capacity(size); for _ in 0..size { ...
true
dfa73adc048bf731769b8f9ad5ee4fa7cf6bde1d
Rust
iCodeIN/Rudra-PoC
/poc/0021-futures-intrusive.rs
UTF-8
2,090
2.53125
3
[]
no_license
/*! ```rudra-poc [target] crate = "futures-intrusive" version = "0.3.1" [[target.peer]] crate = "crossbeam-utils" version = "0.8.0" [report] issue_url = "https://github.com/Matthias247/futures-intrusive/issues/53" issue_date = 2020-10-31 rustsec_url = "https://github.com/RustSec/advisory-db/pull/482" rustsec_id = "RU...
true
0a7d469c6ac1206aff2844fa27a429afc6e05695
Rust
davisvansant/hyper_rs
/echo/src/main.rs
UTF-8
1,717
2.640625
3
[]
no_license
use futures::TryStreamExt as _; use hyper::service::{make_service_fn, service_fn}; use hyper::{Body, Method, Request, Response, Server, StatusCode}; use std::net::SocketAddr; async fn echo(req: Request<Body>) -> Result<Response<Body>, hyper::Error> { let mut response = Response::new(Body::empty()); match (req...
true
55db4c086395a29d91b4fbc5691cb9f0d2380b80
Rust
ryanw/dcpu16-rs
/src/instruction.rs
UTF-8
17,162
3.140625
3
[]
no_license
use super::opcodes::*; use super::processor::Processor; use super::processor::Register::*; use super::value::Value; use std::mem; fn to_signed(val: u16) -> i16 { unsafe { mem::transmute(val) } } fn to_unsigned(val: i16) -> u16 { unsafe { mem::transmute(val) } } #[derive(Debug)] pub struct Instruction { o...
true
00702ce74beee63f9c07bcaa3478951f8d175fe3
Rust
ayazhafiz/slide
/editor/language_server/src/tests/utils.rs
UTF-8
7,073
3.265625
3
[ "BSD-3-Clause" ]
permissive
//! Module `utils` provides test utilities for the slide language server. use pretty_assertions::assert_eq; use tower_lsp::lsp_types::*; /// Converts an offset to an LSP position in a source text. // https://docs.rs/wast/25.0.2/src/wast/ast/token.rs.html#24-36 // TODO: batch this or provide a offset mapping. pub fn t...
true
91c2397cbd5387158e019514fc0bac660f699e5d
Rust
sectopod/hematite
/src/texture.rs
UTF-8
1,623
3.1875
3
[ "MIT" ]
permissive
use gl::types::GLint; use hgl; use image; use image::{GenericImage, ImageBuf, Pixel, Rgba}; fn load_rgba8(path: &Path) -> Result<ImageBuf<Rgba<u8>>, String> { match image::open(path) { Ok(image::ImageRgba8(img)) => Ok(img), Ok(image::ImageRgb8(img)) => { let (w, h) = img.dimensions(); ...
true
fb6ac1b7c9a5930e6da9fb5b7f1bf7d94bfade8d
Rust
Eirenne/boids-rust
/src/systems/alignment.rs
UTF-8
1,584
2.640625
3
[]
no_license
use amethyst::{ core::SystemDesc, core::math::{Vector3}, derive::SystemDesc, core::transform::Transform, ecs::prelude::{Join, ReadStorage, System, SystemData, World, WriteStorage}, }; use crate::components::boid::{Boid, Acceleration, Velocity}; pub const ALIGNMENT_RADIUS: f32 = 50.0; pu...
true
b43be3c98f23ac4b1074e8eee3b2556793233034
Rust
imzacm/crypt-client
/src/repl/dummy_drivers.rs
UTF-8
2,035
3.421875
3
[]
no_license
use crate::repl::ReplDriver; use std::fmt; /// A mock implementation of [`ReplDriver`]. /// /// # Example /// /// Echo mode: /// /// ``` /// use crypt_client::repl::{ReplDriver, MockDriver}; /// /// let mut driver = MockDriver::Echo; /// assert_eq!(driver.prompt_line("..."), Ok("...".to_string())); /// assert_eq!(driv...
true
f09267605de7dee54ebe86cad72290c6a2309329
Rust
imbrn/building
/tests/calling_build.rs
UTF-8
732
3.453125
3
[ "MIT" ]
permissive
use building::Builder; #[derive(Debug, PartialEq, Builder)] pub struct Product { id: i64, name: String, tags: Vec<String>, } fn working() { let product = Product::builder() .id(12) .name("Foo".to_owned()) .tags(vec!["foo".to_owned(), "bar".to_owned()]) .build() ...
true
a599e387d7db7439ecfc0960f6ef5d1f16a57577
Rust
aticu/VeOS
/kernel/src/arch/x86_64/sync.rs
UTF-8
1,567
2.578125
3
[ "MIT" ]
permissive
//! Handles architecture specific synchronization. use core::time::Duration; use sync::time::Timestamp; use x86_64::instructions::interrupts; use x86_64::registers::flags::*; /// The number of milliseconds since boot. pub static mut CLOCK: Duration = Duration::from_secs(0); /// Called while spinning (name borrowed f...
true
7052e0fccae620ca54c19398e5f1d917fe2d727b
Rust
Vicfred/codeforces-rust
/chatroom.rs
UTF-8
480
3.25
3
[ "BSD-3-Clause" ]
permissive
// https://codeforces.com/problemset/problem/58/A use std::io; fn main() { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); let s = s.trim(); let hello = "hello"; let mut idx = 0; for ch in s.chars() { if idx >= 5 { break; } if ch.to_st...
true
8fe9c52967b3cec2f0afa34249c50d607ba2768a
Rust
jmarianer/adventofcode
/2020/src/day19.rs
UTF-8
2,122
3.359375
3
[]
no_license
use std::collections::HashMap; use std::fs::File; use std::io::{BufRead, BufReader}; use regex::Regex; fn get_re(rules : &HashMap<u32, String>, rule_no : u32) -> String { lazy_static! { static ref TERM : Regex = Regex::new("^\"(.*)\"$").unwrap(); } let rule = &rules[&rule_no]; if TERM.is_match(...
true
911909c09530b9ab31ebd7babe1c27dd968f8305
Rust
gnoliyil/fuchsia
/third_party/rust_crates/vendor/tracing-0.1.34/src/instrument.rs
UTF-8
11,553
3.21875
3
[ "MIT", "BSD-2-Clause" ]
permissive
use crate::stdlib::pin::Pin; use crate::stdlib::task::{Context, Poll}; use crate::stdlib::{future::Future, marker::Sized}; use crate::{ dispatcher::{self, Dispatch}, span::Span, }; use pin_project_lite::pin_project; /// Attaches spans to a [`std::future::Future`]. /// /// Extension trait allowing futures to be...
true
c9a351f535eca867c8d45653dac120d229d315c0
Rust
anupvarghese/rust-docker
/shadowing/src/main.rs
UTF-8
440
3.390625
3
[]
no_license
/* Shadowing */ fn main() { let x :i32; x = 5; println!("Value of x, {}", x); let x = "I am a string"; // Here X is immutable and changed to another type in later part of the code, this is shadowing println!("Who are you x?, {}", x); // We can also make x as mutable and keeping the shado...
true
1c249f044c3b06eb2c2406596191b5443ff9413c
Rust
jesus18ld44/RUST-practice
/vectors.rs
UTF-8
385
3.5
4
[]
no_license
fn main() { let v: Vec<i32> = Vec::new(); let mut v = vec![1,2,3]; // ^ macro to create new vector with initial values // to add elements `push` method v.push(5); println!("{:?}", v); let elem = &v[2]; v.push(10); println!("{:?}", v); println!("{}", v.len()); ...
true
44cb5d778db45731137f99d04071309dc987f780
Rust
tmontaigu/dbase-rs
/src/de.rs
UTF-8
9,852
2.75
3
[ "MIT" ]
permissive
use std::fmt::Display; use std::io::{Read, Seek}; use serde::de::{DeserializeOwned, DeserializeSeed, IntoDeserializer, SeqAccess, Visitor}; use serde::Deserializer; use crate::{ ErrorKind, FieldConversionError, FieldIOError, FieldIterator, FieldValue, ReadableRecord, }; impl<'de, 'a, 'f, R1, R2> SeqAccess<'de> f...
true