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
1923441caf41ebc9cc15552893798631484f4d56
Rust
j-browne/advent-of-code
/2021/src/seven_segment_display.rs
UTF-8
4,434
3.21875
3
[]
no_license
use std::collections::HashMap; #[derive(Debug)] pub struct Display { signals: Vec<Signals>, output: Vec<Signals>, } impl Display { #[must_use] pub fn new(s: &str) -> Self { let mut it = s.split(" | "); let signals = it .next() .unwrap() .split_whites...
true
68ad540da2d121eb0edcc5ab9de078f8bce8fe31
Rust
placrosse/drogue-device
/src/supervisor/interrupt_dispatcher.rs
UTF-8
1,687
2.734375
3
[ "Apache-2.0" ]
permissive
use heapless::{consts::*, Vec}; use crate::actor::Actor; use crate::interrupt::{Interrupt, InterruptContext}; use core::sync::atomic::Ordering; pub(crate) trait ActiveInterrupt { fn on_interrupt(&self); } impl<I: Actor + Interrupt> ActiveInterrupt for InterruptContext<I> { fn on_interrupt(&self) { //...
true
9295e3277951d89415fa18d28b249828160072f4
Rust
xayon40-12/wgpu_ray
/src/window.rs
UTF-8
3,837
2.640625
3
[]
no_license
pub mod canvas; use winit::{ event_loop::{ControlFlow, EventLoop}, event::{self,Event,WindowEvent}, }; pub trait Window { fn new(sc_desc: &wgpu::SwapChainDescriptor, device: &wgpu::Device) -> Self; fn update(&mut self, event: Event<()>, device: &wgpu::Device) -> Vec<wgpu::CommandBuffer>; fn resize...
true
333add9265842385519d779800a29651c56a10a5
Rust
larntz/mft_muncher
/src/ntfs_attributes/standard_information.rs
UTF-8
2,618
2.828125
3
[]
no_license
use crate::utils::*; /** reference: [https://flatcap.org/linux-ntfs/ntfs/attributes/standard_information.html](https://flatcap.org/linux-ntfs/ntfs/attributes/standard_information.html) _NOTE:_ this attribute is always resident. ``` Offset Size OS Description ~ ~ Standard Attribute Header 0x00 8 ...
true
390f1c96fb21e0a2ba747f7d3f43111fd2c3822c
Rust
jdwile/advent-of-code
/2022/advent-of-code-2022/src/bin/09.rs
UTF-8
2,379
3.421875
3
[]
no_license
use std::collections::HashSet; #[aoc::main(09)] pub fn main(input: &str) -> (usize, usize) { solve(input) } #[aoc::test(09)] pub fn test(input: &str) -> (String, String) { let res = solve(input); (res.0.to_string(), res.1.to_string()) } fn solve(input: &str) -> (usize, usize) { let p1 = part1(input);...
true
9cfed41b28c9f28df26008ed1507e8e8634e2736
Rust
jaredly/veoluz
/src/state.rs
UTF-8
11,218
2.640625
3
[]
no_license
use std::sync::Mutex; use wasm_bindgen::prelude::*; use web_sys::CanvasRenderingContext2d; #[wasm_bindgen] extern "C" { pub type TimeoutId; #[wasm_bindgen(js_name = "setTimeout")] pub fn set_timeout_inner(cb: &JsValue, timeout: f64) -> TimeoutId; #[wasm_bindgen(js_name = "clearTimeout")] pub fn c...
true
303409b79f66b1c21f72a86538af7a256c3a1776
Rust
denjalonso/sdk-node
/packages/worker/native/src/errors.rs
UTF-8
3,577
2.921875
3
[ "MIT" ]
permissive
use neon::prelude::*; use once_cell::sync::OnceCell; /// An unhandled error while communicating with the server, considered fatal pub static TRANSPORT_ERROR: OnceCell<Root<JsFunction>> = OnceCell::new(); /// Thrown after shutdown was requested as a response to a poll function, JS should stop polling /// once this erro...
true
7c976b8f3d3d1545df643bc091e9a81422347a3c
Rust
l1h3r/did_doc
/src/verification/method_query.rs
UTF-8
1,594
2.921875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::verification::MethodIndex; use crate::verification::MethodScope; /// Specifies the conditions of a DID document method resolution query. /// /// See `Document::resolve`. #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] pub struct MethodQuery<'a> { pub(crate) ident: MethodIndex<'a>, p...
true
6804ece78377aa1fe381e7e0b66008829cda31a4
Rust
distil/diffus
/diffus/src/diffable_impls/string.rs
UTF-8
2,713
3.375
3
[ "Apache-2.0" ]
permissive
use crate::{ edit::{self, string}, lcs, Diffable, }; impl<'a> Diffable<'a> for str { type Diff = Vec<string::Edit>; fn diff(&'a self, other: &'a Self) -> edit::Edit<Self> { let s = lcs::lcs( || self.chars(), || other.chars(), self.chars().count(), ...
true
b1ce2b380c4de3a1a57fef8fadfac811baf8265a
Rust
joseluiscd/wpng
/src/lib.rs
UTF-8
3,655
2.609375
3
[ "MIT" ]
permissive
pub mod raw; pub mod transform; use raw::{ RawPng, Header, Chunk, Palette, RawChunk }; use std::borrow::Cow; use flate2::bufread::{ ZlibDecoder, ZlibEncoder, }; use std::convert::TryFrom; use std::path::Path; pub type Scanline<'a> = Cow<'a, [u8]>; #[derive(Debug)] pub struct Png { pub header: Header,...
true
95713be297ba7c8b9a746a4ad96f07d8229b24b1
Rust
mesainner/easy-file
/src/protocols/smb.rs
UTF-8
1,141
2.71875
3
[]
no_license
use std::io::Result; use crate::file_opt::{FileOpt, FileAttr}; use crate::cache::disk::CacheFlag; #[derive(Debug, Default)] pub struct SmbClient { field: u8, read_offset: i64, } impl FileOpt for SmbClient { fn open(path: &str, flag: Option<CacheFlag>) -> Self { SmbClient{ field:1, ...
true
f65b4d21c84bf3c563c0bd2f3fcf0d3ab6847ad4
Rust
pseudobabble/rust_practice
/src/main.rs
UTF-8
709
3.875
4
[]
no_license
fn reverse_string(phrase: &str) -> String { phrase.chars().rev().collect() } fn bool_to_word(value: bool) -> &'static str { match value { true => { "Yes" } false => { "No" } } } fn main() { let reversed = reverse_string("Hello World"); prin...
true
a7ad00545926b6277dab7d0cbaf9b963c133ccbf
Rust
tock/libtock-rs
/platform/src/termination.rs
UTF-8
587
3.03125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Definition of the Termination trait. The main() function (set using set_main!()) //! must return a type that implements Termination. use crate::{ErrorCode, Syscalls}; pub trait Termination { fn complete<S: Syscalls>(self) -> !; } impl Termination for () { fn complete<S: Syscalls>(self) -> ! { S::...
true
c9b0ec89901a179bfe319411213ae6af7cd974bc
Rust
tahnok/advent2017
/rust/src/bin/day18_1.rs
UTF-8
2,586
2.96875
3
[]
no_license
use std::collections::HashMap; use std::io; use std::io::Read; fn main() { let mut input = String::new(); let _ = io::stdin().read_to_string(&mut input); println!("{}", solve(input.trim())); } fn val_or_reg(val: &str, register: &HashMap<&str, isize>) -> isize { let maybe_val = val.parse(); match m...
true
5051c9cd67e8892ee5c9c649fedf425366373172
Rust
coriolinus/adventofcode-2015
/day21/src/loadout_generator.rs
UTF-8
2,305
3.359375
3
[]
no_license
use crate::{ items::{Item, ItemType}, loadout::Loadout, }; use itertools::Itertools; /// Produce `None`, followed by `Some(t)` for each item in `ts`. fn optional_iter<T: Clone>( ts: impl Iterator<Item = T> + Clone, ) -> impl Iterator<Item = Option<T>> + Clone { std::iter::once(None).chain(ts.map(Some))...
true
ea01a259d651beddc65aa5e047661cd219e9cc29
Rust
snicmakino/practice-aoj
/src/3_2.rs
UTF-8
818
3.03125
3
[]
no_license
use std::io::Read; fn main() { let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).unwrap(); let mut iter = buf.split_whitespace(); let n: i32 = iter.next().unwrap().parse().unwrap(); let mut a: Vec<i32> = (0..n) .map(|_| iter.next().unwrap().parse().unwrap()) ....
true
186f7951737dd26e2f2bcd32af5e423d4b66ce31
Rust
obsc/rustlam
/src/scanner/standard.rs
UTF-8
711
3.265625
3
[]
no_license
use std::io; use std::collections::VecDeque; pub struct StdScanner { std: io::Stdin, buf: VecDeque<String>, } impl StdScanner { pub fn new() -> Self { StdScanner{ std: io::stdin(), buf: VecDeque::new(), } } pub fn next_line(&mut self) -> Option<&String> { ...
true
5eb127a84dba08224929e11b0f69dd01601ab493
Rust
Rohesie/wallmount-slicer
/src/config.rs
UTF-8
2,386
2.8125
3
[]
no_license
use anyhow::bail; use yaml_rust::YamlLoader; use std::path::Path; use std::io::prelude::*; use std::fs::File; use anyhow::Result; #[derive(Clone, PartialEq, Debug, Default)] pub struct PrefHolder { pub x_step: u32, pub y_step: u32, pub north_start_x: u32, pub north_start_y: u32, pub east_start_x: u32...
true
cf7f79020b77d9a654d7f1de7ebbe5ffbc73c99e
Rust
mikialex/soa-derive
/soa-derive-internal/src/vec.rs
UTF-8
12,273
2.703125
3
[ "Apache-2.0", "MIT" ]
permissive
use proc_macro2::{Span, TokenStream}; use syn::Ident; use quote::TokenStreamExt; use quote::quote; use crate::input::Input; pub fn derive(input: &Input) -> TokenStream { let name = &input.name; let vec_name_str = format!("Vec<{}>", name); let other_derive = &input.derive(); let visibility = &input.vis...
true
d4ce5a3f55bdae0d2f013276af64788797929e30
Rust
jbradberry/advent-of-code
/2022/day09-2/src/main.rs
UTF-8
2,775
3.296875
3
[]
no_license
use std::collections::{HashSet, HashMap}; use std::io; use std::io::prelude::*; #[derive(Debug)] enum Move { Up, Down, Left, Right, } fn read() -> Vec<(Move, u8)> { let stdin = io::stdin(); stdin.lock().lines() .map(|x| { let line = x.unwrap(); let split = li...
true
0e5d33ece0070c0adb892a2957e9ec02f3e6f1bc
Rust
elracional/Games-FoxHell
/src/bitmap.rs
UTF-8
3,615
3.203125
3
[]
no_license
/* * Este módulo contiene la clase BitMap en la cual se define el mapa de bits que conforma un sprite. * El mapa de bits consiste en una matriz 8x8 (para un sprite 8bits) en la cual cada posición indica un index * que posteriormente se usará para saber qué color se debe insertar en cada una de las posiciones de la ...
true
6a40aef7ef1c2478d2dce5f58fe4ad986801f71f
Rust
polapl/coreutils
/src/sleep/sleep.rs
UTF-8
2,410
2.703125
3
[ "MIT" ]
permissive
#![crate_name = "sleep"] #![feature(collections, core, old_io, rustc_private, std_misc)] /* * This file is part of the uutils coreutils package. * * (c) Arcterus <arcterus@mail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ ...
true
92c65adb6c0b83931ef35a64b65f89acb76dd11c
Rust
aleb/rofld
/src/lib/caption/engine/config.rs
UTF-8
1,342
3.359375
3
[]
no_license
//! Module with captioning engine configuration. use std::error; use std::fmt; /// Structure holding configuration for the `Engine`. /// /// This is shared with `CaptionTask`s. #[derive(Clone, Copy, Debug)] pub struct Config { /// Quality of the generated JPEG images (in %). pub jpeg_quality: u8, /// Qua...
true
2d36e2105560c2194d61c17ea7123670bdacf6d3
Rust
Rexagon/crypto-labs
/primes/src/modulo_generator.rs
UTF-8
416
2.53125
3
[ "Apache-2.0" ]
permissive
use { num_bigint::BigUint, rand::{distributions::uniform::UniformSampler, prelude::Rng}, }; use crate::range::Range; pub trait ModuloGenerator { fn generate_mod<R: Rng + ?Sized>(&self, modulo: &BigUint, rng: &mut R) -> BigUint; } impl ModuloGenerator for Range { fn generate_mod<R: Rng + ?Sized>(&self...
true
c93e43dfc86cfa192663632bcee1fc257a5d8201
Rust
mvertescher/psoc6-pac
/src/pdm0/rx_fifo_status.rs
UTF-8
1,155
2.53125
3
[ "BSD-3-Clause", "0BSD", "Apache-2.0" ]
permissive
#[doc = "Reader of register RX_FIFO_STATUS"] pub type R = crate::R<u32, super::RX_FIFO_STATUS>; #[doc = "Reader of field `USED`"] pub type USED_R = crate::R<u8, u8>; #[doc = "Reader of field `RD_PTR`"] pub type RD_PTR_R = crate::R<u8, u8>; #[doc = "Reader of field `WR_PTR`"] pub type WR_PTR_R = crate::R<u8, u8>; impl R...
true
c2a8278281404c434d84800133e76da667fb2180
Rust
frankmcsherry/timely-dataflow
/timely/src/dataflow/operators/generic/handles.rs
UTF-8
8,953
2.8125
3
[ "MIT" ]
permissive
//! Handles to an operator's input and output streams. //! //! These handles are used by the generic operator interfaces to allow user closures to interact as //! the operator would with its input and output streams. use std::rc::Rc; use std::cell::RefCell; use crate::Data; use crate::progress::Timestamp; use crate::...
true
3341eb1cc71fc09ae6cc4ae66224545c712644fb
Rust
monsieurbadia/qoeur-and-qoeur-lab-and-qompo
/src/qoeurc/src/utils/iters.rs
UTF-8
1,231
3.046875
3
[ "MIT" ]
permissive
use crate::analyzer::interpreter::{Interpreter, ValueResult}; use crate::transformer::transpiler::Transpiler; use crate::value::instruction::IKind; use crate::value::{Value, Values}; use crate::void; pub fn eval_expressions( interpreter: &mut Interpreter, exprs: Vec<Box<dyn Value>>, ) -> ValueResult<Values> { le...
true
cc0a7ad7e29ea5aaa859fa466907b804359dd175
Rust
jbyte/chip8
/src/main.rs
UTF-8
1,358
2.625
3
[ "MIT" ]
permissive
#[macro_use] extern crate nom; extern crate rand; use std::env; use std::io::Read; use std::fs::File; use std::path::Path; mod cpu; mod debugger; use debugger::Debugger; fn main() { let rom_name: String; let debug: String; let file = env::args().nth(2); let flag = env::args().nth(1); match fil...
true
f933874a79b19114af81e21b10344e62132949bb
Rust
mewbak/Lancelot
/core/src/loader.rs
UTF-8
5,332
2.953125
3
[ "Apache-2.0" ]
permissive
use bitflags::bitflags; use failure::{Error, Fail}; use log::info; use strum_macros::Display; use super::{ analysis::Analyzer, arch::{Arch, RVA, VA}, config::Config, loaders::{pe::PELoader, sc::ShellcodeLoader}, pagemap::PageMap, }; #[derive(Debug, Fail)] pub enum LoaderError { #[fail(display ...
true
1407360ccbdb1ba8aef00d4ae81ffa35997ed06a
Rust
djc/async-imap
/src/imap_stream.rs
UTF-8
9,749
2.828125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::fmt; use std::pin::Pin; use async_std::io::{self, Read, Write}; use async_std::prelude::*; use async_std::stream::Stream; use async_std::sync::Arc; use byte_pool::{Block, BytePool}; use futures::task::{Context, Poll}; use nom::Needed; use crate::types::{Request, ResponseData}; const INITIAL_CAPACITY: usize ...
true
1ec0b1f63e0611dc696f0b566821cb4d6181994f
Rust
mattiascibien/dicenotation-rs
/dicenotation/src/lib.rs
UTF-8
2,923
3.375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
// Copyright 2018 Mattias Cibien // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://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, modified, or distributed except according to tho...
true
34c5c2dfa9e03f380a9764256a69437b09c4adc7
Rust
boa-dev/boa
/fuzz/fuzz_targets/common.rs
UTF-8
2,944
2.75
3
[ "MIT", "Unlicense" ]
permissive
use arbitrary::{Arbitrary, Unstructured}; use boa_ast::{ visitor::{VisitWith, VisitorMut}, Expression, StatementList, }; use boa_interner::{Interner, Sym, ToInternedString}; use std::{ fmt::{Debug, Formatter}, ops::ControlFlow, }; /// Context for performing fuzzing. This structure contains both the gen...
true
c5f9468e18c5ff3ff27c83f73666e0200e24ea2f
Rust
itsrainingmani/adventofcode2020
/day3-tobag-traj/src/main.rs
UTF-8
1,550
3.578125
4
[]
no_license
use std::fs; type Slope = (usize, usize); type Pos = Slope; fn main() { println!("Advent of Code - Day 3 - Tobaggon Trajectory"); let input_filename = String::from("input.txt"); let contents = fs::read_to_string(input_filename).expect("Something went wrong reading the file"); // Convert the...
true
a8ac2b7a998eb793eb69af04da23409399048fcc
Rust
tdejager/winner
/winner_server/src/messages.rs
UTF-8
2,013
2.96875
3
[]
no_license
use crate::types::{Story, StoryPoints, Winner}; use serde_derive::{Deserialize, Serialize}; use std::collections::HashMap; #[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)] pub enum StateChange { Enter, Leave, Leader, } #[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)] pub enum R...
true
1f42c455b12a2984753bc6779a665962362a39f9
Rust
joeferner/raspberry-pi-ir-hat
/drivers/rust/src/bin/irlisten.rs
UTF-8
5,441
2.6875
3
[]
no_license
use clap::App; use clap::Arg; use log::info; use raspberry_pi_ir_hat::{Config, Hat}; use simple_logger; use std::{thread, time}; fn main() -> Result<(), String> { simple_logger::init_with_env().map_err(|err| format!("{}", err))?; info!("starting"); let args = App::new("Raspberry Pi IrHat - irlisten") ...
true
1e32a1ba4557374561461dffbc663e4f169f6401
Rust
casimir/ufind
/src/digraph/mod.rs
UTF-8
1,618
3.078125
3
[ "MIT" ]
permissive
mod data; use self::data::{Digraph, TABLE}; fn get_char(digraph: &str) -> Option<char> { let mut chars_it = digraph.chars(); let chars: [char; 2] = [chars_it.next().unwrap(), chars_it.next().unwrap()]; let res = TABLE.into_iter().find(|&x| x.sequence == chars); match res { Some(digr) => Some(d...
true
2d798d25559055a66a888a3f616ed04164a80b0d
Rust
wasmerio/cranelift
/cranelift-simplejit/src/backend.rs
UTF-8
17,759
2.546875
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
//! Defines `SimpleJITBackend`. use crate::memory::Memory; use cranelift_codegen::binemit::{Addend, CodeOffset, NullTrapSink, Reloc, RelocSink}; use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::{self, ir, settings}; use cranelift_module::{ Backend, DataContext, DataDescription, Init, Linkage, ModuleNa...
true
b69777b2d96568a33b547b7a48b41fdb7e7fbe7a
Rust
veldsla/faimm
/src/lib.rs
UTF-8
15,228
2.890625
3
[ "MIT" ]
permissive
#![doc(html_root_url = "https://docs.rs/faimm/0.4.0")] //! This crate provides indexed fasta access by using a memory mapped file to read the sequence //! data. It is intended for accessing sequence data on genome sized fasta files and provides //! random access based on base coordinates. Because an indexed fasta file ...
true
5b10dda3d1be0f1cbaacdc0c20f78dc4acdfe983
Rust
endoli/disassemble.rs
/src/instruction.rs
UTF-8
2,139
3.046875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// 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, modified, or distributed // except according to those terms. use crate::address:...
true
5b4374b8d4143da00a32ec2cf78e4a3c9b34b497
Rust
ajunlonglive/mockiato
/src/arguments.rs
UTF-8
472
2.671875
3
[ "MIT" ]
permissive
use std::fmt::{Debug, Display}; #[allow(missing_docs)] pub trait Arguments: Display + Debug {} #[cfg(test)] pub(crate) use self::mock::*; #[cfg(test)] mod mock { use super::Arguments; use std::fmt; #[derive(Debug)] pub(crate) struct ArgumentsMock; impl Arguments for ArgumentsMock {} impl s...
true
81a4d8cde1579c3d4580ac30a967cdfbc0e4cb01
Rust
qoollo/bob
/bob-common/src/metrics/collector/accumulator.rs
UTF-8
2,409
2.65625
3
[ "MIT" ]
permissive
use super::snapshot::*; use std::convert::TryInto; use std::sync::Arc; use std::time::{Duration, SystemTime, UNIX_EPOCH}; use tokio::sync::mpsc::Receiver; use tokio::time::{interval, timeout}; const METRICS_RECV_TIMEOUT: Duration = Duration::from_millis(100); const MAX_METRICS_PER_PERIOD: u64 = 100_000; pub(crate) st...
true
a4e00e301a80d80d50ece8b0c67d31a21a2d30dd
Rust
albedium/redox
/filesystem/apps/sodium/keystate.rs
UTF-8
359
3.171875
3
[ "MIT" ]
permissive
/// A key state pub struct KeyState { /// Shift pressed pub shift: bool, /// Ctrl pressed pub ctrl: bool, /// Alt pressed pub alt: bool, } impl KeyState { /// Create new default keystate pub fn new() -> KeyState { KeyState { shift: false, ctrl: false, ...
true
52b3769c2b8322fb7bb94206dc1d46c0052b6389
Rust
tekjar/rust-learn
/tiny-try/read_console/src/main.rs
UTF-8
2,205
3.234375
3
[ "MIT" ]
permissive
use std::io::{self, BufRead}; fn main(){ let stdin = io::stdin(); for line in stdin.lock().lines(){ println!("{:?}", line); } } /* pub fn stdin() -> Stdin ----------------------- Constructs a new handle to the standard input of the current process. Each handle returned is a reference to a...
true
51057e721753979ad27f7e78c43e9e55b10a1875
Rust
mfonism/jwtvault_examples
/src/bin/04_async_postgres_static.rs
UTF-8
9,820
2.625
3
[]
no_license
use jwtvault::prelude::*; use jwtvault_examples::database::setup::connection; use jwtvault_examples::database::users_setup::signup_app_users; use std::collections::HashMap; use std::collections::hash_map::DefaultHasher; use jwtvault::errors::LoginFailed::PasswordHashingFailed; use postgres::NoTls; use r2d2::Pool; use...
true
d515c6c05d311607762de771bbd4a3c4e3c60af7
Rust
morpheyesh/megam_api.rs
/src/megam_api/util/sshkeys.rs
UTF-8
908
2.828125
3
[ "Apache-2.0" ]
permissive
use std::result; //use rustc_serialize::json; pub type Result<Success, Error> = result::Result<Success, Error>; #[derive(Debug)] pub enum Success { Success } #[derive(Debug)] pub enum Error { NotOkResponse, } pub struct SSHKey { pub name : String, pub accounts_id : String, pub path ...
true
2009a65e1d6b67b027efa21db7ee1359923609b4
Rust
kenkoooo/competitive-programming-rs
/src/math/determinant.rs
UTF-8
884
3.375
3
[ "CC0-1.0" ]
permissive
pub fn calc_determinant<T>(mut matrix: Vec<Vec<T>>) -> T where T: Copy + std::ops::Sub<Output = T> + std::ops::Mul<Output = T> + std::ops::Div<Output = T>, { let n = matrix.len(); assert!( matrix.iter().all(|row| row.len() == n), "The matrix is not square!" ); for i in 0..n { ...
true
c4b50ff6b1488fe4a620654a970018a966cd03dd
Rust
sirkibsirkib/naive_fourier
/src/lib.rs
UTF-8
644
2.578125
3
[]
no_license
extern crate simple_vector2d; extern crate textplots; use simple_vector2d::consts::ZERO_F32 as ZERO; use std::ops::Add; type Pt = simple_vector2d::Vector2<f32>; pub fn fourier(samples: &[f32], sample_period: f32, query_frequency: f32) -> f32 { let in_step = sample_period / samples.len() as f32; samples ...
true
6e9b1cb7e5964f02c77d5c58afffdb4fd6f64441
Rust
tuxmark5/north
/north_core/src/model/member/reference_link.rs
UTF-8
1,950
2.65625
3
[]
no_license
use { crate::{ Node, NodeId, model::member::{ Member, Reference, member_descr::MemberDescr }, util::downcast::{ Downcast, DowncastEntry } }, std::{ any::{Any, TypeId}, fmt::{Debug}, mem }, }; /////////////////////////////////////////////////////////////////////...
true
f37d114ea29087824686d70847f28b3494a9c270
Rust
sisshiki1969/ruruby
/ruruby/src/builtin/exception.rs
UTF-8
5,804
2.546875
3
[ "MIT" ]
permissive
use crate::*; pub(crate) fn init(globals: &mut Globals) -> Value { let exception = Module::class_under_object(); globals.set_toplevel_constant("Exception", exception); exception.add_builtin_class_method(globals, "new", exception_new); exception.add_builtin_class_method(globals, "exception", exception_n...
true
6273742ecc71c65434b5b07ada58bc38b2a1aea3
Rust
jonwingfield/atsamd09-rs
/atsamd09d14a/pm/apbbmask/mod.rs
UTF-8
10,522
2.53125
3
[]
no_license
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::APBBMASK { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w ...
true
85db5d321a35d170a0e9c77ed72c1bc8dc523abf
Rust
orium/rustybit
/src/datatype/value.rs
UTF-8
455
3.28125
3
[]
no_license
use std::fmt::Show; use std::fmt::Formatter; /* This makes it safe to change to subunits of satoshi in the future without * creating nasty bugs, because type system. */ #[allow(dead_code)] pub enum Value { Satoshi(u64) } impl Show for Value { fn fmt(&self, f : &mut Formatter) -> Result<(), ::std::fmt::Error...
true
31d189350c6ffe50bcc178aca29069ae55848d04
Rust
derekdreery/pipewire-rs
/libspa/src/dict.rs
UTF-8
10,044
3.359375
3
[ "MIT" ]
permissive
use bitflags::bitflags; use std::{ffi::CStr, fmt, marker::PhantomData}; pub trait ReadableDict { /// Obtain the pointer to the raw `spa_dict` struct. fn get_dict_ptr(&self) -> *const spa_sys::spa_dict; /// An iterator over all raw key-value pairs. /// The iterator element type is `(&CStr, &CStr)`. ...
true
bc5f0ca80693c34b6df9dc4998b47a2211e55581
Rust
apache/incubator-teaclave-sgx-sdk
/samplecode/unit-test/enclave/src/test_serialize.rs
UTF-8
9,426
2.890625
3
[ "BSD-3-Clause", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use sgx_serialize::{DeSerializable, DeSerializeHelper, Serializable, SerializeHelper}; use std::fmt::Debug; use std::string::{String, ToString}; use std::vec::Vec; fn test_serialize_internal<T: Serializable + DeSerializable>(target: &T) -> Option<T> { let helper = SerializeHelper::new(); let data = helper.enco...
true
35e6cc2c9be7aace1253906021362aa6183a16d5
Rust
SDRust/png_decode
/src/lib.rs
UTF-8
5,944
2.875
3
[]
no_license
extern crate flate2; use std::fs::File; use std::io::Read; pub struct Chunk { typ: u32, data: Vec<u8>, } pub fn eat_u32(i: &mut usize, data: &[u8]) -> u32 { let mut b: u32 = 0; b |= data[3 + *i] as u32; b |= (data[2 + *i] as u32) << 8; b |= (data[1 + *i] as u32) << 16; b |= (data[0 + *i] ...
true
3b1e9dd3406c3bb79f16058bf085aa8465c68d63
Rust
RoccoDev/bbCraft
/server/mc_server_impl/src/net/connection.rs
UTF-8
3,784
2.59375
3
[ "MIT" ]
permissive
// Copyright (c) 2019 RoccoDev // // This software is released under the MIT License. // https://opensource.org/licenses/MIT use std::ffi::CString; use std::net::{Shutdown, TcpStream}; use crate::api::player_connect; use crate::net::encryption::EncryptionResponsePacket; use crate::net::handshake::{DisconnectPacket, ...
true
3400cd998e2ccaf55f904157c6ca2213256dff40
Rust
marco-c/gecko-dev-wordified
/third_party/rust/extend/tests/compile_pass/hello_world.rs
UTF-8
266
2.953125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use extend : : ext ; # [ ext ] impl i32 { fn add_one ( & self ) - > Self { self + 1 } fn foo ( ) - > MyType { MyType } } # [ derive ( Debug Eq PartialEq ) ] struct MyType ; fn main ( ) { assert_eq ! ( i32 : : foo ( ) MyType ) ; assert_eq ! ( 1 . add_one ( ) 2 ) ; }
true
fee1d77bde6049b62557f954c098f43b41c2415b
Rust
vshotarov/advent-of-code-2020
/day09/src/main.rs
UTF-8
1,957
3.359375
3
[]
no_license
use std::io::{self, Read}; use std::collections::VecDeque; static BUFFER_SIZE: usize = 25; fn main() -> std::io::Result<()> { let mut input = String::new(); io::stdin().read_to_string(&mut input)?; let first_invalid_number = solve_part1(&input)?; solve_part2(&input, first_invalid_number)?; Ok(()...
true
6d8e31ee91fbae7933a1fe7c6607db9a7ea4a1a1
Rust
doyoubi/Blastoise
/src/test/utils.rs
UTF-8
3,633
2.734375
3
[]
no_license
use std::fmt::{Display, Debug}; use std::option::Option::None; use std::result::Result::Ok; use std::ptr::{write, read}; use libc::malloc; use ::parser::lexer::TokenIter; use ::parser::compile_error::ErrorList; use ::parser::common::exp_list_to_string; use ::utils::pointer::{write_string, read_string}; use ::s...
true
5e6a161421af6f5fbb7ee92a8078690d58556355
Rust
lu-zero/testcase-wasi-alloc
/src/main.rs
UTF-8
1,862
3
3
[]
no_license
use std::marker::PhantomData; use std::alloc::*; use std::mem; #[derive(Debug, PartialEq, Eq)] pub struct PlaneData { ptr: std::ptr::NonNull<u8>, _marker: PhantomData<u8>, len: usize, align: usize, } unsafe impl Send for PlaneData {} unsafe impl Sync for PlaneData {} impl Clone for PlaneData { fn clone(&se...
true
db98e47d368a1357b224d4244cd95301918c99f6
Rust
canhmai/BLAKE3f
/src/gpu/mod.rs
UTF-8
20,307
2.890625
3
[ "Apache-2.0", "LicenseRef-scancode-public-domain", "CC0-1.0" ]
permissive
//! GPU acceleration for BLAKE3. //! //! This module allows accelerating a [`Hasher`] through SPIR-V shaders. //! //! [`Hasher`]: ../struct.Hasher.html use super::*; use core::mem; use core::ops::{Deref, DerefMut}; use core::slice; /// Control uniform for the BLAKE3 shader. /// /// This uniform contains the informati...
true
db5d615c44e1335c2988195fb7f82354cac8968d
Rust
stijnh/rust-advent-of-code-2018
/src/day20.rs
UTF-8
3,247
3.078125
3
[]
no_license
use crate::common::read_file_lines; use std::collections::{HashMap as Map, HashSet as Set, VecDeque as Deque}; type Point = [i32; 2]; type Door = (Point, Point); #[derive(Debug, Clone)] enum MyRegex { Leaf(char), // Single character Seq(Vec<MyRegex>), // Sequence of exprs Alt(Vec<MyRegex>), // Opti...
true
3c45bee754354f8b1a5ad3ba2fe8b97013c1d8d3
Rust
burzek/katas
/AdventOfCode2021/src/day1.rs
UTF-8
759
3.40625
3
[]
no_license
pub fn day1_task1(input: String) { let lines = input.lines(); let mut increased = 0; lines .map(|s| { s.parse::<i32>().unwrap() }) .reduce(|prev, current| { if prev < current { increased = increased + 1 }; current }); println!("day1, task1 : {}", increase...
true
aee3d4b6c2054c6669e32d0d6ab5e7f54bf3c0d0
Rust
dainslef/RustPractice
/src/leetcode/q96_unique_binary_search_trees.rs
UTF-8
1,968
3.8125
4
[ "BSD-3-Clause" ]
permissive
/*! [96. Unique Binary Search Trees](https://leetcode.com/problems/unique-binary-search-trees/) Given an integer n, return the number of structurally unique BST's (binary search trees) which has exactly n nodes of unique values from 1 to n. Example 1: ```html Input: n = 3 Output: 5 ``` Example 2: ```html Input: n ...
true
905b6243f2fb56c2c65edf0a885aca0565283bf2
Rust
Cytosine2020/authernet
/src/athernet/physical.rs
UTF-8
6,832
2.609375
3
[]
no_license
use std::collections::VecDeque; use crate::athernet::mac::MacFrame; const SYMBOL_LEN: usize = 5; const BARKER: [bool; 7] = [true, true, true, false, false, true, false]; pub const PHY_PAYLOAD_MAX: usize = 256; pub type PhyPayload = [u8; PHY_PAYLOAD_MAX]; lazy_static!( static ref CARRIER: [i16; SYMBOL_LEN] = { ...
true
20dad656b0d5a538d3851aff4bbde4c70c8cc87f
Rust
rramsden/uoinspect
/src/utils.rs
UTF-8
558
3.0625
3
[]
no_license
use std::{ path::{Path} }; pub fn print_json<T>(entries: Vec<T>, s: &Fn(&T) -> std::result::Result<std::string::String, serde_json::error::Error>) { print!("["); for i in 0..entries.len() { let entry = &entries[i]; let json = s(&entry).unwrap(); print!("{}", json); if i != ...
true
0b04b57e50ded57fd3ca0a51db20378c3fe611cc
Rust
slpcat/actix
/src/mailbox.rs
UTF-8
2,553
2.5625
3
[ "MIT", "Apache-2.0" ]
permissive
use futures::{Async, Stream}; use std::fmt; use actor::{Actor, AsyncContext}; use address::EnvelopeProxy; use address::{channel, Addr, AddressReceiver, AddressSenderProducer}; /// Maximum number of consecutive polls in a loop const MAX_SYNC_POLLS: u32 = 256; /// Default address channel capacity pub const DEFAULT_CAP...
true
a67e05a4ff7d3fcdc974aff22c22798b0beab9a1
Rust
evopen/maligog
/src/sampler.rs
UTF-8
1,881
2.6875
3
[]
no_license
use std::ffi::CString; use std::sync::Arc; use crate::device::Device; use ash::vk; use ash::vk::Handle; pub(crate) struct SamplerRef { pub(crate) handle: vk::Sampler, device: Device, name: Option<String>, } #[derive(Clone)] pub struct Sampler { pub(crate) inner: Arc<SamplerRef>, } impl Sampler { ...
true
8bba01b4ef351208c3041c2e6988140ca1a52429
Rust
CoffeJunkStudio/daab
/src/diagnostics/mod.rs
UTF-8
7,813
3.109375
3
[ "Apache-2.0" ]
permissive
//! //! # Extensive debugging and analysis module. //! //! **Notice: This module is only available if the `diagnostics` feature has been activated**. //! //! This module contains the types used in debugging the [`ArtifactCache`]. //! The most important one is [`Doctor`] which conducts a diagnosis on a //! `ArtifactCac...
true
1d37091959e72aedd4bcccbada801a27f3e8902a
Rust
haptics-nri/nri
/crates/utils/src/iter.rs
UTF-8
599
3.125
3
[]
no_license
use std::{mem, ops}; use std::ops::Add; /// StepBy iterator pub struct StepBy<T> { range: ops::Range<T>, step: T } impl<T> Iterator for StepBy<T> where T: PartialOrd, for<'a> &'a T: Add<Output=T> { type Item = T; fn next(&mut self) -> Option<T> { if self.range.start < self.range.end { ...
true
53a8e9b5dd7f279d4531975e2574c56ce1f7eb61
Rust
MattRoelle/rustgame
/src/game/player.rs
UTF-8
579
2.8125
3
[ "MIT" ]
permissive
use crate::engine::{sprite::Sprite, game_context::GameObject}; use super::assets::Assets; #[derive(Debug, Copy, Clone)] pub struct PlayerProps { } pub struct Player<'a> { sprite: Sprite<'a> } impl<'a> Player<'a> { pub fn new(props: PlayerProps, assets: &'a Assets<'a>) -> Self { Self { sp...
true
36fb461d0833d8c91148d8518427d1a101c3141a
Rust
pstetz/misc
/leetcode/1266.rs
UTF-8
360
2.96875
3
[]
no_license
use std::cmp; impl Solution { pub fn min_time_to_visit_all_points(points: Vec<Vec<i32>>) -> i32 { let mut time: i32 = 0; for i in 1..points.len() { let x = (points[i-1][0] - points[i][0]).abs(); let y = (points[i-1][1] - points[i][1]).abs(); time = time + cmp::ma...
true
e2174d9d5d8dba3a25e5d412f46e0e5b3be3de6e
Rust
Swatinem/druid
/druid/src/widget/value_textbox.rs
UTF-8
16,380
2.84375
3
[ "Apache-2.0" ]
permissive
// Copyright 2021 The Druid Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed...
true
65d28bf537d43cf9f9f8cfcf7b461fc71d24fd4f
Rust
hephex/api
/examples/httpbin.rs
UTF-8
1,283
2.65625
3
[ "MIT" ]
permissive
#![cfg(feature = "use-hyper")] extern crate api; extern crate hyper; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; use std::collections::BTreeMap; use std::io; use api::Client; struct Delay { delay: u8 } #[derive(Debug, Deserialize)] struct Info { origin: String, ...
true
2f2651eb57f7af92501e1796c5fbbc35f6062f5e
Rust
Harzu/wasm-rsa
/src/lib/private_keys.rs
UTF-8
14,975
2.75
3
[ "MIT" ]
permissive
use super::*; use rsa::pkcs8::FromPrivateKey; use sha2::{ Digest }; use num_traits::{ Num }; #[wasm_bindgen] #[derive(Debug, Clone)] pub struct RSAPrivateKeyPair { n: String, d: String, e: String, private_instance: Option<RsaPrivateKey> } #[wasm_bindgen] impl RSAPrivateKeyPair { #[wasm_bindgen(con...
true
c174399487f7884c888dcaae96b947a8b2c75d0a
Rust
vangroan/vnote-cli
/src/main.rs
UTF-8
5,088
2.5625
3
[ "MIT" ]
permissive
extern crate chrono; #[macro_use] extern crate clap; extern crate colored; extern crate dirs; extern crate levenshtein; extern crate regex; extern crate serde; extern crate serde_yaml; #[macro_use] extern crate error_chain; mod book; mod config; mod errors; mod util; use book::{ Note, NotebookFileStorage, Noteboo...
true
bc906493238622ba0b5a079aa6875bd39fa959d7
Rust
Bixkog/dotastats
/src/analyzers/analyzers_utils.rs
UTF-8
730
2.75
3
[ "MIT" ]
permissive
use crate::heroes_info::Hero; use crate::heroes_info::HeroesInfo; use crate::match_stats::Match; use crate::match_stats::PlayerName; #[macro_export] macro_rules! skip_fail { ($res:expr) => { match $res { Ok(val) => val, Err(_) => continue, } }; } /// Finds heroes played...
true
2d1c2c6d3807a1b9b56673652c014813777c3e9e
Rust
yuulive/oy
/tests/root.rs
UTF-8
4,190
3.28125
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
#![feature(str_split_once)] use core::fmt::Debug; use oy::{Interactive, InteractiveError, InteractiveRoot, Methods}; #[derive(Interactive, Debug, Default)] struct TestStruct { a: bool, } #[Methods] impl TestStruct { fn try_ping(&self) -> core::result::Result<String, ()> { Ok("pong".into()) } ...
true
52617432337ed81d99906da16611711559ecf0a8
Rust
Azegor/wasm-interpreter
/src/parser/table_section.rs
UTF-8
702
2.828125
3
[]
no_license
use parser::{Parser, ResizableLimits, Type}; #[derive(Debug)] pub struct TableEntry { pub typ: Type, pub limits: ResizableLimits, } impl Parser { fn read_table_type(&mut self) -> TableEntry { let typ = Type::elem_type(self.read_varuint7()); let limits = self.read_resizable_limits(); ...
true
72b45eaa86860b46a2d55a170b36fa9932c36efd
Rust
CryZe/cargo-go
/src/open.rs
UTF-8
1,384
2.765625
3
[ "MIT", "Apache-2.0" ]
permissive
// The code is borrowed from and should be kept in sync with: // https://github.com/rust-lang/cargo/blob/master/src/cargo/ops/cargo_doc.rs use std::process::Command; pub fn open(path: &str) -> Result<(), String> { match run(path) { Ok(_) => Ok(()), Err(_) => raise!("cannot go to {:?}", path), ...
true
e20c9d950885ceeb08a5a52c28800097a021ac72
Rust
simongibbons/advent_of_code2020
/src/day25.rs
UTF-8
1,652
3.25
3
[]
no_license
use itertools::Itertools; pub struct PublicKeys { card: u64, door: u64 } #[aoc_generator(day25)] pub fn parse_input(input: &str) -> PublicKeys { let split = input.split("\n") .map(|x| x.parse().unwrap()) .collect_vec(); PublicKeys { card: split[0], door: split[1] }...
true
3787e70dd0641aef18e80cf351eeb3d6e6809581
Rust
bilsen/rust-website
/src/db/user.rs
UTF-8
672
2.65625
3
[]
no_license
use crate::schema::users; #[derive(Queryable, Serialize)] pub struct User { // User id pub id: i32, // Username pub username: String, // Email adress pub email_adress: String, // Hashed password pub password_hash: String, // User rating pub rating: i32, // User preferences ...
true
999137dbf163056be2061084a41be709cde5ed49
Rust
OpenTrustGroup/fuchsia
/src/connectivity/bluetooth/tools/bt-snoop/src/packet_logs.rs
UTF-8
5,453
2.5625
3
[ "BSD-3-Clause" ]
permissive
// Copyright 2018 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { fidl_fuchsia_bluetooth_snoop::SnoopPacket, fuchsia_inspect::{self as inspect, Property}, itertools::Itertools, std::{ collect...
true
2ca1e6b3bbb5d924cf8bda9909e548b88051937f
Rust
starcoinorg/starcoin
/vm/types/src/token/token_value.rs
UTF-8
3,773
3.109375
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 use anyhow::{ensure, Result}; pub trait TokenUnit: Clone + Copy { fn symbol(&self) -> &'static str; fn symbol_lowercase(&self) -> &'static str; fn scale(&self) -> u32; fn scaling_factor(&self) -> u128 { 1...
true
781fc4b38a475b67d469350a0dbc8d6423b1f298
Rust
Tomarchelone/mp3
/src/lib.rs
UTF-8
1,333
2.65625
3
[ "CC0-1.0", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
#![forbid(unsafe_code)] #[macro_use] extern crate smallvec; pub mod frame; pub mod header; pub mod tables; use std::io; use std::str; pub static ID3V1_LEN: usize = 128; #[derive(Debug)] pub enum Mp3Error { // Unable to trim ID3 tag ID3Error, // Incorrect Header HeaderError, IoError(io::Error), ...
true
99878d1de461573a3fc9a5f660b9b9c199aa8d36
Rust
stm32-rs/stm32l0xx-hal
/src/timer.rs
UTF-8
12,620
2.75
3
[ "BSD-3-Clause", "0BSD", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Timers use crate::hal::timer::{CountDown, Periodic}; use crate::pac::{tim2, tim21, tim22, tim6, TIM2, TIM21, TIM22, TIM3, TIM6}; use crate::rcc::{Clocks, Enable, Rcc, Reset}; use cast::{u16, u32}; use cortex_m::peripheral::syst::SystClkSource; use cortex_m::peripheral::SYST; use embedded_time::rate::Hertz; use void...
true
28604b98ec4b8fded7604b77a964425707ac0ec1
Rust
95th/ben
/examples/entry.rs
UTF-8
422
2.578125
3
[]
no_license
use ben::decode::List; use ben::{Encoder, Parser}; fn main() { let mut v = vec![]; let mut list = v.add_list(); list.add(100); list.add("hello"); let mut dict = list.add_dict(); dict.add("a", &b"b"[..]); dict.add("x", "y"); dict.finish(); list.add(1); list.finish(); let m...
true
dd346aac63f0a486307768fabb6545a6358c9e1b
Rust
minus3theta/contest
/atcoder/arc/068/e.rs
UTF-8
2,502
3.015625
3
[]
no_license
#[allow(unused_imports)] use std::io; #[allow(unused_imports)] use std::cmp; #[allow(dead_code)] fn getline() -> Vec<String> { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok().unwrap(); s.split(' ').map(|x| x.trim().to_string()).collect::<Vec<String>>() } #[allow(dead_code)] fn get<T: st...
true
6442c248b2eca084b3de00447425ecda29eb622e
Rust
jtorrez/learning-rust
/slices/src/main.rs
UTF-8
801
4.09375
4
[]
no_license
fn main() { // create the variable my_string which is of String type let my_string = String::from("hello world"); // API of first_word allows passing of all string slices let word = first_word(&my_string[..]); // variable of type &str, a string slice let my_string_literal = "hello world"; ...
true
e9e625b3f892e1cb2f2d1f3c608b44c6135cca8b
Rust
ShirleyChung/rust
/hello2.rs
UTF-8
321
3.0625
3
[]
no_license
mod hello2 { fn is_true()->i32{ 100 } pub fn select()->fn()->i32{ is_true } pub fn hello(x :i32)->i32 { println!("{:} hello!", x); 32 } } fn main() { let a:i32 = 10; let b:i32 = a; let c: &i32 = &b; println!("let c = {:}", c); hello2::hello(4); println!("what is select? {}", hello2::select()()); }...
true
22489a3d97d97d873f469e2da270f5be2e8b2312
Rust
jamhall/pixie
/src/common/error.rs
UTF-8
1,163
3.171875
3
[]
no_license
use std::error::Error; use std::fmt; #[derive(Debug)] pub enum ApplicationError { Configuration(String), InvalidCommand(String), Transport(String), Display, IoError(std::io::Error), } impl Error for ApplicationError {} impl fmt::Display for ApplicationError { fn fmt(&self, formatter: &mut fmt...
true
77465dfbe3a33a8c270d9cf5f48ac1955fccc72b
Rust
Origen-SDK/o2
/rust/origen/src/core/model/registers/bit_collection.rs
UTF-8
30,019
2.6875
3
[ "MIT" ]
permissive
use super::bit::Overlay as BitOverlay; use super::{Bit, Field, Register}; use crate::core::model::registers::AccessType; use crate::generator::PAT; use crate::Transaction; use crate::{Dut, Result, TEST}; use num_bigint::BigUint; use regex::Regex; use std::sync::MutexGuard; const DONT_CARE_CHAR: &str = "X"; const OVERL...
true
5ae5f963ef0218091f1358e5750ae37ef3990779
Rust
18616378431/myCode
/rust/test6-5/src/main.rs
UTF-8
300
3.21875
3
[]
no_license
//函数参数模式匹配 //ref修饰的函数参数为模式匹配的不可变引用,ref mut为可变引用 #[derive(Debug)] struct S { i : i32, } fn f(ref s : S) { println!("{:p}", s); } fn main() { let s = S {i : 42}; f(s); // println!("{:?}", s);//s所有权发生转移 }
true
14fa29cd63e627345ca28eb38442303f139b0195
Rust
GoXLR-on-Linux/goxlr-utility
/profile/src/components/preset_writer.rs
UTF-8
1,268
3.015625
3
[ "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
use anyhow::Result; use quick_xml::events::{BytesEnd, BytesStart, Event}; use quick_xml::Writer; use std::collections::HashMap; use std::io::Write; pub struct PresetWriter { name: String, } impl PresetWriter { pub fn new(name: String) -> Self { Self { name } } pub fn write_initial<W: Write>(&...
true
651113227413cf12655f5f69779ce7d452ac9810
Rust
jsnns/eyelang
/src/types/token.rs
UTF-8
2,124
3.453125
3
[]
no_license
use crate::types::binary_operator::BinaryOperator; #[derive(Clone, PartialEq)] pub enum Token { Symbol(String), Type(String), Str(String), Number(i32), Bool(bool), Operator(BinaryOperator), LParen, RParen, LBrace, RBrace, Comma, Return, Print, If, Else, D...
true
2fd353bd1e3bd3091aa5f7605fc1a6c2815a9a2d
Rust
mdalbello/seqkit
/src/fasta_check.rs
UTF-8
1,641
3.1875
3
[ "MIT" ]
permissive
use crate::common::{parse_args, FileReader}; use std::str; use std::collections::VecDeque; const USAGE: &str = " Usage: fasta check <fasta/fastq> Description: Checks that the input FASTA or FASTQ file is correctly formatted, and reports the line number if any malformatted lines are found. "; struct ReaderWithMemo...
true
6eb09b7bdf9c77d0e525bfb35a7c84652f3d3167
Rust
hsnavarro/retrogame-rust
/src/physics/physics_update.rs
UTF-8
5,871
2.90625
3
[ "MIT" ]
permissive
use crate::algebra::Vec2f; use crate::algebra::{closest_to_point_in_rect_border, is_point_inside_rect}; use crate::entities; use crate::game_settings; use std::vec::Vec; fn detect_circle_rect_collision(circle_entity: &entities::CircleEntity, rect_entity: &entities::RectEntity) -> Opti...
true
5fa258b221f47a62297d6c7006c9a0c371651664
Rust
cscheid/loom
/src/hitable.rs
UTF-8
656
2.9375
3
[]
no_license
use vector::Vec3; use ray::Ray; use material::Material; use aabb::AABB; pub struct HitRecord<'a> { pub t: f64, pub p: Vec3, pub normal: Vec3, pub material: &'a Material } impl<'a> HitRecord<'a> { pub fn hit(t: f64, p: Vec3, normal: Vec3, material: &'a Material) -> HitRecord<'a> { HitRecord...
true
4523d8a5d73d16a66c557ea0fe632e2f73270850
Rust
2teez/arraylist
/src/arl/tests.rs
UTF-8
3,202
3.34375
3
[ "MIT" ]
permissive
use super::*; #[test] fn test_arraylist_new() { let alist: ArrayList<u8> = ArrayList::new(); alist.push(2); alist.push(4); alist.push(6); assert_eq!( alist, ArrayList { vec: Rc::new(RefCell::new(vec![2, 4, 6])), count: alist.count.clone() } ); } ...
true
934bb971c8d9fb64497b31dc0a034532b58989fd
Rust
jpeterson1823/AdventOfCode
/2022/rust/day2/src/main.rs
UTF-8
2,498
3.296875
3
[]
no_license
use std::fs; static ROUND_WIN: i32 = 6i32; static ROUND_DRAW: i32 = 3i32; static ROUND_LOSS: i32 = 0i32; static ROCK: i32 = 1i32; static PAPER: i32 = 2i32; static SCISSORS: i32 = 3i32; fn main() { // get playbook from input let playbook = parse_input(); // play each round let mut p1_total = 0; for...
true
af84e6c8b68154078d6fcbea23f98486c0f422ea
Rust
janispritzkau/rust-base-encode
/examples/base36.rs
UTF-8
343
2.8125
3
[]
no_license
extern crate base_encode; const CHARS: &[u8] = b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; fn main() { let buf: Vec<u8> = (0..16).map(|_| rand::random()).collect(); let encoded = base_encode::to_string(&buf, 36, CHARS).unwrap(); assert_eq!(buf, base_encode::from_str(&encoded, 36, CHARS).unwrap()); prin...
true