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
d68377cd982de22258bac080ee43d28a9c70fc13
Rust
BuBuMan/RustyGear
/SampleApp/src/graphics.rs
UTF-8
13,774
2.625
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::fs; use wgpu::util::DeviceExt; use crate::texture::Texture; pub struct Graphics { pub surface: wgpu::Surface, pub device: wgpu::Device, pub queue: wgpu::Queue, pub swap_chain_descriptor: wgpu::SwapChainDescriptor, pub swap_chain: wgpu::SwapChain, pub size...
true
a2efa77d8fbba8286e2e0faf42fe56e85c7ec33d
Rust
jeffujioka/rust_wizardry
/prjs/data_types/src/vec_traits.rs
UTF-8
209
3.09375
3
[]
no_license
pub trait Summable<T> { fn sum(&self) -> T; } impl Summable<i32> for Vec<i32> { fn sum(&self) -> i32 { let mut res:i32 = 0; for x in self { res += *x; } return res; } }
true
bc22638b78acb6464c37ce407ab27dfb178f52b5
Rust
PayasR/rust_road_router
/engine/src/io.rs
UTF-8
6,874
3.78125
4
[ "BSD-3-Clause" ]
permissive
//! Utilities for reading and writing data structures from and to disk. //! //! This module contains a few traits and blanket implementations //! for (de)serializing and writing/reading data to/from the disc. //! To use it you should import the `Load` and `Store` traits and use the //! `load_from` and `write_to` method...
true
6a9b887ddca57fd2ee2bd7a614ead4d31a751012
Rust
conf8o/yokoidou
/src/main.rs
UTF-8
771
2.828125
3
[]
no_license
use enigo::*; use rand::prelude::*; use rand::distributions::Standard; use std::{thread, time}; fn hold(enigo: &mut Enigo, key: char, mut duration: f32, natural: bool) { let v: f32 = 0.3 * if natural { StdRng::from_entropy().sample(Standard) } else { 0.0 }; duration += v; let t = time::Instant::now(); ...
true
5490cdba322ec4f24798577938132c3cf44c1702
Rust
Leorii/SteamHelper-rs
/crates/steam-totp/src/error.rs
UTF-8
1,057
2.890625
3
[]
no_license
use hmac::crypto_mac::InvalidKeyLength; use std::{ error, fmt, time::SystemTimeError, }; /// The error type for TOTP operations that wraps underlying errors. #[derive(Debug)] pub enum TotpError { Time(SystemTimeError), Hmac(InvalidKeyLength), } impl fmt::Display for TotpError { fn fmt(&self, f...
true
dae11c66d8821cac179909bb0d7367a6ee4845af
Rust
whoiscc/cchsim
/src/main.rs
UTF-8
4,460
3.171875
3
[]
no_license
use std::collections::HashMap; struct Cache { data: Vec<HashMap<u64, usize>>, set_capacity: usize, current: usize, } impl Cache { fn new(set_count: usize, set_capacity: usize) -> Cache { let mut data = Vec::<HashMap<u64, usize>>::new(); data.resize(set_count, HashMap::<u64, usize>::new...
true
7d2817a5481829af9937306e2dfbc282b00449cd
Rust
raedion/rust-aes-file
/src/args.rs
UTF-8
3,240
3.296875
3
[]
no_license
use crate::read::input_read; use crate::encryptor; /// 実行時引数で処理を行う<br> /// ビルドされた実行ファイルを第一引数<br> /// 入力元となるファイルパスを第二引数<br> /// 出力先となるファイルパスを第三引数として処理する pub fn args_main() { let args_result = args_collect(); // 実行の成否、および読み込んだ文字列のベクタをもつタプル生成 if !args_result.0 { // 実行時引数の読み込みがうまくいかなかったと...
true
20c3b37a873a5eabd6d71b229b2cde92f12ae03a
Rust
carlosb1/projects-rust
/ideas/src/main.rs
UTF-8
2,331
2.828125
3
[]
no_license
#[macro_use] extern crate serde_derive; extern crate tokio; extern crate tokio_codec; use tokio::codec::Decoder; use tokio_codec::BytesCodec; use tokio::prelude::*; use tokio::net::TcpListener; extern crate serde; extern crate serde_json; pub struct MsgManager; impl MsgManager { fn run(&self, message: Messag...
true
9ecdf217f09b2c144ebde62bc2c7494b3ccf2842
Rust
isabella232/paired
/src/bls12_381/fq12.rs
UTF-8
9,562
2.90625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use super::fq::FROBENIUS_COEFF_FQ12_C1; use super::fq::{Fq, FqRepr}; use super::fq2::Fq2; use super::fq6::Fq6; use fff::{Field, PrimeField, PrimeFieldRepr}; use rand_core::RngCore; use std::fmt; /// An element of Fq12, represented by c0 + c1 * w. #[derive(Copy, Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Des...
true
13f91a6b13422f841cafd1659c5220400603fbef
Rust
jeamland/aoc2020
/day03/src/main.rs
UTF-8
1,671
3.234375
3
[]
no_license
use std::fs::File; use std::io::prelude::*; use std::io::BufReader; use clap::{App, Arg}; const SLOPES: &[(usize, usize)] = &[(1, 1), (3, 1), (5, 1), (7, 1), (1, 2)]; struct TreeField(Vec<Vec<bool>>); impl TreeField { fn new(data: Vec<Vec<bool>>) -> Self { Self(data) } fn count_trees(&self, rig...
true
249a99b097d56433c26980bb969ff63097c1ac45
Rust
lemonteaa/rusty-raytracer
/src/core.rs
UTF-8
1,995
2.6875
3
[]
no_license
use na::{Vector3, dot}; use rand::{Rng, thread_rng}; use scene::light::{Lighting, LightingType}; use scene::{Scene, Background}; use model::{SceneObject, Ray}; use model::intersect::{Intersection, Intersectable}; use util::{Color, get_ndc}; pub fn trace(ray : &Ray, scene : &SceneObject, lightings : &Vec<Lighting>) -> ...
true
521f3e6a9ff89fac1be84cb7b466c567fa3279d4
Rust
chiro/bme280-rs
/src/lib.rs
UTF-8
847
2.75
3
[ "MIT" ]
permissive
//! # bme280-rs //! //! This crate provides you a way to access bme280 via Linux I2C interface. //! //! # Examples //! ``` //! let config: Config = Config { //! mode: Mode::Force, //! oversampling_temperature: Oversampling::X1, //! oversampling_pressure: Oversampling::X1, //! oversampling_humidity: Over...
true
b4dc72233d94318fa686bd47a4996d8b556c81a7
Rust
dhardy/druid
/druid/src/widget/clip_box.rs
UTF-8
9,954
2.9375
3
[ "Apache-2.0" ]
permissive
// Copyright 2020 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
d29f203fa8ec1fc304aef940933cb9126c0cb756
Rust
fdietze/unbesiegbar
/src/cpu_usage.rs
UTF-8
2,226
3.15625
3
[]
no_license
use std::path::Path; use std::fs::File; use std::io::{BufRead,BufReader}; pub struct CpuUsage { prev: Vec<CpuState> } #[derive(Debug)] struct CpuState{total:u64, idle:u64} pub type Usage = Vec<f32>; impl CpuUsage { pub fn new() -> CpuUsage { CpuUsage { prev: CpuTimes::get_states(), ...
true
eae9a53c737bcee280c103ec830cfbd0064ff2e4
Rust
jmmk/rust-cave-story
/src/input.rs
UTF-8
1,389
3
3
[]
no_license
use collections::hashmap::HashMap; use sdl2::keycode::KeyCode; pub struct Input { held_keys: HashMap<KeyCode, bool>, pressed_keys: HashMap<KeyCode, bool>, released_keys: HashMap<KeyCode, bool> } impl Input { pub fn new() -> Input { Input { held_keys: HashMap::<KeyCode, bool>::new()...
true
0cfdbf5942990f33a5a78c94deb1b693ae6c631a
Rust
forchain/rust-netproxy
/packet/src/udp.rs
UTF-8
549
2.953125
3
[]
no_license
/// https://en.wikipedia.org/wiki/User_Datagram_Protocol#Packet_structure #[derive(Debug, PartialEq, Eq)] pub struct Packet<'a> { src_port: u16, dst_port: u16, length : u16, checksum: u16, data : &'a [u8] } impl <'a>Packet<'a> { #[allow(unused_variables)] pub fn from_bytes(payload: &[...
true
472f7063fd4cbc9cbe3a82cff74c123e0880bdfa
Rust
COLDTURNIP/raphanus_leetcode
/rust/src/p75.rs
UTF-8
2,527
3.734375
4
[]
no_license
/* Problem 75. Sort Colors ======================= Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue. Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blu...
true
c01b971d10f623e687412ffd30b7ec1f0aece3f1
Rust
EbTech/rust-algorithms
/src/math/fft.rs
UTF-8
7,043
3.21875
3
[ "MIT" ]
permissive
//! The Fast Fourier Transform (FFT) and Number Theoretic Transform (NTT) use super::num::{CommonField, Complex, PI}; use std::ops::{Add, Div, Mul, Neg, Sub}; // We can delete this struct once f64::reverse_bits() stabilizes. struct BitRevIterator { a: usize, n: usize, } impl BitRevIterator { fn new(n: usiz...
true
ad5d04e4185107ca7e72d575c8d985410677f892
Rust
Munksgaard/bencode
/tests/tests.rs
UTF-8
987
2.953125
3
[]
no_license
extern crate bencode; use std::collections::HashMap; use bencode::Bencoded::*; #[test] fn parse_big_dict() { let mut m = HashMap::new(); m.insert(b"bar".to_vec(), Bytestring(b"spam".to_vec())); m.insert(b"foo".to_vec(), Integer(42)); assert_eq!(bencode::parse(b"d3:bar4:spam3:fooi42ee"), ...
true
c2ec4d802a3f81c067e38e0d148cc32450c271f0
Rust
isgasho/posish
/src/imp/libc/conv.rs
UTF-8
2,730
2.5625
3
[ "Apache-2.0", "MIT", "LLVM-exception" ]
permissive
#![allow(dead_code)] use super::offset::libc_off_t; use crate::{ io, io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}, }; use io_lifetimes::{BorrowedFd, OwnedFd}; use libc::{c_char, c_int, c_long, ssize_t}; use std::ffi::CStr; #[inline] pub(crate) fn c_str(c: &CStr) -> *const c_char { c.as_ptr().cast::<c_char>(...
true
a4f6a2069d3c2f79866f6ef82a9039409880a681
Rust
programble/patience
/src/game/klondike/tests.rs
UTF-8
17,334
2.84375
3
[ "ISC" ]
permissive
mod is_valid { use card::{Face, Pile}; use game::Game; use game::klondike::{Klondike, Draw, Play, Foundation, Tableau}; #[test] fn valid_draw_full_stock() { let game = Klondike::new(Draw::One); assert!(game.is_valid(&Play::Draw)); } #[test] fn invalid_draw_empty_stock()...
true
24075b3f12d65ec146c5b84961ba5ad77244e7f4
Rust
samanpa/notes
/sio/src/error.rs
UTF-8
356
2.671875
3
[]
no_license
use std; pub struct Error { } pub type Result<T> = std::result::Result<T, std::io::Error>; impl Error { pub fn new(msg : std::string::String) -> std::io::Error { std::io::Error::new(std::io::ErrorKind::Other, msg) } pub fn from_str(msg : &str) -> std::io::Error { std::io::Error::new(std:...
true
17e4ab6290435aa229ea1a117d9ae67ab6461d04
Rust
jankes/AdventOfCode
/2015/7/rust/src/main.rs
UTF-8
16,829
3.015625
3
[]
no_license
use std::collections::HashMap; use std::fs::OpenOptions; use std::io::Read; use std::path::Path; use std::str; use std::str::FromStr; fn main() { let input = read_input("C:\\Users\\sjank\\Documents\\Projects\\AdventOfCode\\2015\\7\\input2.txt"); let mut sim = Simulation::new(); sim.run(&input); print...
true
7d4cb3d38355ba4137955227da8fc25517821915
Rust
austinjones/recode
/src/measures/measure.rs
UTF-8
1,573
2.75
3
[]
no_license
use audio::audio_frame::*; use video::video_frame::*; // pub trait AudioFrameProcessor { // fn process_audio(&mut self, af: &AudioFrame); // } // pub trait VideoFrameProcessor { // fn process_video(&mut self, vf: &VideoFrame); // } // chunking audio volume // window buffer // mean(edge) // mean(avg) // e...
true
66a89fecdfa90bba12aef6395f1f28f08270f7cc
Rust
RichVRed/veye-checker
/src/api.rs
UTF-8
10,691
2.6875
3
[ "MIT" ]
permissive
use std::io::{self, Read, Error, ErrorKind}; use std::borrow::Cow; use hyper; use hyper::{client, Client, Url }; use hyper::net::HttpsConnector; use hyper_native_tls::NativeTlsClient; use std::time::Duration; use serde_json; use product; use configs::{Configs, ApiConfigs, ProxyConfigs}; const HOST_URL: &'static str ...
true
9164fa76081de61468903d200b40777b42bbfce7
Rust
meesvermeulen/druid
/druid/src/tests/mod.rs
UTF-8
6,152
2.5625
3
[ "Apache-2.0" ]
permissive
// Copyright 2020 The xi-editor 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 ag...
true
7c07c3fa855aedd9738fb53271cb875c9ae7e0f2
Rust
andysalerno/search_engine_jeopardy
/src/text_sanitizer.rs
UTF-8
2,780
3.140625
3
[]
no_license
use lazy_static::*; use std::collections::HashSet; lazy_static! { static ref STOP_WORDS: HashSet<&'static str> = { let mut stop_words = HashSet::new(); for word in _STOP_WORDS.iter() { stop_words.insert(*word); } stop_words }; } pub(crate) fn remove_stopwords(inpu...
true
d5124daeeddd50b5af094a31b3f9b206cb860d42
Rust
raunakab/myOS
/src/qemu.rs
UTF-8
356
2.765625
3
[]
no_license
#![allow(unused)] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(u32)] pub enum QemuExitCode { Success = 0x10u32, Failed = 0x11u32, } pub fn exit_qemu(exit_code: QemuExitCode) -> () { use x86_64::instructions::port::Port; unsafe { let mut port: Port::<u32> = Port::new(0xf4u16); po...
true
8c18eab7f33bb2ae2fcc9b80175f30bfa196b352
Rust
thenixan/aoc-2019
/src/task_7.rs
UTF-8
3,555
2.875
3
[]
no_license
use crate::opcodes::Programm; use std::fs::File; use std::io::{BufReader, Read}; struct ProgrammSet { p: Vec<Programm>, } impl ProgrammSet { fn new(count: usize, p: &Programm) -> Self { ProgrammSet { p: std::iter::repeat(p.clone()).take(count).collect(), } } fn run(&mut se...
true
52f1d710ab43bd9bf6b8d06408ab6568213775f3
Rust
thequux/qaraoke
/mpg123/src/lib.rs
UTF-8
5,743
2.515625
3
[]
no_license
extern crate mpg123_sys; use std::ptr; pub use mpg123_sys::Mpg123Error as Error; pub use mpg123_sys::{Enc, ChannelCount}; use std::marker::PhantomData; use std::sync::{Once,ONCE_INIT}; static LIBRARY_START: Once = ONCE_INIT; fn init_lib() { LIBRARY_START.call_once(|| { unsafe { mpg123_sys::mpg123_init(...
true
e6e59c2b5ec505872b0bf4bba9e76cf43b98c5a0
Rust
Dentosal/rust_os
/libs/d7net/src/builder/ipv4_tcp.rs
UTF-8
2,169
2.53125
3
[ "MIT" ]
permissive
use alloc::vec::Vec; use crate::checksum::inet_checksum; use crate::ipv4; use crate::tcp; use crate::{IpProtocol, Ipv4Addr}; #[derive(Debug)] pub struct Builder { pub ipv4_header: ipv4::Header, pub tcp_header: tcp::SegmentHeader, pub payload: Vec<u8>, } impl Builder { /// TODO: fragmentation support ...
true
bd42f13ffdf5cf1e947c18a6390b0f4472108f99
Rust
ultrasaurus/rust-uri-comparison
/examples/hyper-uri.rs
UTF-8
442
2.78125
3
[]
no_license
use hyper::http::Uri; fn main() { let uri = "/foo/bar?baz".parse::<Uri>().unwrap(); assert_eq!(uri.path(), "/foo/bar"); assert_eq!(uri.query(), Some("baz")); assert_eq!(uri.host(), None); let uri = "https://www.rust-lang.org/install.html".parse::<Uri>().unwrap(); assert_eq!(uri.scheme_part().map(|s| s.as_...
true
141958d101dc336c4037dc8c0e6193761b9ca06b
Rust
hawkw/tokio-trace-prototype
/tokio-trace-subscriber/src/observe.rs
UTF-8
11,110
3.25
3
[]
no_license
use { filter::{self, Filter}, registry::SpanRef, }; use tokio_trace::{Event, Metadata}; /// The notification processing portion of the [`Subscriber`] trait. /// /// Implementations of this trait describe the logic needed to process envent /// and span notifications, but don't implement span registration. pub ...
true
90df0453887ab725b2cd8eb3882487f4ee80fe3b
Rust
jkallio/advent-of-code-2020
/day16/src/main.rs
UTF-8
6,649
3.375
3
[]
no_license
use regex::Regex; use std::collections::HashMap; use std::fs::File; use std::io::{BufRead, BufReader, Error, ErrorKind}; type RangeMap = HashMap<String, ValueRange>; type TicketList = Vec<Vec<i32>>; #[derive(Debug)] struct ValueRange { lower_min: i32, lower_max: i32, upper_min: i32, upper_max: i32, } ...
true
16d9e75ec2e12019de15adbee0377526e6584923
Rust
scorpdx/ck3json
/src/ck3json/ck3parser.rs
UTF-8
2,377
2.75
3
[]
no_license
extern crate pest; use pest::error::Error; use pest::Parser; #[derive(Parser)] #[grammar = "grammars/ck3txt.pest"] pub struct CK3Parser; use crate::json::JSONValue; pub fn parse(ck3txt: &str) -> Result<JSONValue, Error<Rule>> { use pest::iterators::Pair; fn parse_pair(pair: Pair<Rule>) -> (&str, JSONValue) ...
true
b4e41d0dac07603c450eed5b5c87cba63dc2729c
Rust
Frizi/surge
/surgemachine/src/oscillator.rs
UTF-8
1,078
3
3
[]
no_license
use waveform::*; pub struct Oscillator<W:Waveform=Dynamic> { phase: f32, frequency: f32, wave: W } impl<W: Waveform> Default for Oscillator<W> where W: Default { fn default () -> Self { Self { phase: 0.0, frequency: 0.0, wave: W::default() } } } ...
true
ae65f38e40dd2ba45959a0efd423a40a94e2a539
Rust
infinyon/fluvio
/crates/fluvio-channel-cli/tests/issue_2168_regression.rs
UTF-8
3,708
3.125
3
[ "Apache-2.0" ]
permissive
// In this test which resolves [issue_2168](https://github.com/infinyon/fluvio/issues/2168), // we want to verify that attempting to create a version that cannot be resolved will // return the correct error message ("Unable to resolve version") AND will also not save the // invalid version to the channel config file (~...
true
ca0d29610795025727f3eb530f9fd9c2a6ddb5af
Rust
Ben-PH/seed-routing
/src/router/path.rs
UTF-8
1,066
3.375
3
[ "MIT" ]
permissive
use std::str::FromStr; #[allow(clippy::module_name_repetitions)] pub trait AsPath { fn as_path(self) -> String; } impl<T: ToString> AsPath for T { fn as_path(self) -> String { format!("/{}", self.to_string()) } } #[allow(clippy::module_name_repetitions)] pub trait ParsePath: AsPath + Sized { /...
true
083c877c10876d215230e33a2b0c3c8bd4dd57ac
Rust
johnterickson/rustdb
/src/pager.rs
UTF-8
5,779
3.078125
3
[]
no_license
use crate::*; pub struct Page { pub node: Node, pub parent: Option<PageNumber>, } impl Page { pub const HEADER_SIZE: usize = 6; pub fn create_leaf(parent: Option<PageNumber>) -> Page { Page { node: Node::Leaf(LeafNode::create_empty()), parent, } } fn s...
true
21b58bf4d22d4924292f21f59773dddd604c50af
Rust
anthonycouture/calculette-rust
/src/operation.rs
UTF-8
7,250
3.515625
4
[]
no_license
#[derive(Debug)] enum Operateur { Plus, Moins, Division, Multiplication, } impl Operateur { fn run(&self, x: f32, y: f32) -> Result<f32, String> { match self { Self::Plus => Ok(x + y), Self::Moins => Ok(x - y), Self::Division => match y { ...
true
5516ce1e486120115ef74545ac70083b7583ecf0
Rust
ankurhimanshu14/novarche_web
/src/users/user_handlers.rs
UTF-8
2,963
2.6875
3
[]
no_license
#[path = "../schema.rs"] mod schema; #[path = "../utils.rs"] mod utils; use bcrypt::{ DEFAULT_COST, hash }; use super::user_models::{NewUser, User}; use crate::schema::users::dsl::*; use crate::utils::Pool; use diesel::QueryDsl; use diesel::RunQueryDsl; use actix_web::{web, Error, HttpResponse}; use diesel::dsl::{del...
true
b8018113d9a521b3956975ff6b6debe5c8047b52
Rust
clundin55/rtracer
/src/hittable.rs
UTF-8
1,778
3.234375
3
[ "MIT" ]
permissive
use crate::materials::Material; use crate::point::Point; use crate::ray::Ray; use crate::vec3::Vec3; use std::rc::Rc; #[derive(Default, Clone)] pub struct HitRecord { pub p: Point, pub normal: Vec3, pub t: f32, pub front_face: bool, pub mat_ptr: Option<Rc<dyn Material>>, } pub trait Hittable { ...
true
1f90395774a907c9903b26237a7502de5e2f6013
Rust
kyrias/mine
/build.rs
UTF-8
1,265
2.90625
3
[ "ISC" ]
permissive
use std::error::Error; use std::fs::File; use std::io::Write; use std::path::PathBuf; use std::process::Command; struct Ignore; impl<E> From<E> for Ignore where E: Error { fn from(_: E) -> Ignore { Ignore } } fn main() { let out_dir = PathBuf::from(std::env::var_os("OUT_DIR").unwrap()); let...
true
d312a50e47980a0b10f542356ea0e80cbc6aa6a3
Rust
mun-lang/mun
/crates/mun_codegen/src/value/function_value.rs
UTF-8
3,337
2.578125
3
[ "MIT", "Apache-2.0" ]
permissive
use super::{ConcreteValueType, IrTypeContext, PointerValueType, SizedValueType, ValueType}; use inkwell::types::BasicType; macro_rules! into_function_info_impl { ($( fn($($T:ident),*) -> $R:ident; )+) => { $( impl<'ink, $R:ConcreteValueType<'ink>, $($T:ConcreteValueType<'ink>,)*> Co...
true
b12c57235a2e0d0cb1d248be20743ecacbce2cfd
Rust
jieyouxu/ray-tracer
/src/ppm/decode.rs
UTF-8
333
2.5625
3
[]
no_license
//! Decodes a supplied plain-text PPM file into a `PpmImage`, including the pixel buffer and //! metadata. use super::PpmHeader; use std::io::Read; /// Decoder responsible for decoding a plain-text PPM image format via the supplied Reader. #[derive(Debug)] pub struct PpmDecoder<R: Read> { reader: R, header: ...
true
5625b93652555525e8c7d879d629a6bf568e515d
Rust
smmalis37/aoc2020
/src/days/day6.rs
UTF-8
1,886
3.296875
3
[ "Unlicense" ]
permissive
use crate::day_solver::DaySolver; pub struct Day6; type N = u8; // TODO: Figure out why deriving copy messes with timings here so much. #[derive(Clone)] pub struct Group { person_count: N, answers: [N; 26], } impl DaySolver<'_> for Day6 { type Parsed = Vec<Group>; type Output = usize; fn parse(...
true
2360ee4b4f65fa50d77918e41a5e0eecd9c63ed7
Rust
tensorbase/tensorbase
/crates/arrow/src/buffer/immutable.rs
UTF-8
18,241
2.765625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-free-unknown" ]
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
49160b59f178890422bade87aff04d798e202a1b
Rust
drgomesp/oxiboy
/src/gameboy/hardware/cpu/mod.rs
UTF-8
17,979
2.84375
3
[]
no_license
use super::bus::MemoryBus; use self::instructions::*; use self::ops::Ops; use self::registers::{Flags, Reg16, Reg8, Registers}; mod instructions; mod ops; pub mod registers; pub struct LR35902 { pub registers: Registers, } impl LR35902 { pub fn new() -> Self { Self { registers: Default::...
true
348ae5a419bae9f8ed1ed5fa33aef0b7deaafbe8
Rust
playXE/librcimmixcons
/src/spaces/immix_space/allocator/mod.rs
UTF-8
3,917
2.71875
3
[ "MIT" ]
permissive
// Copyright (c) <2015> <lummax> // Licensed under MIT (http://opensource.org/licenses/MIT) mod normal_allocator; mod overflow_allocator; mod evac_allocator; pub use self::normal_allocator::NormalAllocator; pub use self::overflow_allocator::OverflowAllocator; pub use self::evac_allocator::EvacAllocator; use spaces::i...
true
3bb22e06fcb216363720d4b44dbc35d8c2dabbf5
Rust
49nord/humblegen-rs
/humblegen/src/ast.rs
UTF-8
10,791
3.5625
4
[ "Apache-2.0", "MIT" ]
permissive
//! Humble language abstract syntax tree /// A spec node. /// /// A spec is the top-level item in humble. #[derive(Debug)] pub struct Spec(pub Vec<SpecItem>); impl Spec { /// Iterate over items in spec. pub fn iter(&self) -> impl Iterator<Item = &SpecItem> { self.0.iter() } /// Mutable iterat...
true
5ac00751faaaca1e24aef713d73c8d3eda1b68d5
Rust
theendsofinvention/dcs-radio-station
/drs-cmd/src/main.rs
UTF-8
1,595
2.828125
3
[ "MIT" ]
permissive
#[macro_use] extern crate log; use std::str::FromStr; use drsplayer::{Error, Player, Position}; pub fn main() -> Result<(), Error> { env_logger::Builder::new() .filter_level(log::LevelFilter::Info) .try_init() .unwrap(); let matches = clap::App::new("dcs-radio-station") .vers...
true
4b958414eec78c601dfd97cce3cfba1d2c740370
Rust
jjmark15/monster-battle-system
/src/combat/combat_service.rs
UTF-8
5,693
3.21875
3
[]
no_license
use rust_decimal::Decimal; use crate::combat::{DamageMultiplier, TypeEffectivenessCalculator}; use crate::monster::{Attack, Damage, Monster}; #[derive(Default)] pub struct CombatService<TEC: TypeEffectivenessCalculator> { type_effectiveness_calculator: TEC, } impl<TEC: TypeEffectivenessCalculator> CombatService<...
true
3e94e0173cfb5ff12388d71c3fbdfe86d84e23d4
Rust
andresattler/rsnake
/src/snake.rs
UTF-8
2,392
3.109375
3
[]
no_license
use piston_window::types::Color; use piston_window::{Context, G2d}; use std::collections::LinkedList; use crate::draw::draw_block; use std::ops::Neg; #[derive(PartialEq, Clone, Copy)] pub enum Direction { Up, Down, Left, Right, } impl Neg for Direction { type Output = Self; fn neg(self) -> D...
true
9e355a6317e89c094f643feab8d28a237cc85280
Rust
mitsuhiko/webgame
/webgame_client/src/api.rs
UTF-8
3,035
2.90625
3
[]
no_license
use std::collections::HashSet; use yew::agent::{Agent, AgentLink, Context, HandlerId}; use yew::format::Json; use yew::services::websocket::{WebSocketService, WebSocketStatus, WebSocketTask}; use crate::protocol::{Command, Message}; #[derive(Debug)] pub enum ApiState { Connecting, Connected, Disconnected...
true
b3c9a1ae4971bbf47c671423510cef7795f4e2a4
Rust
cds-astro/cds-moc-rust
/src/moc2d/range/op/or.rs
UTF-8
55,287
2.625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use core::ops::Range; use std::cmp::Ordering; use std::marker::PhantomData; use crate::idx::Idx; use crate::qty::MocQty; use crate::ranges::Ranges; use crate::moc2d::{ HasTwoMaxDepth, ZSorted, NonOverlapping, MOC2Properties, RangeMOC2Elem, RangeMOC2ElemIt, RangeMOCIterator, RangeMOC2Iterator, range::{RangeMOC...
true
96afe8fdd071597d1bcf3663a0eda433e4303c80
Rust
0queue/boosttorrent-redux
/src/protocol/message/mod.rs
UTF-8
6,310
2.65625
3
[]
no_license
use std::fmt::Formatter; use std::io; use std::time::Duration; use async_std::io::timeout; use async_std::net::TcpStream; use byteorder::BigEndian; use byteorder::ByteOrder; use futures::AsyncReadExt; use futures::AsyncWriteExt; use futures::Future; use futures::io::ReadHalf; use futures::io::WriteHalf; use crate::pr...
true
352424f6e10ccc8b646d23ec89d2d044f010978f
Rust
polyfractal/cormorant
/src/network_handler/protocol.rs
UTF-8
770
2.515625
3
[ "Apache-2.0" ]
permissive
// use chrono::{UTC, NaiveDateTime}; // use semver::Version; #[derive(RustcEncodable, RustcDecodable, Debug)] pub enum Protocol { Ping(PingCommand), Pong(PongResponse) } #[derive(RustcEncodable, RustcDecodable, Debug)] pub struct PingCommand { pub time: i64, pub version: String } impl PingCommand { ...
true
7488da37db3672ca679565e2932081d1860ad7c3
Rust
scotthellman/minesweeper
/src/lib.rs
UTF-8
1,141
2.671875
3
[ "MIT" ]
permissive
#[cfg(test)] #[macro_use] extern crate proptest; pub mod board; pub mod ai; pub mod interaction; pub mod constraint; use board::Point; #[derive(Debug)] pub enum ActionType { Click(Point), Chord(Point), Complete(Point), Flag(Point) } pub trait Agent { fn generate_move(&mut self, board: &board::B...
true
cfe497d6dbc9abea1f93ef87992f295bd0b1421f
Rust
shurizzle/tomography
/src/cpu.rs
UTF-8
2,714
2.6875
3
[]
no_license
use crate::platform::imp::cpu; use crate::types::cpu::{CoreLoadInfo, CoresLoadInfo, LoadAvg}; use crate::Timer; #[derive(Clone)] struct State { prev: CoresLoadInfo, current: Option<CoresLoadInfo>, } pub struct Cpu { timer: Timer<Option<State>>, } impl Cpu { pub fn new() -> Cpu { Cpu { ...
true
27f21666ab489163cbcc4b11f7a9535e53706b36
Rust
pavchip/textile-rs
/src/parser/block/comment.rs
UTF-8
2,434
3.359375
3
[ "MIT" ]
permissive
use parser::Block; use parser::block::parse_block; use parser::patterns::COMMENT_PATTERN; pub fn parse_comment(lines: &[&str]) -> Option<(Block, usize)> { let mut cur_line = 1; if COMMENT_PATTERN.is_match(lines[0]) { let caps = COMMENT_PATTERN.captures(lines[0]).unwrap(); let mut strings = Vec...
true
091702d6041e499fe4d2811a916c6d2c1b70d3ea
Rust
nwtnni/advent-of-code
/aoc-21/src/day_17.rs
UTF-8
3,051
3.140625
3
[ "MIT" ]
permissive
use std::cmp; use aoc::*; #[derive(Copy, Clone, Debug)] pub struct TrickShot { x1: i64, x2: i64, y1: i64, y2: i64, } impl Fro for TrickShot { fn fro(input: &str) -> Self { let (a, b) = input .trim() .trim_start_matches("target area: ") .split_once(", ")...
true
7f2dbe036d0204b35a3dd23de6ca04315a83872d
Rust
fizyk20/generic-array
/tests/generics.rs
UTF-8
3,950
3.1875
3
[ "MIT" ]
permissive
#![recursion_limit = "128"] use generic_array::arr; use generic_array::typenum::consts::U4; use std::fmt::Debug; use std::ops::Add; use generic_array::functional::*; use generic_array::sequence::*; use generic_array::{ArrayLength, GenericArray}; /// Example function using generics to pass N-length sequences and map...
true
b6167f18bf29c5528f6ed400bc954a7b35edac72
Rust
martinsg88/mandel_tut_rust
/main.rs
UTF-8
1,453
2.703125
3
[]
no_license
extern crate image; extern crate num_complex; use std::fs::File; use std::path::Path; use num_complex::Complex; fn main(){ let max_iterations = 512u16; let img_size = 800u32; let cxmin = -2f32; let cymin = -1.5f32; let cxmax = 1f32; let cymax = 1.5f32; let scalex = calc_scalex(cxmax, cxm...
true
51eb099847c54730a61e61a5e9b97f20a40044fe
Rust
irreducible-polynoms/irrpoly-rust
/src/gf_poly/gf_poly.rs
UTF-8
1,931
3.09375
3
[ "MIT" ]
permissive
use crate::{Gf, GfNum}; use std::vec::Vec; use std::fmt; use std::ops; use std::cmp; #[derive(Debug, Clone)] pub struct GfPoly { field: Gf, poly: Vec<GfNum>, } impl fmt::Display for GfPoly { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "[ ")?; for i in 0..self.poly.le...
true
f131f811d414a564c5e3943fce512725795ee055
Rust
ToonSpin/advent-of-code-2018-rust
/src/bin/day12.rs
UTF-8
3,221
3.21875
3
[]
no_license
use std::io; use std::io::prelude::*; use std::collections::VecDeque; struct PotRow { state: VecDeque<bool>, number_of_first_pot: i64, rules: [bool; 32], } impl PotRow { fn new(initial_state: &[u8], rules: [bool; 32]) -> PotRow { let mut state: VecDeque<bool> = VecDeque::new(); for p ...
true
b8fa7bac0f7a7c45682f7ed06843ae4f21ed41d6
Rust
Steven-Ireland/Rust-NBody
/src/world/mod.rs
UTF-8
3,046
3.484375
3
[]
no_license
use std::f64::consts::PI; const G: f64 = 1.0; // wrong, just hacking this in for now. #[derive(PartialEq, Debug, Copy, Clone)] pub struct Point { pub x: f64, pub y: f64 } pub type Vector = Point; pub const ORIGIN: Point = Point { x: 0.0, y: 0.0 }; pub const RESTING: Vector = Vector { x: 0.0, y: 0.0 }; #[derive(...
true
09605b20f4b0f3f1527299ed4e5f05c718ad1bf7
Rust
ric2b/Vivaldi-browser
/chromium/third_party/rust/owo_colors/v3/crate/src/colors/dynamic.rs
UTF-8
3,180
3.015625
3
[ "MIT", "BSD-3-Clause", "Apache-2.0", "LGPL-2.0-or-later", "GPL-1.0-or-later" ]
permissive
use crate::{AnsiColors, DynColor}; use core::fmt; #[allow(unused_imports)] use crate::OwoColorize; /// Available RGB colors for use with [`OwoColorize::color`](OwoColorize::color) /// or [`OwoColorize::on_color`](OwoColorize::on_color) #[derive(Copy, Clone, Debug, PartialEq)] pub struct Rgb(pub u8, pub u8, pub u8); ...
true
bdc341f674e5fcf84704534058a16955da62679a
Rust
nothingnesses/yatima
/core/src/prim/bool.rs
UTF-8
4,547
3.046875
3
[ "MIT" ]
permissive
use sp_ipld::Ipld; use std::fmt; use crate::{ ipld_error::IpldError, literal::Literal, term::Term, yatima, }; #[derive(PartialEq, Eq, Clone, Copy, Debug)] pub enum BoolOp { Eql, Lte, Lth, Gte, Gth, And, Or, Xor, Not, } impl BoolOp { pub fn symbol(self) -> String { match self { ...
true
1b719bc435789feae7d0d537601d478cb51a3094
Rust
SeraphyBR/travelling_salesman
/src/graph.rs
UTF-8
1,551
3.1875
3
[ "MIT" ]
permissive
#![allow(dead_code)] use crate::point::Point; use ndarray::Array2; use num_traits::{Num, Float, zero, NumCast, cast}; /// Describes a graph #[derive(Clone)] pub struct Graph<T: Num> { size: usize, matrix: Array2<T>, vertex_count: usize, points: Vec<Point<T>> } impl<T: Num + Copy> Graph<T> { pub f...
true
887565bbcc6f285641fc1b792b474304516d01e7
Rust
IThawk/rust-project
/rust-master/src/test/ui/issues/issue-46023.rs
UTF-8
151
2.6875
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
fn main() { let x = 0; (move || { x = 1; //~^ ERROR cannot assign to `x`, as it is not declared as mutable [E0594] })() }
true
4a2b8fd959ebb79e12ef5ac0e64ea20555df3154
Rust
joshatron/AdventOfCode-2020
/src/days/day_15.rs
UTF-8
2,488
3.546875
4
[]
no_license
use crate::days::Day; pub struct Day15 {} impl Day15 { pub fn new() -> Day15 { Day15 {} } } impl Day for Day15 { fn day_num(&self) -> usize { 15 } fn puzzle_1(&self, input: &Vec<String>) -> String { let mut initial = Sequence::parse(&input[0]); while initial.turn < 2020 { initial.pl...
true
a49eda648e84ae9ad1b33cc5c0978eeb9b515efc
Rust
prz23/zinc
/zargo/src/transaction/error.rs
UTF-8
960
2.71875
3
[ "Apache-2.0" ]
permissive
//! //! The transaction error. //! use thiserror::Error; /// /// The transaction error. /// #[derive(Debug, Error)] pub enum Error { /// A required transaction field is missing. #[error("parsing: {}", _0)] Parsing(zinc_types::TransactionError), /// The transaction token is invalid. #[error("token ...
true
5dd1a23d43385ea29ab0894b2f518817d0c41a7d
Rust
osmium8/Rust-OS
/src/main.rs
UTF-8
1,128
2.9375
3
[]
no_license
#![no_std] // don't link the Rust standard library #![no_main] // disable all Rust-level entry points use core::panic::PanicInfo; mod vga_buffer; /// This function is called on panic. #[panic_handler] fn panic(info: &PanicInfo) -> ! { println!("{}", info); loop {} } static HELLO: &[u8] = b"Hello World!"; /**...
true
27f3d549d602a37e85afdffee9e31a74d37a3d5e
Rust
hwchen/pour
/src/main.rs
UTF-8
4,116
2.640625
3
[]
no_license
use anyhow::{Context, Error}; use hyper::{ client::connect::Connection, service::Service, Client, Request, Uri, }; use hyper_tls::HttpsConnector; use std::{ fs, iter, path::PathBuf, time::Instant, }; use structopt::StructOpt; use tokio::io::{AsyncRead, AsyncWrite}; #[tokio::main] as...
true
a938cc710d803cfe5d368a2cf2fee108345fd147
Rust
youngspe/rc-vec
/src/test/string/misc.rs
UTF-8
1,603
3.234375
3
[ "MIT" ]
permissive
use crate::rc_str; #[test] pub fn add_str() { let s = rc_str!("foo") + "bar"; assert_eq!(s, "foobar"); } #[test] pub fn add_self() { let s = rc_str!("foo") + rc_str!("bar"); assert_eq!(s, "foobar"); } #[test] pub fn add_assign_str() { let mut s = rc_str!("foo"); s += "bar"; assert_eq!(s, ...
true
e02c3d460030d6a133b3e525737e9e9e07c185df
Rust
crumblingstatue/rgen3
/rgen3-string/src/lib.rs
UTF-8
3,008
3.46875
3
[ "MIT" ]
permissive
use std::collections::HashMap; #[derive(PartialEq, Eq, Hash, Clone, Copy)] pub enum PokeChar { /// Printable character Print(char), /// String terminator Term, Unmapped, } impl PokeChar { pub fn to_char(self) -> char { if let PokeChar::Print(ch) = self { ch } else {...
true
a66c7113d0ec030ea801afc6b498a57d91fc8010
Rust
MarioSieg/KESTD-Ronin-Advanced
/src/resources/mod.rs
UTF-8
2,643
2.859375
3
[]
no_license
pub mod material; pub mod mesh; pub mod texture; use super::systems::SubSystem; use crate::resources::prelude::PathBuf; use log::info; use mesh::Mesh; use std::collections::hash_map::DefaultHasher; use std::collections::HashMap; use std::hash::{Hash, Hasher}; use std::sync::Arc; use texture::Texture; pub type Resourc...
true
7cb12c452d6630c3a71241032698da094858d065
Rust
argv-minus-one/rust-shopsite-utils
/shopsite-aa/src/de/error.rs
UTF-8
1,337
3.140625
3
[ "MIT" ]
permissive
use std::{ borrow::Cow, io, num::{ParseFloatError, ParseIntError}, rc::Rc, path::Path, str::ParseBoolError }; use super::Position; /// Takes an `Option<Rc<Path>>` (like in the `Position` type) and turns it into a `str`. pub(super) fn rc_path_to_str(file: &Option<Rc<Path>>) -> Cow<str> { if let Some(ref file) = ...
true
0d7179dedbd691c2352885168770a77e5a89e760
Rust
NiravSurajlal/Rust_Projects
/Chapter_9/ch9_03/src/main.rs
UTF-8
1,310
4.03125
4
[]
no_license
use std::io; use std::cmp::Ordering; use rand::Rng; fn main() { println!("Guess the number"); let secret_number = rand::thread_rng().gen_range(1,101); loop{ println!("Please input your guess."); let mut guess = String::new(); io::stdin().read_line(&mut guess) .expect("Failed to read l...
true
a886eb9d86b530fc3b784ddacd43aec1b5c39b24
Rust
tonyu0/rust-compro
/ABC/021D.rs
UTF-8
1,588
3.34375
3
[]
no_license
use std::io::Read; // 1 <= a1 <= a2 ... <= ak <= n // これは1 ~ nである数字からk個重複を許して選ぶ方法 (難しく考えることはない) mod enumeration { pub struct Enumeration { fact: Vec<u64>, finv: Vec<u64>, modulo: u64, } impl Enumeration { pub fn new(n: usize, modulo: u64) -> Enumeration { let m...
true
33f995b1b884c15cff31673318c558ab60a18084
Rust
ry/tokio
/src/io.rs
UTF-8
2,404
3.234375
3
[ "MIT" ]
permissive
//! Asynchronous I/O. //! //! This module is the asynchronous version of `std::io`. Primarily, it //! defines two traits, [`AsyncRead`] and [`AsyncWrite`], which extend the //! `Read` and `Write` traits of the standard library. //! //! # AsyncRead and AsyncWrite //! //! [`AsyncRead`] and [`AsyncWrite`] must only be imp...
true
3a188296aae58bc79aae595b36c1f7690d97bdae
Rust
JohnTitor/triagebot
/src/github.rs
UTF-8
35,315
2.65625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use anyhow::Context; use chrono::{DateTime, FixedOffset, Utc}; use futures::stream::{FuturesUnordered, StreamExt}; use futures::{future::BoxFuture, FutureExt}; use hyper::header::HeaderValue; use once_cell::sync::OnceCell; use reqwest::header::{AUTHORIZATION, USER_AGENT}; use reqwest::{Client, Request, RequestBuilder,...
true
74efff938a57a604c2b16f5950227c96409baea5
Rust
hwchen/mitey
/examples/hello_async_std.rs
UTF-8
3,088
2.796875
3
[]
no_license
use async_std::net::TcpListener; use async_std::stream::StreamExt; use async_std::task; use http_types::{Request, Response, StatusCode}; use mitey::{Router, State}; #[async_std::main] async fn main() -> http_types::Result<()> { // server 1 let state_1 = State::init("mitey-state_1".to_owned()); let mut rou...
true
adc10892128783a251199b5b3fb7a8d8a21e37a7
Rust
bhansconnect/earthly-rust-chef
/lib_b/src/lib.rs
UTF-8
557
3.125
3
[ "MIT" ]
permissive
use lib_c::right_now; use log::{info, warn}; pub fn logging_fib(n: i64) -> i64 { if n < 0 { warn!("Someone is sending bad args to fib"); } info!("input was: {}", n); info!("Started at: {}", right_now()); let out = fib(n); info!("Ended at: {}", right_now()); info!("Output was: {}", o...
true
1b35b3553d4b53f5d523d7a1a6f020a40907d2c7
Rust
raghavthakur/contagion
/src/core/vector/vector3.rs
UTF-8
2,328
3.546875
4
[]
no_license
use crate::core::scalar::Scalar; use crate::core::vector::Vector; use std::ops::*; #[derive(Clone, Copy, Debug)] pub struct Vector3 { pub x: Scalar, pub y: Scalar, pub z: Scalar, } pub fn vector3(x: Scalar, y: Scalar, z: Scalar) -> Vector3 { Vector3{ x: x, y: y, z: z } } impl Neg for Vector3 { t...
true
6394b9aedc19041283b8e63076e30bfed6d33432
Rust
zettsu-t/examQuestions
/2008math4rs.rs
UTF-8
3,636
3.234375
3
[ "MIT" ]
permissive
use std::string::String; use std::string::ToString; use std::vec::Vec; use std::collections::LinkedList; use std::env; type ExprValue = usize; struct Result { value : ExprValue, expr : String } fn make_result(value : ExprValue, nums: Vec<ExprValue>, ops: Vec<ExprValue>) -> Result { let mut...
true
73b748ca5796743a6ce5b13a007d3602ee1e3e82
Rust
drbrain/AOC
/2020/src/bin/day_12.rs
UTF-8
11,524
2.984375
3
[]
no_license
use anyhow::Result; use aoc2020::read; use nom::bytes::complete::*; use nom::character::complete::*; use nom::combinator::*; use nom::multi::*; use nom::sequence::*; use nom::IResult; use std::convert::From; use std::fmt; use std::ops::Add; use std::ops::Sub; fn main() -> Result<()> { let input = read("./12.inp...
true
416e9c4b75b4ac41df5092c268b2ffc6504103b5
Rust
pione30/twitter2-api
/src/infra/post_repository.rs
UTF-8
1,255
2.796875
3
[]
no_license
use crate::domain::model::{IPostRepository, NewPost, Post, User}; use diesel::pg::PgConnection; use diesel::prelude::*; use std::sync::{Arc, Mutex}; #[derive(Clone)] pub struct PostRepository { conn: Arc<Mutex<PgConnection>>, } impl PostRepository { pub fn new(conn: Arc<Mutex<PgConnection>>) -> Self { ...
true
3ebea02190276298d43efa5c4b81669bd2759275
Rust
roscale/nesmulator
/src/disassembler.rs
UTF-8
6,875
3.09375
3
[]
no_license
use std::fmt::Write; use crate::cpu::CPU; use crate::opcodes::{AddressingMode, Instruction, OPCODES}; impl CPU { pub fn disassemble_and_log_current_instruction(&mut self) { let op = self.read(self.pc); let (instruction, addressing_mode, _) = OPCODES[op as usize]; write!(self.logs, "{:04X}...
true
8734d2b9ded4728b39c61b0fb27762c3cfd5420b
Rust
mavnn/firstaide
/src/config.rs
UTF-8
5,866
2.9375
3
[]
no_license
use path_absolutize::Absolutize; use serde::Deserialize; use std::env; use std::ffi::OsStr; use std::fmt; use std::fs; use std::io; use std::os::unix::ffi::OsStrExt; use std::path::{Path, PathBuf}; use std::process::Command; use toml; type Result = std::result::Result<Config, Error>; pub enum Error { Io(io::Error...
true
b4159b667ebce78e0a3a89eaccf2e2f6945c6e32
Rust
AdrianDanis/R4
/src/util/string.rs
UTF-8
1,242
3.6875
4
[ "MIT" ]
permissive
//! Helper routines for strings use core::num::ParseIntError; /// Trait for doing more interesting string conversions involving prefixes pub trait FromStrExt: Sized { /// `from_str_radix` does not seem to exist in an existing Trait fn from_str_radix(inpur: &str, radix: u32) -> Result<Self, ParseIntError>; ...
true
ea6cbc832b9c0d422b262ee7abd34338b3324fd2
Rust
gtk-rs/gir
/src/config/property_generate_flags.rs
UTF-8
2,555
3.21875
3
[ "MIT" ]
permissive
use std::str::FromStr; use bitflags::bitflags; use super::error::TomlHelper; bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct PropertyGenerateFlags: u32 { const GET = 1; const SET = 2; const NOTIFY = 4; } } impl FromStr for PropertyGenerateFlags { type Err ...
true
22a1bebb46b29c7c3553da478a0046af280275f2
Rust
robjsliwa/rlox
/src/rlox/token.rs
UTF-8
424
2.875
3
[ "MIT" ]
permissive
use super::literal::Literal; use super::token_type::TokenType; #[derive(Clone)] pub struct Token { pub token_type: TokenType, pub lexeme: String, pub literal: Option<Literal>, pub line: usize, } impl Token { pub fn new( token_type: TokenType, lexeme: String, literal: Option<Literal>, line: u...
true
b5c5d78e60d835b1831d5a229bd24c8bb6e7748f
Rust
EFanZh/LeetCode
/src/problem_1470_shuffle_the_array/mod.rs
UTF-8
675
3.03125
3
[]
no_license
pub mod quick_select; pub trait Solution { fn get_strongest(arr: Vec<i32>, k: i32) -> Vec<i32>; } #[cfg(test)] mod tests { use super::Solution; use crate::test_utilities; pub fn run<S: Solution>() { let test_cases = [ ((&[1, 2, 3, 4, 5] as &[_], 2), &[1, 5] as &[_]), (...
true
9736683511e20380b32db7b37e2da7658300f970
Rust
chromium/chromium
/third_party/rust/clap/v4/crate/examples/repl.rs
UTF-8
2,579
3.046875
3
[ "Apache-2.0", "MIT", "BSD-3-Clause", "GPL-1.0-or-later", "LGPL-2.0-or-later" ]
permissive
use std::io::Write; use clap::Command; fn main() -> Result<(), String> { loop { let line = readline()?; let line = line.trim(); if line.is_empty() { continue; } match respond(line) { Ok(quit) => { if quit { break;...
true
794ec52563925e03b7180a5543ca9e8be8cac576
Rust
frankegoesdown/LeetCode-in-Go
/Algorithms/0338.counting-bits/counting-bits.go
UTF-8
432
3.40625
3
[ "MIT" ]
permissive
package problem0338 func countBits(num int) []int { res := make([]int, num+1) for i := 1; i <= num; i++ { // i>>1 == i/2 // i&1 == i%2 // 只是 位运算 更快 // // 观察以下三个数的二进制表示 // 5 : 101 // 10: 1010, 10>>1 == 5 // 11: 1011, 11>>1 == 5 // 10 的二进制表示,含有 1 的个数,可以由 5 的答案 + 10%2 计算 // 11 同理 res[i] = res[i>>...
true
929e208aad2521983adcedcb5367b59d0a16d96b
Rust
BaldyAsh/ralgo
/src/fibonacci/fib_last_num.rs
UTF-8
1,154
3.46875
3
[ "MIT" ]
permissive
pub fn fib_last_num(num: u64) -> u64 { if num <= 1 { return num; } let mut a = 0; let mut b = 1; let mut c; for _ in 2 ..= num { c = b; b = (a + b) % 10; a = c; } return b; } #[cfg(test)] mod tests_fib_last_num { use super::fib_last_num; #[test] fn te...
true
e21d465704f4b603986f4e2780e3463e3de41c6e
Rust
noiseOnTheNet/OrgLib
/main.rs
UTF-8
1,110
3.078125
3
[ "MIT" ]
permissive
mod org; use org::{Node, Status}; #[cfg(test)] mod tests { use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; // The output is wrapped in a Result to allow matching on errors // Returns an Iterator to the Reader of the lines of the file. fn read_lines<P>(filename: P) -> io::Result<io::Lines<i...
true
704ccc534c0ed54b32df52324844c456d2ee5b9d
Rust
alesharik/smbios-lib
/src/structs/types/baseboard_information.rs
UTF-8
17,032
2.765625
3
[ "MIT" ]
permissive
use crate::core::{Handle, UndefinedStruct}; use crate::SMBiosStruct; use serde::{ser::SerializeSeq, ser::SerializeStruct, Serialize, Serializer}; use core::{fmt, any}; use core::ops::Deref; #[cfg(feature = "no_std")] use alloc::{string::String, vec::Vec}; /// # Baseboard (or Module) Information (Type 2) /// /// Compli...
true
b4e755a5a7dc18f568d53bdd4b54c4df1c6f9346
Rust
danieldulaney/appendlist
/src/appendlist.rs
UTF-8
10,130
3.515625
4
[ "MIT" ]
permissive
use std::cell::{Cell, UnsafeCell}; use std::fmt::{self, Debug}; use std::iter::FromIterator; use std::ops::Index; use crate::common::{chunk_size, chunk_start, index_chunk}; /// A list that can be appended to while elements are borrowed /// /// This looks like a fairly bare-bones list API, except that it has a `push` ...
true