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
0cdd9b10db3d4c21f269b2b918e0748ac88c800f
Rust
Kixunil/dont_panic
/src/lib.rs
UTF-8
3,456
3.953125
4
[ "MITNFA" ]
permissive
//! This crate provides macros that look just like `panic!()` but instead of panicking, they cause a //! linking error if their calls are not optimized-out. This can be used to ensure the compiler //! optimizes away some code. //! //! # Example //! //! ```no_compile //! #[macro_use] //! extern crate dont_panic; //! //!...
true
f7ed501cca4c4cfd64bb09e04949f70806dc83d9
Rust
kjn-void/advent-of-code-2019
/src/day22/mod.rs
UTF-8
2,974
3.546875
4
[ "MIT" ]
permissive
use regex::Regex; use super::Solution; type Deck = Vec<u32>; enum Technique { DealIntoNewStack, DealWithIncrement(usize), Cut(isize), } fn deal_into_new_stack(deck: &Deck) -> Deck { deck.iter().rev().map(|&d| d).collect() } fn cut_n(deck: &Deck, n: isize) -> Deck { let cn = if n >= 0 { n...
true
642bf865eeb8ff8ff6e4c871239f55e70aba08cc
Rust
TimLikesTacos/Blackjack
/src/gui_classes/header.rs
UTF-8
1,260
2.59375
3
[ "MIT" ]
permissive
use crate::gui_classes::{BUTTON_H, PADDING}; use crate::Message; use fltk::app::Sender; use fltk::button::Button; use fltk::enums::Align; use fltk::frame::Frame; use fltk::group::{Pack, PackType, Row}; use fltk::prelude::*; #[allow(dead_code)] pub struct GUIHeader { restart: Button, } impl GUIHeader { pub fn ...
true
cb5661375c2e515095d4effc1a7f24f1a11d98c0
Rust
dysinger/rarathon
/src/structs.rs
UTF-8
8,060
2.640625
3
[ "MIT" ]
permissive
#![allow(non_camel_case_types,non_snake_case)] use rustc_serialize::{Decoder, Decodable, Encoder, Encodable}; use std::collections::HashMap; // Mesos types #[derive(RustcDecodable, RustcEncodable, PartialEq, Eq, Debug)] pub enum VolumeMode { RW, RO } #[derive(RustcDecodable, RustcEncodable)] pub struct Volum...
true
88a44d848cbaeeafa2c0505b7de7efe81c5bed36
Rust
HowProgrammingWorks/EventEmitter
/Rust/src/event_emitter.rs
UTF-8
1,700
3.609375
4
[ "MIT" ]
permissive
use std::collections::HashMap; use std::cmp::Eq; use std::hash::Hash; type HandlerPtr<T> = Box<Fn(&T)>; /// Node.js-like event emitter. /// /// # Example /// /// ``` /// # use event_emitter::EventEmitter; /// # /// #[derive(Hash, Eq, PartialEq)] /// enum Event { /// A, /// B, /// } /// /// let mut emitter = E...
true
68b353537a7f7bb09f5a83605350992654afbc3b
Rust
rrika/yvis
/portalvis/src/cluster.rs
UTF-8
3,480
2.8125
3
[]
no_license
pub trait ClusterProcess { type Item: Clone; type ItemEx: Clone + Ord; type Cluster: Clone; // also, must support *a|*b which isn't expressible in current rust type ClusterEx: Clone; fn unit(i: &Self::Item) -> Self::Cluster; fn ex(i: &Self::Item) -> Self::ItemEx; fn ex_score<'a>(ix: &'a Self::ItemEx) -> usize;...
true
732e0921ca2dbed8234f93bd9a23370ee112810d
Rust
miso24/rust_brainfuck
/tests/lexer_test.rs
UTF-8
1,049
3.25
3
[]
no_license
use brainfuck::lexer::{lex, Token, LexError}; #[test] fn lex_simple_code() { let code = ">+-<"; let tokens = lex(code).unwrap(); assert_eq!(tokens, vec![ Token::Less, Token::Plus, Token::Minus, Token::Greater, ]) } #[test] fn lex_complex_code() { let code = ">+++++...
true
bcc89a48c37d9a1153c97fdb5aaf8efeefbaa4ee
Rust
abizzaar/rust-lockfree
/src/main.rs
UTF-8
3,020
3.375
3
[]
no_license
// see blog post of arr_macro here: https://www.joshmcguigan.com/blog/array-initialization-rust/ use arr_macro::arr; use std::sync::atomic::{AtomicI32, Ordering}; fn main() {} struct Entry { pub key: AtomicI32, pub value: AtomicI32, } struct HashTable { pub entries: [Entry; 1000], } impl HashTable { ...
true
f17298de24ed1855d9981c84ab672e280742fb8a
Rust
inda20plusplus/leopoldh-chess
/gui/src/network.rs
UTF-8
2,934
3.21875
3
[]
no_license
use std::io::{Read, Write}; use std::net::{TcpListener, TcpStream}; use std::sync::mpsc; pub struct Network { stream: TcpStream, rx: mpsc::Receiver<(char, char, (i32, i32), (i32, i32))>, } impl Network { pub fn new(address: &str, connect: bool) -> Self { let (tx, rx) = mpsc::channel::<(char, char,...
true
768da8766288c52beaf496c678240f7eda83c496
Rust
eduhenke/yolm
/src/sway.rs
UTF-8
605
2.828125
3
[]
no_license
use std::os::unix::process::CommandExt; use std::process::Command; use users::User; pub fn spawn(user: User) -> Result<(), ()> { // we now try to spawn `/usr/bin/sway` as this user // note that setting the uid/gid is likely to fail if this program is not already run as the // proper user or as root let...
true
5bf6fee62bab70ab416f973cba369d22614d82bb
Rust
Devolutions/picky-rs
/picky-asn1/src/restricted_string.rs
UTF-8
12,549
3.203125
3
[ "Apache-2.0", "MIT" ]
permissive
use serde::{de, ser}; use std::error::Error; use std::fmt; use std::marker::PhantomData; use std::ops::Deref; use std::str::FromStr; // === CharSetError === // #[derive(Debug)] pub struct CharSetError; impl Error for CharSetError {} impl fmt::Display for CharSetError { fn fmt(&self, f: &mut fmt::Formatter<'_>) ...
true
e6fcaa808a380e53f3eb6499b88d1e2c351b7b6d
Rust
katharostech/PolyFS
/src/cli/mount.rs
UTF-8
1,544
2.734375
3
[]
no_license
//! PolyFS `mount` subcommand use crate::cli::config::load_config; use crate::cli::ArgSet; use crate::PolyfsResult; use clap::{App, Arg, SubCommand}; /// Get CLI for the `mount` subcommand pub fn get_cli<'a, 'b>() -> App<'a, 'b> { SubCommand::with_name("mount") .about("Mount the filesystem") .arg(...
true
e316560d43cf3f7af968a0947b6075ddf26d701c
Rust
hobbitalastair/feedutils
/src/feedutil.rs
UTF-8
24,555
2.890625
3
[ "MIT" ]
permissive
extern crate url; extern crate xml; use std::collections::HashMap; use std::env; use std::io; use std::io::{BufWriter, Write, BufReader, BufRead}; use std::fs; use std::fs::OpenOptions; use std::path::PathBuf; use std::process::{Command, ExitStatus}; use std::thread; use std::time; use chrono::DateTime; use thiserror...
true
cd3404ab46ac34c27bdd7408a78a9ccc6fa0441f
Rust
Mic92/cntr
/src/dotcntr.rs
UTF-8
2,419
2.640625
3
[ "MIT" ]
permissive
use libc::pid_t; use nix::fcntl::{self, OFlag}; use nix::sys::stat; use nix::unistd::Pid; use simple_error::try_with; use std::fs::{self, File}; use std::io::prelude::*; use std::os::unix::prelude::*; use std::{ fs::{set_permissions, Permissions}, os::unix::fs::PermissionsExt, }; use crate::capabilities; use c...
true
8f00aa5836fd9993cd9c12c0f6a69226114564d8
Rust
feifeigd/rust
/slog_demo/src/player.rs
UTF-8
707
2.765625
3
[]
no_license
use super::weapon::PlasmaCannon; use slog::Logger; use crate::PlayingCharacter; // use weapon::PlasmaCannon; pub struct Player { name: String, logger: Logger, weapon: PlasmaCannon, } impl Player { pub fn new(logger: &Logger, name: &str) -> Self { let player_log = logger.new(o!("Player"=>form...
true
a37c5eb4035693d5f5f336b42db290c4ff230180
Rust
emberian/spaceapi-server-rs
/tests/lib.rs
UTF-8
1,937
2.703125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern crate spaceapi_server; use std::net::Ipv4Addr; use std::net::TcpStream; use std::io::ErrorKind; use spaceapi_server::SpaceapiServer; use spaceapi_server::api; use spaceapi_server::api::optional::Optional; /// Create a new status object containing test data. fn get_status() -> api::Status { api::Status::n...
true
ebc0bb4a2d2d00e3054ce0053f5654c5228d9a8d
Rust
pete21/tickgrinder
/util/src/transport/command_server.rs
UTF-8
18,300
3.03125
3
[ "MIT" ]
permissive
//! Internal server that accepts raw commands, queues them up, and transmits //! them to the Tick Processor asynchronously. Commands are re-transmitted //! if a response isn't received in a timout period. //! //! Responses from the Tick Processor are sent back over the commands channel //! and are sent to worker proce...
true
ec02366102dfc606a33a98441c03539482543944
Rust
icefoxen/lang
/rust/old/match.rs
UTF-8
319
3.1875
3
[ "MIT" ]
permissive
enum OptionalInt { Value(int), Missing } fn main() { let x = Value(5); let y = Missing; match x { Value(n) => println!("Value is {:d}", n), Missing => println!("Value is missing"), } match y { Value(n) => println!("Value is {:d}", n), Missing => println!("Value is missing"), } }
true
0c736e11a4aa034d5690a1631ca48893cb1b3b83
Rust
dalalsunil1986/Methylenix
/src/kernel/drivers/acpi/table/xsdt.rs
UTF-8
8,202
2.609375
3
[ "Apache-2.0" ]
permissive
//! //! Extended System Description Table //! //! This manager contains the information about Extended System Description Table(XSDT). //! XSDT is the list of tables like MADT. use super::bgrt::BgrtManager; use super::dsdt::DsdtManager; use super::fadt::FadtManager; use super::madt::MadtManager; use crate::kernel::dri...
true
2bc8ffb7d90c2ab6ff60138d445b7d1d0c7b69c0
Rust
tomgrean/stardict
/src/main.rs
UTF-8
18,755
2.921875
3
[ "MIT" ]
permissive
extern crate regex; pub mod dict; pub mod dictionary; pub mod idx; pub mod ifo; pub mod reformat; pub mod result; pub mod syn; //pub mod web; use self::regex::bytes::Regex; use std::cmp::Ordering; use std::io::prelude::*; use std::iter::Iterator; use std::mem; use std::net::TcpListener; use std::net::TcpStream; use s...
true
d311a0c03217f8e1b597cf3c089f5f285895632b
Rust
gvissers/babs
/src/ubig/cmp.rs
UTF-8
2,712
3.15625
3
[ "Apache-2.0" ]
permissive
// Copyright, 2021, Gé Vissers // // 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 in ...
true
5b2d3888fbe7e7752c1625b091896aba603d9d6e
Rust
joshhansen/Fil
/src/in_/term.rs
UTF-8
6,883
2.796875
3
[]
no_license
use std::collections::{HashMap,VecDeque}; use std::io::{Write,stdout}; use cv::Mat; use cv::highgui::{WindowFlags,highgui_named_window}; use cv::videoio::{CapProp,VideoCapture}; use rand; use rand::distributions::{IndependentSample, Range}; use super::super::util::{MovingAvg,MostFrequent}; const FPS: u8 = 60; const...
true
141a29bb2391384d1f0b6fac82a00eab5484c033
Rust
huin/accountmerge
/src/rules/cmd.rs
UTF-8
1,433
2.75
3
[]
no_license
use anyhow::Result; use clap::{Args, Subcommand}; use crate::filespec::{self, FileSpec}; use crate::internal::TransactionPostings; use crate::rules::processor::TransactionProcessorFactory; #[derive(Debug, Args)] pub struct Command { // The engine to interpret the rules as. #[command(subcommand)] engine: E...
true
fa464abe0d42c0466c522f97c76fd4c48c666031
Rust
justinpombrio/synless
/language/src/ast/ast_forest.rs
UTF-8
2,501
3.171875
3
[]
no_license
use super::ast::{Ast, Id, NodeData}; use super::ast_ref::AstRef; use super::text::Text; use crate::language::LanguageSet; use crate::language::{Arity, ConstructId, Grammar}; use forest::Forest; /// All [`Asts`] belong to an `AstForest`. /// /// It is your responsibility to ensure that `Ast`s are kept with the forest t...
true
7d78a8eff148c5cce26528d09151268fafa19df8
Rust
tcharding/self_learning
/rust/rust-book/add/add-one/src/lib.rs
UTF-8
405
3.9375
4
[]
no_license
use rand; /// Adds one to the given number. /// /// # Example /// /// ``` /// let x = 5; /// let result = add_one::add_one(x); /// /// assert_eq!(result, 6); /// ``` pub fn add_one(x: i32) -> i32 { x + 1 } #[cfg(test)] mod tests { use super::*; #[test] fn it_works() { assert_eq!(2 + 2, 4); ...
true
970e4bfc4cd6c634e6b4462dd274ef28822ac1b3
Rust
Velrok/the-rust-programming-language-book
/ownership/src/main.rs
UTF-8
4,406
3.984375
4
[ "Unlicense" ]
permissive
// Keep these rules in mind as we work through the examples that illustrate them: // ----------------------- // 1. Each value in Rust has a variable that’s called its owner. // 2. There can be only one owner at a time. // 3. When the owner goes out of scope, the value will be dropped. fn main() { simple_example();...
true
8239396f3faa8a8316266eed195d92660eb0acaf
Rust
stec-zcps/rperf
/src/server_udp.rs
UTF-8
2,424
2.578125
3
[ "Apache-2.0" ]
permissive
/*<copyright file="server_udp.rs" company="Fraunhofer Institute for Manufacturing Engineering and Automation IPA"> Copyright 2021 Fraunhofer Institute for Manufacturing Engineering and Automation IPA Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the...
true
36c814398e869cce47d7a1203241b5a889369a7f
Rust
ChristophHaag/wyvern
/src/algebra/vector.rs
UTF-8
16,059
3.015625
3
[ "BSD-3-Clause" ]
permissive
// Copyright (c) 2016-2017 Bruce Stenning. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of co...
true
6b424a4a26a6937d3fea616049e9d2bd4fb51aa1
Rust
noocene/core-futures-io
/src/ext/read/take.rs
UTF-8
1,681
2.546875
3
[]
no_license
use crate::AsyncRead; use _futures::ready; use core::{ mem::MaybeUninit, pin::Pin, task::{Context, Poll}, }; use pin_project_lite::pin_project; pin_project! { #[derive(Debug)] #[must_use = "streams do nothing unless you `.await` or poll them"] #[cfg_attr(docsrs, doc(cfg(feature = "io-util")))]...
true
39366e8179ad610d5aa3ed932528c83d1d1a946f
Rust
nolanderc/advent-of-code
/2020/day-5/part-1/src/main.rs
UTF-8
997
3.453125
3
[]
no_license
fn main() { std::io::BufRead::lines(std::io::stdin().lock()) .map(Result::unwrap) .map(|line| { let mut splits = line.chars().map(|ch| match ch { 'F' | 'L' => Split::Low, 'B' | 'R' => Split::High, _ => panic!("not a valid partition: {:?}", ...
true
ad29a21d0934341fc588eaf9cd4d31ad49f1972f
Rust
primitiv/primitiv-rust
/primitiv-derive/src/lib.rs
UTF-8
15,148
2.53125
3
[ "Apache-2.0" ]
permissive
extern crate proc_macro; extern crate proc_macro2; extern crate syn; #[macro_use] extern crate quote; use proc_macro2::{Span, TokenStream}; use syn::punctuated::Punctuated; use syn::token::Comma; use syn::*; // TODO(chantera): support generics // // ```rust // struct ModelImpl<T>(T); // // impl Model for Modelmpl<Par...
true
6b9474831a255ec47cf27f937e36d4a57efa0c45
Rust
rune-rs/rune
/crates/rune/src/runtime/guarded_args.rs
UTF-8
1,504
2.890625
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::runtime::{Stack, UnsafeToValue, VmResult}; /// Trait for converting arguments onto the stack. /// /// This can take references, because it is unsafe to call. And should only be /// implemented in contexts where it can be guaranteed that the references will /// not outlive the call. pub trait GuardedArgs { ...
true
5f049777e884b9c507b45678a15d558e8f05f1c7
Rust
Tamiyo/Mango
/src/bytecode/constant.rs
UTF-8
496
2.796875
3
[]
no_license
/// Defines the 'Constants' to be used within the Compiler. /// /// These are constants that the Compiler comes by during it's compilation phase, /// and they get stored in the Constant Pool for later use. use crate::bytecode::distance::Distance; use string_interner::Sym; use crate::compiler::class::Class; use crate::...
true
20237af79e3c6ac49a3a71c2a1310049b4b215cc
Rust
inferiorhumanorgans/crc-rs
/benches/bench.rs
UTF-8
818
2.546875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![feature(test)] extern crate crc; extern crate test; use crc::{crc32, crc64}; use test::Bencher; #[bench] fn bench_crc32_make_table(b: &mut Bencher) { b.iter(|| crc32::make_table(crc32::IEEE, true)); } #[bench] fn bench_crc32_update_megabytes(b: &mut Bencher) { let table = crc32::make_table(crc32::IEEE, tr...
true
a379b362dcacb86df8a66092865dd2698276d2b7
Rust
lucadonnoh/pathfinder
/crates/pathfinder/src/rpc/types.rs
UTF-8
58,973
2.78125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Data structures used by the JSON-RPC API methods. use crate::core::{StarknetBlockHash, StarknetBlockNumber}; use serde::{Deserialize, Serialize}; /// Special tag used when specifying the `latest` or `pending` block. #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] #[serde(deny_unknown_fields)] ...
true
0e60fa8c90e85d9107ac2c3fa3c8e925936dd1d7
Rust
hamadakafu/kyopro
/src/bin/abc210c.rs
UTF-8
671
2.515625
3
[]
no_license
use std::cmp::{max, min}; use std::collections::{HashMap, HashSet}; use itertools::Itertools; use whiteread::parse_line; fn main() { let (n, k): (usize, usize) = parse_line().unwrap(); let cc: Vec<usize> = parse_line().unwrap(); let mut m = HashMap::new(); for i in 0..k { let e = m.entry(cc[i]...
true
828ab097cc6979e51c904d6ae6bbcce9c9b50502
Rust
amgarrett09/discord-chatbot
/src/types/module_status.rs
UTF-8
1,082
3.125
3
[]
no_license
use std::error; use std::fmt; use std::str::FromStr; #[derive(Clone, Copy)] pub enum ModuleStatus { Enabled, Disabled, } impl ToString for ModuleStatus { fn to_string(&self) -> String { match self { ModuleStatus::Enabled => "enabled".to_string(), _ => "disabled".to_string()...
true
4f43f26eb5bd6d797ea7c2b8248a812a6d5ced36
Rust
davhogan/RestaurantTheGame
/src/ui/simulator/restaurant/menu_item.rs
UTF-8
2,444
3.625
4
[ "MIT" ]
permissive
// Copyright © 2019 David Hogan // [This program is licensed under the "MIT License"] // Please see the file COPYING in the source // distribution of this software for license terms. // The following code is used to represent a menu item at the restaurant. // A menu item has a name, price, quality and an inventory. //...
true
65d3d76117e10c6b4dcfc88aa1b8e7c5f03712a9
Rust
ThomasZumsteg/project-euler
/common.rs
UTF-8
8,393
3.1875
3
[]
no_license
extern crate clap; use clap::ArgMatches; use env_logger::Builder; use log::{info, LevelFilter}; use std::collections::HashSet; use std::io::Write; pub fn set_log_level(args: &ArgMatches) -> LevelFilter { let log_level = match args.occurrences_of("verbose") { 0 => LevelFilter::Off, 1 => LevelFilter...
true
fcd4d23562836037891d2dc5f50ef322efc9e3be
Rust
oOBoomberOo/rna
/src/util.rs
UTF-8
2,554
2.984375
3
[]
no_license
use std::path::PathBuf; use std::fs; use serde_json as js; use serde::{Serialize, Deserialize}; #[derive(Serialize, Deserialize)] struct MetaFormat { compiler_options: Option<Vec<CompilerOption>> } #[derive(Serialize, Deserialize)] struct CompilerOption { name: String } /// Shorthand for `Result<(), MetaError>` pu...
true
400e486cd678372482c6aeed96ca6ef1cefc183b
Rust
flada-auxv/graph-node
/graph/src/components/query.rs
UTF-8
299
2.640625
3
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer", "MIT" ]
permissive
use futures::sync::mpsc::Sender; use data::query::Query; /// Common trait for query runners that run queries against a [Store](../store/trait.Store.html). pub trait QueryRunner { // Sender to which others can write queries that need to be run. fn query_sink(&mut self) -> Sender<Query>; }
true
6331af272cba2251681c7db445461046d333517b
Rust
Byron/gitoxide
/gix/src/reference/log.rs
UTF-8
1,274
2.78125
3
[ "MIT", "Apache-2.0" ]
permissive
//! use gix_object::commit::MessageRef; use gix_ref::file::ReferenceExt; use crate::{ bstr::{BStr, BString, ByteVec}, Reference, }; impl<'repo> Reference<'repo> { /// Return a platform for obtaining iterators over reference logs. pub fn log_iter(&self) -> gix_ref::file::log::iter::Platform<'_, '_> { ...
true
4d13611f3077cc271e786c6cac3f75e9cd531500
Rust
Nazek42/krisp
/src/builtins.rs
UTF-8
11,522
2.90625
3
[ "MIT" ]
permissive
#![allow(non_snake_case)] use bacon_rajan_cc::Cc; use std::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Rem, Shl, Shr, Sub}; use std::iter::once; use std::collections::HashMap; use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; use crate::expr::*; use crate::interpreter::Namespace; use crate:...
true
6262cde677e34eabaccfa9a375d455ac26960991
Rust
dtamai/aoc
/2020/src/bin/05.rs
UTF-8
1,507
3.546875
4
[ "Unlicense" ]
permissive
fn main() -> eyre::Result<()> { let passes = passes()?; let ids = passes.into_iter().map(|p| seat_id(&p)); // first part let max = ids.clone().max().unwrap(); println!("Max seatID = {}", max); // second part let mut sorted = ids.collect::<Vec<i32>>(); sorted.sort_unstable(); let fi...
true
7b87494e9dc1cdc938afd86f2753c3727f4f8273
Rust
rust-lang/rust
/src/tools/unicode-table-generator/src/cascading_map.rs
UTF-8
3,497
2.578125
3
[ "Apache-2.0", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
use crate::fmt_list; use crate::raw_emitter::RawEmitter; use std::collections::HashMap; use std::fmt::Write as _; use std::ops::Range; impl RawEmitter { pub fn emit_cascading_map(&mut self, ranges: &[Range<u32>]) -> bool { let mut map: [u8; 256] = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
true
331cd57826ee0411246facf691b5ed13deb55a51
Rust
WisartArfun/Divisionaries
/src/logger/mod.rs
UTF-8
1,644
3.234375
3
[]
no_license
//! Configures and manages the logging. use log; use log4rs; /// Initializes the root logger from the rust log crate using a config file. /// /// This is done with a config file. It uses the `log` crate, /// which is a lightweight logging facade, and `log4rs` crate, /// which is inspired by the java log4j library. //...
true
293b2e8a246a2d0edf2959c791b6a3a79c4cd0ad
Rust
thibault-ml/lfw-solver
/src/lfw/graph.rs
UTF-8
5,852
3.125
3
[ "Unlicense" ]
permissive
extern crate serde_json; use self::serde_json::Error as JsonError; use self::serde_json::Value as JsonValue; use self::serde_json::from_value as parse_json_value; use std::collections::BTreeMap; use std::collections::HashSet; use std::error; use std::fmt; use std::iter::FromIterator; use std::ops::Index; pub const ...
true
4a177d41d0c1b2e4e7e4b76180488d4f1bd6c384
Rust
stuij/thalgar
/src/common.rs
UTF-8
1,948
3.828125
4
[]
no_license
pub trait MemAccess { fn read_mem(src: &[u8], addr: usize) -> Self; fn write_mem(src: &mut [u8], addr: usize, val: Self); } impl MemAccess for u8 { fn read_mem(src: &[u8], addr: usize) -> u8 { src[addr] } fn write_mem(src: &mut [u8], addr: usize, val: u8) { src[addr] = val; } ...
true
284ca9970884b44c3691ad75d28731887debf1fe
Rust
lallotta/chip8-wasm
/src/cpu.rs
UTF-8
10,423
2.875
3
[]
no_license
use crate::display::{Display, FONT_SET}; use crate::keypad::Keypad; pub struct Cpu { pub memory: [u8; 4096], pub v: [u8; 16], pub i: u16, // program counter pub pc: u16, pub stack: [u16; 16], // stack pointer pub sp: u8, pub display: Display, pub keypad: Keypad, pub draw_fla...
true
0b979349557d3f40b7431b233f596976fa7659ce
Rust
jwarwick/aoc_2018
/device/src/lib.rs
UTF-8
13,330
3.3125
3
[ "MIT" ]
permissive
type Instruction = (OpCode, i64, i64, i64); type Registers = [i64; 6]; use std::collections::HashSet; #[derive(Debug, Clone)] enum OpCode { Nop, AddR, AddI, MulR, MulI, BanR, BanI, BorR, BorI, SetR, SetI, GtRI, GtIR, GtRR, EqRI, EqIR, EqRR, } #[derive(Debug)] pub struct Device { r...
true
e86593eaa5a8c911dd0f02193c86d3658dc76dab
Rust
studylessshape/qcpro
/src/addition/string_addition.rs
UTF-8
1,482
3.328125
3
[]
no_license
use std::fs; /// Get the first index by pattern fn first_index(s: &String, pattern: &str) -> Option<usize> { let matched_pattern : Option<_> = s.match_indices(pattern).next(); if let Some((index, _)) = matched_pattern { Some(index) } else { None } } /// Get the project name for file co...
true
4d7de8e1c5346b16992c14779822e237d114a73f
Rust
PsypherPunk/advent-of-code
/2017/08/src/main.rs
UTF-8
413
2.796875
3
[ "BSD-3-Clause" ]
permissive
use std::fs; use ::day08::*; fn main() { let input = fs::read_to_string("input.txt").expect("Error reading input.txt"); let cpu = get_cpu(&input); println!( "What is the largest value in any register…? {}", &cpu.registers.values().max().unwrap(), ); println!( "…the highe...
true
1d2aebde7cbe81b575f1c642fd4c875f9a1fb054
Rust
niconicoj/amethyst-physics
/src/resources/context.rs
UTF-8
724
2.609375
3
[]
no_license
use serde::Deserialize; use ron::de::from_reader; use std::error::Error; use std::fs::File; use std::io::BufReader; use std::path::Path; #[derive(Clone, Copy, Deserialize)] pub struct Context { pub map_width: f32, pub map_height: f32, pub scale: f32, } impl Default for Context { fn defa...
true
c2d084763900cca75d0adf0df38fbe673e997090
Rust
mmstick/redox
/libstd/src/path.rs
UTF-8
1,396
3.203125
3
[ "MIT" ]
permissive
use fmt; use mem; use core_collections::borrow::{Cow, IntoCow}; use string::String; pub struct Display<'a> { string: &'a str } impl<'a> fmt::Display for Display<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.string) } } pub struct Path { pub inner: str, } i...
true
febe9f59017fb1bf705b2ef4e2881e1a8cf5a9ef
Rust
creativcoder/forest
/utils/bitfield/src/rleplus/mod.rs
UTF-8
7,733
2.875
3
[ "MIT", "Apache-2.0" ]
permissive
// Copyright 2020 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT //! # RLE+ Bitset Encoding //! //! (from https://github.com/filecoin-project/specs/blob/master/src/listings/data_structures.md) //! //! RLE+ is a lossless compression format based on [RLE](https://en.wikipedia.org/wiki/Run-length_encoding)...
true
9d324fa13610dda80e0e602b3686f5a6385dec8d
Rust
amadeusine/pdbtbx
/src/structs/atom.rs
UTF-8
28,144
2.859375
3
[ "MIT" ]
permissive
#![allow(dead_code)] use crate::reference_tables; use crate::structs::*; use crate::transformation::*; use doc_cfg::doc_cfg; use std::cmp::Ordering; use std::fmt; use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering}; static ATOM_COUNTER: AtomicUsize = AtomicUsize::new(0); /// A struct to represent a singl...
true
54863df2e06c1ececb137785d93d84ba7487321f
Rust
osenft/manticore
/src/crypto/ring/rsa.rs
UTF-8
5,882
2.65625
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
// Copyright lowRISC contributors. // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 //! Implementations of [`crypto::rsa`] based on `ring`. //! //! Requires the `std` feature flag to be enabled. use ring::error::Unspecified; use ring::signature::KeyPai...
true
777be5e5fa569791a232954e07606437afdd8ba6
Rust
pnowojski/gravity
/src/models/player.rs
UTF-8
3,021
2.859375
3
[]
no_license
use graphics::{Context, rectangle, polygon, Transformed}; use opengl_graphics::GlGraphics; use color; use geom; use geom::Direction; use piston::window::Size; use super::GameObject; use super::PhysicalObject; const PLAYER_SPEED: f64 = 200_000_000.0; const PLAYER_SIZE: f64 = 20.0; // Drift for this long after movement...
true
76e97b4341fb1b1340686d4cd87a0a865bca0a24
Rust
kroeckx/ruma
/crates/ruma-common/src/directory.rs
UTF-8
9,496
2.84375
3
[ "MIT" ]
permissive
//! Common types for room directory endpoints. use std::fmt; use js_int::UInt; use ruma_identifiers::{MxcUri, RoomAliasId, RoomId}; use ruma_serde::Outgoing; use serde::{ de::{Error, MapAccess, Visitor}, ser::SerializeStruct, Deserialize, Deserializer, Serialize, Serializer, }; use serde_json::Value as Js...
true
39f6275d17a30edb3da3989ec7636ceda4cbe596
Rust
xpeerchain/xpeerchain
/network/src/protocols/direct_send/mod.rs
UTF-8
11,703
2.578125
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The XPeer Core Contributors // SPDX-License-Identifier: Apache-2.0 //! Protocol for fire-and-forget style message delivery to a peer //! //! DirectSend protocol takes advantage of [muxers] and [substream negotiation] to build a simple //! best effort message delivery protocol. Concretely, //! //! 1. E...
true
7ee172d6456d981848e047e78e7d91d07986b42f
Rust
yutopp/erl_tokenize
/examples/tokenize.rs
UTF-8
824
2.546875
3
[ "MIT" ]
permissive
extern crate clap; extern crate erl_tokenize; #[macro_use] extern crate trackable; use std::fs::File; use std::io::Read; use clap::{App, Arg}; use erl_tokenize::Tokenizer; fn main() { let matches = App::new("tokenize") .arg(Arg::with_name("SOURCE_FILE").index(1).required(true)) .get_matches(); ...
true
b21d4c387182f2d7844bb98ff05d7c7f3c879726
Rust
BrianOn99/matasano-crypto-challenges
/src/set1/challenges.rs
UTF-8
1,216
3.140625
3
[ "BSD-2-Clause" ]
permissive
use super::*; use hex::FromHex; extern crate base64; // challenge1 #[test] fn test_hex_to_base64() { fn hex_to_base64(src: &str) -> String { let decoded = Vec::from_hex(src).expect("invalid hex string"); base64::encode(&decoded) } assert_eq!( hex_to_base64("49276d206b696c6c696e672...
true
95be0256183ca283d1631075a1365f001a68c5c6
Rust
exonum/exonum
/components/merkledb/tests/migration.rs
UTF-8
14,175
2.734375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! This test checks that migration works properly: //! //! - Migrated indexes are properly aggregated during and after migration //! - Migrated data is correctly added / replaced / removed after merge //! - Migration rollbacks work properly //! //! **NB.** For performance, some tests initialize the database outside th...
true
5e37fca649dc5ec29b43f6019c2f61664f0d5b5f
Rust
DLR-FT/a653rs
/src/apex/types.rs
UTF-8
7,426
2.921875
3
[ "MIT", "Apache-2.0" ]
permissive
/// ARINC653 types pub mod basic { /// According to ARINC653-P1, the maximum name length is always 32 pub const MAX_NAME_LENGTH: usize = 32; /// Apex internal ReturnCode Type pub type ReturnCode = u32; pub type ApexName = [u8; MAX_NAME_LENGTH]; // Base Types pub type ApexByte = u8; pub ...
true
5033765e20b5e84d23fa41aaa548875a3d8abfdf
Rust
AntyMew/livesplit-core
/src/run/run_metadata.rs
UTF-8
3,444
3.59375
4
[ "MIT", "Apache-2.0" ]
permissive
use indexmap::map::{IndexMap, Iter}; /// The Run Metadata stores additional information about a run, like the /// platform and region of the game. All of this information is optional. #[derive(Default, Clone, Debug, PartialEq)] pub struct RunMetadata { run_id: String, platform_name: String, uses_emulator: ...
true
67575a6f6f1ad10645144cdc920e9d294a7f5c15
Rust
bk-rs/rust-io-peek
/futures-util-io-peek/tests/cursor.rs
UTF-8
731
2.84375
3
[ "MIT", "Apache-2.0" ]
permissive
use futures_executor::block_on; use futures_util::io::{AsyncReadExt as _, Cursor}; use futures_util_io_peek::AsyncPeekExt as _; #[test] fn sample() -> Result<(), Box<dyn std::error::Error>> { block_on(async { let mut cursor = Cursor::new(vec![1, 2, 3]); let mut buf = vec![0; 5]; let n = c...
true
f338169dc30e89dcbbaf434cfa476ad10039193b
Rust
pfeyz/learners
/src/domain.rs
UTF-8
9,316
2.65625
3
[]
no_license
extern crate csv; extern crate rand; use std::mem; use rand::{Rng}; use rand::distributions::{Range, Sample}; use std::error::Error; use std::collections::{HashSet, HashMap}; use sentence::{SurfaceForm, Illoc}; pub const NUM_PARAMS: usize = 13; pub type Grammar = u16; pub type Sentence = u32; pub type TriggerVec = [...
true
d823b99b6f413711fe728464945bad67296834be
Rust
Journeycorner/advent-of-code
/aoc18/src/main.rs
UTF-8
6,375
3.21875
3
[ "MIT", "Unlicense" ]
permissive
use std::error::Error; use std::fmt; use std::io::{self, Read, Write}; use std::mem; use std::result; use std::str::{self, FromStr}; macro_rules! err { ($($tt:tt)*) => { Err(Box::<Error>::from(format!($($tt)*))) } } type Result<T> = result::Result<T, Box<Error>>; fn main() -> Result<()> { let mut input = Str...
true
d5c03ebf4f14123685a9f4b5a40ac7b25da41ed1
Rust
xaviripo/aoc2020
/src/day22.rs
UTF-8
522
2.5625
3
[]
no_license
pub mod part1; pub mod part2; use std::collections::VecDeque; pub const INPUT_FILE: &str = "input/22.txt"; fn parse<T: Iterator<Item=String>>(mut lines: T) -> (VecDeque<usize>, VecDeque<usize>) { let deck1: VecDeque<usize> = lines .by_ref() .take_while(|line| line != "") .skip(1) .map(|line| lin...
true
66c32c8f5595e5cfe0c341b86f158570597b4b1e
Rust
Joey9801/igc-rs
/src/util/manufacturer.rs
UTF-8
4,632
3.015625
3
[ "MIT" ]
permissive
#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[cfg_attr( feature = "serde", derive(Deserialize, Serialize), serde(rename_all = "lowercase") )] pub enum Manufacturer<'a> { Aircotec, CambridgeAeroInstruments, ClearNavInstruments, ...
true
977f0a0bd42482a2df8797b8b173b3f691b91972
Rust
alexmeli100/pbrt-rust
/src/core/pbrt.rs
UTF-8
6,814
2.78125
3
[ "MIT", "Apache-2.0" ]
permissive
use std::ops::{Sub, Add, Mul, BitAnd}; use num::{One, Zero}; use num::traits::Pow; use std::sync::{Arc, Weak}; use std::path::PathBuf; use lazy_static::lazy_static; use indicatif::ProgressBar; use parking_lot::RwLock; lazy_static! { static ref PB: RwLock<Option<Weak<ProgressBar>>> = RwLock::new(None); } pub fn s...
true
2953aef49047961bc513f3565f6a3e4a34343cf4
Rust
brayden-marshall/Logo
/src/lib.rs
UTF-8
2,435
3.5
4
[]
no_license
mod command; mod error; mod evaluator; mod lexer; mod parser; use error::LogoError; use evaluator::Evaluator; use lexer::Lexer; use parser::Parser; // re-exports pub use evaluator::Instruction; pub use command::Command; /// Exposed type that acts as the interface to the library. pub struct Interpreter { evaluato...
true
6a2e32a64c567108c82bce065b2e701ecbb5025a
Rust
adriano-moreira/benchmark
/rust_project/src/nothing.rs
UTF-8
99
2.8125
3
[]
no_license
pub fn exec() { let value = 2 + 2; if value == 5 { print!("value is five") } }
true
40a75e1d0b640fc2443db87d3ecf2862476a4328
Rust
bevyengine/bevy
/examples/stress_tests/many_glyphs.rs
UTF-8
2,571
2.984375
3
[ "Apache-2.0", "MIT", "Zlib", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive" ]
permissive
//! Simple text rendering benchmark. //! //! Creates a `Text` with a single `TextSection` containing `100_000` glyphs, //! and renders it with the UI in a white color and with Text2d in a red color. //! //! To recompute all text each frame run //! `cargo run --example many_glyphs --release recompute-text` use bevy::{ ...
true
31b949bef1c67805c2c6c3d862b2e5abdae85a9a
Rust
dgreid/crosvm
/fuse/src/filesystem.rs
UTF-8
51,652
2.640625
3
[ "BSD-3-Clause" ]
permissive
// Copyright 2019 The Chromium OS 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 std::convert::TryInto; use std::ffi::CStr; use std::fs::File; use std::io; use std::mem; use std::time::Duration; use crate::sys; use crate::serv...
true
8de04fd4c6c48f64fdb89648ea0561cc57aa24c7
Rust
JRAndreassen/graph-rs
/examples/rocket_open_id_code.rs
UTF-8
3,423
2.828125
3
[ "MIT" ]
permissive
#![feature(proc_macro_hygiene, decl_macro)] #![feature(plugin)] #[macro_use] extern crate rocket; #[allow(unused_imports)] #[macro_use] extern crate serde_json; extern crate reqwest; use from_as::*; use graph_rs::oauth::{IdToken, OAuth}; use rocket::Data; use rocket_codegen::routes; use std::convert::TryFrom; use std::...
true
e4cba87328af31e822bd467ed96ac8718710745c
Rust
iotaledger/iota.rs
/types/src/api/plugins/participation/error.rs
UTF-8
667
2.578125
3
[ "Apache-2.0" ]
permissive
// Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 #[derive(Debug)] pub enum Error { /// Invalid participations error InvalidParticipations, /// IO error Io(std::io::Error), } impl core::fmt::Display for Error { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Resu...
true
94f6cac5c52c9f69485e758eb2ae8dd36bc23cbb
Rust
rnestler/rustfest-2019-nannou-workshop
/src/main.rs
UTF-8
1,050
2.703125
3
[]
no_license
use nannou::color::rgba; use nannou::prelude::*; fn main() { nannou::app(model).update(update).simple_window(view).run(); } struct Model { x: f32, y: f32, size: f32, t: f32, } fn model(_app: &App) -> Model { Model { x: 0.0, y: 0.0, size: 20.0, t: 0.0, } } ...
true
5e2222d641fe9229222be7da22cb0db26fe786a5
Rust
rfdonnelly/lift-rs
/src/main.rs
UTF-8
6,843
3.140625
3
[]
no_license
use std::cmp; use std::fmt; use structopt::StructOpt; const MAX_SETS: u32 = 6; const MAX_REPS: u32 = 5; fn parse_sets(s: &str) -> Result<u32, String> { let value = match u32::from_str_radix(s, 10) { Ok(v) => v, Err(e) => return Err(e.to_string()), }; if value > MAX_SETS { ret...
true
797d55dd8b6ae993cc66a0962c07ed6eb2f8c240
Rust
davidkern/holder
/benches/ledger.rs
UTF-8
3,287
2.71875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use criterion::{ black_box, criterion_group, criterion_main, measurement::Measurement, BatchSize, BenchmarkGroup, BenchmarkId, Criterion, Throughput, }; use holder::{Ledger, Direction}; use std::num::NonZeroUsize; // comprehensive: //const INCREMENTAL_ALLOCATION_COUNTS: [usize; 4] =...
true
f0269085f90bd2691585ec8cc8047c85bae5856b
Rust
halvko/tide-handlebars
/src/lib.rs
UTF-8
9,694
3.078125
3
[ "Apache-2.0" ]
permissive
//! # Tide-Handlebars integration This crate exposes [an extension //! trait](TideHandlebarsExt) that adds two methods to [`handlebars::Handlebars`]: //! [`render_response`](TideHandlebarsExt::render_response) and //! [`render_body`](TideHandlebarsExt::render_body). //! [`Handlebars`](handlebars::Handlebars)s. use hand...
true
9b24ea686d80bb0591b97e5026245b543dabdcd5
Rust
timvisee/ffsend-api
/src/file/info.rs
UTF-8
1,864
3.125
3
[ "MIT" ]
permissive
use serde_json; use crate::config; use crate::crypto::key_set::KeySet; /// File information, sent to the server before uploading. /// /// This is used for Firefox Send v3. #[derive(Debug, Serialize, Deserialize)] pub struct FileInfo { /// The expirey time in seconds. /// /// Must be in any of these bounds...
true
72cd8d0b2908c4d2d26da8ae9aca1ddf65c472b5
Rust
yazgoo/sliders
/src/lib.rs
UTF-8
8,759
3.03125
3
[]
no_license
use std::env; use std::error::Error; use std::process::Command; use crossterm::{cursor::{Show,Hide,MoveTo},event::{read, Event, KeyCode, KeyModifiers},terminal::{size, Clear, ClearType, enable_raw_mode, disable_raw_mode}, ExecutableCommand}; use std::io::stdout; pub trait SetterGetter { fn get(&mut self) -> Result...
true
636cb73fd860854ce2ed123c14f90fe2c6c9fb09
Rust
nfiles/pips
/src/parser/test_helpers.rs
UTF-8
830
2.84375
3
[ "MIT" ]
permissive
#[cfg(test)] type ParseFunc<I, O> = fn(input: I) -> nom::IResult<I, O>; #[cfg(test)] pub fn test_parser<'a, I, O>(test: ParseFunc<I, O>, cases: Vec<(&'a str, O)>) where I: std::fmt::Debug, I: std::convert::From<&'a str>, I: std::fmt::Display, O: std::fmt::Debug, O: std::cmp::PartialEq, {...
true
508c34869550979ef3ef776ce264ca7180927567
Rust
xy-plus/Rust
/slice_word/src/main.rs
UTF-8
444
3.359375
3
[]
no_license
use std::io; fn slice_word (sentence: &str) -> &str { let sentence_bytes = sentence.as_bytes(); for (i, &c) in sentence_bytes.iter().enumerate() { if c == b' ' { return &sentence[..i]; } } &sentence } fn main() { let mut sentence = String::new(); io::stdin().read_li...
true
59eb571c635ec80e66b40a9c79cd02f428070b9b
Rust
rust-lang-ja/rust-by-example-ja
/src-old/fn/closures/input_functions/input_functions.rs
UTF-8
410
3.34375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// 関数を引数として取り、即座に実行する関数を定義 fn call_function<F: Fn()>(f: F) { f() } // 引数として渡すための簡単な関数を定義 fn print() { println!("I'm a function!") } fn main() { // 上で定義した`print()`に似たクロージャを定義 let closure = || println!("I'm a closure!"); call_function(closure); call_function(print); }
true
7443d033724dd4c43d7ce4fcd65566454a8a2fdf
Rust
Owez/superconf
/src/lib.rs
UTF-8
3,620
3.5625
4
[ "MIT" ]
permissive
#![no_std] extern crate alloc; use alloc::vec::Vec; #[derive(Debug, PartialEq, Clone)] pub enum SuperError { /// When an item being parsed by [SuperItem] is empty, this is ignored by /// [Parse] implementation for the [SuperValue] parsing EmptyItem, } pub trait Parse<'a>: Sized { fn parse(input: &'a ...
true
c1f3e730baafe81a8f92a94b485c7c8775de3389
Rust
lk29/braiins-open
/utils-rs/unvariant/unvariant-tests/tests/common/str_frame.rs
UTF-8
3,298
2.640625
3
[]
no_license
// Copyright (C) 2020 Braiins Systems s.r.o. // // This file is part of Braiins Open-Source Initiative (BOSI). // // BOSI is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or ...
true
d90a4b0485249ddfc167a27ea4f387e9ae383a67
Rust
kpensec/rusty_synth
/src/synth/mod.rs
UTF-8
2,047
2.90625
3
[ "Apache-2.0" ]
permissive
extern crate rand; mod key; mod periodical_wave; mod noise; mod envelop; mod note; use utils::clamp; use synth::key::Key; pub struct Synthesizer { volume: f32, playback_freq: i32, sample_number: i32, keys: [Key; 13], step: f32, active: bool, } impl Synthesizer { pub fn new(playback_freq...
true
868e42bc5ebc8379571ae199d9a10b12db0b7dd3
Rust
pepyakin/spree-proto
/polkadot-re-mock/src/error.rs
UTF-8
434
2.703125
3
[]
no_license
use std::io; use thiserror::Error; #[derive(Error, Debug)] pub enum Error { /// A generic error coming from the interpreter. #[error("Interpreter error")] Interpreter(#[from] wasmi::Error), /// A generic I/O error has happened. #[error("I/O error")] Io(#[from] io::Error), #[error("{0}")] Msg(String), } impl F...
true
da41dd5b46144e049620bff31241a0702a735f4e
Rust
gyk/TrivialSolutions
/CuckooHashing/src/lib.rs
UTF-8
8,613
3.375
3
[ "WTFPL" ]
permissive
//! Cuckoo Hashing use std::hash::{Hash, Hasher}; use std::mem; use rand::{thread_rng, Rng}; use siphasher::sip::SipHasher; const DEFAULT_CAPACITY: usize = 1024; struct KeyValue<K, V> { key: K, value: V, } impl<K, V> KeyValue<K, V> { fn new(key: K, value: V) -> Self { Self { key, ...
true
fb32d30128a0eb424fd07a3175bd1e65a039be4e
Rust
shakram02/HamdOS
/src/vga_driver.rs
UTF-8
6,501
3.15625
3
[]
no_license
use core::fmt; use spin::Mutex; use lazy_static::lazy_static; const VGA_BUFFER_ADDR: usize = 0xB8000; const DEFAULT_TEXT_ATTR: u8 = 0x07; // VGA buffer address const SCREEN_WIDTH: usize = 80; const SCREEN_HEIGHT: usize = 25; const BACKSPACE: u8 = 8; const LINE_FEED: u8 = 10; lazy_static! { pub static ref VGA_WRI...
true
ccf6b6603b7235eeaea197f7ffe533f1d76f3056
Rust
iCodeIN/tabin-plugins
/make-docs/src/main.rs
UTF-8
2,360
2.765625
3
[ "BSD-3-Clause" ]
permissive
use std::process::Command; struct Check { name: &'static str, about: &'static str, } fn main() { let preamble = "Documentation about the various scripts contained herein\n"; let checks = [ Check { name: "check-graphite", about: "Cross platform, only requires access to ...
true
575ec3dd2a1db8cdaabedc120634de0a050334b7
Rust
MDGSF/JustCoding
/rust-leetcode/leetcode_806/src/solution1.rs
UTF-8
1,114
3.34375
3
[ "MIT" ]
permissive
impl Solution { pub fn number_of_lines(widths: Vec<i32>, s: String) -> Vec<i32> { if s.is_empty() { return vec![0, 0]; } let mut lines = 1; let mut cur_line_num = 0; s.as_bytes().iter().for_each(|&c| { let cur_num = widths[(c - b'a') as usize]; if cur_line_num + cur_num > 100 { ...
true
b56f9811c41a5266b3eb94e5b20c5f9901530e8c
Rust
horup/blueprint2-rs
/game/src/game.rs
UTF-8
3,278
2.625
3
[]
no_license
use core::num; use image::DynamicImage; use nalgebra::Vector3; use engine::*; use crate::{AISystem, Animator}; #[derive(Default)] pub struct BlueprintGame { } impl Game for BlueprintGame { type GameEvent = (); type GameComponent1 = (); fn setup(&mut self, engine:&mut Engine<Self>) { let mut as...
true
8987ecaf17d50f259181a783960af55fff18e179
Rust
felix-d/troll
/src/cache.rs
UTF-8
1,910
2.953125
3
[]
no_license
use errors::Error; use std::io::prelude::*; use std::io::SeekFrom; use std::fs::File; use rustc_serialize::json; use std::fs::OpenOptions; use std::collections::BTreeMap; const CACHE: &'static str = "/tmp/troll_cache"; pub struct Cache { handle: File, content: BTreeMap<String, json::Json>, } impl Cache { ...
true
fa57774d82fc7003cd6cf0af07e11820b807a745
Rust
LionelBergen/ZedScript
/src/api_structs/lol_account.rs
UTF-8
632
2.53125
3
[]
no_license
use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] pub struct LeagueAccount { #[serde(rename = "id")] pub summoner_id: String, #[serde(rename = "accountId")] pub account_id: String, pub puuid: String, pub name: String, #[serde(rename = "profileIconId")] pub pr...
true
b42068ae7506aaaaddd1978d02975ae0a5397d76
Rust
HeroicKatora/oxide-auth
/oxide-auth/src/endpoint/query.rs
UTF-8
10,300
3.25
3
[ "MIT", "Apache-2.0" ]
permissive
use std::borrow::{Borrow, Cow}; use std::collections::HashMap; use std::fmt; use std::iter::FromIterator; use std::hash::{BuildHasher, Hash}; use std::rc::Rc; use std::sync::Arc; use serde::de; use serde::Deserializer; /// Allows access to the query parameters in an url or a body. /// /// Use one of the listed implem...
true
17daaec9d5be5c52971f4d04bf15f49b183ac19f
Rust
4meta5/cosmwasm-examples
/escrow/tests/integration.rs
UTF-8
7,228
2.859375
3
[ "Apache-2.0" ]
permissive
use cosmwasm::serde::{from_slice, to_vec}; use cosmwasm::types::{coin, mock_params, Coin, ContractResult, CosmosMsg, Params}; use cosmwasm_vm::testing::{handle, init, mock_instance, query}; use cw_escrow::contract::{raw_query, HandleMsg, InitMsg, State, CONFIG_KEY}; /** This integration test tries to run and call the...
true
7fc840a78a00eade9817092cc79700579fad8a7c
Rust
Erikovsky/curve-tracer
/src/model/pwc.rs
UTF-8
3,086
3.265625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use itertools::Itertools; use num_traits::float::Float; pub struct PieceWiseConstantFunction { min: f64, max: f64, buckets: Vec<f64>, } impl PieceWiseConstantFunction { pub fn from_points( min: f64, max: f64, buckets: usize, min_bucket_population: usize, points:...
true