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
495f37bca5229c7dd146a6a244451044f5ebefd0
Rust
mun-lang/mun
/crates/mun_hir/src/code_model/module.rs
UTF-8
5,643
2.890625
3
[ "Apache-2.0", "MIT" ]
permissive
use super::{Function, Package, Struct, TypeAlias}; use crate::ids::{ItemDefinitionId, ModuleId}; use crate::primitive_type::PrimitiveType; use crate::{DiagnosticSink, FileId, HirDatabase, Name}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] pub struct Module { pub(crate) id: ModuleId, } impl...
true
912a155700e734f7e25a80d30d27f8b1683bc731
Rust
flipstone/dolittle
/src/websockets/websocket.rs
UTF-8
5,174
2.75
3
[]
no_license
use http::parser::*; use websockets::protocol::*; struct WebSocket<T> { socket: T } trait Transport { fn read(&self) -> Result<~[u8],Error>; fn write(&self, bytes: ~[u8]); } fn accept_websocket<T: Transport>(transport: T) -> Result<WebSocket<T>,~str> { match read_and_parse_request(&transport) { Ok(pa...
true
db15cd407edd6ee2c1b28b597aae9adf3a672f1c
Rust
arden/wechat-rs
/src/replies/articles.rs
UTF-8
4,012
3.21875
3
[ "MIT" ]
permissive
use time; use replies::ReplyRenderer; #[derive(Debug, Eq, PartialEq, Clone)] pub struct Article { pub title: String, pub description: String, pub url: String, pub image: String, } #[derive(Debug, Eq, PartialEq, Clone)] pub struct ArticlesReply { pub source: String, pub target: String, pub ...
true
2160d431da738ec794c252f09d6d6841d0fb1e67
Rust
tdgne/voicething
/src/audio/common.rs
UTF-8
3,681
3
3
[]
no_license
use derive_new::new; use getset::{Getters, Setters}; use rustfft::num_complex::Complex32; use rustfft::num_traits::{FromPrimitive, Num, NumAssignOps, NumCast, NumOps}; use serde::{Deserialize, Serialize}; #[derive(Getters, Clone, Debug, new)] #[getset(get = "pub")] pub struct AudioMetadata { channels: usize, s...
true
f2be5fe6ef3e2258fa6aa3f063925716de3719b1
Rust
shigedangao/capoomobi
/src/kubernetes/controllers/ingress.rs
UTF-8
1,816
2.796875
3
[]
no_license
use serde::{Serialize}; use super::service::SVC_SUFFIX; use crate::confiture::config::ConfigIngress; use crate::docker::parser::DockerService; use crate::kubernetes::controllers::service::{get_ports}; /// Kube Ingress /// /// # Description /// Structure which define a K8S ingress object #[derive(Serialize)] pub struct...
true
742a9439cc46853c5085761cee18f848b18a9e3d
Rust
ThomasZumsteg/adventofcode2015
/day01.rs
UTF-8
670
3.0625
3
[]
no_license
use common::get_input; type Input = Vec<isize>; fn part1(brackets: &Input) -> isize { brackets.iter().sum() } fn part2(brackets: &Input) -> isize { let mut total: isize = 0; for (b, bracket) in brackets.iter().enumerate() { total += bracket; if total < 0 { return 1 + b as isiz...
true
c08d5728784957f3604c901ca2500ded42158a03
Rust
Curt-White/virtual-printer
/parse_macro/src/lib.rs
UTF-8
5,959
2.9375
3
[]
no_license
extern crate proc_macro; extern crate quote; extern crate inflector; use inflector::Inflector; use proc_macro::{TokenStream, TokenTree}; use quote::quote; use syn::*; #[derive(Debug)] struct TokenType<T> { pub value: T, pub stream: TokenStream, } #[derive(Debug)] enum Token { Int(TokenType<i64>), Equ...
true
cc58f8a49512c5800a329b680889438cbff1c7b4
Rust
HowProgrammingWorks/EventEmitter
/Rust/examples/example1.rs
UTF-8
721
3.671875
4
[ "MIT" ]
permissive
// Example 1: an EventEmitter with events of type `GreetEvent` and payload of // type `&str`. extern crate event_emitter; use event_emitter::EventEmitter; #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)] enum GreetEvent { SayHello, SayBye, } fn main() { let mut emitter = EventEmitter::new(); emit...
true
8595d0a9dd45d7949bf367b0d85dd2f77b44cd15
Rust
0e4ef622/aoc
/2020/day10/src/solution.rs
UTF-8
950
2.578125
3
[]
no_license
use std::collections::*; use rand::random; use serde_scan::scan as s; pub fn part1(input: &str) -> impl std::fmt::Display { let mut n = input.lines().map(|x| x.parse::<usize>().unwrap()).collect::<Vec<_>>(); n.sort_unstable(); n.insert(0, 0); n.push(n.last().unwrap() + 3); n.windows(2).map(|x| x[1] ...
true
a0ff090f94ecf9cdf9611f4bc24f44323ef531fe
Rust
bsurmanski/rockwork
/examples/draw/src/main.rs
UTF-8
1,992
2.796875
3
[]
no_license
use rockwork::context::Context; use rockwork::mesh::Mesh; use rockwork::program::Program; use rockwork::texture::Texture; use sdl2::event::Event; use sdl2::keyboard::Keycode; use std::cell::RefCell; use std::io::Cursor; use std::io::Error; use std::time::Duration; pub struct GameData { program: Program, quad: ...
true
babb6e85c9ccf55c5aeb297e6a42d47aeb56ae50
Rust
esmaeilmirzaee/rust
/Strings/src/main.rs
UTF-8
613
3.6875
4
[]
no_license
fn main() { println!("Strings!"); /// String slices /// String slices are immutable let cat = "Fluffy"; let cat: &'static str = "Fluffy"; println!("{}", cat); /// string objects let mut dog = String::new(); dog = "Max".to_string(); let mut dog = String::from("Max"); println...
true
1e4a6c5effb11a504d240361c8087083bb167bdb
Rust
iulyaav/advent-of-code
/2021/4.day_four/four.rs
UTF-8
3,126
3.421875
3
[]
no_license
use std::env; use std::fs; use std::iter; #[derive(Debug)] struct BingoBox { rows: Vec<Vec<String>> } impl BingoBox { fn mark(&mut self, x: String) { for i in 0..5 { for j in 0..5 { if self.rows[i][j].to_string() == x { self.rows[i][j] = String::from("")...
true
3f4c0ae315937b7a088b12b95d59d5dec51fb8f1
Rust
shigedangao/maomao
/src/lib/helper/toml.rs
UTF-8
1,061
3.390625
3
[]
no_license
/// Toml.rs /// /// # Description /// List of helper (decorator) method to operate more easily with the toml library use toml::Value; use super::error::LError; use super::conv::Convert; // Constant const KEY_NOT_FOUND: &str = "Key not found"; /// Get Value For T /// /// # Description /// Retrieve a T: Convert value f...
true
7ce75facfd269478b7313890cb2b39cc001ee6a4
Rust
tmickel/brainrust
/src/main.rs
UTF-8
6,029
3.5
4
[]
no_license
use std::io; use std::io::Read; use std::env; use std::fs::File; use std::num::Wrapping; const MEMORY_SIZE : usize = 30000; type InstructionIndex = usize; type CellType = Wrapping<u8>; #[derive(Clone)] enum Op { IncreaseDPBy(usize), DecreaseDPBy(usize), IncreaseByteAtDPBy(CellType), DecreaseByteAtDPBy(...
true
c54101f05647a305d5c8b4483a565245e9666053
Rust
jiahaog/monkey
/monkey/src/vm/core/mod.rs
UTF-8
5,735
3.25
3
[]
no_license
use crate::ast::Operator; use crate::bytecode::Instruction; use crate::compiler; use crate::object::{Object, FALSE, TRUE}; pub use error::Error; mod error; // TODO use this somehow. const _STACK_SIZE: usize = 2048; pub struct Vm { // For testing. // TODO: Put this into the Stack object. pub last_popped: ...
true
637842ccbf9a91b30787682117daa6979cc23037
Rust
RobbieClarken/AdventOfCode2019
/day-16/src/main.rs
UTF-8
4,817
3.375
3
[ "MIT" ]
permissive
#![allow(dead_code)] use std::iter; const PATTERN: [i32; 4] = [0, 1, 0, -1]; fn main() { challenge_1(); challenge_2(); } fn challenge_1() { let input: Signal = std::fs::read_to_string("input").unwrap().trim().into(); let output = input.fft(100); println!( "Challenge 1: The first 8 digits ...
true
29ae2fab7bf40f7c4fae3a4a27ce018ccdc93eb7
Rust
bobbin-rs/bobbin-sdk
/mcu/bobbin-stm32/stm32-common/src/usart.rs
UTF-8
86,842
3.0625
3
[ "MIT", "Apache-2.0" ]
permissive
#[derive(Clone, Copy, PartialEq, Eq)] #[doc="USART Peripheral"] pub struct UsartPeriph(pub usize); impl UsartPeriph { #[doc="Get the CR1 Register."] #[inline] pub fn cr1_reg(&self) -> ::bobbin_mcu::register::Register<Cr1> { ::bobbin_mcu::register::Register::new(self.0 as *mut Cr1, 0x0) } #[...
true
8aa042c07370feb016c5cd399ccb99af11e33a35
Rust
tweag/nickel
/lsp/nls/src/requests/completion.rs
UTF-8
39,403
2.53125
3
[ "MIT" ]
permissive
use lazy_static::lazy_static; use log::debug; use lsp_server::{RequestId, Response, ResponseError}; use lsp_types::{ CompletionItem, CompletionItemKind, CompletionParams, Documentation, MarkupContent, MarkupKind, }; use nickel_lang_core::{ identifier::Ident, term::{ record::{Field, FieldMetadata}, ...
true
b3c1d2cda74be2bfe077ac25208ff7d9a3875ed8
Rust
rstevenson555/helm_foil
/src/helmruntime.rs
UTF-8
10,863
2.875
3
[]
no_license
use std::collections::HashMap; use std::fs; use clap::ArgMatches; use regex::Regex; use std::borrow::Borrow; use std::fmt::Display; use std::fs::File; use std::hash::Hash; use std::io::Write; use std::path::Path; use std::process::{Command as ProcessCommand, Output}; #[derive(Debug, Clone)] pub(crate) struct HelmRun...
true
6bcee1ee327070544a9986a75eeb4583da963470
Rust
Keksoj/multi_topic_with_books
/src/book_consumer.rs
UTF-8
3,082
2.84375
3
[]
no_license
use crate::{line::Line, PULSAR_ADDRESS}; use anyhow::{Context, Result}; use futures::TryStreamExt; use log::{debug, info, trace}; // use log::{debug, error, info}; use pulsar::{ // message::proto, Consumer, // DeserializeMessage, Pulsar, SubType, TokioExecutor, }; // use std::io::{prelude::*, B...
true
1c12ce7d00828bb8b5ad47ba254e3d0b8057cc9a
Rust
nickChenyx/rdial
/src/main.rs
UTF-8
3,272
3.0625
3
[]
no_license
//! 端口扫描工具 //! ulimit -n 限制会影响端口扫描的准确性,请确保扫描的端口范围大小在限制大小内。 //! 例如:connect 127.0.0.1:1959 err: Too many open files (os error 24) //! @author: nickChenyx #[macro_use] extern crate may; // for macro go use std::net::{ToSocketAddrs, Shutdown}; use may::net::TcpStream; use std::time::Duration; use crossbeam::sync::WaitGro...
true
573387e5e16376907e8d877f9934d2eb105c2321
Rust
shaleh/rust-readline
/examples/fileman.rs
UTF-8
6,028
2.953125
3
[ "MIT" ]
permissive
extern crate readline; use std::env; use std::fs; use std::io; use std::process::Command; type Func = fn(&[&str]) -> Result<bool, String>; struct COMMAND { name: &'static str, /* User printable name of the function. */ func: Func, /* Function to call to do the job. */ expected_args: u32, /* number...
true
60464cfa0c2fdceadea8c3169704458e18da4b2d
Rust
kitesoft/raptor
/src/market/bitflyer/bitflyer.rs
UTF-8
3,063
2.765625
3
[]
no_license
use std::error::Error; use reqwest::Proxy; use serde_json; use crate::market::bitflyer::boards::BitFlyerBoards; use crate::market::bitflyer::execution::BitFlyerExecution; use crate::market::bitflyer::order::BitFlyerOrder; use crate::market::bitflyer::utils::BitFlyerUtils; use crate::types::atomic::{Boards, Execution,...
true
8d801f47075a559369ed5c408c557fa9d5d4da8c
Rust
meh/rust-casing
/src/unicode.rs
UTF-8
16,653
3.46875
3
[ "WTFPL" ]
permissive
use std::borrow::Cow; use std::str::CharIndices; use {Casing, Locale, Separator}; impl Casing for str { type Character = char; fn upper(&self, _locale: Locale) -> Cow<Self> { let mut chars = self.char_indices(); while let Some((start, ch)) = chars.next() { // There's a lower case character, gotta copy the s...
true
d66f675d25a36ab5e4b9eda8ff85a9edbc064127
Rust
virtualgraham/wasm-graph-app
/src/graph/memstore/all_iterator.rs
UTF-8
6,062
2.6875
3
[]
no_license
use crate::graph::value::Value; use crate::graph::refs::{Size, Ref, Content}; use crate::graph::iterator::{Base, Scanner, Index, Shape, Costs, ShapeType}; use std::rc::Rc; use std::cell::RefCell; use std::collections::HashMap; use std::fmt; use std::collections::BTreeMap; use super::quadstore::{PrimStore, Primitive};...
true
40fe9f8629d8ad4d86cd41ecef15191971f19bf8
Rust
AlexNav73/rusty_dam
/libcore/src/models/collections/files.rs
UTF-8
1,169
2.828125
3
[]
no_license
use uuid::Uuid; use std::collections::HashMap; use Entity; use models::collections::{EntityCollection, Ids, Iter}; use models::file::File; use connection::App; pub struct FileCollection { latest: Option<Uuid>, files: HashMap<Uuid, File>, application: App, } impl FileCollection { pub fn new(app: App...
true
6be41bfd6dcecb6b6a2e790b7cd1964578d18024
Rust
nskillen/advent-of-code-2017
/src/days/d13.rs
UTF-8
4,016
3.125
3
[]
no_license
use super::read_file; use time; #[derive(Clone)] struct Scanner { position: usize, range: usize, velocity: i32 } impl Scanner { fn new() -> Scanner { Scanner { position: 1, range: 1, velocity: 1 } } fn with_range(range: usize) -> Scanner { Scanner { position: 1, range: range, ...
true
20bd3e67f3d6d9a0937aa5e1320bcdb4f58d4a2c
Rust
zhzy0077/workflows
/src/atom.rs
UTF-8
1,864
2.6875
3
[ "MIT" ]
permissive
use crate::{Context, Input, Inputs, Outputs, Workflow}; use anyhow::Result; use atom_syndication::Feed; use chrono::{Duration, Local}; use std::{io::BufReader}; pub struct Atom {} impl Atom { // Input const TEXT: &'static str = "text"; const SCHEDULE_IN_SECS: &'static str = "schedule_in_secs"; const P...
true
ce32d0380cc9ef3e91e74d5e2824d45c2621c73e
Rust
TimelyDataflow/differential-dataflow
/examples/interpreted.rs
UTF-8
3,815
2.765625
3
[ "MIT" ]
permissive
extern crate timely; extern crate graph_map; extern crate differential_dataflow; use std::hash::Hash; use timely::dataflow::*; use timely::dataflow::operators::*; use differential_dataflow::Collection; use differential_dataflow::lattice::Lattice; use differential_dataflow::operators::*; use differential_dataflow::op...
true
272a2e1b8488ba05d49d669326f0acdca4941c31
Rust
IThawk/rust-project
/rust-master/src/test/ui/issues/issue-16098.rs
UTF-8
339
2.625
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
macro_rules! prob1 { (0) => { 0 }; ($n:expr) => { if ($n % 3 == 0) || ($n % 5 == 0) { $n + prob1!($n - 1); //~ ERROR recursion limit reached while expanding the macro `prob1` } else { prob1!($n - 1); } }; } fn main() { println!("Problem 1: {}"...
true
5263795f993dd0110f0319bf48dee9370f0ce5b6
Rust
jurand2008/Szaklon-api
/src/init.rs
UTF-8
4,191
2.84375
3
[]
no_license
use crate::db::models::Song; use crate::db::schema::songs; use crate::utils::PerfLog; use crate::Config; use diesel::prelude::*; use failure::format_err; use indicatif::{ProgressBar, ProgressStyle}; use reqwest::ClientBuilder; use serde::{Deserialize, Serialize}; use std::thread; use std::time::Duration; #[derive(Dese...
true
3cbf2cd064be31967ee9d9d3d44329f8a49e4915
Rust
iwilare/factorio-planner
/src/main.rs
UTF-8
8,725
2.765625
3
[ "MIT" ]
permissive
struct Item<'a> { name: &'a str, factory: &'a Factory<'a>, count: i32, time: f64, components: &'a [(i32, &'a Item<'a>)], } struct Factory<'a> { name: &'a str, crafting_speed: f64, is_assembly: bool, } #[derive(Clone)] struct Production<'a> { target: &'a Item<'a>, output_per_sec...
true
8a78f16609e780b3f51594e8b894b76e0e1b7df0
Rust
mmun/advent-of-code-2017
/src/bin/1-1.rs
UTF-8
602
3.328125
3
[]
no_license
fn solve(input: &str) -> i64 { let input = input.trim().as_bytes(); let len = input.len(); let mut sum = 0; for i in 0..len { let j = (i + 1) % len; if input[i] == input[j] { sum += (input[i] - b'0') as i64; } } sum } fn main() { println!("{}", solve(...
true
9e396554a8d297d7670048400bba215d317bc6f0
Rust
Yesterday17/SNLCompiler
/snlc/src/main.rs
UTF-8
2,798
2.9375
3
[ "Apache-2.0" ]
permissive
use clap::{App, Arg}; use std::io::Read; use std::process::exit; use snl_semantic::Semantic; fn main() { let matches = App::new("SNL Compiler") .arg(Arg::with_name("mode") .long("mode") .required(true) .takes_value(true) .possible_values(&["lex", "parse", "se...
true
bf019d65ba16aaad9d0eb27fa004fbe346cae3dc
Rust
sporto/exercism
/rust/bob/src/lib.rs
UTF-8
652
3.375
3
[]
no_license
extern crate regex; use regex::Regex; pub fn reply(input: &str) -> String { let trimmed = input .trim(); match trimmed { _ if trimmed == "" => "Fine. Be that way!".to_string(), _ if is_yell(trimmed) => "Whoa, chill out!".to_string(), _ if is_question(trimmed) => "Sure.".to_string(), _ => "W...
true
740a67a23f3953ca8d3e6d7407b3df91afc0179c
Rust
dollarkillerx/RUST-Newcomer-Development-Program
/s13/demo4/src/main.rs
UTF-8
393
3.578125
4
[ "MIT" ]
permissive
fn annotate<T, F>(f: F) -> F where for<'a> F: Fn(&'a T) -> &'a T { f } fn annotate2<'a, T: 'a, F>(f: F) -> F where F: Fn(&'a T) -> &'a T { f } fn main() { println!("Hello, world!"); // let f = |x: &i32| x; // let f: for<'a> Fn(&'a i32) -> &'a i32 = |x| x; let f = annotate(|x: &i32| x);...
true
bb9a321a5d4a74b11097375a941b643b2a19b8b2
Rust
wezm/cc2650
/src/cpu_scs/shcsr.rs
UTF-8
31,372
2.640625
3
[ "Apache-2.0", "MIT" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::SHCSR { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut...
true
fcadf002a9199bfb8fd754bbc97c81287df8be01
Rust
SUSTechFlow/server_v2
/src/util/ops.rs
UTF-8
813
2.84375
3
[]
no_license
use mongodb::bson::{Bson, doc, Document}; use serde::{Deserialize, Serialize}; #[derive(Debug, Deserialize, Serialize)] pub enum PatchOperator { AddToSet(String, Bson), Set(String, Bson), Inc(String, i64), RmFromSet(String, Bson), } impl PatchOperator { pub fn as_op(&self) -> Document { ma...
true
b24de129bac9cb72d4122a4055d070babd19b49c
Rust
jetbrains-academy/rustlings-course
/Common Programming Concepts/Tuples and Arrays/Destructure a Tuple/tests/tests.rs
UTF-8
873
2.703125
3
[ "MIT" ]
permissive
extern crate escargot; #[test] fn prints_is_years_old() { //TODO: here are even two unwraps in a row, that's dangerous let actual = escargot::CargoBuild::new() .bin("tuples") .run() .unwrap() .command() .output() .unwrap() .stdout; //TODO: recover fro...
true
87124bdb15ab7eea2a7883ea7cc75aa7995c7efa
Rust
matthewelse/advent-of-code-2017
/day3/src/main.rs
UTF-8
1,927
3.34375
3
[]
no_license
use std::collections::HashMap; fn location(input: i32) -> i32 { // find the ring to search through let input_f = input as f64; let result = ((input_f.sqrt() - 1.0) / 2.0).ceil(); let px = result as i32; let py = 1 - px; let mut x = px; let mut y = py; let mut n = (px * 2 - 1) * (px *...
true
687df6484bb4545f97d6d865229f9cd5ef985690
Rust
korpiq/rust_json_parser
/src/json/source.rs
UTF-8
1,771
2.65625
3
[]
no_license
use std::io::{stdin, Read}; use circular::Buffer; //type Parseable = [u8]; pub type Parseable = StreamSource; //JsonInput<'static>; pub struct StreamSource { } /* impl Parseable { pub fn new(data : &[u8]) -> Parseable { JsonInput { data } } } impl nom::AtEof for Parseable { ...
true
1a974a91e73bab94fc462e271450a18ab8e51cec
Rust
MarcusDunn/chess
/src/board.rs
UTF-8
10,897
2.953125
3
[ "MIT" ]
permissive
pub mod board { use crate::chess::{FailReason, Piece, Movable, Color, Pawn, King}; use crate::location::location::Location; use std::collections::LinkedList; use crate::chess_move::chess_move::Move; pub struct Board { squares: [[Option<Piece>; 8]; 8], past_moves: LinkedList<(Move, P...
true
22e2158f83769fe8f25e47dcdd6757ab5b216196
Rust
ahdinosaur/snafu
/compatibility-tests/compile-fail/tests/compile-fail/visibility.rs
UTF-8
895
2.515625
3
[ "Apache-2.0", "MIT" ]
permissive
extern crate snafu; // There are also happy-path tests mod outer { pub mod inner { use snafu::Snafu; #[derive(Debug, Snafu)] #[snafu(visibility = "pub(crate)")] pub(crate) enum Error { PubCrate, #[snafu(visibility = "pub(in ::outer)")] PubInPath...
true
355906f435675fcdcdd42192479eaec4b57ef7b5
Rust
nglaeser/sonic-ucse
/src/lib.rs
UTF-8
6,865
2.546875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use dusk_jubjub; use pairing::{Engine, Field}; use std::ops::{Add, Neg, Sub}; pub mod batch; pub mod circuits; pub mod dlog; pub mod kupke; pub mod protocol; pub mod schnorrots; pub mod srs; pub mod synthesis; pub mod usig; pub mod util; pub fn usage() { println!("Usage: cargo run --example [example name] -- [ped...
true
2cfd517e326216a3dc5ef7e283184750d1ec8770
Rust
sam701/awscredx
/src/util.rs
UTF-8
1,784
2.78125
3
[ "MIT" ]
permissive
use std::path::{Path, PathBuf}; use std::{env, fs}; use ansi_term::{Color, Style}; use reqwest::Proxy; use crate::version::VERSION; pub fn path_to_absolute(path: &str) -> PathBuf { let home = env::var("HOME").expect("HOME is not set"); let abs = path.replace("~", &home).replace("$HOME", &home); PathBuf::...
true
d3c4f1e1453941e190677416853b03d30476e5de
Rust
AE9RB/basic-lang
/src/lang/lex.rs
UTF-8
13,836
3.3125
3
[]
no_license
use super::{token::*, LineNumber, MaxValue}; use std::collections::VecDeque; pub fn lex(source_line: &str) -> (LineNumber, Vec<Token>) { BasicLexer::lex(source_line) } fn is_basic_whitespace(c: char) -> bool { c == ' ' || c == '\t' } fn is_basic_digit(c: char) -> bool { c.is_ascii_digit() } fn is_basic_...
true
2514c6eba61b6d60f41364387a44f65ef95a2d2f
Rust
SpaceSchmucks/SpaceSchmucks
/src/player.rs
UTF-8
1,421
2.5625
3
[]
no_license
use anyhow::Context; use bevy::math::Vec2; use bevy::prelude::Texture; use pgp::composed::key::SecretKeyParams; use pgp::crypto::{HashAlgorithm, SymmetricKeyAlgorithm}; use pgp::types::CompressionAlgorithm; use pgp::KeyType; use pgp::SignedSecretKey; use smallvec::smallvec; pub struct User { username: String, ...
true
0c32ea0d2a345aeabef386a2bf9e5148b0bf5a65
Rust
xasopheno/rusty-vision
/src/programs/uniforms/color.rs
UTF-8
1,360
2.59375
3
[]
no_license
use nannou::prelude::*; use crate::programs::config; use crate::programs::uniforms::base::Bufferable; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct Data { pub color_mode: i32, pub color1_r: f32, pub color1_g: f32, pub color1_b: f32, pub color2_r: f32, pub color2_g: f32, pub color2_b:...
true
8e5fc8a9026731c5dba2246ee14b46810a42e139
Rust
colin-kiegel/rust-derive-builder
/derive_builder/tests/validation.rs
UTF-8
1,881
3.421875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[macro_use] extern crate derive_builder; #[derive(Debug, Clone, Builder, PartialEq, Eq)] #[builder(build_fn(validate = "LoremBuilder::validate"))] pub struct Lorem { /// A percentile. Must be between 0 and 100. my_effort: u8, /// A percentile. Must be less than or equal to `Lorem::my_effort`. #[build...
true
8bded88b8dd274236016c8f2496af0ebc528a741
Rust
volker48/advent-of-code
/2021/src/day1.rs
UTF-8
1,157
3
3
[]
no_license
use itertools::{izip, Itertools}; use std::fs; pub fn part1() -> i32 { let raw_input = fs::read_to_string("src/day1_input.txt").expect("error reading file"); let depths: Vec<i32> = raw_input .lines() .map(|x| x.trim().parse::<i32>().unwrap()) .collect(); let i1 = depths.iter(); ...
true
41ddbcf9eae614c940f915ee845e7ffb04ae8890
Rust
ivan-ruizrosello/rust-lang-book-code-examples
/src/4-ownership/ownership.rs
UTF-8
1,172
4.25
4
[]
no_license
fn main() { let mut s = "hello"; // s += "a"; // Error: binary assignment operation `+=` cannot be applied to type `&str let mut st = String::from("Hello!"); st.push('a'); st += "a"; println!("{}", st + "H"); /****** * */ { let s1 = String::from("hello"); ...
true
a3901d468197fc4dbc479066aaaa20ac17ecfef6
Rust
asib/todo-rs
/src/lib/domain.rs
UTF-8
804
2.53125
3
[]
no_license
use super::models; use anyhow::Result; pub trait TodoRepository: TodoRepositoryClone + Send + Sync { fn todos(&self) -> Result<Vec<models::Todo>>; fn todo(&self, idx: i32) -> Result<models::Todo>; fn create_todo(&self, todo: models::NewTodo) -> Result<models::Todo>; fn update_todo(&self, todo_update: m...
true
5d5a5873f3ab1d039fb278b3f4f91295b7d88c09
Rust
MDGSF/JustCoding
/rust-leetcode/leetcode_297/src/solution1.rs
UTF-8
2,658
3.484375
3
[ "MIT" ]
permissive
// Definition for a binary tree node. // #[derive(Debug, PartialEq, Eq)] // pub struct TreeNode { // pub val: i32, // pub left: Option<Rc<RefCell<TreeNode>>>, // pub right: Option<Rc<RefCell<TreeNode>>>, // } // // impl TreeNode { // #[inline] // pub fn new(val: i32) -> Self { // TreeNode { // val, ...
true
a36e621d4b45544fa2dcbaf915fa167f4cf8f6cb
Rust
siku2/aoc_2019
/src/puzzles/day_13.rs
UTF-8
3,240
3.046875
3
[ "MIT" ]
permissive
use crate::input::Input; use crate::lib::intcode::Machine; use colored::Colorize; use std::collections::{HashMap, HashSet}; use std::error::Error; use std::io; type Position = (isize, isize); type TileID = u8; const EMPTY: TileID = 0; const WALL: TileID = 1; const BLOCK: TileID = 2; const HOR_PADDLE: TileID = 3; cons...
true
513e0767b360430057c4f3c8e6f46773d43909bc
Rust
kadotami/rust-web-app-example
/todo_list/domain/src/error/domain_error.rs
UTF-8
268
2.828125
3
[]
no_license
use thiserror::Error; #[derive(Error, Debug, Clone)] pub enum DomainError { #[error("Requested resource not found")] ResourceNotFound, #[error("Unexpected error from Database")] UnexpectedDatabaseError, #[error("{0}")] BadRequest(String), }
true
e003f2973ffe6aebe0ab53b46731bb5b02eafd9c
Rust
divinerapier/crack-the-coding-interview
/linked-list/src/linkedlist/mod.rs
UTF-8
2,792
3.5625
4
[]
no_license
pub struct LinkedList<T> { pub head: Option<std::ptr::NonNull<Node<T>>>, pub tail: Option<std::ptr::NonNull<Node<T>>>, pub length: usize, } pub struct Node<T> { pub prev: Option<std::ptr::NonNull<Node<T>>>, pub next: Option<std::ptr::NonNull<Node<T>>>, pub data: T, } impl<T> Node<T> { pub ...
true
366c7a154b5373168a6afad6ecc33fe7a66d9309
Rust
gglouser/advent2017
/src/day19.rs
UTF-8
2,250
3.59375
4
[]
no_license
struct Map<'a>(Vec<&'a [u8]>); impl<'a> Map<'a> { fn new(s: &str) -> Map { Map(s.lines() .map(|line| line.as_bytes()) .collect()) } fn start(&self) -> (i32, i32) { (0, self.0[0].iter().position(|&b| b == b'|').unwrap() as i32) } fn get(&self, pos: (i32, i32...
true
7821e3bb1e86312bdf54975e599f33dcc07c6ef0
Rust
bramvdbogaerde/calculator-rs
/src/ast.rs
UTF-8
353
3.1875
3
[]
no_license
#[derive(Debug)] pub enum Expr { NumExp(usize), AddExp(Box<Expr>, Box<Expr>), MulExp(Box<Expr>, Box<Expr>), DivExp(Box<Expr>, Box<Expr>), MinusExp(Box<Expr>, Box<Expr>) } impl Expr { pub fn number<S: Into<String>>(num: S) -> Expr { let parsed = num.into().parse::<usize>().unwrap(); ...
true
4679740d9c40fb01a2edd57ab026bfe18ee61b98
Rust
nerdalert/rust-examples
/concurrency-tokio-5/src/main.rs
UTF-8
1,914
3.015625
3
[ "WTFPL" ]
permissive
use futures::StreamExt; use std::{env, error::Error, net::SocketAddr}; use tokio::{ self, codec::{self, Framed}, net::{TcpListener, TcpStream}, }; pub struct LogListener { listen_bind: String, } type AsyncRes = Result<(), Box<dyn Error>>; impl LogListener { pub fn new(listen_bind: String) -> Self...
true
4782ef505564ee4af12d477a48150e177fd9fd3c
Rust
tomasvdw/rust-bitcoin
/src/blockdata/transaction.rs
UTF-8
9,001
2.921875
3
[ "CC0-1.0" ]
permissive
// Rust Bitcoin Library // Written in 2014 by // Andrew Poelstra <apoelstra@wpsoftware.net> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warrant...
true
939660b9965d108eb594110e74d66e86688154e2
Rust
Thejuampi/impuesto-ganancias
/rust/src/income_tax.rs
UTF-8
2,650
2.6875
3
[]
no_license
struct Scale { threshold: f64, percentage: f64, base_fix_income: f64, } const SCALES: [Scale; 9] = [ Scale { threshold: 0.0, percentage: 0.05, base_fix_income: 0.00 }, Scale { threshold: 47_669.16, percentage: 0.09, base_fix_income: 2_383.46 }, Scale { threshold: 95_338.32, percentage: 0.12, base_fix_incom...
true
ebe075fbf055b5a8f4c6b84910c7fd43dac7952b
Rust
ozankasikci/rust-music-theory
/src/note/pitch.rs
UTF-8
5,453
3.5
4
[ "MIT" ]
permissive
use crate::interval::Interval; use crate::note::errors::NoteError; use lazy_static::lazy_static; use regex::{Match, Regex}; use std::fmt; use std::str::FromStr; use strum_macros::EnumIter; use std::collections::HashMap; lazy_static! { static ref REGEX_PITCH: Regex = Regex::new("^[ABCDEFGabcdefg][b♭♯#s𝄪x]*").unwra...
true
6be0e334d23b2261e41d13684accf90c61fb6ac0
Rust
White-Green/selecting_flow
/src/data_types/mod.rs
UTF-8
16,621
2.546875
3
[ "MIT" ]
permissive
use std::borrow::Cow; use std::cmp::Ordering; use std::collections::BTreeMap; use std::rc::Rc; use num_traits::NumAssign; use rayon::prelude::{IndexedParallelIterator, ParallelIterator, ParallelSlice, ParallelSliceMut}; use crate::compute_graph::constant::Constant; use crate::compute_graph::{IntoComputeGraphNode, Sha...
true
444b8e59928cd404971fbef47f52148ab915efae
Rust
Financial-Times/scrumple
/src/es6/export.rs
UTF-8
579
2.8125
3
[ "MIT" ]
permissive
use std::borrow::Cow; #[derive(Debug, PartialEq, Eq)] pub enum Export<'s> { Default(&'s str), AllFrom(&'s str, Cow<'s, str>), Named(Vec<ExportSpec<'s>>), NamedFrom(Vec<ExportSpec<'s>>, &'s str, Cow<'s, str>), } #[derive(Debug, PartialEq, Eq, Hash)] pub struct ExportSpec<'s> { pub bind: &'s str, ...
true
fb506d49cf341ea8d7bb84882bf0f3bef7929ca8
Rust
aylei/leetcode-rust
/src/solution/s0104_maximum_depth_of_binary_tree.rs
UTF-8
1,530
3.5
4
[ "Apache-2.0" ]
permissive
/** * [104] Maximum Depth of Binary Tree * * Given a binary tree, find its maximum depth. * * The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. * * Note: A leaf is a node with no children. * * Example: * * Given binary tree [3,9,20,null,null,15...
true
cdc9949ed4efcae385c028951befb19310cf6b31
Rust
sparkle-os/sparkle
/src/arch/x86_64/memory/paging/temporary_page.rs
UTF-8
2,408
3.171875
3
[ "BSD-3-Clause" ]
permissive
use super::table::{EntryFlags, Level1}; use super::{ActivePageTable, Page, Table, VirtualAddress}; use arch::x86_64::memory::{Frame, FrameAllocator}; pub struct TemporaryPage { page: Page, allocator: TinyAllocator, } impl TemporaryPage { pub fn new<A>(page: Page, allocator: &mut A) -> TemporaryPage wh...
true
d420b32ca8c74c5bc44723bd2294a802c64be7cd
Rust
Xatabch/technopark_highload
/src/server/server.rs
UTF-8
4,751
3.015625
3
[]
no_license
use crate::thread_pool::thread_pool::ThreadPool; use std::net::{TcpListener, TcpStream}; use std::sync::{Arc, Mutex}; use std::io::prelude::*; use crate::http::request::HTTPRequest; use crate::http::response::HTTPResponse; use std::time::Duration; use std::collections::{HashMap}; use std::fs::File; use std::path::Path;...
true
b45d3ec16df997a190f0d0a5467d79ee13164012
Rust
tearne/library
/rust/03_old_unicorn/src/keyboard/mod.rs
UTF-8
1,214
2.609375
3
[]
no_license
use std::collections::HashMap; use libc::input_event; use crate::error::Error; pub mod device; pub mod monitor; pub struct KeyBuffer { key_buffer: Vec<&'static str>, max_length: usize, key_map: HashMap<u16, &'static str>, } impl KeyBuffer { pub fn new(length: usize) -> Self { KeyBuffer { ...
true
b22702edb1826d02a22a7c59b4728445324c15bb
Rust
podo-os/podo-std-eye
/src/cam/capture.rs
UTF-8
5,365
2.546875
3
[ "BSD-2-Clause" ]
permissive
use std::path::Path; use std::sync::{Arc, Mutex}; use std::thread; use std::time::Duration; use super::queue::Queue; use crate::common::VideoReader; use crate::config::{Configurable, VideoColor, VideoMeta}; use crate::frame::Frame; use chrono::prelude::*; use opencv::prelude::*; use opencv::videoio; use podo_core_dri...
true
c5c05055cc07265fd53fa26ecd0b7883b07f1580
Rust
timHau/gauss-seidel
/src/utils.rs
UTF-8
543
3.359375
3
[]
no_license
pub(crate) fn dist_2(v: &[f64], w: &[f64]) -> f64 { assert_eq!( v.len(), w.len(), "v, w should come from the same Vectorspace" ); let mut res = 0.0; for (&v_i, &w_i) in v.iter().zip(w.iter()) { res += (v_i - w_i).abs().powf(2.0); } res.sqrt() } #[cfg(test)] mo...
true
53c2ca3116c9322c3d833530d0566c5737f51788
Rust
ElliottLester/euler
/src/q6.rs
UTF-8
411
3.015625
3
[]
no_license
pub fn soln() -> usize{ let mut sosq:u64 = 0; let mut sqos:u64 = 0; for i in 0..101 { sosq += (i as u64).pow(2); sqos += i as u64; } sqos = sqos.pow(2); //println!("Sum of squares: {}",sosq); //println!("Square of sum: {}",sqos); //println!("diffrence {}",sqos - sosq); ...
true
cc939939df7d4b12e349b8bd4a0a7465d9954b6d
Rust
hooneun/recmd
/src/config.rs
UTF-8
1,602
3.234375
3
[ "MIT" ]
permissive
#[derive(Debug)] pub struct Config { kind: String, pub key: String, pub cmd: String, } impl Config { pub fn new(args: &[String]) -> Result<Config, std::io::Error> { let mut kind = ""; let mut key: String = String::new(); let mut cmd: String = String::new(); if args.len(...
true
0928c388b310ac93563ea8bea43ecbb819134623
Rust
Floeckchengrafik/LangJam0001-Comstruct
/🌌/src/main.rs
UTF-8
1,555
2.875
3
[]
no_license
#![feature(try_trait_v2)] mod ast; mod builtins; mod interpreter; mod lexer; mod parser; use std::{ env, fs, io::{self, Read, Result}, }; use interpreter::{Exec, Interpreter}; use lexer::Lexer; use parser::Parser; fn process(code: &str) { let lexer = Lexer::new(code); match lexer.into_tokens() { ...
true
7c6ff94abf4759730359797c07578d025fa1e0c8
Rust
ChaosStudyGroup/webrtc
/stun/src/checks.rs
UTF-8
603
2.859375
3
[ "MIT" ]
permissive
use crate::attributes::*; use crate::errors::*; use util::Error; // check_size returns ErrAttrSizeInvalid if got is not equal to expected. pub fn check_size(_at: AttrType, got: usize, expected: usize) -> Result<(), Error> { if got == expected { Ok(()) } else { Err(ERR_ATTRIBUTE_SIZE_INVALID.cl...
true
c430f1bea390dad01e6e33d7f2f2fa7dbc067a20
Rust
dbp/rustle
/rustle.rs
UTF-8
1,859
3.015625
3
[]
no_license
use types::*; fn main() { let args = os::args(); if args.contains(&~"-h") || args.contains(&~"--help") { usage(); return; } // load in data let data = load::load(path::from_str("rustle.data")); if args.len() == 1 { // start interactive loop io::println(~"Rustle...
true
098fe3e4a7ed0100eef291db2c6dc722f86814f5
Rust
mredlek/rs-opentherm
/src/application/dataid20.rs
UTF-8
2,704
3.109375
3
[ "MIT" ]
permissive
use super::{DataClass, DataIdDefinition}; use ::ErrorKind; use ::std::marker::PhantomData; pub type DataIdSimpleType = (u8, u8); pub(crate) static DATAID_DEFINITION : DataIdDefinition<DataIdSimpleType, DataIdType> = DataIdDefinition { data_id: 20, class: DataClass::SensorAndInformationalData, ...
true
98967e0f94d05aa8a99b74bb9fb982eb0c01670f
Rust
brandonedens/transitfeed
/src/gtfs/agencies.rs
UTF-8
3,483
2.90625
3
[ "MIT" ]
permissive
use std::io::BufRead; use quick_csv::Csv; use transit::Agency; use gtfs::error::{GtfsResult, GtfsError}; const AGENCY_FILENAME: &'static str = "agency.txt"; /// An decoder which returns as its iterator output a new `Stop` struct from /// a CSV iterator. pub struct AgencyIterator<B: BufRead> { csv: Csv<B>, hea...
true
cfadbde3f3abcd88b944d1c3bbb93a79cff10b2d
Rust
KaiserY/trpl-zh-cn
/listings/ch19-advanced-features/listing-19-14/src/main.rs
UTF-8
412
3.78125
4
[ "MIT" ]
permissive
use std::ops::Add; #[derive(Debug, Copy, Clone, PartialEq)] struct Point { x: i32, y: i32, } impl Add for Point { type Output = Point; fn add(self, other: Point) -> Point { Point { x: self.x + other.x, y: self.y + other.y, } } } fn main() { assert_eq!(...
true
8cf202455e43d24799e0d18b0ace7a69cfc0f2a8
Rust
sayrer/rust
/src/test/run-pass/obj-self-3.rs
UTF-8
341
2.796875
3
[ "LicenseRef-scancode-unknown-license-reference", "BSD-1-Clause", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-public-domain", "MIT", "BSD-2-Clause", "bzip2-1.0.6" ]
permissive
fn main() { obj foo() { fn m1(int i) -> int { i += 1; ret i; } fn m2(int i) -> int { ret self.m1(i); } fn m3(int i) -> int { i += 1; ret self.m1(i); } } auto a = foo(); let int i = 0; i = a.m1(i); assert (i == 1); i = a.m2(i); assert (i == 2); i = a.m3(i); ...
true
9c37edcfd2bf36e8be0e471b76208a510536c2c3
Rust
AustinHaugerud/oxidsys
/src/language/operations/agents_and_teams/agent_set_hit_points.rs
UTF-8
956
2.546875
3
[ "MIT" ]
permissive
use language::operations::{make_param_doc, Operation, ParamInfo}; pub struct AgentSetHitPointsOp; const DOC : &str = "Sets new value for agent health. Optional last parameter determines whether the value is interpreted as actual health (absolute = 1) or relative percentile health (absolute = 0). Default is relative."...
true
b8da41d2a939c032f49bff933aabb3a99bfdd20a
Rust
redbadger/feature-targeting
/data-plane/src/features/explicit.rs
UTF-8
3,055
2.96875
3
[ "MIT" ]
permissive
use crate::features::expression::{Str, StrList}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; pub fn from_request(request: &HashMap<&str, &str>, config: &Config) -> Vec<String> { let mut features = config .0 .iter() .flat_map(|x| x.eval(request).unwrap_or_else(|_| vec...
true
8359207fbf2c9092ab2a7cd99523fc03b68613a4
Rust
cipepser/programming-rust-sample
/chap15/inspect/src/main.rs
UTF-8
256
3.234375
3
[]
no_license
fn main() { let upper_case: String = "große".chars() .inspect(|c| println!("before: {:?}", c)) .flat_map(|c| c.to_uppercase()) .inspect(|c| println!("after: {:?}", c)) .collect(); assert_eq!(upper_case, "GROSSE") }
true
33fe6b26b03d1608bc36981b1543ba4ea1244ba8
Rust
thodges314/Rust
/projects/chapters1_3/add_floats/src/main.rs
UTF-8
915
3.90625
4
[]
no_license
fn main() { let x_1 = 0.1; let x_2 = 0.1; println!("{}", x_1+x_2); let x_1: f32 = 0.1; let x_2: f32 = 0.1; println!("{}", x_1+x_2); let c = 'z'; let heart_eyed_cat='😻'; println!("{}{}{}", c, heart_eyed_cat, c); let number = 3; // if !!number { // does not work, does not return bool i...
true
967867f89ccfa839782ddf550dc13216d2cdbf87
Rust
beagleknight/roguelike-ecs
/src/systems/player_movement.rs
UTF-8
985
2.609375
3
[]
no_license
use specs::{Join, ReadStorage, System, WriteStorage}; use crate::components::{Block, Player, Position, Velocity}; pub struct PlayerMovement; impl<'a> System<'a> for PlayerMovement { type SystemData = ( WriteStorage<'a, Position>, ReadStorage<'a, Velocity>, ReadStorage<'a, Block>, R...
true
3b758068a34574c5364b4cc783b171234e61e88d
Rust
dam4rus/dam4nes
/src/rom.rs
UTF-8
2,102
3.1875
3
[]
no_license
pub(crate) const PRG_PAGE_SIZE: usize = 16 * 1024; pub(crate) const CRH_PAGE_SIZE: usize = 8 * 1024; #[derive(Debug, Default)] pub struct ROM { content: Vec<u8>, prg_rom_page_count: u8, chr_rom_page_count: u8, flags_6: u8, flags_7: u8, prg_ram_page_count: u8, flags_9: u8, flags_10: u8, ...
true
81b30770faf17e54e7e73a8b333742b410f2da19
Rust
ethindp/wasm-tools
/crates/wasm-mutate/src/mutators/remove_export.rs
UTF-8
2,960
2.875
3
[ "LLVM-exception", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Mutator that removes a random prexisting export use super::Mutator; use crate::{ModuleInfo, Result, WasmMutate}; use rand::prelude::SmallRng; use rand::Rng; use wasm_encoder::{Export, ExportSection, Module}; use wasmparser::ExportSectionReader; /// Mutator that removes a random prexisting export pub struct Remove...
true
8f9bb32f53d2bc904dc2f91b52b3ee3354552ef0
Rust
22388o/client_side_validation
/strict_encoding/src/net.rs
UTF-8
36,084
2.640625
3
[ "LicenseRef-scancode-public-domain-disclaimer", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// LNP/BP client-side-validation foundation libraries implementing LNPBP // specifications & standards (LNPBP-4, 7, 8, 9, 42, 81) // // Written in 2019-2021 by // Dr. Maxim Orlovsky <orlovsky@pandoracore.com> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neigh...
true
bb82281fe42949fe3b5849323b6821f32f219acb
Rust
transparencies/oas3-rs
/src/conformance/param.rs
UTF-8
1,705
3.171875
3
[ "MIT" ]
permissive
use std::cell::Cell; #[derive(Debug, Clone)] pub struct ParamReplacement { pub name: String, pub value: String, pub used: Cell<bool>, } impl ParamReplacement { pub fn new<N, V>(name: N, val: V) -> Self where N: Into<String>, V: Into<String>, { Self { name: n...
true
5409cb2b38515faa760b89b36b5b5bb4197bbddc
Rust
phiresky/tantivy
/src/directory/file_watcher.rs
UTF-8
5,464
2.859375
3
[ "MIT" ]
permissive
use crate::directory::{WatchCallback, WatchCallbackList, WatchHandle}; use crc32fast::Hasher; use std::fs; use std::io; use std::io::BufRead; use std::path::Path; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; use std::thread; use std::time::Duration; pub const POLLING_INTERVAL: Duration = Duratio...
true
090b332d9b47be57be8fe93205fe9e2ed9aaddb0
Rust
lygstate/rudy
/tests/smoke.rs
UTF-8
297
2.515625
3
[ "Apache-2.0", "MIT" ]
permissive
extern crate rudy; #[test] fn smoke_test() { use rudy::rudymap::RudyMap; let mut map: RudyMap<u32, u32> = RudyMap::new(); let n = 10_000; for i in 0..n { assert!(map.insert(i, i).is_none()); } for i in 0..n { assert_eq!(map.remove(i), Some(i)); } }
true
08cba564f748841648cdca1ad96109756b1a595e
Rust
nytopop/hyperbole
/examples/crud.rs
UTF-8
4,315
2.90625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A simple json CRUD api. #![allow(clippy::option_map_unit_fn)] use hyper::{server::Server, StatusCode}; use hyperbole::{ body::jsonr, f, r, record_args, reply::{self, Reply}, uri, App, Response, R, }; use serde::Serialize; use std::{ collections::BTreeMap, num::ParseIntError, ops::{Bound,...
true
1d95b16092e1de485d60e19c9a5968a56f1fb603
Rust
nilgradisnik/gmusic-to-spotify
/src/main.rs
UTF-8
2,188
2.625
3
[]
no_license
use dotenv; use std::env; use clap::clap_app; mod gmusic; mod spotify; use gmusic::{parse_songs, read_json_from_file, Song}; use spotify::{find_track, playlist_tracks_add, saved_tracks_add}; const VERSION: &'static str = env!("CARGO_PKG_VERSION"); const AUTHOR: &'static str = env!("CARGO_PKG_AUTHORS"); const DESCRI...
true
35088b1197000dafae11424b03e259950422efaa
Rust
johnwalker/jni-rs
/src/wrapper/objects/jclass.rs
UTF-8
841
2.78125
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::{ objects::JObject, sys::{jclass, jobject}, }; /// Lifetime'd representation of a `jclass`. Just a `JObject` wrapped in a new /// class. #[repr(transparent)] #[derive(Clone, Copy, Debug)] pub struct JClass<'a>(JObject<'a>); impl<'a> From<jclass> for JClass<'a> { fn from(other: jclass) -> Self {...
true
293d7c17f29bbd97bac5d14b2147c72a6fe90231
Rust
Dylan-Cannisi/ossim-oxide
/src/tiff/mod.rs
UTF-8
4,964
2.828125
3
[]
no_license
mod constants; mod display; mod parser; use std::error::Error; use std::fs::File; use std::fmt; use std::io::Read; use std::path::Path; use std::str::FromStr; use core::convert::From; use image::{ DynamicImage, ImageFormat, }; use crate::image::Loadable; use crate::flatten_vec_u16; pub struct Tiff { ...
true
6b789c123a6c0e8b2dec9f30956e21dfde73548d
Rust
lunacookies/fjord
/src/parser/error.rs
UTF-8
223
2.703125
3
[ "MIT", "Apache-2.0" ]
permissive
use text_size::TextRange; /// A syntax error encountered during parsing. #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub struct SyntaxError { pub(super) message: &'static str, pub(super) range: TextRange, }
true
60d11448464cbd9ec0e5c9c9d74d67ac384d886e
Rust
ashikkunjumon/cocogitto
/tests/coco_commit_test.rs
UTF-8
2,541
2.546875
3
[ "MIT" ]
permissive
use anyhow::Result; use assert_cmd::prelude::*; use std::process::Command; use tempfile::TempDir; mod helper; #[test] #[cfg(not(tarpaulin))] fn commit_ok() -> Result<()> { let current_dir = std::env::current_dir()?; let mut command = Command::cargo_bin("coco")?; let temp_dir = TempDir::new()?; std::en...
true
41a691260391c12642969baa56b43566a5cecd6f
Rust
mozamimy/mozami.me
/codes/2019/12/10/dht11.rs
UTF-8
2,849
3.078125
3
[]
no_license
const THRESHOLD_0_1: u32 = 250; const THRESHOLD_TIMEOUT: u32 = 2000; pub struct DHT11 { pin: rppal::gpio::IoPin, } pub struct Metric { pub temperature: f64, pub humidity: u8, pub parity: u8, } #[derive(failure::Fail, std::fmt::Debug)] pub enum DHT11Error { #[fail(display = "The expected parity is...
true
53b438f19ec9c013b277939f44b2bd144c939bc3
Rust
emmanueltouzery/zbus
/zvariant/src/from_value.rs
UTF-8
3,063
2.921875
3
[ "MIT" ]
permissive
use crate::Value; use crate::{Array, Dict, Error, Fd, Maybe, ObjectPath, Signature, Str, Structure}; use std::convert::TryFrom; macro_rules! value_try_from { ($kind:ident, $to:ty) => { impl<'a> TryFrom<Value<'a>> for $to { type Error = Error; fn try_from(value: Value<'a>) -> Result...
true
794b2c2dfff913d4d25a68e380a4823b7c7ede72
Rust
CristinaStaicu/AstroPlant-API
/src/controllers/quantity_type/mod.rs
UTF-8
1,772
2.53125
3
[]
no_license
use futures::future::FutureExt; use serde::Deserialize; use warp::{filters::BoxedFilter, Filter, Rejection}; use crate::database::PgPool; use crate::problem::{AppResult, Problem}; use crate::response::{Response, ResponseBuilder}; use crate::{helpers, models, views}; pub fn router(pg: PgPool) -> BoxedFilter<(AppResult...
true
9e9cebfa0bcfa84726541fc16969f05b213d6596
Rust
Torrencem/addcomb_kyle
/src/main.rs
UTF-8
1,827
2.921875
3
[]
no_license
use addcomb_comp::setlike::SetLike; use addcomb_comp::setlike::Group; use addcomb_comp::exactset; use addcomb_comp::comb::gcd; /// Compute whether there is a set A of size two such that [ia, ib]A = G /// If there is such a set, this function returns one of these sets. Otherwise, it returns None. fn do_two_elements_sp...
true