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
62c62b050318e6d548675f7d35a0d3234b7c5459
Rust
ClementTsang/bottom
/src/app/layout_manager.rs
UTF-8
47,635
2.8125
3
[ "MIT" ]
permissive
use std::collections::BTreeMap; use crate::constants::DEFAULT_WIDGET_ID; use crate::error::{BottomError, Result}; /// Represents a more usable representation of the layout, derived from the /// config. #[derive(Clone, Debug)] pub struct BottomLayout { pub rows: Vec<BottomRow>, pub total_row_height_ratio: u32,...
true
683d5251dcec688edd5087aa251008f78a4aa3a1
Rust
JaapRood/optic-domain-rust
/src/aggregate/rfc.rs
UTF-8
768
2.625
3
[]
no_license
use cqrs_core::{Aggregate, AggregateEvent, Event}; use crate::events::rfc::RfcEvent; #[derive(Default, Debug)] pub struct RfcState {} #[derive(Default)] pub struct RfcAggregate { pub state: RfcState, } impl RfcAggregate { pub fn get_state(&self) -> &RfcState { &self.state } } impl Aggregate for RfcAggreg...
true
2a8bc5a502ff237d1331ec64ae9e452bc444ceb8
Rust
MichaelByrneAU/Daphnis
/src/scene.rs
UTF-8
430
2.78125
3
[ "MIT" ]
permissive
use crate::camera::Camera; use crate::objects::Object; pub struct Scene { pub width: u32, pub height: u32, pub samples: u32, pub camera: Camera, pub world: Object, } impl Scene { pub fn new(width: u32, height: u32, samples: u32, camera: Camera, world: Object) -> Scene { Scene { ...
true
52b722169c1318f9f3c78d786c3561c20d9ae48f
Rust
cjmochrie/pascal-rust
/src/interpreter/part_4.rs
UTF-8
2,024
3.890625
4
[]
no_license
#[derive(Debug, PartialEq, Clone)] pub enum Token { Integer(u32), Plus, Minus, Multiply, Divide, End, } impl Token { fn new(token: &str) -> Token { if token.chars().next().unwrap().is_numeric() { Token::Integer(token.parse::<u32>().unwrap()) } else { ...
true
75581871522afa54f303948f37f0240265a2cfd7
Rust
alireza-gsh/sorting-algorithms
/quick_sort.rs
UTF-8
1,067
3.828125
4
[]
no_license
use std::fmt::Display; fn quick_sort<T: PartialOrd>(array: &mut [T], start: usize, end: usize) -> () { if array.len() > 1 { let pivot = (start + end) / 2; let mut left = start; let mut right = end; while left <= right { while array[left] < array[pivot] { left += 1; } while array[right] > array[pi...
true
ade8293571a1552b20173f60d88beec1a1da842d
Rust
stm32-rs/stm32-rs-nightlies
/stm32f7/src/stm32f750/ethernet_mac/macpmtcsr.rs
UTF-8
12,051
2.515625
3
[]
no_license
#[doc = "Register `MACPMTCSR` reader"] pub type R = crate::R<MACPMTCSR_SPEC>; #[doc = "Register `MACPMTCSR` writer"] pub type W = crate::W<MACPMTCSR_SPEC>; #[doc = "Field `PD` reader - Power down"] pub type PD_R = crate::BitReader<PD_A>; #[doc = "Power down\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq,...
true
e5bcf4d9149be7ed2afc38203f553cb2790055d8
Rust
st3fan/aoc
/2015/rs/the-ideal-stocking-stuffer/src/lib.rs
UTF-8
705
2.828125
3
[]
no_license
use md5; const INPUT: &str = "bgvyzdsv"; pub fn part1() -> usize { for i in 0..999999999 { let digest = md5::compute(format!("{}{}", INPUT, i)); if digest[0] == 0 && digest[1] == 0 && digest[2] & 0xf0 == 0 { return i; } } 0 } pub fn part2() -> usize { for i in 0..9...
true
8254b879339ad2f123d504bc81f0a4928fb5bbbb
Rust
SpaceXCheeseWheel/20020-map
/src/geo.rs
UTF-8
2,622
3.078125
3
[]
no_license
pub use geo::prelude::*; use geo::algorithm::line_interpolate_point::LineInterpolatePoint; pub type Coordinate = geo::Coordinate<f64>; pub type Line = geo::Line<f64>; pub type LineString = geo::LineString<f64>; pub type Point = geo::Point<f64>; pub trait CoordinateExt { fn bearing_from_slope(self, slope: f64) ->...
true
efc3d959ddbe167411fe779dd34829e04759a5a7
Rust
peterwmwong/aoc2019
/d6/src/main.rs
UTF-8
1,356
3.546875
4
[]
no_license
use std::collections::{HashMap, HashSet}; use std::fs::read_to_string; type Orbits = HashMap<String, String>; type Path<'a> = HashSet<&'a str>; fn read_orbits(path: &str) -> Orbits { read_to_string(path) .unwrap() .trim() .lines() .map(|s| { if let [parent, object] = s....
true
059527433e474b72c4b9dcbded28ab127e9f0284
Rust
iCodeIN/nailgun
/bin/src/query.rs
UTF-8
4,666
2.890625
3
[ "MIT" ]
permissive
use std::{ fs::File, io::{BufRead, BufReader, Lines}, path::PathBuf, str::FromStr, }; use anyhow::Result; use rand::Rng; use tracing::error; use trust_dns_proto::{ op::{Edns, Message, MessageType, Query}, rr::{DNSClass, Name, RecordType}, }; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Or...
true
a485f9a8a2607d3c7d778d2e12fb021e120ca7cc
Rust
antonyisoardi/a32nx
/src/systems/systems/src/adirs/mod.rs
UTF-8
33,165
2.671875
3
[ "GPL-3.0-only", "CC-BY-NC-4.0", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-unknown" ]
permissive
use crate::{ overhead::IndicationLight, simulation::{ Read, Reader, SimulationElement, SimulationElementVisitor, SimulatorReader, SimulatorWriter, UpdateContext, Write, Writer, }, }; use std::time::Duration; use uom::si::{angle::degree, f64::*}; pub struct AirDataInertialReferenceSystemOver...
true
9e1d995e2be72251d0fb74ab73bb919d3c3f70e7
Rust
eturino/key-set.rs
/tests/remove_test.rs
UTF-8
2,979
3.15625
3
[]
no_license
use key_set::KeySet; #[test] fn test_all() { let key_set: KeySet<i32> = KeySet::All; assert_eq!(key_set.remove(&KeySet::All), KeySet::None as KeySet<i32>); assert_eq!(key_set.remove(&KeySet::None), KeySet::All as KeySet<i32>); assert_eq!( key_set.remove(&KeySet::Some(vec![1, 2, 3])), K...
true
58d3ff6c68e11a6ab42aac8e75e384fcff313b50
Rust
FauxFaux/fapt
/src/system.rs
UTF-8
6,628
2.75
3
[ "MIT" ]
permissive
//! Lower level operations on a [crate::system::System]. //! //! ``` //! # fn main() -> Result<(), anyhow::Error> { //! # use fapt::system::System; //! let fapt = System::cache_only()?; //! // ... //! fapt.update()?; //! # Ok(()) //! # } //! ``` use std::env; use std::fs; use std::io::Read; use std::path::Path; use st...
true
a4aa720f551454605729b72a18469c909f9a4d28
Rust
olson-dan/rip8
/src/lib.rs
UTF-8
9,105
3.3125
3
[]
no_license
use std::fmt; use std::time::Instant; #[derive(Copy, Clone)] struct Address { value: u16, } impl Address { fn new(x: u8, y: u8, z: u8) -> Address { Address { value: ((x as u16) << 8) | ((y as u16) << 4) | (z as u16), } } } impl fmt::Display for Address { fn fmt(&self, f: &...
true
d644aa5cd7016a7b296ae88064d25e7bbbb13be2
Rust
wibbe/tiny-rts
/tiny/src/platform/glutin_platform.rs
UTF-8
17,348
2.640625
3
[ "MIT" ]
permissive
mod gl { include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs")); } extern crate glutin; use self::glutin::GlContext; use std::boxed::Box; use std::mem; use std::ptr; use super::super::*; pub const COLOR_OFFSET_R: u32 = 0; pub const COLOR_OFFSET_G: u32 = 8; pub const COLOR_OFFSET_B: u32 = 16; pub const COLOR_OFFS...
true
b56c982b707917a37ff831ada8fcbeb3ac4bb2b4
Rust
ygyzys/bzip2-rs
/src/decoder/parallel/reader.rs
UTF-8
4,281
3.078125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::io::{self, Read, Result}; use super::{ParallelDecoder, ReadState, ThreadPool}; /// A high-level **multi-threaded** decoder that wraps a [`Read`] and implements [`Read`], yielding decompressed bytes /// /// ```rust /// # // A fake threadpool just to make the docs build when the `rayon` feature isn't enabled /...
true
1b33970efd692de15708b8ff94c28b8aa3de3737
Rust
bumzack/rust-cuda-matrix
/cuda_matrix/src/matrix_ops/matrix_invert.rs
UTF-8
10,413
2.78125
3
[]
no_license
use std::error::Error; use std::ffi::CString; use std::time::Instant; use crate::utils::matrix_utils::print_matrix; use rustacuda::prelude::*; use std::fmt; pub fn invert_matrix_2D2D() -> Result<(), Box<dyn Error>> { // Initialize the CUDA API rustacuda::init(CudaFlags::empty())?; // Get the first device...
true
1a67bf67662170fe90b0610ffc841d615d064e9f
Rust
AdamHarries/Monopoly
/src/main.rs
UTF-8
22,627
3.015625
3
[]
no_license
#[macro_use] extern crate enum_primitive_derive; extern crate num_traits; extern crate rand; use num_traits::FromPrimitive; use rand::prelude::*; #[derive(Primitive)] enum DieRoll { One = 1, Two = 2, Three = 3, Four = 4, Five = 5, Six = 6, } impl DieRoll { fn roll<T: Rng>(rng: &mut T) -> ...
true
02562d49c9e40740c83ab52a863f1aa4aa427090
Rust
mesalock-linux/crates-io
/vendor/rocket_http/src/parse/uri/error.rs
UTF-8
3,147
3.375
3
[ "Apache-2.0", "Unlicense", "BSD-3-Clause", "0BSD", "MIT" ]
permissive
use std::fmt; use std::borrow::Cow; use pear::{ParseErr, Expected}; use crate::parse::indexed::Context; use crate::parse::uri::RawInput; use crate::ext::IntoOwned; /// Error emitted on URI parse failure. /// /// Internally, the type includes information about where the parse error /// occured (the error's context) an...
true
a50614e1166728ae527195f8b7d22f6d905c1913
Rust
bonedaddy/diesel-derive-enum
/tests/src/schema.rs
UTF-8
1,420
2.828125
3
[ "Apache-2.0", "MIT" ]
permissive
use diesel::prelude::*; #[cfg(any(feature = "sqlite", feature = "postgres", feature = "mysql"))] use crate::common::get_connection; #[derive(Debug, PartialEq, diesel_derive_enum::DbEnum)] #[PgSchema = "schema"] pub enum SomeEnum { One, Two, } table! { use diesel::sql_types::Integer; use super::SomeEn...
true
8f0dbeee2e9bef8b156adf75a483783af082e310
Rust
rrevenantt/antlr4rust
/src/token_stream.rs
UTF-8
9,506
2.9375
3
[ "BSD-3-Clause", "LicenseRef-scancode-warranty-disclaimer", "BSD-2-Clause" ]
permissive
//! `IntStream` that produces tokens for Parser use std::borrow::Borrow; use std::cmp::min; use std::marker::PhantomData; use crate::char_stream::InputData; use crate::int_stream::{IntStream, IterWrapper}; use crate::token::{OwningToken, Token, TOKEN_EOF, TOKEN_INVALID_TYPE}; use crate::token_factory::TokenFactory; us...
true
8fb42fe2ffe027bdc5e6eb2ae626e8ed19cff33f
Rust
drollings/tw3-modlist-manager
/src/models/modlist.rs
UTF-8
19,107
3.046875
3
[ "MIT" ]
permissive
use std::fs; use std::path::{Path, PathBuf}; use fs::{copy, remove_dir_all}; use serde::{Deserialize, Serialize}; use toml; use fs_extra; use crate::constants; use crate::utils::symlinks::{ symlink_children, remove_symlinks, make_symlink, remove_symlink }; #[derive(Deserialize, Serialize)] pub struct ModL...
true
25f6c9573801df142b85c05366ae569d494945aa
Rust
tokio-rs/tokio
/tokio/src/runtime/context/runtime_mt.rs
UTF-8
1,000
3
3
[ "MIT" ]
permissive
use super::{EnterRuntime, CONTEXT}; /// Returns true if in a runtime context. pub(crate) fn current_enter_context() -> EnterRuntime { CONTEXT.with(|c| c.runtime.get()) } /// Forces the current "entered" state to be cleared while the closure /// is executed. pub(crate) fn exit_runtime<F: FnOnce() -> R, R>(f: F) ->...
true
65b474795470d6550e9f4adbb1389d6a030fa65f
Rust
solareenlo/rust_by_example
/23_Casting.rs
UTF-8
1,212
3.015625
3
[]
no_license
#![allow(overflowing_literals)] fn main() { let decimal = 12.4321_f32; // let integer: u8 = decimal; let integer = decimal as u8; let character = integer as char; println!("Castring: {} -> {} -> {}", decimal, integer, character); println!(" 1000 as a u16 is : {}", 1000 as u16); println!(" ...
true
055d11d5726766104f3e04b85d28fe4c3c134693
Rust
gotham-rs/gotham
/gotham/src/handler/assets/accepted_encoding.rs
UTF-8
4,606
3.453125
3
[ "MIT", "Apache-2.0" ]
permissive
//! Defines `AcceptedEncoding` for parsing 'Accept-Encoding' header //! values in requests, used to determine whether compressed versions //! of static assets are supported by the client. use hyper::header::{HeaderMap, ACCEPT_ENCODING}; use std::result; use std::str::FromStr; /// An error returned from the `FromStr`...
true
ff4c171332af7907ccdb7b2dbd5f7395ed57799f
Rust
Creckle/amethyst
/src/ecs/util/resources.rs
UTF-8
1,337
3.609375
4
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Util Resources use util::circular_buffer::CircularBuffer; /// The FPSCounter resource needed by the FPSCounterSystem. /// /// Add it to your resources with id 0 to be able to use the FPSCounterSystem. /// /// ## Usage: /// Get the FPSCounter resource from the world then call either `frame_fps` or `sampled_fps` to...
true
90ece99c2bebbaabb3722d06eb4f0dbcfaf01364
Rust
microcluster/devand
/devand-ui/src/app/workers/main_worker/mock.rs
UTF-8
2,245
2.625
3
[ "Apache-2.0" ]
permissive
use super::{MainWorker, Request, Response}; use maplit::{btreemap, btreeset}; pub fn request(worker: &mut MainWorker, msg: Request) { log::info!("Request: {:?}", msg); let link = worker.link.clone(); match msg { Request::Init => { log::info!("Initializing..."); link.send_...
true
1f209cd0ef98968580c9ba45b32af0813e49cbd2
Rust
Luro02/stable-vec
/examples/printing.rs
UTF-8
244
2.984375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use stable_vec::StableVec; fn main() { let mut sv = StableVec::from(&['a', 'b', 'c', 'd', 'e', 'f']); println!("{:?}", sv); sv.remove(1); sv.remove(4); println!("{:?}", sv); sv.push('x'); println!("{:?}", sv); }
true
bf83575ecebba4e0dcb85ef87dc3bae430a4b9fe
Rust
libonomy/libo-wasmer
/lib/api/src/types.rs
UTF-8
3,101
2.875
3
[ "MIT" ]
permissive
use crate::externals::Function; use crate::store::{Store, StoreObject}; use crate::RuntimeError; use std::ptr; use wasmer_types::Value; pub use wasmer_types::{ ExportType, ExternRef, ExternType, FunctionType, GlobalType, HostInfo, HostRef, ImportType, MemoryType, Mutability, TableType, Type as ValType, }; /// ...
true
0c1b8f0fd0849541bdfcfd97be5e2a3fac43f897
Rust
lutzer/midi_clock
/src/memory.rs
UTF-8
790
2.90625
3
[]
no_license
use crate::eeprom::{Eeprom}; use crate::statemachine::{State, ClockSource, RunState, DEFAULT_STATE}; use crate::debug; const BPM_ADDRESS: u16 = 0x0004; #[derive(Debug, Eq, PartialEq)] pub enum MemoryError { ReadError } pub struct Memory { eeprom: Eeprom } impl Memory { pub fn new(eeprom: Eeprom) -> Memory { ...
true
4cfc0de4a8c5ad5fbe097e0f64299426dc561d99
Rust
brownian-motion/lisp_compiler_rust
/src/parser/elems.rs
UTF-8
671
2.96875
3
[ "MIT" ]
permissive
use crate::lexer::token::*; use crate::memory::*; use crate::text::*; use std::ops::Range; pub enum Expr { Terminal(Token), SExpr(ArenaIdx<SExpr>), } impl From<Token> for Expr { fn from(token: Token) -> Self { Expr::Terminal(token) } } pub enum Es { Empty(CharLocation), Cons(ArenaIdx<...
true
b9c8898c458ce16083e752f311381c6b613df916
Rust
pierrechevalier83/unicode_types
/src/generated/miscellaneous_technical.rs
UTF-8
52,464
2.765625
3
[ "LicenseRef-scancode-unicode" ]
permissive
/// An enum to represent all characters in the MiscellaneousTechnical block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum MiscellaneousTechnical { /// \u{2300}: '⌀' DiameterSign, /// \u{2301}: '⌁' ElectricArrow, /// \u{2302}: '⌂' House, /// \u{2303}: '⌃' UpArrowhead, ...
true
bd1a71570f0fe70425742871a3dcc205f5576f72
Rust
rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust
/Chapter 7/arrfun3.rs
UTF-8
2,649
3.4375
3
[]
no_license
// arrfun3.rs -- array functions and const use std::io; use std::io::prelude::*; use std::string::String; const MAX: usize = 5; fn main() -> io::Result<()> { let mut stdout: io::Stdout = io::stdout(); let stdin: io::Stdin = io::stdin(); let mut properties: [f64; MAX] = [0.0; MAX]; let size: usize =...
true
23c0c2af8b19e341356e958231b31bc9ecf24335
Rust
happyborg/gitoxide
/git-packetline/src/decode.rs
UTF-8
3,795
3.203125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::{ PacketLine, {DELIMITER_LINE, FLUSH_LINE, MAX_DATA_LEN, MAX_LINE_LEN, RESPONSE_END_LINE, U16_HEX_BYTES}, }; use bstr::BString; use quick_error::quick_error; quick_error! { #[derive(Debug)] pub enum Error { HexDecode(err: String) { display("Failed to decode the first four hex...
true
ca119907a559a01f048e17ffd90cdd3295f712f3
Rust
emakryo/cmpro
/src/agc054/src/bin/a.rs
UTF-8
437
2.53125
3
[]
no_license
fn main() { proconio::input!{ n: usize, s: proconio::marker::Bytes, } let ans; if s[0] != s[n-1] { ans = 1; } else { let mut ok = false; for i in 1..(n-1) { if s[i] != s[0] && s[i+1] != s[0] { ok = true; } } ...
true
d747cd843329bd08ffe13c05281d2a7789e5d371
Rust
caibirdme/leetcode_rust
/src/prob_244.rs
UTF-8
1,076
3.40625
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::cmp::min; struct WordDistance { dis: HashMap<String, Vec<usize>>, n: usize, } /** * `&self` means the method takes an immutable reference. * If you need a mutable reference, change it to `&mut self` instead. */ impl WordDistance { fn new(words: Vec<String>) -> ...
true
8f32c6f1f20afdfa01c9ee045021d8cb30174da0
Rust
ugnom/programming_competition_archive
/abc/abc033/a.rs
UTF-8
638
3.53125
4
[]
no_license
use std::str::FromStr; fn get_one<T : FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); return s.trim().parse().ok().unwrap(); } fn get_vec<T : FromStr>() -> Vec<T> { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); return s.trim().split_w...
true
d0839ff46f85804c1d8ed65b1958f95faf0e9987
Rust
Keruspe/brainfuck.rs
/src/error.rs
UTF-8
1,130
2.984375
3
[]
no_license
use nom; use std::{error, fmt, io, result}; #[derive(Debug)] pub enum Error { IOError(io::Error), ParseError(String), } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::IOError(ref err) => write!(f, "IO Error: {}", err), ...
true
27bda7f72b892945a59895342bf41a04d6817295
Rust
lesguillemets/curly-octo-funicular
/src/board.rs
UTF-8
3,881
3.140625
3
[]
no_license
use std::fmt; use std::io; use base::*; use face::Face; #[derive(Debug, Clone)] pub struct Board(pub [[Option<Face>; SIZE]; SIZE]); /// For simplicity, we'll denote to locations as (x,y) /// and access to the cell by board[x][y]. impl Board { fn empty() -> Board { Board([[None; SIZE]; SIZE]) } pu...
true
8fd0cfb1775fa39d38292a5bfd27e3e03e537302
Rust
fan-tom/liquid-rust
/lint_plugin/src/folder.rs
UTF-8
275
3.03125
3
[]
no_license
pub trait Folder<T> { fn fold(&mut self, expr: T) -> T; } impl<'e, T, F: FnMut(T) -> T> Folder<T> for F { fn fold(&mut self, expr: T) -> T { self(expr) } } pub trait Foldable<T = Self>: Sized { fn accept<'s>(self, v: &mut impl Folder<T>) -> Self; }
true
89ba5cac6c96f3f9aba3e39447937dd77da35697
Rust
jthelin/demikernel
/src/rust/catnap/queue.rs
UTF-8
16,439
2.515625
3
[ "MIT" ]
permissive
// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. //====================================================================================================================== // Imports //==============================================================================================================...
true
a70e56b7dbe3a7e854488af61de030e682507071
Rust
joeftiger/rust-v
/src/debug_utils.rs
UTF-8
581
2.90625
3
[ "MIT" ]
permissive
#![allow(dead_code)] use crate::*; use utility::floats::FloatExt; #[inline(always)] pub fn is_finite(v: Vector3) -> bool { v.x.is_finite() && v.y.is_finite() && v.z.is_finite() } #[inline(always)] pub fn is_not_nan(v: Vector3) -> bool { !(v.x.is_nan() && v.y.is_nan() && v.z.is_nan()) } #[inline(always)] pub...
true
b73efc1cd4cb29a7457695f019fd4b9b785ee0ba
Rust
rodrimati1992/type_level
/type_level_examples/src/_05_capabilities.rs
UTF-8
6,375
2.765625
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
//! This example demonstrates a zero overhead builder using a ConstValue-parameter //! to track initialization of the fields. //! //! //! pub fn main_() { let side_effects = SideEffectful::new(FakeFileSystemOps, FakeExecuteCommand, AllCapabilities::CW); let fs = side_effects.access_ref(cap_fields::fil...
true
c58ac5a3d1bc4d209bb4db7d18b5ca6e4965c2a4
Rust
cseitz/spl-project
/rust/main.rs
UTF-8
974
3.625
4
[]
no_license
// Rust // Reverse an unsigned int32 Array via Linked List struct Node { value: u32, // Pass by Value prev: Option<Box<Node>>, // Pass by Reference } fn main() { // Entry point because Rust is compiled let array: [u32; 10] = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]; // We must define the array type as u32...
true
fc9d9c40bc745c4d3acca7563853af06190c16b9
Rust
micromaomao/ctclient
/src/internal/mod.rs
UTF-8
3,881
2.640625
3
[ "MIT" ]
permissive
//! Things that are only useful if you are doing your own API calling. //! //! Note that the RFC calls inclusion proof "audit proof". use std::convert::TryInto; use log::{debug, trace}; use openssl::pkey::PKey; pub use consistency::*; pub use digitally_signed_struct::*; pub use getentries::*; pub use inclusion::*; p...
true
c477c9aeac40f735acbac04992e51de22a879e3e
Rust
giodamelio/little_boxes
/vendor/rustix/src/maybe_polyfill/no_std/net/socket_addr.rs
UTF-8
21,521
3.421875
3
[ "MIT", "Apache-2.0", "LLVM-exception" ]
permissive
//! The following is derived from Rust's //! library/std/src/net/socket_addr.rs at revision //! bd20fc1fd657b32f7aa1d70d8723f04c87f21606. //! //! All code in this file is licensed MIT or Apache 2.0 at your option. //! //! This defines `SocketAddr`, `SocketAddrV4`, and `SocketAddrV6` in a //! platform-independent way. I...
true
91dfeef788fab6bff63682c75462fa5af4a61820
Rust
Yoric/esprit
/crates/estree/src/util.rs
UTF-8
3,101
3.25
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use serde_json::Value; use serde::ser::*; pub enum Container { NothingMeaningful, FunctionDeclaration, FunctionExpression, } /// A container used to represent some piece of data being /// serialized. Future versions may add options to the /// serialization format. pub struct Serialization<'a, T> where T: ...
true
b1372c1d3fdb7a2facfeeaf3e4d442ce00cacbcf
Rust
han2time/rust-tutorial
/projects/chapter15/smart_pointer_box/src/main.rs
UTF-8
1,999
3.640625
4
[]
no_license
use crate::List::{Cons, Nil}; /* enum List { Cons(i32, Box<List>), Nil, } fn main() { // let b = Box::new(5); // println!("b = {}", b); // let list = Cons(1, Cons(2, Cons(3, Nil))); let list = Cons(1, Box::new(Cons(2, Box::new(Cons(3, Box::new(Nil)))))); ...
true
a500a4c77f597574e0f4e0af1a91bfc8dd07a7c8
Rust
redsnapper2006/leetcode-cn
/L/2765-longest-alternating-subarray/main.rs
UTF-8
710
2.59375
3
[]
no_license
impl Solution { pub fn alternating_subarray(nums: Vec<i32>) -> i32 { let buf = (0..nums.len() - 1) .map(|i| nums[i + 1] - nums[i]) .collect::<Vec<i32>>(); let mut max = 0; let mut idx: usize = 0; let mut cnt: i32 = 0; let mut sign: i32 = 1; while idx < buf.len() { if buf[idx...
true
03d9e1a9c5c30103c281a52cf9ab9a845087333d
Rust
Apostoln/WaitGroup
/examples/scope_smart_split.rs
UTF-8
836
3.03125
3
[]
no_license
use std::sync::atomic::{AtomicIsize, Ordering}; use std::sync::Arc; use std::thread; use wait_group::{Doer, SmartWaitGroup}; fn process_counter(counter: Arc<AtomicIsize>, _doer: Doer) { counter.fetch_add(1, Ordering::SeqCst); //drop(doer) implicit call } fn spawn_threads(counter: Arc<AtomicIsize>, doer: Doer...
true
07b153b39d100a85d2db9e1a74c3e87e68162ac3
Rust
rune-rs/rune
/crates/rune/src/cli/visitor.rs
UTF-8
1,312
2.625
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::no_std::prelude::*; use crate::compile::meta; use crate::compile::{CompileVisitor, ItemBuf, MetaRef}; use crate::Hash; /// Attribute to collect. #[derive(Debug, Clone, Copy)] pub(super) enum Attribute { /// Do not collect any functions. None, /// Collect `#[test]` functions. Test, /// C...
true
2a6fb56dbedb21b00bff2df54f535ed062107010
Rust
rust-p2p/efcp
/dtp/src/dtp.rs
UTF-8
6,015
2.625
3
[ "ISC" ]
permissive
use crate::packet::DtpPacket; use crate::udp::UdpEcnSocket; use addr::Addr; use async_std::io::{Error, ErrorKind, Result}; use async_std::task::{Context, Poll}; use bytes::BufMut; use channel::BasePacket; use crossbeam::queue::SegQueue; use slab::Slab; use std::collections::{HashMap, HashSet}; use std::sync::Mutex; #[...
true
5b5ff54a0628c214033eb477e6b0707c6e0633e2
Rust
Ryan1729/canadian-fish
/common/src/lib.rs
UTF-8
21,798
2.765625
3
[ "MIT" ]
permissive
extern crate rand; use std::fmt; use rand::{StdRng, Rand, Rng}; use std::cmp::Ordering; use std::cmp::Ordering::{Less, Equal, Greater}; use std::collections::HashMap; pub struct Platform { pub print_xy: fn(i32, i32, &str), pub clear: fn(Option<Rect>), pub size: fn() -> Size, pub pick: fn(Point, i32) ...
true
58076fef651bdd438d578a16ca2cff07cb2ffbe1
Rust
plumenator/coin-mixer-challenge
/src/api.rs
UTF-8
2,702
3.03125
3
[]
no_license
use anyhow::{anyhow, Context}; use bigdecimal::{BigDecimal, Zero}; use serde::Deserialize; use url::Url; #[derive(Deserialize)] pub(crate) struct AddressInfo { pub(crate) balance: BigDecimal, transactions: Vec<TransactionInfo>, } #[derive(Deserialize)] #[serde(rename_all = "camelCase")] pub(crate) struct Tran...
true
ea0d968a8b47cbfa026879a39acf3f4d29309887
Rust
tailhook/marafet
/marafet_parser/src/html.rs
UTF-8
16,648
2.890625
3
[ "MIT" ]
permissive
use combine::{parser, Parser}; use combine::combinator::{optional, ParserExt, sep_by, many, many1}; use combine::combinator::{chainl1, between, choice, sep_end_by}; use util::join; use super::Block; use super::parse_html_expr; use super::token::{Token, ParseToken}; use super::token::TokenType as Tok; use super::token...
true
d91c2db36cc6db4b09bac24d08d863b2f4990d5e
Rust
biaoma-ty/arrow-datafusion
/datafusion/physical-expr/src/intervals/interval_aritmetic.rs
UTF-8
53,222
2.78125
3
[ "Apache-2.0", "MIT", "BSD-3-Clause", "BSD-2-Clause" ]
permissive
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
true
71b46797dafd3e2bcc06b60039998e99328d8ae6
Rust
marco-c/gecko-dev-wordified
/third_party/rust/goblin/src/elf/sym.rs
UTF-8
15,944
2.671875
3
[ "BSD-3-Clause", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/ / / = = = Sym bindings = = = / / / Local symbol . pub const STB_LOCAL : u8 = 0 ; / / / Global symbol . pub const STB_GLOBAL : u8 = 1 ; / / / Weak symbol . pub const STB_WEAK : u8 = 2 ; / / / Number of defined types . . pub const STB_NUM : u8 = 3 ; / / / Start of OS - specific . pub const STB_LOOS : u8 = 10 ; / / / Un...
true
46d2af57573b4ed655350090e5cf261db5d4f459
Rust
LucasForster/day-plans
/src/trips.rs
UTF-8
2,233
2.765625
3
[]
no_license
use super::categories::{Category, CATEGORIES}; use super::districts::{self, District}; use super::io; use lazy_static::lazy_static; use std::hash::{Hash, Hasher}; const TRIP_COUNT_FACTOR: f64 = 0.05; #[derive(Clone, Copy)] pub enum Transport { Public, Individual, } impl Transport { pub fn to_str(&self) ->...
true
b749b9d1d319844545d81968c536968c97dc956f
Rust
gpolek/schema-tools
/src/codegen/jsonschema/title.rs
UTF-8
1,521
2.921875
3
[]
no_license
use crate::{error::Error, scope::SchemaScope}; use serde_json::{Map, Value}; use super::JsonSchemaExtractOptions; pub fn extract_title( data: &Map<String, Value>, scope: &mut SchemaScope, _options: &JsonSchemaExtractOptions, ) -> Result<String, Error> { match data.get("title") { Some(v) => mat...
true
984edc60c5ec4dd73dcd2925e873fe1491d04f71
Rust
rajputrajat/rust_cpp_ffi_cdylib_experiment
/src/lib.rs
UTF-8
1,037
2.734375
3
[]
no_license
use std::ffi::CStr; use std::os::raw::{c_char, c_float, c_int, c_short}; use widestring::WideCStr; #[repr(C)] pub struct Args { message: *const c_char, first: c_int, sec: c_float, third: *const c_short, } #[repr(C)] pub struct Returns { first: c_int, sec: *const c_char, third: *const c_sho...
true
70f505a00d667bd164e63cc538b898b620a61ad1
Rust
fits/try_samples
/rust/hyper/json_sample/src/main.rs
UTF-8
2,639
2.8125
3
[]
no_license
use hyper::service::{make_service_fn, service_fn}; use hyper::{Body, Error, Method, Request, Response, Result, Server, StatusCode, header}; use hyper::body::Buf; use serde_json::Value as JsValue; use std::sync::{Arc, RwLock}; #[derive(Default, Clone, Debug)] struct Store(Arc<RwLock<Vec<JsValue>>>); fn json_response...
true
9d110e9c23c52314ef9d5ee0a44b055c6bf13279
Rust
willglynn/artichoke
/src/bin/artichoke.rs
UTF-8
1,506
2.625
3
[ "MIT" ]
permissive
#![warn(clippy::all)] #![warn(clippy::pedantic)] #![deny(intra_doc_link_resolution_failure)] #![warn(missing_debug_implementations)] #![warn(rust_2018_idioms)] //! `artichoke` is the `ruby` binary frontend to Artichoke. //! //! `artichoke` supports executing programs via files, stdin, or inline with one or //! more `-...
true
76eb51e3c68e957754cb10d15c0b88fd55cd46da
Rust
seritools/chmparse
/src/encint.rs
UTF-8
4,860
3.265625
3
[]
no_license
use pahs::try_parse; use pahs_snafu::ProgressSnafuExt; use snafu::Snafu; use super::{Driver, Pos, Progress}; /// Parses a CHM `ENCINT` variable-length integer. /// /// An ENCINT is a variable-length integer. /// The high bit of each byte indicates "continued to the next byte". /// Bytes are stored most significant to...
true
6c46630fecf1a769e977be659d0484848cb6deda
Rust
ealasu/rust-keyboard
/framed/src/stream.rs
UTF-8
5,541
3.1875
3
[]
no_license
use futures::{Poll, Async}; use futures::stream::Stream; use constants::{SOF, ESC, ESC_SOF, ESC_ESC, CRC}; #[derive(Debug)] enum State { /// Scanning for Start-Of-Frame byte. Sof, /// Recieved a Start-Of-Frame byte. AfterSof, /// Read `len` bytes of the payload. If `esc`, next byte will be un-escap...
true
7409560e7f5fa27f59ac4f1336b4a59f36d81a40
Rust
Phala-Network/phala-blockchain
/vendor/ring/tests/rand_tests.rs
UTF-8
2,428
2.5625
3
[ "OpenSSL", "MIT", "ISC", "LicenseRef-scancode-mit-taylor-variant", "LicenseRef-scancode-openssl", "LicenseRef-scancode-ssleay-windows", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
// Copyright 2015-2019 Brian Smith. // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies. // // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAI...
true
d61eda371d34188d1799c2155a5aff9eba98d432
Rust
tstree-oscomp2021/hecto-os
/vendor/bare-metal/src/lib.rs
UTF-8
2,436
3.671875
4
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Abstractions common to bare metal systems #![deny(missing_docs)] #![deny(warnings)] #![no_std] use core::cell::UnsafeCell; /// A peripheral #[derive(Debug)] pub struct Peripheral<T> where T: 'static, { address: *mut T, } impl<T> Peripheral<T> { /// Creates a new peripheral /// /// `address` ...
true
f0ba1fa8c27329ed7b83346cc2f770d29c636f77
Rust
nairyl/stronghold
/stronghold-rust/src/errors.rs
UTF-8
3,080
2.75
3
[ "MIT" ]
permissive
use std::error::Error; use std::fmt; use std::io; use bellman::SynthesisError; /// Error raised if constructing a sapling key fails for any reason. #[derive(Debug)] pub enum SaplingKeyError { IOError, FieldDecodingError, InvalidViewingKey, InvalidPaymentAddress, InvalidPublicAddress, Diversifi...
true
edbd8d12aac40131fb1ec3ec6cc4685ea8a1bb7c
Rust
rust-lang-ve/rust-lang-ve.github.io
/src/components/icon/icon_name.rs
UTF-8
411
3.03125
3
[ "MIT", "Apache-2.0" ]
permissive
use std::string::ToString; #[derive(Clone, PartialEq)] pub enum IconName { Discord, GitHub, Telegram, } impl ToString for IconName { fn to_string(&self) -> String { match self { IconName::Discord => String::from("discord-icon"), IconName::GitHub => String::from("github-...
true
e68d1c7c1a4da28875fd760e42d884bd269c5434
Rust
slysherz/rust-tensortrade
/src/oms/wallets/wallet.rs
UTF-8
3,151
2.796875
3
[ "Apache-2.0" ]
permissive
use crate::oms::exchanges::Exchange; use crate::oms::instruments::{Instrument, Quantity}; use crate::oms::wallets::{Ledger, WalletLike}; use crate::ttcore::decimal::{decimal_from_f32, Decimal}; use crate::ttcore::{base::TimeIndexed, errors::TensorTradeError}; use std::collections::HashMap; pub type WalletTuple = (Exch...
true
6887cf4f092ba1558f108a4e50de410e6456deb9
Rust
dmgolembiowski/detox
/src/main.rs
UTF-8
2,244
3.078125
3
[ "MIT" ]
permissive
//! Cleaning of unnecessary files in development directories. #![doc(html_root_url = "https://docs.rs/detox/0.1.2")] mod cleaner; mod options; use walkdir::WalkDir; use crate::options::Options; use std::env; use std::error::Error; use std::path::Path; fn main() -> Result<(), Box<dyn Error>> { // parse in our op...
true
90b55e819118f54c6c4f3e6c7e9f4f288783d00e
Rust
monomadic/tinyui-rs
/examples/vst-webkit/src/ui.rs
UTF-8
1,070
2.765625
3
[]
no_license
use tinyui::*; const WIDTH: f64 = 480.; const HEIGHT: f64 = 320.; #[derive(Clone, Copy)] pub struct PluginWindow { window: Window, button: Button, } impl EventHandler for PluginWindow { fn handle(&mut self, event: Event) { match event { // Event::WindowWillClose => App::quit(), // don...
true
01410a9de5b63c9ffe1d76f60fdff74bdeea8f7a
Rust
jomei/hackasm
/src/symbol_table.rs
UTF-8
2,277
2.828125
3
[]
no_license
use std::collections::HashMap; use instruction::Instruction; lazy_static! { static ref KNOWN_SYMBOLS: HashMap<String, usize> = { let mut map = HashMap::new(); map.insert("R0".to_string(), 0); map.insert("R1".to_string(), 1); map.insert("R2".to_string(), 2); map.insert("R3".t...
true
862e47ae4867328c7ac2827c7411e9d8e825440a
Rust
greyhillman/IncrementalReadingConverter
/src/lib/ir/textblock/mod.rs
UTF-8
2,087
3.75
4
[]
no_license
mod text; pub use self::text::Text; #[derive(Debug, PartialEq, Clone)] pub struct TextBlock { content: Vec<Text>, } impl TextBlock { pub fn new() -> Self { TextBlock { content: vec![] } } pub fn add(&mut self, text: Text) -> &mut Self { match (self.content.pop(), text) { (...
true
409e179bc914451d84a2e63930d482f4297a0eec
Rust
zhaofengli/attic
/attic/src/signing/mod.rs
UTF-8
8,136
2.984375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Object Signing and Verification. //! //! Nix utilitizes Ed25519 to generate signatures on NAR hashes. Currently //! we can either generate signatures on the fly per request, or cache them //! in the data store. //! //! ## String format //! //! All signing-related strings in Nix follow the same format (henceforth //...
true
ad3d38893b4dd8ffb6232746fa1ff8f013caf3ec
Rust
epequeno/advent_of_code
/2019/day04/src/main.rs
UTF-8
3,163
3.53125
4
[]
no_license
// https://adventofcode.com/2019/day/4 fn has_two_adjacent(n: usize) -> bool { let chars: Vec<char> = n.to_string().chars().collect(); for i in 0..chars.len() { if i + 1 >= chars.len() { break; } if chars[i] == chars[i + 1] { return true; } } fals...
true
319ce2cd17cbab2a0da2404a29c92f3d28b22eaf
Rust
SnoozeTime/spacegame
/src/gameplay/trail.rs
UTF-8
949
2.65625
3
[]
no_license
use crate::core::transform::Transform; use crate::gameplay::physics::DynamicBody; use crate::render::particle::ParticleEmitter; use hecs::World; #[derive(Debug)] pub struct Trail { pub should_display: bool, pub offset: f32, } pub fn update_trails(world: &mut World) { for (_, (trail, transform, emitter, _b...
true
67fd560e386aeaf8ce1ae002cb1d225a4fdb9a5d
Rust
maximbaz/advent2019
/src/day8.rs
UTF-8
1,592
3.390625
3
[]
no_license
use std::fs; pub fn run_part1() -> usize { part1(input(), 25, 6) } pub fn run_part2() -> String { "\n".to_owned() + &part2(input(), 25, 6) .chunks(25) .map(|line| { line.iter() .map(|&c| if c == 1 { '▅' } else { ' ' }) .co...
true
870bed6b3f39a82023864faca7a655021756b5aa
Rust
micouy/dodo
/src/deps.rs
UTF-8
14,171
2.734375
3
[]
no_license
use std::{ collections::{HashMap, HashSet}, path::PathBuf, }; use crate::{ error::{Error, Result, UserError}, target::Target, util::ResultIterator, }; use daggy::{petgraph::visit::IntoNeighborsDirected, NodeIndex as Nx}; type DependencyDag = daggy::Dag<Node, ()>; type Identifier = PathBuf; type F...
true
3ae2acbcbff8e69fe965c740115d6609ad00f38c
Rust
owenthewizard/scrap
/src/common/x11.rs
UTF-8
2,343
2.84375
3
[]
no_license
use x11; use std::{io, ops}; use std::rc::Rc; pub struct Capturer(x11::Capturer); impl Capturer { pub fn new(display: Display) -> io::Result<Self> { x11::Capturer::new(display.0).map(Self) } #[must_use] pub const fn width(&self) -> usize { self.0.display().rect().w as usize } ...
true
de56d52cce87eecb3932acb3c211609a1260e81b
Rust
chiral-data/rust-canonical-numbering
/src/core/givp/partition.rs
UTF-8
3,142
3.203125
3
[ "Apache-2.0" ]
permissive
// Copyright 2021 Chiral Ltd. // Licensed under the Apache-2.0 license (https://opensource.org/licenses/Apache-2.0) // This file may not be copied, modified, or distributed // except according to those terms. fn partition_once<T: std::cmp::PartialOrd>( indexes: &Vec<usize>, values: &Vec<T> ) -> (Vec<usize>, Ve...
true
388ef7d794ab849b59f71646cfacea7214d544fc
Rust
christheblog/throttler
/src/main.rs
UTF-8
4,505
3.25
3
[]
no_license
extern crate clap; use clap::{App, Arg}; use std::io::BufRead; use std::io; use std::time::{SystemTime, UNIX_EPOCH}; fn main() { let args = App::new("throttler") .version("0.1.0") .author("christheblog") .about("Throttles stdout") .arg( Arg::with_name("rate") ...
true
08fb4c2a916f27b14907029fceabc6582264040b
Rust
bokuweb/docx-rs
/docx-core/src/documents/elements/table_row.rs
UTF-8
3,699
2.890625
3
[ "MIT" ]
permissive
use serde::ser::{SerializeStruct, Serializer}; use serde::Serialize; use super::{Delete, Insert, TableCell, TableRowProperty}; use crate::xml_builder::*; use crate::{documents::BuildXML, HeightRule}; #[derive(Debug, Clone, PartialEq, Serialize)] #[serde(rename_all = "camelCase")] pub struct TableRow { pub cells: ...
true
ce1ba207917915ee0c1d0d351a23737307876aaf
Rust
sperlingpl/stringc
/lib/src/excel_reader.rs
UTF-8
3,337
2.90625
3
[ "MIT" ]
permissive
use std::collections::BTreeMap; use std::error::Error; use std::fmt; use crate::excel_file::EFile; use crate::json_data::{Translation, Project, DataRootTranslations}; pub struct ImportResult { pub added: Vec<String>, pub updated: Vec<String>, pub ignored: Vec<String> } #[derive(Debug, Clone)] pub struct ...
true
db53493714c74370acadff8b795fe63ce565f2ec
Rust
plaidman/advent
/2021-rust/rust-10/src/part-one.rs
UTF-8
1,207
3.265625
3
[]
no_license
use std::{ io::{ BufReader, BufRead }, fs::File }; fn main() { let file = File::open("src/input.txt").expect("failed to open file"); let lines = BufReader::new(file).lines().map(|i| i.unwrap()); let mut sum = 0; for line in lines { let chars = Vec::from_iter(line.chars()); let mism...
true
0f9a1f728a3cb518e9cf56b69b82772f532a1ed2
Rust
jeffdn/rust-canteen
/src/route.rs
UTF-8
7,167
3.203125
3
[ "MIT" ]
permissive
/* Copyright (c) 2016 * Jeff Nettleton * * Licensed under the MIT license (http://opensource.org/licenses/MIT). This * file may not be copied, modified, or distributed except according to those * terms */ extern crate regex; use std::collections::HashMap; use regex::Regex; use crate::request::*; use crate::res...
true
750708687ddaa7e2ff6ff52db950cf9deca2a0a3
Rust
notflan/chacha20stream
/src/lib.rs
UTF-8
2,113
2.859375
3
[ "MIT" ]
permissive
/*! # chacha20_poly1305 stream wrapper Contains a writable stream that wraps another, applying the chacha20_poly1305 cipher to the input before writing for either encryption or decryption. ## Examples Encrypt a message to an in-memory buffer. ``` # use chacha20stream::Sink; # use std::io::Write; // Generate random key...
true
982dd9a1550bcb3712600a57860852cdd6c3344c
Rust
sonro/linurgy
/tests/basic.rs
UTF-8
1,309
2.875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use linurgy::factory; #[test] fn extra_line() { let input = "foo\nbar\nbaz\n"; let expected = "foo\n\nbar\n\nbaz\n\n"; let actual = factory::appender("\n", 1).edit(input); assert_eq!(expected, actual); } #[test] fn extra_line_crlf() { let input = "foo\r\nbar\r\nbaz\r\n"; let expected = "fo...
true
8808cc1a6d69057f4b6f3756229ae1efc8381899
Rust
aminraay/win-partitions
/src/win_api.rs
UTF-8
5,637
3.0625
3
[ "MIT" ]
permissive
use std::io::{Error}; use crate::bindings::{ Windows::Win32::Foundation::PWSTR, Windows::Win32::Storage::FileSystem::GetDiskFreeSpaceExW, Windows::Win32::Storage::FileSystem::GetDriveTypeW, Windows::Win32::Storage::FileSystem::GetLogicalDrives, Windows::Win32::Storage::FileSystem::GetVolumeInformat...
true
11b6cd52dd411646e2befa9cd51e94e146c5d13e
Rust
HowProgrammingWorks/EventEmitter
/Rust/src/event.rs
UTF-8
1,611
4
4
[ "MIT" ]
permissive
/// Single event emitter. /// /// Contrary to the Node.js-like `EventEmitter`, this one isn't parametrized /// with the event type, because it, basically, represents the event itself. /// /// Such design gives us more flexibility without sacrificing type safety. /// Events that are logically bound together can still be...
true
b82599dddff3faba52ccbe6810536444db55495a
Rust
TrueDoctor/Graphite
/core/editor/src/dispatcher/mod.rs
UTF-8
3,089
2.609375
3
[ "Apache-2.0", "LicenseRef-scancode-free-unknown" ]
permissive
pub mod events; use crate::{tools::ToolType, Color, Document, EditorError, EditorState}; use document_core::Operation; use events::{Event, Key, Response}; pub type Callback = Box<dyn Fn(Response)>; pub struct Dispatcher { callback: Callback, } impl Dispatcher { pub fn handle_event(&self, editor_state: &mut EditorSt...
true
ce982f29d51daa39f125304f618eeed8131a6214
Rust
pdf-rs/font
/examples/parse.rs
UTF-8
333
2.59375
3
[ "MIT" ]
permissive
use font::{parse}; fn main() { env_logger::init(); let arg = std::env::args().nth(1).unwrap(); let data = std::fs::read(&arg).expect("can't read file"); let font = parse(&data).unwrap(); println!("{} glyphs", font.num_glyphs()); let gid = font.gid_for_unicode_codepoint(205).unwrap(); font.g...
true
de33bb840af8f370e55dce8a545b50ead89ea311
Rust
celluloce/Rust
/main.rs
UTF-8
139
2.546875
3
[]
no_license
fn main() { let mut bytes = "abcdefghijklmnopqrstuvwxyz".bytes(); for c in 0..20 { println!("{:?}", bytes.next()); } }
true
9e2f902184ca816fee2cb69291a5f94772196af3
Rust
misonomi/casko-bot-rs
/src/meltomos/stat.rs
UTF-8
1,588
2.8125
3
[]
no_license
use std::u8::MAX; use crate::handler::combat::CombatStatus; #[derive(Debug, Clone)] pub enum BondType { Normal, Watching, Admin, Unknown } impl BondType { pub fn into_borrow(&self) -> &u8 { match self { BondType::Normal => &1, BondType::Watching => &2, ...
true
7707af58fde94829843801477a396a796eb87da5
Rust
prataprc/gist
/rs/examples/008-scope.rs
UTF-8
481
3.328125
3
[ "MIT" ]
permissive
// all variables have a scope, and are constrained to live in // a block. fn main() { let long_lived_binding = 1; // nested BLOCK, say we call it A { let short_lived_binding = 2; // restricted to block A. println!("inner short: {}", short_lived_binding); let long_lived_binding = 3...
true
08a83d3fdb067feeac8585b287ee85ba4177f70e
Rust
m-dahl/hello-rust
/src/parse.rs
UTF-8
4,266
3.15625
3
[]
no_license
use crate::prop::Prop::*; use crate::prop::*; use uuid::Uuid; named!(parse_true<&str, Prop>, map!(tag_no_case!("true"), |_| TRUE)); named!(parse_false<&str, Prop>, map!(tag_no_case!("false"), |_| FALSE)); named!(parse_id<&str, Prop>, complete!(map_res!(take_s!(36), |s| Uuid::parse_str(s).map(|id| ID(id))))); named!(pa...
true
e572b187089bb0c2609a13e9871de2ce9ff63b4a
Rust
bouzuya/rust-atcoder
/cargo-atcoder/contests/abc168/src/bin/c.rs
UTF-8
409
2.765625
3
[]
no_license
use proconio::input; fn main() { input! { a: f64, b: f64, h: f64, m: f64, }; let th = (h * 60_f64 + m) / (60_f64 * 12_f64) * 2_f64 * std::f64::consts::PI; let tm = m / 60_f64 * 2_f64 * std::f64::consts::PI; let dx = th.cos() * a - tm.cos() * b; let dy = th.sin() ...
true
24277dc54d8ac1514c4d31c177a3800aebe45fcb
Rust
zbrdge/mre
/examples/helloeveryone/person.rs
UTF-8
2,721
3.328125
3
[ "MIT" ]
permissive
use std::time; use time::Tm; use mre::model::{Model, Error}; // Create a class to act as our model. Unfortunately Rust's classes aren't // finished yet, and are missing a couple features that would help clean up // models. First, there's no way to mix in implementation of functions, so we // need to duplicate some cod...
true
990e30daec17b7b046c749b835088c32737db376
Rust
jamesmcm/aoc2020_rust
/src/day11.rs
UTF-8
10,832
3.125
3
[ "MIT" ]
permissive
use anyhow::{anyhow, Result}; use aoc_runner_derive::{aoc, aoc_generator}; use std::collections::HashMap; use std::convert::TryFrom; use std::str::FromStr; #[derive(Debug, PartialEq, Clone, Copy)] pub enum Tile { Empty, Occupied, Floor, } impl TryFrom<char> for Tile { type Error = anyhow::Error; ...
true
31e58dd07883ee777e71b9e283721d7691038aff
Rust
hershi/cryptopals_rust
/ex_11_ecb_cbc_oracle/src/main.rs
UTF-8
1,883
3.203125
3
[]
no_license
use std::collections::HashMap; use utils::*; use utils::encryption::*; use rand::prelude::*; const BLOCK_SIZE : usize = 16; const KEY_SIZE : usize = 16; const IV_SIZE : usize = 16; #[derive(Debug, Eq, PartialEq)] enum EncryptionMode { CBC, ECB } fn encryption_oracle(input: &[u8]) -> (Vec<u8>, EncryptionMode)...
true
160c2f040bb373eb10a0bea302a4a4948eef4cc8
Rust
cloudflare/etherparse
/src/transport/udp.rs
UTF-8
10,501
3.203125
3
[ "BSD-3-Clause" ]
permissive
use super::super::*; extern crate byteorder; use self::byteorder::{ByteOrder, BigEndian, ReadBytesExt, WriteBytesExt}; ///Udp header according to rfc768. #[derive(Clone, Debug, Eq, PartialEq, Default)] pub struct UdpHeader { ///Source port of the packet (optional). pub source_port: u16, ///Destination por...
true