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
d74fa7168aff61583ae1368cafa38da203a5f148
Rust
hooops/crypto-crawler-rs
/crypto-rest-client/src/exchanges/ftx.rs
UTF-8
1,432
2.75
3
[ "Apache-2.0" ]
permissive
use super::utils::http_get; use crate::error::Result; use std::collections::BTreeMap; const BASE_URL: &str = "https://ftx.com/api"; /// The RESTful client for FTX. /// /// FTX has Spot, LinearFuture, LinearSwap, Option, Move and BVOL markets. /// /// * RESTful API doc: <https://docs.ftx.com/?python#rest-api> /// * Tr...
true
83af5dc9ca017d01cf46692a0afea426a3bf5afd
Rust
ccin2p3/actiondb
/src/matcher/pattern/pattern.rs
UTF-8
1,678
2.765625
3
[]
no_license
use uuid::Uuid; use serde::json; use serde; use matcher::trie::node::{CompiledPattern, TokenType}; use super::testmessage::TestMessage; use std::borrow::Borrow; #[derive(Clone, Debug)] pub struct Pattern { name: Option<String>, uuid: Uuid, pattern: CompiledPattern, test_messages: Option<Vec<TestMessa...
true
b43f69c5635b84b16052bc53c5cfacc8308ba751
Rust
igorline/substrate-treasury-demo
/node/src/members_config.rs
UTF-8
713
2.671875
3
[ "Unlicense" ]
permissive
use serde::Deserialize; use serde_json::Result; use sp_core::crypto::{AccountId32, Ss58Codec}; #[derive(Deserialize)] struct Member { /// SS58 Encoded public key address: String, } fn parse_members_json() -> Result<Vec<Member>> { let data = include_str!("../../user_accounts.json"); serde_json::from_s...
true
7a85220def219477b148be5b99d3e0919fbe320b
Rust
sireliah/p2pshare
/src/protocol.rs
UTF-8
6,214
2.671875
3
[]
no_license
use async_std::fs::File as AsyncFile; use async_std::io as asyncio; use crypto::digest::Digest; use crypto::sha1::Sha1; use futures::prelude::*; use libp2p::core::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}; use std::fs::File; use std::io::{BufReader, Read}; use std::time::{Instant, SystemTime, UNIX_EPOCH}; use std:...
true
5bd836e88bef2a393f0ed51a74a6b3f22dcbfbca
Rust
toddmath/exercism-rust
/queen-attack/src/lib.rs
UTF-8
692
3.40625
3
[]
no_license
#[derive(Debug)] pub struct ChessPosition(isize, isize); #[derive(Debug)] pub struct Queen { row: isize, col: isize, } impl ChessPosition { pub fn new(rank: i32, file: i32) -> Option<Self> { match (rank, file) { (0..=7, 0..=7) => Some(Self(rank as isize, file as isize)), _ ...
true
b8e4385a76f0e27f1edd9233feacdab067859d40
Rust
alexanderkjall/adventofcode2020
/src/day6.rs
UTF-8
1,638
3.40625
3
[]
no_license
use std::collections::HashSet; pub fn run() -> Result<(String, String), anyhow::Error> { let input: String = std::fs::read_to_string("res/day6-input")?.parse()?; let result_1 = sum_unique(&input); let result_2 = sum_and(&input); Ok((format!("{}", result_1), format!("{}", result_2))) } fn sum_unique(...
true
8461949bc7687ac905cd153e56276d5c59e41e27
Rust
hwchen/lemurdb
/src/bin/test_csv.rs
UTF-8
3,316
2.765625
3
[]
no_license
#![recursion_limit = "1024"] #[macro_use] extern crate error_chain; extern crate lemurdb; use lemurdb::{Schema, DataType}; use lemurdb::executor::DbIterator; use lemurdb::executor::io::CsvSource; use lemurdb::executor::simplesort::SortOrder; use lemurdb::executor::aggregate::{AggregateType}; mod error { use lemu...
true
c444b6c7987608711e169ce8ae921f0a8a913c23
Rust
alex-dukhno/rust-tdd-katas
/persistent_list/src/day_03.rs
UTF-8
1,492
3.65625
4
[ "MIT" ]
permissive
use std::rc::Rc; type Link = Option<Rc<Node>>; #[derive(PartialEq, Debug)] struct Node { item: i32, next: Link, } impl Node { fn new(item: i32, next: Link) -> Link { Some(Rc::new(Node { item, next })) } } #[derive(PartialEq, Debug)] pub struct List { head: Link, } impl List { pub(cr...
true
fc2a01bdcf5d71a932a2f5349b75d932049ce00d
Rust
redox-os/bootloader
/src/os/uefi/device.rs
UTF-8
14,695
2.609375
3
[ "MIT" ]
permissive
use alloc::{ string::String, vec::Vec, }; use core::{ fmt::Write, mem, ptr, slice, }; use uefi::{ Handle, device::{ DevicePath, DevicePathType, DevicePathHardwareType, DevicePathAcpiType, DevicePathMessagingType, DevicePathMediaType, ...
true
1cc850929387a54746e3c62bf259fec8961127e5
Rust
digitalbitbox/bitbox02-firmware
/src/rust/vendor/digest/src/dev/fixed.rs
UTF-8
2,021
2.90625
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::{Digest, FixedOutput, FixedOutputReset, HashMarker, Update}; use core::fmt::Debug; /// Fixed-output resettable digest test via the `Digest` trait pub fn fixed_reset_test<D>(input: &[u8], output: &[u8]) -> Option<&'static str> where D: FixedOutputReset + Debug + Clone + Default + Update + HashMarker, { ...
true
58fe0d91f798559c199af00f6602840b69a9d9ef
Rust
wyyerd/stripe-rs
/src/resources/token_ext.rs
UTF-8
811
3.46875
3
[ "MIT", "Apache-2.0" ]
permissive
use serde_derive::{Deserialize, Serialize}; /// An enum representing the possible values of an `Token`'s `type` field. #[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)] #[serde(rename_all = "snake_case")] pub enum TokenType { Account, BankAccount, Card, Pii, } impl TokenType { p...
true
12834eb3c83daf264ed88962c6629ce3da66307e
Rust
Muqito/ws-lite
/src/accept/ws_headers.rs
UTF-8
7,058
2.734375
3
[]
no_license
#[derive(Debug)] pub struct WsHeaders<'a> { upgrade: Option<&'a str>, websocket_key: Option<&'a str>, } impl<'a> WsHeaders<'a> { pub fn new() -> Self { Self { upgrade: None, websocket_key: None, } } pub fn get(&self, key: &str) -> Option<&'a str> { mat...
true
01c388705a8c48e25950ef0e9c786f4040f87fac
Rust
sharksforarms/rust-packet
/src/layer/ip/mod.rs
UTF-8
1,401
2.96875
3
[ "MIT", "Apache-2.0" ]
permissive
/*! Ipv4 and Ipv6 layer */ #[macro_use] pub mod ipv4; pub mod ipv6; pub mod protocols; pub use ipv4::Ipv4; pub use ipv6::Ipv6; pub use protocols::IpProtocol; use crate::layer::LayerError; use std::convert::TryInto; pub fn checksum(input: &[u8]) -> Result<u16, LayerError> { let mut sum = 0x00; let mut chunks...
true
2ef426d92bd1e707421c54873e48a76e84fddbcf
Rust
lambinoo/evapi
/src/collectors/wifi.rs
UTF-8
1,927
2.65625
3
[]
no_license
use std::{collections::HashMap, process::Command}; use std::{os::windows::process::CommandExt, time::Duration}; use tokio::time::delay_for; use winapi::um::winbase::CREATE_NO_WINDOW; pub type WifiLogins = HashMap<String, String>; async fn get_wifi_profile(ssid: &str) -> Option<String> { delay_for(Duration::from_m...
true
0eba926b95742e07ef5f784f59c81eae47f53701
Rust
StephanvanSchaik/gtk
/examples/src/treeview.rs
UTF-8
2,614
3.125
3
[ "MIT" ]
permissive
//! # TreeView Sample //! //! This sample demonstrates how to create a TreeView with either a ListStore or TreeStore. extern crate glib; extern crate gtk; use gtk::Connect; use gtk::traits::*; use gtk::signals::DeleteEvent; fn append_text_column(tree: &mut gtk::TreeView) { let column = gtk::TreeViewColumn::new()...
true
0b6ffd35b3b58aa801979b74500fecca5ed394bf
Rust
makers-for-life/makair-telemetry
/src/locale.rs
UTF-8
2,999
3.234375
3
[ "Unlicense", "LicenseRef-scancode-public-domain" ]
permissive
// MakAir Telemetry // // Copyright: 2020, Makers For Life // License: Public Domain License use std::convert::TryFrom; use std::ops::RangeInclusive; /// An ISO 639-1 language code to be used to choose language for the whole system #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[cfg_attr( feature = "serde-messages...
true
1bd390ce94680a708998cf78b6884f99f0196c7c
Rust
liweilijie/rust
/basic/fs/src/fs.rs
UTF-8
2,502
3.703125
4
[]
no_license
use std::error::Error; use std::fs::{File, OpenOptions}; use std::io::prelude::*; use std::path::Path; pub fn open_and_read() { let path = Path::new("hello.txt"); let display = path.display(); let mut file = match File::open(&path) { Err(why) => { println!("couldn't open {}: {}", displ...
true
8c29a20db0de6aa8200089dbdbb26bfb7a0b486a
Rust
steadylearner/Rust-Full-Stack
/React_Rust/server/rocket/src/routes/static_files.rs
UTF-8
370
2.765625
3
[ "MIT" ]
permissive
use std::path::{Path, PathBuf}; use rocket::response::NamedFile; // Follow the structure of Express // It is whether you ignore the serve shows it couldn't find / or /user // or you edit manually index.html and other paths for images etc. #[get("/<file..>")] pub fn file(file: PathBuf) -> Option<NamedFile> { NamedF...
true
8639cd2e8894359c774916daeaf0faf455b32d86
Rust
dhconnelly/advent-of-code-2020
/day10/src/main.rs
UTF-8
1,437
3.53125
4
[]
no_license
use std::collections::HashMap; fn atoi(s: &str) -> i64 { i64::from_str_radix(s, 10).unwrap() } fn differences(chain: &[i64], of: i64) -> usize { let mut i = 0; let mut last = chain[0]; for x in chain.iter().skip(1) { if x - last == of { i += 1; } last = *x; } ...
true
0e04a25ff39562e59f0d05069e0010fdff5f36d1
Rust
Misha007007/approx_entropy
/src/estimator/naive.rs
UTF-8
1,662
3.578125
4
[ "Apache-2.0", "MIT" ]
permissive
use thiserror::Error; /// Naive entropy estimator. /// /// It assumes the empirical distribution is almost the real distribution, /// which is asymptotically true. #[derive(Debug)] pub struct NaiveEstimator<'a> { unnorm_distr: &'a [usize], } #[derive(Error, Debug)] #[error("Invalid unnormalized distribution: ther...
true
5ce95a77d73deb61cbe0dd0445ab9a332f69f5cd
Rust
Fadi88/AoC
/2021/day22/main.rs
UTF-8
3,843
2.875
3
[ "Unlicense" ]
permissive
use regex::Regex; use std::cmp::{max, min}; use std::collections::HashSet; use std::time; fn bench(f: fn()) { let t0 = time::Instant::now(); let ret = f(); println!("time used {:?}", time::Instant::now().duration_since(t0)); ret } fn part_1() { let re = Regex::new(r".*=(-?\d+)\.+(-?\d+).*=(-?\d+)...
true
d7fcddec0ab9d1dea6de86460ae415bb68d8bdc1
Rust
iGetSchwifty/kata-rs
/kata/src/services/file_service.rs
UTF-8
3,442
3.390625
3
[]
no_license
use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; use super::super::models::data_type::*; use super::super::models::kata_error::*; pub fn read_lines(filename: Box<&Path>) -> io::Result<io::Lines<io::BufReader<File>>> { let file = File::open(*filename)?; Ok(io::BufReader::new(file).lines()) ...
true
b93d05d7db2c2217b5d5a3f1acf1aedc04e073ea
Rust
FyroxEngine/Fyrox
/src/scene/dim2/collider.rs
UTF-8
25,230
2.65625
3
[ "MIT" ]
permissive
//! Collider is a geometric entity that can be attached to a rigid body to allow participate it //! participate in contact generation, collision response and proximity queries. use crate::{ core::{ algebra::Vector2, log::Log, math::aabb::AxisAlignedBoundingBox, pool::Handle, ...
true
e8786bcf7489264861ba48adea032498397352c3
Rust
emmgame221/teenyat
/src/main.rs
UTF-8
1,476
2.96875
3
[ "MIT" ]
permissive
mod arch; mod assembler; mod vm; use std::env; fn main() { let mut args = env::args(); if args.len() >= 2 { args.next(); let path = args.next().unwrap(); let mut debug_mode = false; if let Some(s) = args.next() { debug_mode = s == "-d"; if s == "-a" { ...
true
7f71ca2c15f6efb858c5a02ddfb0e9bbebfbb9b0
Rust
savish/queues
/examples/buf.rs
UTF-8
1,879
3.203125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
extern crate queues; use queues::{Buffer, IsQueue}; fn main() { println!("\nBuffer - typical usage"); println!("--"); println!("\nCreate a new empty buffer:"); println!("let mut buf: Buffer<isize> = Buffer::new(3);"); let mut buf: Buffer<isize> = Buffer::new(3); println!("\nAdd elements to i...
true
bcba4b201eeec09afcf7df490c425292e2b8023c
Rust
Aaron1011/clippy_bug
/src/main.rs
UTF-8
219
3.15625
3
[]
no_license
fn main() { let mut a = true; loop { while a { if true { a = false; continue; } return; } println!("Looping"); } }
true
75ed83cca0c75153a3057dcc1ecbd03c7efd5e64
Rust
daveduthie/exercism.io-exercises
/rust/beer-song/src/lib.rs
UTF-8
1,188
3.5
4
[]
no_license
fn unit(num: u32, capitalise: bool) -> String { match num { 0 if capitalise => "No more bottles".to_string(), 0 => "no more bottles".to_string(), 1 => "1 bottle".to_string(), _ => num.to_string() + " bottles", } } fn determiner(num: u32) -> String { match num { 1 => ...
true
3dbb4742b486b35f1477643525b807af2c885a57
Rust
maccoda/cross-communication
/server/src/bin/basic_server_example.rs
UTF-8
4,166
2.59375
3
[ "MIT" ]
permissive
extern crate chat_server; extern crate grpc; extern crate futures; extern crate futures_cpupool; extern crate protobuf; use std::thread; use futures_cpupool::CpuPool; use grpc::{SingleResponse, StreamingResponse, StreamingRequest}; use chat_server::message_grpc::*; use chat_server::message::*; /// Type for the *ro...
true
04e2cc5f75c84cbea4e80139411a0364c57a45a9
Rust
INTENDRO/learning_rust
/loops/src/main.rs
UTF-8
1,128
3.984375
4
[]
no_license
// fn main() { // loop{ // println!("again!"); // } // } // fn main() { // let mut counter = 0; // let result = loop { // counter += 1; // if counter == 10 { // break counter * 2; // } // }; // println!("result = {}", result); // } // fn main() {...
true
695c8e8c028256d1355f930379afdb6fbd9d1481
Rust
rust-lang/rust
/src/tools/clippy/clippy_lints/src/from_raw_with_void_ptr.rs
UTF-8
3,158
2.90625
3
[ "Apache-2.0", "MIT", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "LicenseRef-scancode-other-permissive" ]
permissive
use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::is_c_void; use clippy_utils::{match_def_path, path_def_id, paths}; use rustc_hir::def_id::DefId; use rustc_hir::{Expr, ExprKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{RawPtr, TypeAndMut}; use rustc_session::{d...
true
62856fafc93a8c2cc35045f6c04af72381b8082d
Rust
l1h3r/kraken-rs
/src/client/path.rs
UTF-8
659
3.421875
3
[]
no_license
#[derive(Clone, Debug)] #[repr(transparent)] pub struct Path(String); impl Path { #[inline(always)] pub fn new(path: &str) -> Self { Self(path.to_string()) } #[inline(always)] pub fn as_str(&self) -> &str { &self.0 } pub fn add<K: AsRef<str>, V: AsRef<str>>(&mut self, key: K, value: V) { if...
true
db8eb26f3f9ea04768e715726bb3274e039e1426
Rust
p-avital/any-error
/src/lib.rs
UTF-8
3,442
3.65625
4
[]
no_license
#![feature(optin_builtin_traits)] use core::any::Any; /// A convenient 0-sized Error type that implements From<Type> and Into<Type: Default>. /// Useful for when you only really care that "some error happened, and I want to use `?` to handle it" #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct SomeError; pub au...
true
80badab3a5632d5466899430f16a9cb7639be7ba
Rust
foxfriends/gmlpp
/src/gmlpp/tokenizer/state.rs
UTF-8
16,630
3.578125
4
[]
no_license
use error::Error; #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum State { Start, // comments SlashSlash, SlashSlashSlash, LineComment, DocComment, SlashStar(u8), SlashStarSlash(u8), SlashStarStar(u8), // numbers Zero, ZeroX, ZeroB, Hex, Bin, Dec, ...
true
3e0d20701cfdf37b86f18bfa36450dfa45c03b38
Rust
dennisss/dacha
/pkg/crypto/src/random.rs
UTF-8
19,238
2.90625
3
[ "Apache-2.0" ]
permissive
use alloc::boxed::Box; use std::f64::consts::PI; use std::num::Wrapping; use std::sync::Arc; use std::vec::Vec; use common::bytes::{Buf, Bytes}; use common::io::Readable; use common::{ceil_div, errors::*}; use executor::sync::Mutex; use file::LocalFile; use math::big::{BigUint, SecureBigUint}; use math::integer::Integ...
true
60f7434b3a2c36018a137dca8c1b124f0dce58f4
Rust
Atul9/sana
/sana_core/src/ir.rs
UTF-8
12,529
3.03125
3
[ "MIT" ]
permissive
use std::{ops::Not, collections::VecDeque}; use crate::automata::{Automata, NodeKind, State}; /// An intermediate representation #[derive(Debug, Clone)] pub struct Ir<T> { pub blocks: Vec<Block<T>> } #[derive(Debug, Clone)] pub enum Block<T> { Block(Vec<Op<T>>), Func(Vec<Op<T>>), } impl<T> Block<T> { ...
true
648ebb66ae8853b70082e45cff1c8602663fb2cb
Rust
tett23/rskk-core
/src/transformers/abbr.rs
UTF-8
6,348
2.765625
3
[ "MIT" ]
permissive
use super::{ AsTransformerTrait, ContinuousTransformer, Displayable, KeyCode, SelectCandidateTransformer, Stackable, StoppedTransformer, Transformable, TransformerTypes, UnknownWordTransformer, WithContext, Word, }; use crate::Context; #[derive(Clone)] pub struct AbbrTransformer { context: Context, stack: Ve...
true
96ae676a879c860cfaeb9ae52c01e49915c099c1
Rust
sathorn6/rust-compress
/src/lz4.rs
UTF-8
23,274
2.703125
3
[ "MIT", "Apache-2.0" ]
permissive
/*! LZ4 Decompression and Compression. Requires `lz4` feature, enabled by default This module contains an implementation in Rust of decompression and compression of LZ4-encoded streams. These are exposed as a standard `Reader` and `Writer` interfaces wrapping an underlying stream. # Example ```rust,ignore use compr...
true
ef369331e0d02abe6eaaa191a347122e35fb2533
Rust
haraldmaida/advent-of-code-2018
/src/day14/mod.rs
UTF-8
8,789
3.875
4
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! # Day 14: Chocolate Charts //! //! You finally have a chance to look at all of the produce moving around. //! Chocolate, cinnamon, mint, chili peppers, nutmeg, vanilla... the Elves must //! be growing these plants to make hot chocolate! As you realize this, you hear //! a conversation in the distance. When you go t...
true
33faa2170dc0c334abd4d9769c1cc8fff67c24dd
Rust
Vzaa/advent_of_code_2019
/day19/src/main.rs
UTF-8
8,883
3.140625
3
[ "Unlicense" ]
permissive
use std::collections::HashMap; use std::convert::{TryFrom, TryInto}; type Pos = (i64, i64); type TileMap = HashMap<Pos, i64>; #[derive(Debug)] enum Mode { Pos, Im, Rel, } #[derive(Debug)] enum Intcode { Add(Mode, Mode, Mode), Mult(Mode, Mode, Mode), In(Mode), Out(Mode), Jit(Mode, Mode...
true
01333d959f4ce4d37227b696131b3169e492c3de
Rust
swerdloj/wgpu-raytracer
/src/application.rs
UTF-8
4,664
2.8125
3
[]
no_license
use sdl2::{ keyboard::{Keycode, KeyboardState, Scancode}, event::{Event, WindowEvent}, mouse::MouseButton, }; use crate::system::{Message, Runnable, SDL2}; use crate::camera::Camera; use crate::raytrace::RayTracer; pub struct ApplicationState { // Application state camera: Camera, relative_mo...
true
ffb602611641af8d32a983c4e1e24c386896aeb3
Rust
teloxide/teloxide
/crates/teloxide-core/src/payloads/create_invoice_link.rs
UTF-8
3,741
2.953125
3
[ "MIT" ]
permissive
//! Generated by `codegen_payloads`, do not edit by hand. use serde::Serialize; use crate::types::LabeledPrice; impl_payload! { /// Use this method to create a link for an invoice. Returns the created invoice link as String on success. #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)] pub CreateInv...
true
6c01f3dc6092b4ded51df198d0544b19576e8d2c
Rust
yysofiyan/naskah
/src/lib.rs
UTF-8
1,426
2.71875
3
[ "MIT" ]
permissive
#[macro_use] extern crate nom; extern crate regex; mod ast; mod parser; mod printer; use parser::parse; use printer::js::print; use std::ffi::CString; use std::mem; use std::os::raw::{c_char, c_void}; fn transpile_to_js(s: String) -> String { let naskah_ast = parse(&s); match naskah_ast { Ok(ast) =>...
true
0f4c26ab62e2e7308d3ac44a5bb5f9b0ba48ff1e
Rust
Arsalankhan1982/Rust_variableprogram
/variables/src/main.rs
UTF-8
225
3.21875
3
[]
no_license
/*fn main() { let mut x = 5; println!("The Value of x is : {}",x); x = 6; println!("The Value of x is : {}",x); }*/ fn main() { for number in (1..4).rev() { println!("{}!", number); } println!("LIFTOFF!!!"); }
true
30726ce2bd56f91bf6fe34980e2b1b6b3aa97d53
Rust
iCodeIN/advent-of-code-3
/crates/core/src/year2015/day15.rs
UTF-8
3,472
3.34375
3
[ "MIT" ]
permissive
use crate::Input; struct Ingredient { capacity: i32, durability: i32, flavour: i32, texture: i32, calories: i32, } fn score_recipe(ingredients: &[Ingredient], teaspoons: &[i32], part2: bool) -> i32 { if teaspoons.iter().sum::<i32>() != 100 { return 0; } let mut capacity = 0; ...
true
de0798313764a7fdeda19c4b8347c2223def1adb
Rust
chatblanc-ciel/openrr
/arci-speak-audio/src/lib.rs
UTF-8
1,762
2.953125
3
[ "Apache-2.0" ]
permissive
use arci::Speaker; use std::{collections::HashMap, fs::File, io, path::Path, path::PathBuf}; use tracing::error; use thiserror::Error; #[derive(Error, Debug)] #[non_exhaustive] pub enum Error { #[error("io: {:?}", .0)] Io(#[from] std::io::Error), #[error("rodio: {:?}", .0)] Decoder(#[from] rodio::deco...
true
0b2ba9e41144f73819463d5e397a3c5ae3f23801
Rust
kakikikki/rust_exercises
/fibonacci/src/main.rs
UTF-8
1,255
3.375
3
[ "MIT" ]
permissive
use std::time::{Instant}; fn main() { for number in (0..51).step_by(10) { // Test simple rec let start = Instant::now(); let result = fibonacci(number); let duration = start.elapsed(); println!("Simple recursion: N: {:<3} Result: {} Time: {:?}", number, result, duration); ...
true
4f245f612a126be7471e919347c1d0f16106655a
Rust
meirce/TicTacToe
/src/tictactoe/minmax.rs
UTF-8
2,142
3.3125
3
[]
no_license
use failure::{err_msg, Error}; use std::collections::HashMap; use super::board::Board; #[derive(Clone, Copy)] struct MoveValue { cell: usize, value: i8, } pub struct Minmax { memory: HashMap<Board, MoveValue> } impl Minmax { pub fn new() -> Self { Minmax {memory: HashMap::new()} } p...
true
23f7fe88f58dbf3c3aa944a3bd096a63e2141594
Rust
BorisWauters/SecureSoftware_imgparser
/src/main.rs
UTF-8
5,216
2.90625
3
[]
no_license
extern crate sdl2; #[macro_use] extern crate simple_error; use std: : error: : Error; use std: : path: : Path; use std: : fs: : File; use std: : io: : {Read, Cursor}; use byteorder:: {LittleEndian, ReadBytesExt}; use std: : fmt; use std: : io: : prelude:: *; use std: : io: ...
true
c82b04237f89c7723f93a1045c030450a660d70a
Rust
gregscott94/gspos-server
/src/main.rs
UTF-8
2,183
2.890625
3
[]
no_license
extern crate ws; extern crate nickel; use std::thread; use std::time; use std::env; use ws::{listen, Handler, Sender, Result, Message, Handshake, CloseCode, Error}; use nickel::{Nickel, Mountable, StaticFilesHandler}; mod youtube; struct Server { out: Sender, } impl Handler for Server { fn on_open(&mut sel...
true
ff67828189d6c0c830be3ce881e876a9604364c1
Rust
svc-excavator-bot-org/conjure-rust
/conjure-http/src/server.rs
UTF-8
11,838
2.578125
3
[ "Apache-2.0" ]
permissive
// Copyright 2019 Palantir Technologies, Inc. // // 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 a...
true
3b21541fb0d7a307c80b771235b5007157ddd8ad
Rust
ravinderj/rush
/src/main.rs
UTF-8
2,606
2.625
3
[]
no_license
extern crate chrono; use std::env; use std::fs::OpenOptions; use std::io::{Error, Write}; use std::os::unix::process::ExitStatusExt; use std::process::{Command, ExitStatus, Stdio, Child}; use rush::builtins::builtins; use rush::input::*; use rush::output::println_err; use rush::rush::Rush; use rush::utils::get_histfi...
true
15a1fd716818b53bc87ed0b02aeb89459750bdba
Rust
maxbannach/Fluid
/src/graph.rs
UTF-8
19,680
3.1875
3
[ "MIT" ]
permissive
use std::collections::{HashSet, HashMap, VecDeque}; use std::mem; use std::sync::atomic::AtomicBool; pub static GLOBAL_ABORT: AtomicBool = AtomicBool::new(false); #[derive(Debug)] pub struct Graph { pub n: usize, // vertices are 0,1,...,n.1 (Some might get removed later on) pub neighbors...
true
8b85b7ccdb4f6f8e5895fb875f560b2921ac3074
Rust
sria91-rlox/rlox-6
/interpreter/src/main.rs
UTF-8
3,140
3.21875
3
[]
no_license
mod token; mod scanner; mod parser; mod interpreter; mod environment; use std::{env, sync::Mutex}; use std::process; use std::io; use std::fs; use std::sync::atomic::{AtomicBool, Ordering}; use interpreter::{Interpreter, RuntimeError}; use token::{Token, TokenType}; use scanner::Scanner; use parser::{ParseError, Pars...
true
9d7ae7eb167206752e9f220ac4b77625f27f6f74
Rust
Aedius/horfimbor
/server/src/domain.rs
UTF-8
701
3.03125
3
[ "MIT" ]
permissive
use crate::error::InvalidResources; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub struct Resources { uranium: usize, steel: usize, gold: usize, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub struct Buildings { ...
true
b7738b30720766392224ed12eb234afd52716e0c
Rust
storyfeet/collide_tree
/src/lib.rs
UTF-8
2,902
3.28125
3
[]
no_license
use std::fmt::Debug; use std::ops::*; pub mod boxes; #[cfg(test)] mod test; pub trait BoundBox: Sized + Clone { ///Split the box in half somehow, normally this should vary in direction fn split(&self) -> (Self, Self); ///Test if one box collides with another. fn hits(&self, b: &Self) -> bool; } pub t...
true
fe28086fff462b5078491e616c5d141452aa0cf5
Rust
oil-lang/oil-rs
/shared/src/asset.rs
UTF-8
2,182
3.1875
3
[ "MIT" ]
permissive
use std::fmt::{self, Debug}; use std::path::Path; use deps::Constructor; use resource::{BasicResourceManager, ResourceId}; #[derive(Debug, Clone)] pub struct FontData; // TODO handle shared images somehow // even in a disgusting way, but something ! // The opengl backend will do it by using the same texture id. #[de...
true
7fb07a318ae4cad2c45d085f90202e980249c2d2
Rust
timmyjose-study/programming-rust-2nd-edition
/chapter2/actix-gcd/src/main.rs
UTF-8
1,361
3.15625
3
[]
no_license
use actix_gcd; use actix_web::{web, App, HttpResponse, HttpServer}; use serde::Deserialize; #[derive(Deserialize)] struct GcdParameters { m: u64, n: u64, } fn main() { let server = HttpServer::new(|| { App::new() .route("/", web::get().to(get_index)) .route("/gcd", web::pos...
true
e6d4f09a2adf6512b42df3809fd56cc9c29f5de3
Rust
manuel-rhdt/mlayout
/src/mathmlparser/error.rs
UTF-8
3,525
2.984375
3
[ "MIT" ]
permissive
use std; use std::fmt; use std::io::prelude::*; #[cfg(feature = "mathml_parser")] use quick_xml::{self, XmlReader}; pub type Result<T> = std::result::Result<T, ParsingError>; #[derive(Debug)] pub struct ParsingError { pub position: Option<usize>, pub error_type: ErrorType, } impl ParsingError { #[cfg(fea...
true
ef2972d2e3ce878ba2f2053b15d2a9f15c537762
Rust
xzfc/ufcs.rs
/src/lib.rs
UTF-8
137
2.59375
3
[ "MIT", "Unlicense" ]
permissive
#![no_std] pub trait Pipe: Sized { fn pipe<R, F: FnOnce(Self) -> R>(self, f: F) -> R { f(self) } } impl<T> Pipe for T {}
true
057a71d35ea1d47a854539e642ed29f3cef68b4a
Rust
jamesrweb/rust-coursework
/05 - Tuples and Arrays/01 - Tuples/main.rs
UTF-8
520
3.265625
3
[]
no_license
fn main() { let tuple_inferred = (220, true, 8.5); println!("{:?}", tuple_inferred); println!("Items by key:"); println!("First item: {}", tuple_inferred.0); println!("Second item: {}", tuple_inferred.1); println!("Third item: {}", tuple_inferred.2); let tuple_typed: (i32, bool, f64) = (123, false, 22.1...
true
75b9f37158ecd8a6cfef7e0cd757376642fc4b4d
Rust
IThawk/rust-project
/rust-master/src/librustc_target/abi/call/x86.rs
UTF-8
4,540
2.640625
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
use crate::abi::call::{ArgAttribute, FnType, PassMode, Reg, RegKind}; use crate::abi::{self, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods}; use crate::spec::HasTargetSpec; #[derive(PartialEq)] pub enum Flavor { General, Fastcall } fn is_single_fp_element<'a, Ty, C>(cx: &C, layout: TyLayout<'a, Ty>) -> b...
true
1f224825e7ec62d3a7d79c30570a16399902c26d
Rust
hn3000/greatest-predictor
/src/lib.rs
UTF-8
8,139
2.515625
3
[]
no_license
use chrono::{Datelike, NaiveDate}; use serde::{Deserialize,Serialize}; use std::iter::Peekable; #[derive(Debug, Deserialize)] pub struct AllocationRecord { #[serde(rename = "DATE")] pub date: NaiveDate, #[serde(rename = "NCBEILQ027S_BCNSDODNS_CMDEBT_FGSDODNS_SLGSDODNS_FBCELLQ027S_DODFFSWCMI")] pub all...
true
f240b72cc965b7baae51e997cceb8abc143d359a
Rust
suyanlongfamily/rust_study
/Study/arry.rs
UTF-8
287
3.796875
4
[]
no_license
fn main() { //定义数组 let mut arrtobj:[i32;3] = [0;3]; arrtobj[1] = 1; arrtobj[2] = 2; assert_eq!([1,2],&arrtobj[1..]);//对数组的引用。 //数组的引用才有迭代器。 for pat in &arrtobj { println!("{}---",pat); } }
true
5593f28e280a311c07d0c40eda53b79b4ea6f841
Rust
elpnt/rust-rtnw
/src/translate.rs
UTF-8
3,920
3.015625
3
[]
no_license
use crate::aabb::AABB; use crate::hitable::{HitRecord, Hitable}; use crate::ray::Ray; use crate::vec3::Vec3; use std::f32::consts::PI; pub struct Translate<H: Hitable> { pub hitable: H, pub offset: Vec3, } impl<H: Hitable> Translate<H> { pub fn new(hitable: H, offset: Vec3) -> Self { Translate { ...
true
a9f618c512704ade4eb53f58df6d37a0aba1f41d
Rust
Mokosha/Regex-Rust
/src/nfa.rs
UTF-8
7,850
3.34375
3
[ "MIT" ]
permissive
use std::collections::HashSet; use expr::Expression; use expr::Character; #[derive(Debug, PartialEq, Clone)] pub enum ExpectedChar { Specific(char), Wildcard, Any(Vec<Character>), None(Vec<Character>) } #[derive(Debug, PartialEq, Clone)] pub enum State { Success, // In order to transition to...
true
02e45dba705021a6f90302a79470f304d8150bac
Rust
icewind1991/warp-real-ip
/src/lib.rs
UTF-8
9,947
2.90625
3
[]
no_license
use ipnetwork::IpNetwork; use rfc7239::{parse, Forwarded, NodeIdentifier, NodeName}; use std::borrow::Cow; use std::convert::Infallible; use std::iter::{once, FromIterator, IntoIterator}; use std::net::{IpAddr, SocketAddr}; use std::str::FromStr; use warp::filters::addr::remote; use warp::Filter; /// Represents a set ...
true
3999b71803bfe31daa051cd06351a5a1f95f5b38
Rust
kokeshiM0chi/BlockMaze
/libsnark-hdsnark/src/subgadget/gen_data/gen_sha256_two_block_data/main.rs
UTF-8
1,147
2.6875
3
[ "MIT" ]
permissive
#![feature(rustc_private)] extern crate rustc; use rustc::util::sha2::{Digest,Sha256}; //use std::u8; //use self::Test::*; fn main() { println!("valid: "); gen(); } fn gen() { let v: Vec<u8> = vec![3, 0, 0, 0, 0, 0, 0, 0]; let sn: Vec<u8> = vec![1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
true
2f5743d779ae38526bff2434a91a78666af5bfd3
Rust
mbrook22yr/logos
/logos/src/lexer.rs
UTF-8
5,022
3.3125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::ops::Range; use crate::source::{Source, ByteArray}; use super::{Logos}; use super::internal::LexerInternal; /// A Lookup Table used internally. It maps indices for every valid /// byte to a function that takes a mutable reference to the `Lexer`, /// reads the input and sets the correct token variant for it. ...
true
5633aec609cd0a4dfe0fe96e74a0afff8b6cdf30
Rust
librespot-org/librespot
/audio/src/decrypt.rs
UTF-8
1,424
2.515625
3
[ "MIT", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
use std::io; use aes::cipher::{KeyIvInit, StreamCipher, StreamCipherSeek}; type Aes128Ctr = ctr::Ctr128BE<aes::Aes128>; use librespot_core::audio_key::AudioKey; const AUDIO_AESIV: [u8; 16] = [ 0x72, 0xe0, 0x67, 0xfb, 0xdd, 0xcb, 0xcf, 0x77, 0xeb, 0xe8, 0xbc, 0x64, 0x3f, 0x63, 0x0d, 0x93, ]; pub struct AudioDec...
true
b8346deb7316b113c53448619cddcaf39a889e7b
Rust
SakaDream/actix-web-rest-api-with-jwt
/src/api/account_controller.rs
UTF-8
17,293
2.515625
3
[ "MIT" ]
permissive
use actix_web::{web, HttpRequest, HttpResponse}; use crate::{ config::db::Pool, constants, error::ServiceError, models::{ response::ResponseBody, user::{LoginDTO, UserDTO}, }, services::account_service, }; // POST api/auth/signup pub async fn signup( user_dto: web::Json<Use...
true
67599042cbcb143251aea523b3da9633ca194b96
Rust
mbilker/kbinxml-rs
/kbinxml/src/value/mod.rs
UTF-8
22,862
2.515625
3
[ "MIT" ]
permissive
use std::borrow::Cow; use std::convert::TryFrom; use std::fmt; use std::io::Cursor; use std::net::Ipv4Addr; use rustc_hex::FromHex; use snafu::ResultExt; use crate::error::{HexSnafu, KbinError, Result}; use crate::node_types::StandardType; use crate::types::{FromKbinBytes, FromKbinString, IntoKbinBytes}; mod array; ...
true
d6ffcd52b234e81073dfd38af9ddcfe220e06fd1
Rust
baitcenter/starship
/src/modules/character.rs
UTF-8
1,450
3.390625
3
[ "ISC" ]
permissive
use super::{Context, Module}; use ansi_term::Color; /// Creates a module for the prompt character /// /// The character segment prints an arrow character in a color dependant on the exit- /// code of the last executed command: /// - If the exit-code was "0", the arrow will be formatted with `COLOR_SUCCESS` /// (green ...
true
1c6c519578e06b49c64df78b8397c8dfab63d581
Rust
adarqui/small-bites
/rust/misc/align.rs
UTF-8
476
2.9375
3
[]
no_license
use std::os; fn align_to(size: uint, align: uint) -> uint { assert!(align != 0); (size + align - 1) & !(align - 1) } fn print_uint(x:uint) { println!("{}",x); } fn main() { let argv = os::args(); let size = from_str::<uint>(argv[1]).unwrap(); // println!("{}",size); let align = from_str::<uint>(argv[...
true
0a697884dcadc9e65cbb6a18086fcdf54e47af5b
Rust
placrosse/experiments
/conditional-batch-write/rust/src/main.rs
UTF-8
7,072
2.703125
3
[ "LicenseRef-scancode-generic-cla", "Apache-2.0" ]
permissive
/* * Copyright 2015 Treode, Inc. * * 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 to...
true
adc963923f6e51e41c840839859e1b72369ecb22
Rust
marco-c/gecko-dev-wordified-and-comments-removed
/third_party/rust/rusqlite/src/types/mod.rs
UTF-8
12,227
2.578125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "LicenseRef-scancode-public-domain" ]
permissive
# ! [ cfg_attr ( feature = " time " doc = r # # " For example to store datetimes as i64 s counting the number of seconds since the Unix epoch : use rusqlite : : types : : { FromSql FromSqlError FromSqlResult ToSql ToSqlOutput ValueRef } ; use rusqlite : : Result ; pub struct DateTimeSql ( pub time : : OffsetDateTime ) ...
true
9ff53f52ccae742d9e4a50ed2383f9c434363a12
Rust
ncatelli/mud
/mud/src/web/event.rs
UTF-8
611
3.046875
3
[]
no_license
extern crate serde; extern crate serde_json; #[derive(Serialize, Deserialize, Debug, Clone)] pub enum EventType { Game, } #[derive(Serialize, Deserialize, Debug)] pub struct Event { event: EventType, message: String, } #[allow(dead_code)] impl Event { #[allow(dead_code)] pub fn new(event: EventTyp...
true
3b8693c714310223e84a274523d1a8c4b0426baf
Rust
bytecodealliance/wasmtime
/cranelift/codegen/src/souper_harvest.rs
UTF-8
26,128
3.21875
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
//! Harvest left-hand side superoptimization candidates. //! //! Given a clif function, harvest all its integer subexpressions, so that they //! can be fed into [Souper](https://github.com/google/souper) as candidates for //! superoptimization. For some of these candidates, Souper will successfully //! synthesize a rig...
true
c5a44995eada26a3f50ef14959b364ca74afa37c
Rust
shreyasdamle/rust_101
/src/ctci_02.rs
UTF-8
1,125
3.90625
4
[ "MIT" ]
permissive
use std::collections::HashMap; pub fn run() { let result = is_permutation("abc", "cba"); println!("Result: {}", result); } //CTCI: Is permutation fn is_permutation(input1: &str, input2: &str) -> bool { if input1.len() != input2.len() { return false; } let count_map_input1 = count_char(inpu...
true
b03cb0d29aff7258f8a8875eedae9c7181fcbcbd
Rust
KeenS/WebAssembler-rs
/src/util.rs
UTF-8
1,992
3.109375
3
[]
no_license
#[inline] pub fn write_uint8(buf: &mut Vec<u8>, u: u8) -> usize { buf.push(u); 1 } #[inline] pub fn write_uint16(buf: &mut Vec<u8>, u: u16) -> usize { let mut size = 0; size += write_uint8(buf, (u & 0xff) as u8); size += write_uint8(buf, ((u >> 8) & 0xff) as u8); size } #[inline] pub fn write_...
true
017b97b3fc23083cf32f4470f62d90f4569c4abf
Rust
alecdwm/advent-of-code
/src/year_2018/day2.rs
UTF-8
5,602
3.859375
4
[]
no_license
//! --- Day 2: Inventory Management System --- //! //! You stop falling through time, catch your breath, and check the screen on the device. "Destination reached. Current Year: 1518. Current Location: North Pole Utility Closet 83N10." You made it! Now, to find those anomalies. //! //! Outside the utility closet, you he...
true
1f8c9cabdc88d7113c1277f9a603aa131c18c019
Rust
nrf-rs/nrf-pacs
/pacs/nrf5340-app-pac/src/cache_s/writelock.rs
UTF-8
4,102
2.578125
3
[ "0BSD" ]
permissive
#[doc = "Register `WRITELOCK` reader"] pub struct R(crate::R<WRITELOCK_SPEC>); impl core::ops::Deref for R { type Target = crate::R<WRITELOCK_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<WRITELOCK_SPEC>> for R { #[inline(always)] fn from(read...
true
c6e7ab01a75b56fdd8294771e02ae57958cb606e
Rust
EarlGray/language-incubator
/js/slothjs/src/parse/mod.rs
UTF-8
30,647
2.953125
3
[ "BSD-3-Clause" ]
permissive
pub mod estree; mod heapnode; mod jsonnode; #[cfg(test)] mod test; use crate::prelude::*; use crate::ast::*; // yes, EVERYTHING. use crate::error::ParseError; use crate::source; use crate::JSON; pub use self::heapnode::HeapNode; type ParseResult<T> = Result<T, ParseError>; /// `ParserContext` collects lexical sco...
true
62be7b9b2c30ebb2ec0913035d07b5191bb185a9
Rust
peterholak/mh_z19b
/examples/raspberry.rs
UTF-8
703
2.71875
3
[ "MIT" ]
permissive
use mh_z19b::mhz19b; use std::time::Duration; use std::thread::sleep; fn main() { let port_name = "/dev/ttyAMA0"; // On Windows with a USB to serial adapter. // let port_name = "COM4"; let mut port = mhz19b::serial::connect(port_name, Duration::from_secs(5)) .expect("Failed to connect."); ...
true
4fd8feab9d860a1d6d83fd8a9fe186c56b558c09
Rust
Feldar99/RustEngine
/math/tests/matrix.rs
UTF-8
29,721
3.40625
3
[]
no_license
extern crate math; extern crate num; #[cfg(test)] mod tests { use math::matrix::Mat4; use math::matrix::Mat3; use math::vector::Vec4; use math::vector::Vec3; use math::vector::Vec2; use num::Zero; use num::One; const EPSILON:f32 = 0.0005; macro_rules! assert_approx_eq { ...
true
36a33115f933c37278d64c4161b64469e646257b
Rust
rust-lang/chalk
/tests/test/discriminant_kind.rs
UTF-8
4,404
2.921875
3
[ "Apache-2.0", "BSD-3-Clause", "bzip2-1.0.6", "LicenseRef-scancode-other-permissive", "NCSA", "MIT", "ISC", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "Unlicense" ]
permissive
use super::*; // Test that user-provided impls of `Discriminantkind` are prohibited #[test] fn no_discriminant_kind_impls() { lowering_error! { program { #[lang(discriminant_kind)] trait DiscriminantKind { type Discriminant; } impl Discrimina...
true
07e9e7410aa4e2c3c9b4bb009ea8c6f842287963
Rust
oro13/rust-algos-practice
/sorting/src/b_rand.rs
UTF-8
974
3.390625
3
[]
no_license
// generate random numbers by storing a large number in curr, // multiplying by another lager number // incrementing that new number // and then taking the modulo, so it remains with a given range // mul inc should be less than the modulo, to save computation // they should be prime, to slow frequency of repeated numbe...
true
304cc565e5c64f9d8a87626144a8460443553dcc
Rust
MichaelAquilina/adventofcode2017
/day1/src/main.rs
UTF-8
1,880
3.546875
4
[]
no_license
extern crate clap; use clap::{Arg, App}; use std::fs::File; use std::io::prelude::*; fn main() { let matches = App::new("Advent of Code 2017 - Day 1") .arg(Arg::with_name("filename") .required(true)) .arg(Arg::with_name("part") .possible_values(&["1", "2"])) .get_...
true
b270488720b475a0c171d09e44c018dd8810f694
Rust
ardwalker/learn-rust
/src/rc.rs
UTF-8
312
3.46875
3
[]
no_license
#[cfg(test)] mod tests { use std::rc::Rc; use std::ops::Mul; #[test] fn simple_rc() { let five = Rc::new(5); assert_eq!(five.mul(5), 25); } #[test] fn rc_pin() { let _five = Rc::new("hello"); // five. // assert_eq!(five.pin(), 25); } }
true
73d439d2cca0e96cad13efe947d878079c0075bf
Rust
ysmiraak/ir-homework
/kmeans/src/bin/kmeans.rs
UTF-8
2,947
2.6875
3
[ "MIT" ]
permissive
// Author: Kuan Yu, 3913893 // Honor Code: I pledge that this program represents my own work. extern crate kmeans; extern crate getopts; extern crate rust2vec; use getopts::Options; use std::fs::File; use std::path::Path; use std::env::args; use std::process::exit; use std::io::{BufReader, BufWriter, Write}; use rus...
true
d237eee3b04da4e239274a70bfebb854f5b5e430
Rust
makadaw/advent-of-code-2020
/src/day22.rs
UTF-8
2,462
3.25
3
[ "MIT" ]
permissive
use std::collections::HashSet; type Deck = Vec<usize>; #[aoc_generator(day22)] pub fn input_generator(input: &str) -> (Deck, Deck) { let decks: Vec<Deck> = input .split("\n\n") .map(|d| d.lines().skip(1).flat_map(str::parse::<usize>).collect()) .collect(); (decks[0].to_vec(), decks[1]....
true
10419ff81fa91529b9cc7565a26cc3e9e61cf9b0
Rust
Hsiaopan/rust_learning
/algo-heapsort/src/main.rs
UTF-8
1,057
3.6875
4
[]
no_license
pub fn heapsort(arr: &mut [i32]) -> &mut [i32] { // -- Heapify part -- // This procedure would build a valid max-heap. // (or min-heap for sorting descendantly) let end = arr.len(); for start in (0..end / 2).rev() { sift_down(arr, start, end - 1); } // -- Sorting part -- // Iter...
true
5ede057063e2056556736a76f372bbba2b55d46e
Rust
udoprog/sysmon-rs
/src/config.rs
UTF-8
6,057
2.578125
3
[ "Apache-2.0" ]
permissive
use serde; use plugin::*; use errors::*; use std::sync::Arc; use std::cell::RefCell; use std::rc::Rc; use std::fs; use std::io::Read; use toml; use num_cpus; use futures_cpupool::*; use tokio_core; use std::time::Duration; pub struct Config { /// Number of threads to configure in thread pool. threads: usize, ...
true
b3a8e539b7ad2cd5f33f62cb33918990e54c1629
Rust
jplevyak/sdk
/src/dfx/src/commands/canister/deposit_cycles.rs
UTF-8
2,803
2.59375
3
[ "Apache-2.0" ]
permissive
use crate::lib::environment::Environment; use crate::lib::error::DfxResult; use crate::lib::identity::identity_utils::CallSender; use crate::lib::models::canister_id_store::CanisterIdStore; use crate::lib::operations::canister; use crate::lib::root_key::fetch_root_key_if_needed; use crate::util::clap::validators::cycle...
true
4b2ba0eba187bfd7315a4b0e2aaf0468efe797b8
Rust
ZhongliGao/memtable-rs
/memtable-core/src/capacity.rs
UTF-8
848
3.515625
4
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
/// Represents the capacity of the list #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde-1", derive(serde::Serialize, serde::Deserialize))] pub enum Capacity { /// Represents a capacity that has a maximum bounds Limited(usize), /// Represents a capacity with n...
true
b945ff90cc63c7aacba870ed588cc940e39ec1df
Rust
caemor/epd-waveshare
/src/epd2in13_v2/command.rs
UTF-8
6,872
2.796875
3
[ "ISC" ]
permissive
//! SPI Commands for the Waveshare 2.13" v2 use crate::traits; extern crate bit_field; use bit_field::BitField; /// Epd2in13 v2 /// /// For more infos about the addresses and what they are doing look into the pdfs #[allow(dead_code)] #[derive(Copy, Clone)] pub(crate) enum Command { DriverOutputControl = 0x01, ...
true
fb06622a0d953880b8045215e89167c33ed45cf8
Rust
ioncodes/thicc
/src/server.rs
UTF-8
2,093
2.65625
3
[]
no_license
use rocket::response::{Redirect, NamedFile}; use rocket::Config; use rocket::config::Environment; use rocket::response::content::Html; use rocket_contrib::json::Json; use rocket_contrib::serve::StaticFiles; use askama::Template; use crate::db::Db; use crate::constants::{PROTOCOL, HOSTNAME, PORT}; use crate::create_temp...
true
0047af285b5e7e7354b94cc8feb95c97142a587d
Rust
rodrimati1992/zeroable_crates
/zeroable_derive/src/repr_attr.rs
UTF-8
2,575
2.828125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use crate::attribute_parsing_shared::with_nested_meta; use quote::ToTokens; use syn::{Meta, NestedMeta}; //////////////////////////////////////////////////////////////////////////////// #[derive(Debug, Copy, Clone, PartialEq)] #[allow(dead_code)] pub(crate) enum ReprAttr { C { integer_repr: bool }, IntegerR...
true
b012cb5891909a401ae35f83aa4100318085b564
Rust
Rolledm/sip-server-rust
/src/logger.rs
UTF-8
1,973
3.484375
3
[]
no_license
use lazy_static::lazy_static; use std::sync::Mutex; use chrono::Utc; use std::fs::File; use std::io::prelude::*; lazy_static! { static ref LOGGER: Mutex<Option<Logger>> = Mutex::new(None); } #[derive(Debug)] pub enum Severity { Debug, Info, Warning, Error, Fatal, } fn severity_to_number(sever...
true
11ef92471a9fb92ace20c121e21ffeb8f90639ec
Rust
Dragoteryx/brainfuck
/src/memory/memory32.rs
UTF-8
1,907
3.203125
3
[]
no_license
use crate::{Args, Error, Memory}; #[derive(Debug)] pub struct Memory32<'a> { memory: Vec<u32>, pointer: u32, args: &'a Args } impl Memory32<'_> { pub fn new<'a>(args: &'a Args) -> Memory32<'a> { Memory32 { memory: vec![0; u32::from(args.memory_size) as usize], pointer: 0, args } } ...
true
e6fbf3e270217994db6821a1356fd7d053786a34
Rust
himlpplm/rust-tdlib
/src/types/input_personal_document.rs
UTF-8
2,161
2.734375
3
[ "MIT" ]
permissive
use crate::errors::*; use crate::types::*; use uuid::Uuid; /// A personal document to be saved to Telegram Passport #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct InputPersonalDocument { #[doc(hidden)] #[serde(rename(serialize = "@extra", deserialize = "@extra"))] extra: Option<String>...
true