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
6e2360ce8f15c59519be10586424bb363a340a2a
Rust
andrew-d/interfaces-rs
/src/error.rs
UTF-8
2,018
3.328125
3
[ "MIT", "Apache-2.0" ]
permissive
use std::convert::From; use std::error::Error; use std::fmt; use nix; /// InterfacesError is the error type that is returned by all functions in this crate. See the /// documentation on the individual variants for more information. #[derive(Debug)] pub enum InterfacesError { /// Errno indicates that something we...
true
af02a046649f2a6628f3b6192cec1fc386dc7609
Rust
mijnadres/elm_export
/src/lib.rs
UTF-8
2,453
3.484375
3
[ "MIT" ]
permissive
//! Provides easy communication between [Elm](http://elm-lang.org/) and //! [Rust](https://www.rust-lang.org/en-US/) by leveraging //! [syn](https://crates.io/crates/syn). //! //! ## Usage //! Notice that at the moment some of this is dreamcode. //! //! Lets say we have some models in Rust. //! //! ```rust //! enum Mes...
true
10f8544a041e2452829b5146554733a5bf09709f
Rust
thisisian/rspaint
/src/controller/color.rs
UTF-8
771
3.046875
3
[ "BSD-2-Clause" ]
permissive
extern crate cairo; #[derive(Clone)] pub struct RGBColor(u8, u8, u8); pub const BLACK: RGBColor = RGBColor(0, 0, 0); pub const WHITE: RGBColor = RGBColor(128, 128, 128); impl RGBColor { pub fn get_rgb(&self) -> (u8, u8, u8) { (self.0, self.1, self.2) } pub fn new(r: u8, g: u8, b: u8) -> RGBColor ...
true
8ee1899366dc9bc366cf5a16872af748b615847d
Rust
Alex6614/rust-qlearning
/src/structs.rs
UTF-8
703
3.4375
3
[]
no_license
#[derive(Hash, Eq, PartialEq, Debug)] /// Describes the current state at which the system is in. At the moment it only allows for one i32 variable, but this can be extended easily. pub struct State { x_1: i32, } impl State { // Create a new State pub fn new(x_1: i32) -> State { State { x_1: x_1} } } /// A tuple...
true
be60205752e4b1918fd0c63d9d2802ced95e191b
Rust
michimani/Project-Euler-Solutions
/rust/src/utils/prime.rs
UTF-8
1,859
4.21875
4
[ "MIT" ]
permissive
/// Returns the number is prime number. /// /// # Example /// ``` /// assert_eq!(false, is_prime_number(1)); /// assert_eq!(true, is_prime_number(2)); /// assert_eq!(false, is_prime_number(100)); /// assert_eq!(true, is_prime_number(104729)); /// ``` pub fn is_prime_number(num: usize) -> bool { if num < 2 { ...
true
f7e18c0607e32bcab9deaca7744f5c09febebb10
Rust
andywarduk/aoc2020
/day23-2/src/main.rs
UTF-8
1,626
3.546875
4
[]
no_license
fn main() -> Result<(), Box<dyn std::error::Error>> { play("315679824", 1_000_000, 10_000_000); Ok(()) } fn play(start_str: &str, size: usize, moves: usize) { let mut nexts: Vec<usize> = Vec::new(); for _ in 0..=size + 1 { nexts.push(0) } let start_chars: Vec<char> = start_str.chars(...
true
b21b973ac7f5985bdc2771a6635e3b39f7653ebe
Rust
gdesmott/gst-log-parser
/examples/omx-perf.rs
UTF-8
3,023
2.65625
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright (C) 2017-2019 Guillaume Desmottes <guillaume@desmottes.be> // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modifi...
true
c154a785690df4c160a377bf3a52e9c87d15ef6a
Rust
Ruin0x11/sabi
/src/terrain/mod.rs
UTF-8
2,588
2.6875
3
[]
no_license
use std::collections::HashMap; use world::Bounds; use chunk::*; use chunk::serial::SerialChunk; use prefab::Markers; use world::WorldPosition; use infinigen::*; pub mod traits; pub mod regions; use self::regions::Regions; use self::traits::*; impl BoundedTerrain<WorldPosition, ChunkIndex> for Terrain { fn in_...
true
9e518050cd6c543935a80ea38b6f50f40faf99d9
Rust
sycer-dev/kwp
/tests/main.rs
UTF-8
1,717
3.125
3
[ "Apache-2.0" ]
permissive
use kwp::{Parser, Prefixes}; #[test] fn basic_text() { let parser = Parser::new( "+foo,-bar,+baz", Prefixes { positive: "+", negative: "-", }, ); let keywords = parser.parse(); assert_eq!(keywords.positive, vec!["foo", "baz"]); assert_eq!(keywords.ne...
true
76a7a3b8ce71d11d21049f8eaeb91ac2a176cb90
Rust
RustyGecko/sensor-tracker
/src/cmdparse.rs
UTF-8
1,481
3.25
3
[]
no_license
use core::prelude::*; use core::str::FromStr; use collections::vec::Vec; use collections::string::String; use modules::Usart; const NL: u8 = '\n' as u8; const CR: u8 = '\r' as u8; const BS: u8 = 8u8; #[derive(Debug)] pub enum Cmd { Read(u32), Write(u32), Unknown } pub fn get_command() -> Cmd { pr...
true
3d44e7349ff354a1e149725e786fb82b02326ec2
Rust
nazeudon/rust_tutrial
/10_1_generic/src/main.rs
UTF-8
1,023
4.125
4
[]
no_license
fn main() { let number_list = vec![34, 50, 25, 100, 65]; // let mut largest = number_list[0]; // for number in number_list { // if number > largest { // largest = number // } // } let result = largest(&number_list); println!("The largest number is {}", result); l...
true
aa4e42e71b670b630f1dae81586f4eeb2456a3f4
Rust
brayniac/rips
/src/macros.rs
UTF-8
375
2.765625
3
[ "MIT", "Apache-2.0" ]
permissive
#[macro_export] /// Macro for sending on a Tx until it does not return an `TxError::InvalidTx`. macro_rules! tx_send { ($create:expr; $($arg:expr),*) => {{ let mut result = Err(TxError::InvalidTx); while let Err(TxError::InvalidTx) = result { let mut tx = $create(); result = ...
true
1f7b37d2900d32e6fc2903aa6526e3b5c693ab1d
Rust
lineCode/tuix
/widgets/src/dropdown.rs
UTF-8
9,473
2.859375
3
[ "MIT" ]
permissive
use crate::common::*; use crate::{CheckButton, CheckboxEvent, Label, Popup, PopupEvent, List}; const ICON_DOWN_DIR: &str = "\u{25be}"; #[derive(Debug, Clone, PartialEq)] pub enum DropdownEvent { SetText(String), } pub struct DropdownItem { //checkbox: Entity, text: String, pressed: bool, } impl Drop...
true
a2b96b908218155287df5dfbae924f1b3def14ec
Rust
singee-study/rust-minigrep
/src/app.rs
UTF-8
390
2.546875
3
[]
no_license
pub mod utils; pub use self::utils::search; use crate::config::Config; use std::error::Error; use std::fs::read_to_string; pub fn run(config: Config) -> Result<(), Box<dyn Error>> { let file_content = read_to_string(config.file_path)?; let search_result = search(&config.target, &file_content); for line...
true
c01ae01589656a6bd011a2588d80de27d6a610cf
Rust
kindlychung/stool
/src/widget_controller.rs
UTF-8
875
2.65625
3
[]
no_license
//! Controller widgets use druid::widget::Controller; use druid::{Env, Event, EventCtx, UpdateCtx, Widget}; use crate::AppData; /// A widget that wraps all root widgets #[derive(Debug, Default)] pub struct RootWindowController; impl<W: Widget<AppData>> Controller<AppData, W> for RootWindowController { fn event(...
true
9dfead512951eaf6f69ea447dcb6286281b8419c
Rust
spriest487/advent-of-code-2018
/src/day_15.rs
UTF-8
11,855
2.96875
3
[]
no_license
mod point; mod astar; use { crate::{ astar::Pathfinder, point::{ Point, Neighbors, }, }, std::{ fmt, cmp::Ordering, collections::{ HashSet, HashMap, }, time::Instant, usize, }, ra...
true
a0f3de490c25093358f07f103c9c0e54caac5d2c
Rust
DuBistKomisch/jakebarnes
/src/home.rs
UTF-8
434
2.75
3
[]
no_license
use chrono::{Local, TimeZone}; use rocket::get; use rocket_dyn_templates::Template; use serde::Serialize; const SECONDS_PER_YEAR: i64 = 31_557_600; // 365.25 * 24 * 60 * 60; #[derive(Serialize)] struct HomeContext { age: i64 } #[get("/")] pub fn get() -> Template { let age = Local::today().signed_duration_si...
true
e814d15b6e26bfcefe8a5a3bc2f897ffb60203a2
Rust
tov/broadword-rs
/src/lib.rs
UTF-8
11,603
3.4375
3
[ "Apache-2.0", "MIT" ]
permissive
#![doc(html_root_url = "https://docs.rs/broadword/0.2.2")] //! Broadword operations treat a `u64` as a parallel vector of eight `u8`s or `i8`s. //! This module also provides a population count function [`count_ones`](fn.count_ones.html) and a //! select function [`select1`](fn.select1.html). //! //! The algorithms here...
true
542b946dbab82b0020c75346c0ae0e9cb12ecfa5
Rust
andrewhickman/fs-err
/src/os.rs
UTF-8
355
2.578125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! OS-specific functionality. // The std-library has a couple more platforms than just `unix` for which these apis // are defined, but we're using just `unix` here. We can always expand later. #[cfg(unix)] /// Platform-specific extensions for Unix platforms. pub mod unix; #[cfg(windows)] /// Platform-specific extens...
true
5e40fb9972d05f3cbb80ed8d39653a528aadeeef
Rust
konny0311/Rust_tutorial
/rectangles/src/lib.rs
UTF-8
1,117
3.984375
4
[]
no_license
struct Rectangle { width: u32, height: u32, } impl Rectangle { fn area(&self) -> u32 { self.width * self.height } fn can_hold(&self, compared_rect: &Rectangle) -> bool { let base_area : u32 = self.area(); let compared_area : u32 = compared_rect.area(); println!("Area...
true
91e7b66ddd83fd3234c0e6ed11213d92c92b34bd
Rust
azdavis/advent-of-code
/years/y2015/src/d16.rs
UTF-8
1,421
3.21875
3
[ "MIT" ]
permissive
use helpers::HashMap; const EQ: [(&str, usize); 6] = [ ("children", 3), ("samoyeds", 2), ("akitas", 0), ("vizslas", 0), ("cars", 2), ("perfumes", 1), ]; const GT: [(&str, usize); 2] = [("cats", 7), ("trees", 3)]; const LT: [(&str, usize); 2] = [("pomeranians", 3), ("goldfish", 5)]; fn run(s: &str, f: fn...
true
600b7fdb38d85ea31421cef1a964bea66a681596
Rust
khernyo/simple-message-channels-rs
/examples/basic.rs
UTF-8
688
2.59375
3
[ "Apache-2.0", "MIT" ]
permissive
use bytes::Bytes; use simple_message_channels::{Channel, Decoder, Encoder, MessageType}; fn main() { let mut decoder = Decoder::new(None); let mut encoder = Encoder::new(None); let mut bytes = encoder .send(Channel(0), MessageType(1), &Bytes::from(b"a".as_ref())) .unwrap(); bytes.exten...
true
0420198e5bf463b7cfec74395b87322318abf9b9
Rust
AlisCode/utopia
/utopia_core/src/math/mod.rs
UTF-8
2,814
3.921875
4
[]
no_license
#[derive(Default, Debug, Clone, Copy)] pub struct Size { pub width: f32, pub height: f32, } impl From<(f32, f32)> for Size { fn from((width, height): (f32, f32)) -> Self { Size { width, height } } } impl Size { pub const ZERO: Size = Size { width: 0., height: 0., }; ...
true
42c6a3ab3671e43f668a0d4d4a91dd5ad929c818
Rust
tempbottle/probor
/rust/src/errors.rs
UTF-8
3,363
3
3
[]
no_license
use cbor; use std::error::Error; use std::fmt::{self, Formatter, Debug, Display}; pub enum DecodeError { AbsentField(&'static str), WrongArrayLength(usize), DuplicateKey, UnexpectedNull, WrongType(&'static str, cbor::DecodeError), WrongValue(&'static str), BadFieldValue(&'static str, Box<D...
true
0f9312665bf86ace9d05b084984d19ab8a4a8be7
Rust
rust-lang/regex
/regex-cli/cmd/find/which/mod.rs
UTF-8
7,216
2.5625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unicode" ]
permissive
use std::io::{stdout, Write}; use { anyhow::Context, lexopt::Parser, regex_automata::{Input, MatchError, PatternID, PatternSet}, }; use crate::{ args, util::{self, Table}, }; mod dfa; mod nfa; pub fn run(p: &mut Parser) -> anyhow::Result<()> { const USAGE: &'static str = "\ Executes a 'which...
true
f6f184591efb4fcb371cada34ccc6c8c20fe5194
Rust
GuillaumeGomez/docs.rs
/src/utils/consistency/diff.rs
UTF-8
6,803
3.203125
3
[ "MIT" ]
permissive
use std::fmt::Display; use super::data::Crate; use itertools::{ EitherOrBoth::{Both, Left, Right}, Itertools, }; #[derive(Debug, PartialEq)] pub(super) enum Difference { CrateNotInIndex(String), CrateNotInDb(String, Vec<String>), ReleaseNotInIndex(String, String), ReleaseNotInDb(String, String...
true
0bbac58213d888db2c6fc5ccab6f9b6d65b5fa4c
Rust
digitsu/bitcrust
/encode-derive/src/lib.rs
UTF-8
1,524
2.765625
3
[ "MIT" ]
permissive
extern crate proc_macro; extern crate syn; #[macro_use] extern crate quote; use proc_macro::TokenStream; #[proc_macro_derive(Encode, attributes(count))] pub fn derive_encode(input: TokenStream) -> TokenStream { // Construct a string representation of the type definition let s = input.to_string(); //...
true
a17f255fca0e66f19b2a2daa3fa08a40e659d8fa
Rust
SViksha/jormungandr
/tests/common/file_utils.rs
UTF-8
1,415
3.53125
4
[ "Apache-2.0", "MIT" ]
permissive
#![allow(dead_code)] extern crate mktemp; use std::fs::File; use std::io::Write; use std::path::PathBuf; /// Gets path in temp directory (does not create it) /// /// # Arguments /// /// * `file_path` - A string slice that holds the path /// that will be glued to temp directory path /// /// # Example /// /// use file...
true
f6c7b0e35bc5edd86297693eed3f9ac60f6379f4
Rust
RReverser/serde-xml-rs
/src/de/map.rs
UTF-8
5,070
2.90625
3
[ "MIT" ]
permissive
use std::io::Read; use serde::de::{self, IntoDeserializer, Unexpected}; use serde::forward_to_deserialize_any; use xml::attribute::OwnedAttribute; use xml::reader::XmlEvent; use crate::error::{Error, Result}; use crate::Deserializer; use super::buffer::BufferedXmlReader; pub struct MapAccess<'a, R: Read, B: Buffere...
true
7f581bfa56b198a773b886de56296c50f279fe87
Rust
AlekseyAstakhov/diskomap
/src/file_worker.rs
UTF-8
3,170
3.5625
4
[ "Apache-2.0", "MIT" ]
permissive
use std::sync::mpsc::{channel, Sender}; use std::thread::{spawn, JoinHandle}; /// For write to the file in background thread. pub(crate) struct FileWorker { task_sender: Sender<FileWorkerTask>, join_handle: Option<JoinHandle<()>>, } impl FileWorker { /// Constructs 'FileWorker' for write to the file in ba...
true
8bbcfa597d7736d7a2016b827624eac2a3f6c704
Rust
AntonGepting/tmux-interface-rs
/src/commands/windows_and_panes/previous_window_tests.rs
UTF-8
1,022
2.921875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
#[test] fn previous_window() { use crate::PreviousWindow; use std::borrow::Cow; // tmux ^0.9: // ```text // previous-window [-a] [-t target-session] // (alias: prev) // ``` // // tmux ^0.8: // ```text // previous-window [-t target-session] // (alias: prev) // ``` ...
true
4da80c59b75f084be494e6faa63f8d0d45e39e1b
Rust
pac85/vulkano-events
/vulkano/src/buffer/sys.rs
UTF-8
19,119
2.59375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
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
97db85d620417a8ef8305972e9fb32fa111388a5
Rust
reline/AdventOfCode2020
/src/reduce.rs
UTF-8
433
3.109375
3
[]
no_license
pub trait ReduceExt: Iterator { fn reduce<F>(self, f: F) -> Option<Self::Item> where Self: Sized, F: FnMut(Self::Item, Self::Item) -> Self::Item; } impl<I: Iterator> ReduceExt for I { fn reduce<F>(mut self, f: F) -> Option<Self::Item> where Self: Sized, F: FnMut(Self::It...
true
2fb8ffb1d61e8c0f59c7d82803d4b24aad7200bc
Rust
luke-titley/imath-traits
/src/lib.rs
UTF-8
1,933
2.9375
3
[ "Apache-2.0" ]
permissive
//! imath-traits provides a set of traits which constrain the types used in Rust translations of //! C++ APIs that rely on `Imath`, or `Imath-alike` types. //! //! This is solely about memory layout and being able to convert the implementing types back and //! forward into slices and pointers to be able to be used in t...
true
59aa738a83693c0269a9ff382784749f99a253a0
Rust
kdeconinck/Monkey-1
/src/compiler/symbol_table.rs
UTF-8
2,565
3.359375
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::mem; #[derive(Debug, Clone, Eq, PartialEq)] pub enum SymbolScope { GLOBAL, LOCAL, BUILTIN, FREE } #[derive(Debug, Clone, Eq, PartialEq)] pub struct Symbol { pub name: String, pub scope: SymbolScope, pub index: usize, } impl Default for Symbol { fn default() -> Self { ...
true
ffcde8b2db25184b4e150811eb58a951369a8dc6
Rust
timvermeulen/advent-of-code
/src/solutions/year2018/day23.rs
UTF-8
6,659
3.71875
4
[]
no_license
use super::*; #[derive(Debug, Eq, PartialEq, Copy, Clone)] struct Point { x: i32, y: i32, z: i32, } impl Point { fn distance_to(&self, position: Point) -> i32 { (self.x - position.x).abs() + (self.y - position.y).abs() + (self.z - position.z).abs() } fn distance_to_origin(&self) -> i3...
true
9f3fe51ed2d3c495222e1eb1ad8ce20300978bf2
Rust
bmc-msft/command-group
/src/stdlib/child/unix.rs
UTF-8
3,920
2.609375
3
[ "Apache-2.0", "MIT" ]
permissive
use std::{ convert::TryInto, io::{Error, ErrorKind, Read, Result}, os::unix::{ io::{AsRawFd, RawFd}, process::ExitStatusExt, }, process::{Child, ChildStderr, ChildStdin, ChildStdout, ExitStatus}, }; use nix::{ errno::Errno, libc, poll::{poll, PollFd, PollFlags}, sys::{ signal::{killpg, Signal}, wait::...
true
4fb51dd792c567b093a017b005efa41186ec2e2d
Rust
mmitteregger/cuke-runner
/core/glue/src/scenario.rs
UTF-8
2,451
3.203125
3
[ "MIT" ]
permissive
use std::any::{Any, TypeId}; use std::collections::HashMap; use std::fmt; use failure::Fail; #[derive(Debug, Default)] pub struct Scenario { data: HashMap<TypeId, Box<dyn Any>>, } impl Scenario { #[doc(hidden)] pub fn new() -> Scenario { Scenario { data: HashMap::new(), } ...
true
6b9c993c27451b9ea58b0d4792fd8f44f5dc2941
Rust
trussed-dev/trussed
/src/virt/store.rs
UTF-8
6,591
2.578125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use std::{ fs::{File, OpenOptions}, io::{Read as _, Seek as _, SeekFrom, Write as _}, marker::PhantomData, path::PathBuf, }; use generic_array::typenum::{U512, U8}; use littlefs2::{const_ram_storage, driver::Storage, fs::Allocation}; use crate::{ store, store::Store, types::{LfsResult, Lfs...
true
8fdd027fb346935d43419bf99cd225bf970aee92
Rust
seppo0010/rusttojs
/test/call3.rs
UTF-8
157
3.09375
3
[ "BSD-2-Clause" ]
permissive
struct MyStruct { n: i8 } impl MyStruct { fn get(&self) -> i8 { self.n } } fn main() { let myvar = MyStruct { n: 3 }; println!("{}", myvar.get()); }
true
d0cd428bd8b7c21706bd82d657957a8d7caa2c38
Rust
barabadzhi/improvement-mkp
/src/knapsack/neighborhood.rs
UTF-8
3,011
2.890625
3
[ "MIT" ]
permissive
use std::sync::RwLock; use knapsack::item::Item; use knapsack::rayon::prelude::*; use knapsack::statistics::Statistics; #[derive(Debug)] pub struct Neighborhood<'a> { pub result: &'a Statistics, pub base_items: Vec<&'a Item>, pub neighbors: Vec<(usize, &'a Item)>, } impl<'a> Neighborhood<'a> { pub fn...
true
58d17c1f9e6001b2cb047bae8185afcc7be5e310
Rust
nraynaud/mpu9250
/src/ak8963.rs
UTF-8
1,028
2.75
3
[ "Apache-2.0", "MIT" ]
permissive
//! AK8963, I2C magnetometer // I2C slave address pub const I2C_ADDRESS: u8 = 0x0c; pub const R: u8 = 1 << 7; pub const W: u8 = 0 << 7; #[allow(dead_code)] #[allow(non_camel_case_types)] #[derive(Clone, Copy)] pub enum Register { WHO_AM_I = 0x00, // should return 0x48 INFO = 0x01, ST1 = 0x02, // data r...
true
7da1f80d1d7ea7e9f9ee3558b511ac0b27215683
Rust
waynedupreez1/eeprom34c04-rs
/src/eeprom34c04.rs
UTF-8
11,533
3.015625
3
[ "Apache-2.0", "MIT" ]
permissive
use hal::blocking::i2c::{Write, WriteRead, Read}; use Eeprom34c04; use SlaveAddr; use super::error; //Constants const RW_FUNC_BITS: u8 = 0b1010000; // Page Address Functions bits:) const PA_FUNC_BITS: u8 = 0b0110110; impl<I2C, E> Eeprom34c04<I2C> where I2C: Write<Error = E> + WriteRead<Error = E>, { ...
true
93b5d97d55e40d383cb73f94f07f69097b06c6ee
Rust
wonjin/rust_snake
/src/main.rs
UTF-8
1,111
2.78125
3
[]
no_license
extern crate piston_window; extern crate rand; mod game; mod snake; mod draw; use piston_window::types::Color; use piston_window::*; use self::game::Game; use self::draw::to_coord; const BACK_COLOR: Color = [0.5, 0.5, 0.5, 1.0]; fn main() { let (w, h) = (10,10); let (gui_w_u32, gui_h_u32) = (to_coord(w) as...
true
736b0dcc860035e8b7c8113089511d988e68b983
Rust
pine/rust-hands-on
/ownership/src/main.rs
UTF-8
173
2.6875
3
[ "LicenseRef-scancode-public-domain" ]
permissive
fn main() { let v = vec![1, 2, 3]; println!("{:?}", v); // let v2 = v; let v2 = &v; println!("{:?}", v2); println!("{:?}", v); // v2[0] = 1; }
true
6afdc2e547b5045038cc0fa8145cf336d680ff36
Rust
JustusFT/ultimate_tic_tac_toe
/terminal_game/src/main.rs
UTF-8
10,007
2.625
3
[]
no_license
use base_game::game::Game; use base_game::monte_carlo::MctsTree; use rustyline::Editor; use std::convert::TryFrom; use std::io::{stdout, Write}; use std::time::Instant; use termion::clear; use termion::cursor; use termion::raw::IntoRawMode; const BOARD_DISPLAY: &'static str = " \ │ │ ┃ │ │ ┃ │ │...
true
5e2108384b4c28c3f5179b74a6a564e762217839
Rust
gwy15/leetcode
/src/1140.石子游戏-ii.rs
UTF-8
1,596
3.03125
3
[]
no_license
/* * @lc app=leetcode.cn id=1140 lang=rust * * [1140] 石子游戏 II */ struct Solution; // @lc code=start #[allow(unused)] impl Solution { pub fn stone_game_ii(piles: Vec<i32>) -> i32 { let n = piles.len(); let mut post_sum = vec![0; n + 1]; for i in (0..n).rev() { post_sum[i] = p...
true
6afdf185aed1b5f2c5dad1b2dda6dea6c48b0e45
Rust
gefjon/zeldesque
/src/color.rs
UTF-8
469
2.734375
3
[]
no_license
pub type Color = [f32; 4]; pub type RawColor = [f32; 3]; pub fn with_opacity(color: RawColor, opacity: f32) -> Color { [color[0], color[1], color[2], opacity] } pub const OPAQUE: f32 = 1.0; pub const RED: RawColor = [1.0, 0.0, 0.0]; pub const GREEN: RawColor = [0.0, 1.0, 0.0]; pub const BLUE: RawColor = [0.0, 0....
true
4b03beed9f98cf250506519df5991e5820902f73
Rust
jakyle/rust-algos
/src/smaller_than_the_current_number.rs
UTF-8
708
3.5
4
[ "MIT" ]
permissive
pub fn smaller_numbers_than_current(nums: Vec<i32>) -> Vec<i32> { let mut result = vec![0; nums.len()]; for (i, x) in nums.iter().enumerate() { for (j, y) in nums.iter().enumerate() { if i == j { continue; } if y < x { result[i] += 1;...
true
53c36cad96e7c8e6de05ff1ada3b836faa7a528f
Rust
rust-lang/thanks
/src/main.rs
UTF-8
19,851
2.515625
3
[ "MIT", "Apache-2.0" ]
permissive
use git2::{Commit, Oid, Repository}; use mailmap::{Author, Mailmap}; use regex::{Regex, RegexBuilder}; use semver::Version; use std::collections::{BTreeMap, HashMap, HashSet}; use std::io::Read; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; use std::sync::Mutex; use std::{cmp, fmt, str}; use conf...
true
fed3678abf892207e590bc9d5a45be5e7c5ce057
Rust
TheBlueMatt/rust-lightning
/lightning-block-sync/src/http.rs
UTF-8
26,310
2.6875
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! Simple HTTP implementation which supports both async and traditional execution environments //! with minimal dependencies. This is used as the basis for REST and RPC clients. use chunked_transfer; use serde_json; use std::convert::TryFrom; use std::fmt; #[cfg(not(feature = "tokio"))] use std::io::Write; use std::...
true
29059a3f1cbdd37361fde505e2c1f1d0a6396adb
Rust
ChrisRG/CodingChallenges
/old_leetcode/easy/322_coin_change.rs
UTF-8
637
3.53125
4
[]
no_license
// You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. // Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1. // You may ...
true
c1da12e94e7baf177ce47c6b2fcb453979f86957
Rust
benbrunton/pusoy-dos
/src/game/player.rs
UTF-8
2,400
3.53125
4
[]
no_license
use cards::card::PlayerCard; /// A player #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Player{ hand: Vec<PlayerCard>, id: u64 } impl Player{ /// creates a new `Player` pub fn new(id: u64) -> Player{ Player{ hand: vec!(), id: id } ...
true
a957c17ba8d1910f4044ab1340ec06628a03da42
Rust
msoermc/rmc-core-2018-2019
/src/motor_controllers/print_motor.rs
UTF-8
1,729
3.46875
3
[]
no_license
use std::sync::Arc; use super::*; const FLOAT_ERROR: f32 = 0.05; pub struct PrintMotor { name: String, state: Arc<GlobalMotorState>, is_stopped: bool, } impl MotorController for PrintMotor { fn set_speed(&mut self, new_speed: f32) { if (self.get_motor_state().get_speed() - new_speed < FLOAT_...
true
18974a9f5e2ef00b711b3ee6ecb0ec9aa4fd2734
Rust
AlexseiT/sibsutis
/4course/graphical_information/labs/src/lib.rs
UTF-8
5,800
3.109375
3
[ "WTFPL" ]
permissive
use std::path::Path; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use std::fs::{File, OpenOptions}; use std::io::{Read, Seek, SeekFrom, Write}; pub struct BMP { file: File, filesize: u32, offset: u32, width: u16, height: u16, image_data: Vec<u8>, } impl BMP { pub fn open(pa...
true
d7fc45881875c6c2f5b460a9dd482c8938e143e4
Rust
rustwasm/wasm-bindgen
/crates/web-sys/tests/wasm/olist_element.rs
UTF-8
1,373
2.859375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use wasm_bindgen::prelude::*; use wasm_bindgen_test::*; use web_sys::HtmlOListElement; #[wasm_bindgen(module = "/tests/wasm/element.js")] extern "C" { fn new_olist() -> HtmlOListElement; } #[wasm_bindgen_test] fn test_olist_element() { let olist = new_olist(); olist.set_reversed(true); assert_eq!( ...
true
ab9bfd0d331aa8111f6199db0861e9c21d949cf7
Rust
JelteF/derive_more
/tests/deref.rs
UTF-8
1,172
2.734375
3
[ "MIT" ]
permissive
#![cfg_attr(not(feature = "std"), no_std)] #![allow(dead_code, unused_imports)] #[cfg(not(feature = "std"))] extern crate alloc; #[cfg(not(feature = "std"))] use ::alloc::{boxed::Box, vec::Vec}; use derive_more::Deref; #[derive(Deref)] #[deref(forward)] struct MyBoxedInt(Box<i32>); #[derive(Deref)] #[deref(forward...
true
7722b90e34b420ac83bb88aeedd12ec6aa782f79
Rust
whytheplatypus/diem
/src/lib.rs
UTF-8
5,652
3.203125
3
[]
no_license
extern crate chrono; use chrono::NaiveDate; use std::fmt; use std::str::FromStr; pub type List = Vec<Event>; type Day = NaiveDate; #[derive(Debug)] pub enum Action { Add, Remove, Complete, } #[derive(Debug)] pub struct ActionParseError; impl fmt::Display for ActionParseError { fn fmt(&self, fmt: &...
true
cf9adc9251bdaf20babeaa8978c07370d11aba24
Rust
melkibalbino/rust-conc-e-perf-seguro
/05-Vetores-strings-e-tipos-genericos/vetor-05-map/src/main.rs
UTF-8
657
3.5
4
[]
no_license
#[derive(Debug)] struct Contact { name: &'static str, phone_number: &'static str } fn main() { let contato_01 = Contact { name: "Sivirina Chique Chique", phone_number: "+55 (82) 93325-6554" }; let contato_02 = Contact { name: "Maria Jose", phone_number: "+55 (81) 9...
true
f6fba57f7af0bb9144cc4bf22feaf0b0d683b23c
Rust
helloooooo/prac-algo
/drken-training/lakecounting.rs
UTF-8
5,473
3
3
[]
no_license
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lo...
true
a8fae04e8c6bd54d0f6f91f979db4bcd9875bdee
Rust
Grinshpon/Feldunor
/src/states/rl.rs
UTF-8
2,525
2.546875
3
[]
no_license
use bracket_lib::prelude::*; use shipyard::{AllStoragesViewMut, EntityId, EntitiesViewMut, UniqueView, ViewMut}; use std::any::Any; use crate::state::{AppData, SEvent, State}; use crate::components::*; use crate::map::*; #[derive(Clone,Copy,PartialEq,Eq)] pub enum Turn { Player, World, } pub struct R...
true
92991f8950f3eed76fd09034ddecdf5e74ac1f21
Rust
ticketland-io/sharks
/src/lib.rs
UTF-8
7,263
3.515625
4
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
//! Fast, small and secure [Shamir's Secret Sharing](https://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing) library crate //! //! Usage example (std): //! ``` //! use sharks::{ Sharks, Share }; //! //! // Set a minimum threshold of 10 shares //! let sharks = Sharks(10); //! // Obtain an iterator over the shares for s...
true
6bbae8b015adb3b8ea9cfb15b08a41815a6f9c9b
Rust
i-dentify/echarge-vnext
/rust/car/api/src/graphql/models.rs
UTF-8
460
2.546875
3
[]
no_license
use std::num::NonZeroU16; use async_graphql::{ID, Object}; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] pub struct Car { pub id: ID, pub name: String, pub battery_capacity: NonZeroU16, } #[Object] impl Car { async fn id(&self) -> &ID { &self.id } async fn nam...
true
54bdb966b84d57a224d504c5e00576e8ba80d97a
Rust
yvt/farcri-rs
/src/bencher/bencher.rs
UTF-8
4,645
3.625
4
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::measurement; /// Timer struct used to iterate a benchmarked function and measure the runtime. /// /// This struct provides different timing loops as methods. Each timing loop provides a different /// way to time a routine and each has advantages and disadvantages. /// /// * If you want to do the iteration a...
true
a3088ae53e4f2c6d482b043ebe65ab5f0c8d99b9
Rust
AngelOnFira/advent-of-code
/2021/src/day25.rs
UTF-8
3,079
3.421875
3
[]
no_license
use std::collections::HashMap; use regex::Regex; pub struct Instruction {} #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Place { East, South, Empty, } const xlen: usize = 8; const ylen: usize = 7; #[aoc_generator(day25)] pub fn input_generator(input: &str) -> [[Place; xlen]; ylen] { // v......
true
b4aced5eda990bc669ff1858e048b8f62f0b0f27
Rust
EvanLib/Chip8
/src/core/display.rs
UTF-8
4,576
3.109375
3
[]
no_license
use minifb::{Key, Scale, Window, WindowOptions}; use std::fmt; const CHIP8_WIDTH: usize = 64; const CHIP8_HEIGHT: usize = 32; #[derive(Clone, Debug)] pub struct Display { // vram pub vram: [[u8; CHIP8_WIDTH]; CHIP8_HEIGHT], // update pub update: bool, // minifb buffer pub buffer: Vec<u32>, }...
true
341a39435e90d1c4f7bf35cfe4faabcd787721dd
Rust
timvermeulen/hollow_heap
/tests/proptests.rs
UTF-8
1,495
2.875
3
[ "MIT" ]
permissive
#[macro_use] extern crate proptest; use proptest::prelude::*; use proptest::collection::vec; use hollow_heap::HollowHeap; proptest! { #[test] fn doesnt_crash(num in 0..100000) { let mut heap = HollowHeap::max_heap(); heap.push(num); assert!(heap.pop() == Some(num)); assert!(h...
true
4ce01454291b4694418af0ceb422491b447ba22b
Rust
henryboisdequin/vsreview
/server-rs/src/models/answer.rs
UTF-8
749
2.6875
3
[ "MIT" ]
permissive
use crate::models::user::User; use crate::utils::DATE_FORMAT; use chrono::{DateTime, Utc}; use serde::Serialize; #[derive(Queryable)] pub struct Answer { pub id: i32, pub content: String, pub question: i32, pub author: i32, pub created_at: DateTime<Utc>, } impl Answer { pub fn attach(self, aut...
true
b2964ab0ae1c434529af16974b0a6a23a165628b
Rust
dfischer/unbase
/examples/ping-pong.rs
UTF-8
2,842
2.703125
3
[ "Apache-2.0" ]
permissive
#![feature(proc_macro, conservative_impl_trait, generators)] extern crate futures_await as futures; use futures::stream::Stream; extern crate unbase; use unbase::{Network,SubjectHandle}; use std::{thread,time}; /// This example is a rudimentary interaction between two remote nodes /// As of the time of this writing,...
true
25bed8cf7e1aeffa0e3e6e1b14867883bda86131
Rust
zarbafian/draft
/src/util.rs
UTF-8
2,370
3.625
4
[ "MIT" ]
permissive
use std::sync::{mpsc, Arc, Mutex}; use std::thread; use log::{debug, info}; type MessageHandler = Box<dyn FnOnce() + Send + 'static>; enum Message { New(MessageHandler), Terminate, } struct Worker { id: usize, thread: Option<thread::JoinHandle<()>>, } impl Worker { fn new(id: usize, receiver: Arc...
true
b5067895ceff2758edf7d286c888ab8c1c3d86ec
Rust
Daivasmara/rust_book
/06/if_let/src/main.rs
UTF-8
1,294
4.09375
4
[]
no_license
#[derive(Debug)] enum UsState { Alabama, } enum Coin { Penny, Quarter(UsState), } fn main() { let some_u8_values = Some(0u8); match some_u8_values { Some(3) => println!("three"), _ => (), } // code above too verbose since you need to add _ in order to make this code works...
true
5274975d6f2894b24fe5d820583fb5e2dd745ffb
Rust
joedborg/diffie-hellman-demo
/src/onlookers.rs
UTF-8
287
2.84375
3
[ "Apache-2.0", "LicenseRef-scancode-public-domain" ]
permissive
pub struct Public { pub prime: u64, pub root: u64, pub amy: Option<u64>, pub ben: Option<u64>, } impl Public { pub fn amy(&mut self, value: u64) { self.amy = Some(value); } pub fn ben(&mut self, value: u64) { self.ben = Some(value); } }
true
1f4bf4b00f733de27532785730039b2d0404ec7d
Rust
jeremyschlatter/enigma
/src/main.rs
UTF-8
4,691
2.875
3
[]
no_license
const ALPHABET_SIZE: usize = 26; type Permutation = [usize; ALPHABET_SIZE]; const PERMUTATIONS: [Permutation; 5] = [ [ 0, 21, 4, 7, 15, 18, 12, 14, 16, 8, 3, 19, 24, 23, 2, 11, 13, 5, 22, 20, 6, 25, 10, 17, 9, 1, ], [ 5, 22, 8, 24, 14, 16, 7, 11, 10, 18, 6, 15, 9, 25, 0, 2, 13, 3, 2...
true
fb1992794599f32637b606e768ff6f64d37480ef
Rust
rainapepe/rust-nes-emulator
/src/ppu/memory_access.rs
UTF-8
13,763
2.875
3
[]
no_license
use crate::cartridge::Mirror; use super::ppu2C02::Ppu2C02; impl Ppu2C02 { pub fn cpu_read(&mut self, addr: u16, read_only: bool) -> u8 { if read_only { // Reading from PPU registers can affect their contents // so this read only option is used for examining the // state...
true
19213870fe36612dee3150a6eb27188eee8d723f
Rust
togatoga/competitive-lib
/rust/src/lazy_segment_tree.rs
UTF-8
13,555
2.734375
3
[ "MIT" ]
permissive
use cargo_snippet::snippet; #[allow(clippy::module_inception)] #[snippet] /// LazySegmentTree is copied from ac-library-rs pub mod lazy_segment_tree { pub trait Monoid { type S: Clone; fn identity() -> Self::S; fn binary_operation(a: &Self::S, b: &Self::S) -> Self::S; } pub trait Map...
true
e38a4a12eaf3e88241ad2bb5f48103626fe19bd0
Rust
zeromq/zmq.rs
/examples/task_sink.rs
UTF-8
1,008
2.65625
3
[ "MIT" ]
permissive
mod async_helpers; use std::error::Error; use std::io::Write; use std::time::Instant; use zeromq::{Socket, SocketRecv, SocketSend}; #[async_helpers::main] async fn main() -> Result<(), Box<dyn Error>> { // Socket to receive messages on let mut receiver = zeromq::PullSocket::new(); receiver.bind("tcp://12...
true
3b1b00232fc570a70996728339cb30e5bda5ff00
Rust
CyberFlameGO/abi_stable_crates
/abi_stable/src/type_layout/tl_fields.rs
UTF-8
6,334
2.984375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use super::*; use std::{ iter, slice, }; /// The layout of all compressed fields in a type definition, /// one can access the expanded fields by calling the expand method. #[repr(C)] #[derive(Copy, Clone, StableAbi)] #[sabi(unsafe_sabi_opaque_fields)] pub struct CompTLFields { /// All TLField fields which...
true
2f1a4f8d66b4dc297566ddb5109200825fb9344b
Rust
ijanos/euler-rust
/src/euler14.rs
UTF-8
545
3.25
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// I thought I need to memoize this but it is plenty fast already fn collatz_length(a: u32) -> u32 { let mut length = 1; let mut n: u64 = a as u64; while n != 1 { n = if n % 2 == 0 { n / 2 } else { 3 * n + 1 }; length += 1; } length } pub fn m...
true
15223932ba5972c70eea6ef8c2a4ca6b785128b8
Rust
ScottDillman/rune
/crates/rune-ssa/src/lib.rs
UTF-8
1,160
2.5625
3
[ "Apache-2.0", "MIT" ]
permissive
//! The state machine assembler of Rune. #![allow(clippy::new_without_default)] mod block; mod constant; mod error; mod global; mod internal; mod phi; mod program; mod term; mod value; pub use self::block::Block; pub use self::constant::Constant; pub use self::error::Error; pub use self::global::{Assign, BlockId, Con...
true
80060d31eab3ea1b5f14ec36d195a7114ecad1fa
Rust
acmcarther/cargo-raze-examples
/bazel/complicated_cargo_library/cargo/vendor/arrayvec-0.3.25/tests/generic_array.rs
UTF-8
463
2.546875
3
[ "Apache-2.0", "MIT" ]
permissive
#![cfg(feature = "use_generic_array")] extern crate arrayvec; #[macro_use] extern crate generic_array; use arrayvec::ArrayVec; use generic_array::GenericArray; use generic_array::typenum::U41; #[test] fn test_simple() { let mut vec: ArrayVec<GenericArray<i32, U41>> = ArrayVec::new(); assert_eq!(vec.len(),...
true
f79c4161a3a63eb9fe819dde81d1df030cfef4ce
Rust
occlum/occlum
/src/libos/src/process/current.rs
UTF-8
1,064
2.96875
3
[ "BSD-3-Clause" ]
permissive
use super::process::IDLE; use super::{Thread, ThreadRef}; /// Get and set the current thread/process. use crate::prelude::*; pub fn get() -> ThreadRef { let current_ptr = CURRENT_THREAD_PTR.with(|cell| cell.get()); let current_ref = unsafe { Arc::from_raw(current_ptr) }; let current_ref_clone = current_ref...
true
fdfc1d80c90f3988f5112003a4d0eba81e4e1dd7
Rust
qryxip/ac-library-rs-parted
/ac-library-rs-parted-segtree/src/lib.rs
UTF-8
9,445
2.8125
3
[ "CC0-1.0" ]
permissive
// This code was expanded by `xtask`. extern crate __acl_internal_bit as internal_bit; extern crate __acl_internal_type_traits as internal_type_traits; pub use self::segtree::*; mod segtree { use super::internal_bit::ceil_pow2; use super::internal_type_traits::{BoundedAbove, BoundedBelow, One, Zero}; use...
true
14f9f72c621f19fc4311730e8c1fd005b99069be
Rust
kanerogers/ovr-mobile-sys
/src/helpers.rs
UTF-8
34,628
2.671875
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use super::*; use std::ptr; use std::{ ffi::c_void, mem::{self, MaybeUninit}, }; //----------------------------------------------------------------- // Matrix helper functions. //----------------------------------------------------------------- fn ovrVector4f_MultiplyMatrix4f(a: &ovrMatrix4f, v: &ovrVector4f)...
true
89080a3c30be616b7f9f0418c06dae0a06e67c01
Rust
omadoyeabraham/rust-book-codealong
/chapter-6/playground.rs
UTF-8
904
3.5625
4
[]
no_license
#[derive(Debug)] enum IpAddressKind { V4, V6 } #[derive(Debug)] enum IPAddress { V4(String), V6(String) } #[derive(Debug)] struct IpAddress { kind: IpAddressKind, address: String } fn main() { route(IpAddressKind::V4); route(IpAddressKind::V6); go_to(&IpAddress { kind: Ip...
true
e9a5ca72937d2fae75f85361f1e92fad105fe104
Rust
lazmond3/rust-nand2tetris
/src/alu.rs
UTF-8
1,502
3.53125
4
[]
no_license
use crate::bit::Bit; use crate::not_word::not_word; use crate::word::Word; fn alu( a: Word, b: Word, a_is_zero_x: Bit, // zx : a -> 0 b_is_zero_x: Bit, // zy : b -> 0 not_a_x: Bit, // nx : a -> !a not_b_x: Bit, // ny : b -> !b functional_x: Bit, // f : when 0 -> add, when 1 -> an...
true
005ac4d51cfff218f0cb18b7b2fdb0aeb78788c9
Rust
Haizzz/zoxide
/src/utils.rs
UTF-8
288
3.390625
3
[ "MIT" ]
permissive
use std::process; pub fn exit_with_message(msg: &str) -> ! { // print a message to stderr and exit eprint!("{}", msg); process::exit(1); } pub fn bit_at_index(byte: u8, index: u8) -> bool { // given a byte, return the bit value at index (byte & (1 << index)) != 0 }
true
f96c8ef385be2849a7798420429d4fa50ea94dfb
Rust
greendwin/rust_ray
/src/math/ray.rs
UTF-8
1,072
3.03125
3
[]
no_license
use super::vec3::Vec3; #[derive(Debug, Clone)] pub struct Hit { pub pt: Vec3, pub norm: Vec3, pub t: f64, pub front_face: bool, } impl Hit { pub fn new(ray: &Ray, t: f64, pt: Vec3, outward_norm: Vec3) -> Self { let front_face = ray.dir.dot(outward_norm) < 0.0; let norm = if front_f...
true
290fd23b46015e97ba97e9d27bc6539b6bfef0b2
Rust
denningk/blues
/src/textures/model_texture.rs
UTF-8
239
2.90625
3
[]
no_license
pub struct ModelTexture { texture_id: u32, } impl ModelTexture { pub fn new(texture_id: u32) -> ModelTexture { ModelTexture { texture_id } } pub fn get_texture_id(&self) -> &u32 { &self.texture_id } }
true
8ed6e9edc06634ef8dafa4cfa272b1a76fb46e8f
Rust
whentze/drydock
/src/error.rs
UTF-8
878
2.796875
3
[]
no_license
use core::fmt; #[derive(Debug, PartialEq, Eq)] pub enum BadBytes { LengthMismatch { wanted: usize, got: usize, }, VetFailed, } impl fmt::Display for BadBytes { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "the bytes are bad. just really bad.") } } #[cfg(...
true
21d9194b411650b10a732d54940cee3a346e58cc
Rust
nickmass/nickmass-com
/src/server/db.rs
UTF-8
576
2.546875
3
[ "MIT" ]
permissive
pub use deadpool_redis::Connection; use std::sync::Arc; use super::Error; #[derive(Clone)] pub struct Db { pool: Arc<deadpool_redis::Pool>, } impl Db { pub fn new<S: Into<String>>(url: S) -> Result<Db, Error> { let pool = deadpool_redis::Config::from_url(url) .create_pool(Some(deadpool_r...
true
b1bd83ce24f283cf8e7557119604d2c4d6e14918
Rust
coffeecup-winner/icfpc2020
/src/eval.rs
UTF-8
9,844
3.40625
3
[ "MIT" ]
permissive
use std::cell::RefCell; use std::collections::HashMap; use std::rc::Rc; use crate::syntax::{Stmt, Token, Var}; #[derive(Debug, Default)] pub struct State { vars: HashMap<Var, Value>, } #[derive(Debug, PartialEq, Clone)] pub enum Value_ { Var(Var), Number(i64), BuiltIn(BuiltIn), Apply(Value, Value...
true
78dd8a098efcf4785c3d5693903f42d961582f35
Rust
Enigmatrix/aoc17
/src/day09.rs
UTF-8
1,569
3.109375
3
[]
no_license
use std::collections::*; pub fn day09_1(s : String) -> u32{ let mut running_total = 0; let mut scope = 0; let mut in_garbage = false; let mut prev_cancel = false; for c in s.chars(){ if in_garbage { if c == '>' && !prev_cancel { in_garbage = false; ...
true
51873643e1c834476aa10a33115dc48e67a7223b
Rust
boa-dev/boa
/boa_engine/src/vm/opcode/iteration/loop_ops.rs
UTF-8
1,100
3.03125
3
[ "MIT", "Unlicense" ]
permissive
use crate::JsNativeError; use crate::{ vm::{opcode::Operation, CompletionType}, Context, JsResult, }; /// `IncrementLoopIteration` implements the Opcode Operation for `Opcode::IncrementLoopIteration`. /// /// Operation: /// - Increment loop itearation count. #[derive(Debug, Clone, Copy)] pub(crate) struct Inc...
true
8dfe5acb97c76f092738d24f73ee258e33e39660
Rust
anasahmed700/Rust-examples
/ch05.1_structs/src/main.rs
UTF-8
2,739
3.671875
4
[]
no_license
// 1. structs are user defined datatypes // 2. stored in heap memory // defining a struct #[derive(Debug)] struct Food { restaurant : String, item : String, size : u8, price : u16, available : bool } // new datatype Food is defined (blueprint) #[derive(Debug)] struct User { username: String, ...
true
029094f879a3f01199ab7f0c0bd2134345a0ee1a
Rust
sugyan/atcoder
/arc040/src/bin/b.rs
UTF-8
496
2.875
3
[]
no_license
use proconio::marker::Chars; use proconio::{fastout, input}; #[fastout] fn main() { input! { n: usize, r: usize, mut s: Chars, } let mut answer = 0; if let Some(pos) = s.iter().rev().position(|&c| c == '.') { if n - r > pos { answer += n - r - pos; } } ...
true
9e8723f4f0b16eee2c836371d6f6e63a4a7d9d31
Rust
jpverkamp/advent-of-code
/2022/src/bin/25-snafuinator.rs
UTF-8
1,920
3.265625
3
[]
no_license
use aoc::*; use std::{fmt::Display, path::Path}; #[derive(Clone, Debug)] struct Snafu { value: String, } impl Display for Snafu { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.value) } } impl From<String> for Snafu { fn from(value: String) -> Self {...
true
6a3299f29f84cf56e7e95e950721283af87adb00
Rust
gijs/t-rex
/src/cache/filecache.rs
UTF-8
2,570
3.15625
3
[ "MIT" ]
permissive
// // Copyright (c) Pirmin Kalberer. All rights reserved. // Licensed under the MIT License. See LICENSE file in the project root for full license information. // use cache::cache::Cache; use std::fs::{self,File}; use std::io::{self,Read,Write}; use std::path::Path; pub struct Filecache { pub basepath: String, }...
true
893478139584067fcb035cc6a4e6b83dc9cabab4
Rust
bootandy/ports2
/src/main.rs
UTF-8
5,710
2.734375
3
[]
no_license
extern crate pnet; use pnet::datalink::Channel::Ethernet; use pnet::datalink::{self, NetworkInterface}; use pnet::packet::ethernet::EtherType; use pnet::packet::ethernet::EtherTypes::{Arp, Ipv4, Ipv6, Rarp, Vlan, WakeOnLan}; use pnet::packet::ethernet::EthernetPacket; use pnet::packet::PrimitiveValues; use pnet::util:...
true
1764463440aeff4dd12782e01b3a3c2a081f6ac4
Rust
Pomettini/impostor
/src/adapter/mod.rs
UTF-8
689
2.640625
3
[ "MIT" ]
permissive
use {Address, AddressBusIO, As, Data}; pub struct BusAdapter<'a, T: Address, U: Data> { connection: &'a mut dyn AddressBusIO<T, U>, } impl<'a, T: Address, U: Data> BusAdapter<'a, T, U> { pub fn new(bus: &'a mut dyn AddressBusIO<T, U>) -> BusAdapter<'a, T, U> { BusAdapter { connection: bus } } } i...
true
28d1fa46bb30bd930ab207a4ca040de3704f8869
Rust
austinkeeley/rust
/src/tools/clippy/clippy_lints/src/methods/unnecessary_lazy_eval.rs
UTF-8
4,254
2.953125
3
[ "Apache-2.0", "MIT", "BSD-3-Clause", "BSD-2-Clause", "LicenseRef-scancode-other-permissive", "NCSA" ]
permissive
use crate::utils::{is_type_diagnostic_item, match_qpath, snippet, span_lint_and_sugg}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; use super::UNNECESSARY_LAZY_EVALUATIONS; // Return true if the expression is an accessor of any of the arguments fn expr_us...
true