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
404a7319a68a78977324ea1051fd181c2585ab11
Rust
crackcomm/yew_router
/crates/yew_router_macro/src/lib.rs
UTF-8
4,203
3.578125
4
[ "Apache-2.0", "MIT" ]
permissive
extern crate proc_macro; use proc_macro::TokenStream; mod switch; /// Implements the `Switch` trait based on attributes present on the struct or enum variants. /// /// If deriving an enum, each variant should have a `#[to = ""]` attribute, /// and if deriving a struct, the struct itself should have a `#[to = ""]` att...
true
a0a1a9d7fd43de299f3c57599a0ed166085b724c
Rust
tezedge/tezedge-actor-system
/examples/basic.rs
UTF-8
698
2.8125
3
[ "MIT" ]
permissive
use std::time::Duration; use tezedge_actor_system::actors::*; #[derive(Default)] struct MyActor; // implement the Actor trait impl Actor for MyActor { type Msg = String; fn recv(&mut self, ctx: &Context<Self::Msg>, msg: Self::Msg, _sender: Sender) { println!("{} received: {}", ctx.myself.name(), msg)...
true
70b3367d9f6695477bfbe968465643587e49bbbb
Rust
CristinaStaicu/AstroPlant-API
/src/controllers/me/auth.rs
UTF-8
4,936
2.859375
3
[]
no_license
use futures::future::FutureExt; use serde::{Deserialize, Serialize}; use warp::{Filter, Rejection}; use crate::database::PgPool; use crate::problem::{self, AppResult, Problem}; use crate::response::{Response, ResponseBuilder}; use crate::{helpers, models}; /// Authenticate a user through provided credentials. /// Ret...
true
5dcbd8b438b7540e78823fb06c05581ef0c7342a
Rust
rustyforks/kiro-synth
/kiro-synth-engine/src/program/blocks/osc.rs
UTF-8
2,272
2.734375
3
[]
no_license
use kiro_synth_dsp::oscillators::osc_waveform::OscWaveform; use kiro_synth_dsp::oscillators::pitched_oscillator::PitchedOscillator; use crate::float::Float; use crate::globals::SynthGlobals; use crate::program::{Program, SignalRef}; use crate::signal::SignalBus; #[derive(Debug, Clone)] pub struct Inputs { pub shape...
true
e7fee30f000890d32bc700ae0d4aba85e17e7c6d
Rust
bjphilli/aoc
/2020/6/src/main.rs
UTF-8
2,519
3.34375
3
[]
no_license
use std::fs::File; use std::time::{Instant}; use std::io::{BufRead, BufReader, Error, Read}; use std::collections::HashSet; fn main() -> std::io::Result<()> { let begin = Instant::now(); let _ints = parse_file(File::open("input.txt")?)?; let part_one_answer = run_part_one(_ints.clone()); println!("Pa...
true
f08aa4890e00006a8c9183dc001f97c91c115c2e
Rust
bnjbvr/linear_scan
/src/gap.rs
UTF-8
3,265
2.828125
3
[ "MIT" ]
permissive
use crate::graph::{GapAction, GapActionKind, GapState, Graph, InstrId}; use crate::*; #[derive(PartialEq, Clone, Eq)] enum MoveStatus { ToMove, Moving, Moved, } pub trait GapResolver { fn resolve_gaps(&mut self); } trait GapResolverHelper { fn resolve_gap(&mut self, id: &InstrId) -> GapState; ...
true
1cce6b41584b86e3ccbc06fb1aedf825ca91d28e
Rust
katyo/c4dart
/src/main.rs
UTF-8
2,343
2.671875
3
[]
no_license
use std::{ path::PathBuf, fs::File, }; use regex::Regex; use log::LevelFilter; pub use c4dart::{Options, translate}; /// Command-line arguments #[derive(Debug, structopt::StructOpt)] #[structopt(about)] struct Args { /// Print version number #[structopt(short = "V", long)] version: bool, ...
true
821ca647c31e133a2a1eb96e2d4c75eb7ba5aa11
Rust
mockersf/jenkins-api.rs
/src/client_internals/errors.rs
UTF-8
2,996
3.125
3
[ "MIT" ]
permissive
use std::fmt; use thiserror::Error; /// Wrapper `Result` type pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; /// Errors that can be thrown #[derive(Debug, Error)] pub enum Error { #[error("invalid url for {expected}: {url}")] /// Error thrown when a link between objects has an unex...
true
90e0c30df74352361db14172275e697037408f58
Rust
Kixunil/parse_bitcoin
/src/types/block_header.rs
UTF-8
3,035
2.75
3
[ "MIT" ]
permissive
use crate::types::Bytes; use crate::types::Hash256; use chrono::prelude::*; use std::convert::TryInto; #[derive(Debug)] pub struct BlockHeader { pub version: u32, pub prev_block_hash: Hash256, pub merkle_root_hash: Hash256, pub time_str: String, pub time: u32, pub bits: Bytes, pub nonce: By...
true
7f60ac2898225b0cedbfa054898875982464f265
Rust
GTxx/leetcode
/algorithms/014. Longest Common Prefix/solution-rs/src/main.rs
UTF-8
1,247
3.609375
4
[]
no_license
struct Solution; impl Solution { pub fn longest_common_prefix(strs: Vec<String>) -> String { let mut prefix: String = String::new(); let mut idx :usize= 0; 'outer: loop { let mut common: Option<char> = None; for str in strs.iter() { if let Some(a) = ...
true
cf859a270acf9bc1d678a5388edfddcedb17b302
Rust
coriolinus/adventofcode-2016
/day11/src/gadget.rs
UTF-8
414
3.078125
3
[]
no_license
use std::fmt; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] pub enum Gadget { Generator, Microchip, } impl fmt::Display for Gadget { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "{}", match self { Se...
true
4833baeac819e608f37b680e5c9986309be02e1d
Rust
slmjkdbtl/dirty_rust
/src/math/map.rs
UTF-8
397
3.046875
3
[ "Zlib" ]
permissive
// wengwengweng use std::ops::*; pub trait Map: Copy + Add<Output=Self> + Sub<Output=Self> + Mul<f32, Output=Self> + Div<Output=f32> { fn map(self, a1: Self, a2: Self, b1: Self, b2: Self) -> Self { let r = (self - a1) / (a2 - a1); return b1 + (b2 - b1) * r; } } impl<T> Map for T where T: Copy + Add<O...
true
0abd54bdc85ba9ff4b6f2ed363b2b681ecfb52f7
Rust
00mjk/stylist-rs
/packages/stylist/src/macros.rs
UTF-8
5,446
3.625
4
[ "MIT" ]
permissive
//! This module contains runtime support for the macros and documents their usage. //! //! There are two syntaxes available: [string literal] and [inline]. //! //! # String Literal //! //! This syntax is simliar to the [`format!`] macro from the standard library. //! //! The first argument of this syntax is a string li...
true
91a0c362109553723407165a44b0097b2505fb03
Rust
davecrowder/piClock
/src/main.rs
UTF-8
7,375
3
3
[]
no_license
use std::time::Duration; use std::thread::{sleep, spawn}; use std::sync::mpsc::{channel, Sender}; // use std::convert::TryInto; use chrono::prelude::*; use rppal::spi::{Bus, Mode, SlaveSelect, Spi}; use rppal::gpio::{Gpio, Level, Trigger}; // use rppal::spi::*; fn main() { // Open the SPI bus. let mut display ...
true
0f54a8dda217b999d7d621175a1bc670f061bb8a
Rust
3c1u/fluent-rs
/fluent-bundle/tests/functions_test.rs
UTF-8
2,270
2.8125
3
[ "MIT", "Apache-2.0" ]
permissive
mod helpers; use fluent_bundle::errors::FluentError; use fluent_bundle::resolve::ResolverError; use fluent_bundle::FluentValue; use std::collections::HashMap; use self::helpers::{ assert_format, assert_format_no_errors, assert_get_bundle_no_errors, assert_get_resource_from_str_no_errors, }; #[test] fn functio...
true
9c51584411914246dcc7de610805c83d5be05a38
Rust
ypoluektovich/tmux-interface-rs
/src/commands/key_bindings/unbind_key_tests.rs
UTF-8
2,231
2.796875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[test] fn unbind_key() { use crate::UnbindKey; use std::borrow::Cow; // # Manual // // ```text // tmux ^2.4: // tmux unbind-key [-an] [-T key-table] key // (alias: unbind) // ``` // // tmux ^2.1: // ```text // tmux unbind-key [-acn] [-t mode-table] [-T key-table] ke...
true
28b9a325e5aac459ba6e01fa988eccc9f4e9b839
Rust
jtgs/advent-of-code
/src/two.rs
UTF-8
952
3.109375
3
[]
no_license
use crate::intcode::*; pub fn part_a() -> i64 { let mut program = Intcode::from_file("input2.txt"); program.program[1] = 12; program.program[2] = 2; program.run(); program.program[0] } pub fn part_b() -> i64 { let base = Intcode::from_file("input2.txt"); for noun in 0..100 { fo...
true
30368ac05aa728524b0e68013abecc37932ae231
Rust
tesuji/rust_inline_bug
/src/y2015/day_20.rs
UTF-8
1,215
3.453125
3
[]
no_license
pub fn solve(){ const INPUT : &str = include_str!("../../inputs/2015/20"); let target_presents : usize = INPUT.parse().unwrap(); let input = target_presents / 10; let mut house_number = input; let mut houses = vec![0;input]; for i in 1..input { let mut elf = i; while elf < in...
true
14b9b1cdd2ac3b4dcf87a37c2555143283f7dc20
Rust
manpat/web-common-rs
/src/rendering/shader.rs
UTF-8
10,295
2.734375
3
[]
no_license
#![allow(dead_code)] use std; use math::*; use rendering::gl; use std::fmt::Write; #[derive(Copy, Clone, Debug)] pub struct Shader { pub gl_handle: u32, pub proj_loc: i32, pub view_loc: i32, } impl Shader { pub fn new(vertex_shader_src: &str, fragment_shader_src: &str) -> Result<Shader, String> { use std::ff...
true
226cbcbb63938946c0e4f6291885f858fc0fce87
Rust
dfrankland/sfbart
/src/client/apis/route_information/routes.rs
UTF-8
2,524
2.84375
3
[ "MIT" ]
permissive
use crate::client::{ constants::{color::Color, PUBLIC_KEY}, serde_helpers::from_str, }; use anyhow::Result; use chrono::NaiveDate; use reqwest; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct Route { pub name: String, // Should be an enum pub a...
true
94dca5f544a8d4d1cd25426d42852e09eb4bb993
Rust
asandst/aoc_2020
/src/bin/day7.rs
UTF-8
2,524
3.203125
3
[]
no_license
extern crate regex; use regex::Regex; use std::collections::HashMap; use std::collections::HashSet; use std::fs::File; use std::io::prelude::*; use std::io::{self, BufReader}; fn main() -> io::Result<()> { let input = File::open("input_day7")?; let input = BufReader::new(input); let bag_regex = Regex::ne...
true
4f43139a5d7fb730b2138b2480763d1f6370b467
Rust
hardenedapple/playing_with_rust
/src/string_word_swap/mod.rs
UTF-8
4,129
3.578125
4
[]
no_license
/* Algorithm: Take a string type, have two pointers that iterate from either end. Each pointer stores elements into a String buffer one character at a time. When either pointer reaches a space, it moves its data into the other end of the total string. Alternate (better) algorithm: Take a string ...
true
367f1ba81a105492217d944a3b243bea8f4769aa
Rust
ModProg/docker-game-servers
/src/server/ls.rs
UTF-8
5,038
2.640625
3
[]
no_license
use std::collections::HashMap; use std::convert::TryFrom; use std::iter; use anyhow::{bail, Result}; use bollard::container::ListContainersOptions; use bollard::models::{ContainerStateStatusEnum, PortTypeEnum}; use bollard::Docker; use clap::Clap; use comfy_table::presets::UTF8_FULL; use comfy_table::{Cell, CellAlignm...
true
885ecb13794b4c53cefa7c0492848daa591c7362
Rust
creativcoder/forest
/ipld/amt/src/value_mut.rs
UTF-8
1,192
3
3
[ "MIT", "Apache-2.0" ]
permissive
// Copyright 2020 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT use std::ops::{Deref, DerefMut}; /// A wrapper around a mutable reference to a value in an Amt. Keeps track of whether /// the value was mutated by setting a flag when `DerefMut::deref_mut` is called. pub struct ValueMut<'a, V> { valu...
true
817e9c41a943decbae94f25bfe676f849c6a949c
Rust
swlody/advent-2019-rs
/src/day7.rs
UTF-8
2,106
2.796875
3
[]
no_license
use crate::intcode::*; use itertools::Itertools; #[aoc_generator(day7)] fn input_generator(input: &str) -> Vec<i64> { input .trim() .split(',') .map(|x| { x.parse() .unwrap_or_else(|_| panic!("Unable to parse \"{}\" as integer", x)) }) .collect() ...
true
8cb1d31a5029500cf7ccfa8b4d8272e4fe709a86
Rust
planet0104/miniprogram-gifmaker
/server/wx_sec_check/src/sec_check.rs
UTF-8
3,136
2.59375
3
[]
no_license
use std::{time::Instant, io::Read}; use crate::{token::*, tools::bytes_to_string}; use anyhow::Result; use bytes::Bytes; use log::info; use multipart::client::lazy::Multipart; use serde::{Deserialize, Serialize}; use serde_json::json; #[derive(Debug, Serialize, Deserialize)] pub struct CheckResult { pub(crate) err...
true
a2a1ab48c0628d4a22af7ec6d8224601a8a60408
Rust
bohdaq/rust-web-server
/src/response/example/mod.rs
UTF-8
3,818
2.734375
3
[]
no_license
use file_ext::FileExt; use crate::header::Header; use crate::http::VERSION; use crate::mime_type::MimeType; use crate::range::{ContentRange, Range}; use crate::response::{Response, STATUS_CODE_REASON_PHRASE}; #[test] fn parse() { // in this example response is from reading a file let path = FileExt::build_path...
true
1d013798a7ccffa94774f015a103d4faccdeab45
Rust
arturocs/Toy-interpreter
/interpreter/src/parser.rs
UTF-8
4,793
3.296875
3
[]
no_license
use crate::tokenizer::*; use expr_eval::{parser::parse_expr, parser::ParseExprNode, tokenizer::tokenize_expr}; type Error = &'static str; #[derive(PartialEq, Debug, Clone)] pub enum ParseNode { If(Box<ParseNode>, Vec<ParseNode>, Option<Vec<ParseNode>>), //If(Expression, If block, Else Block) While(Box<ParseNod...
true
218d1d571942fc8e93f17c6fad685595389dc50b
Rust
charlescerisier/tempest
/tempest-source/src/source.rs
UTF-8
6,705
2.765625
3
[ "MIT" ]
permissive
use config; use log::{debug, error, info, log, trace, warn}; use serde_derive::Deserialize; use std::fmt; use std::time::{Duration, SystemTime, UNIX_EPOCH}; static TARGET_SOURCE_BUILDER: &'static str = "tempest::source::SourceBuilder"; /// `SourceBuilder` trait for defining how to configure /// structs that implement...
true
5568436a4ecb5b28d4d81857e9cccb9538ba86b2
Rust
d3lio/lexpar
/src/parser.rs
UTF-8
53,013
4.375
4
[ "Apache-2.0", "MIT" ]
permissive
//! This module contains parser related macros and structures. //! //! The following chapters will walk you through the basics of the `parse_rules` macro. //! Prior knowledge of [formal grammars](https://en.wikipedia.org/wiki/Formal_grammar) //! is recommended but not necessary. If you are familiar with grammars just s...
true
6da95e8cc6d3cfc6ac0d33dda6aec742253fe219
Rust
nushell/nushell
/crates/nu-cmd-extra/src/extra/bits/not.rs
UTF-8
5,952
2.828125
3
[ "MIT" ]
permissive
use super::{get_number_bytes, NumberBytes}; use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, }; #[derive(Clone)] pub struct BitsNot; impl C...
true
3ef724580c4aeaa94e5d8261371184e9b3f611f0
Rust
xitep/lines-rs
/src/linemapper.rs
UTF-8
2,154
3.671875
4
[ "MIT" ]
permissive
//! Implements line-by-line iteration over a given reader by mapping a //! user defined function over each line. use std::io::{BufRead, Result}; use bytes; /// Counts the number of lines in the given reader by utilizing /// `map_lines`. pub fn count_lines<R: BufRead>(r: R) -> Result<usize> { let mut lines = 0usiz...
true
c2f408e13506f028ade2c47831231cac1c70fdee
Rust
cpprhtn/Rust-study
/generic-types/src/main.rs
UTF-8
1,985
4.125
4
[ "MIT" ]
permissive
/* // 함수 정의 내에서 제네릭 데이터 타입 fn largest_i32(list: &[i32]) -> i32 { let mut largest = list[0]; for &item in list.iter() { if item > largest { largest = item; } } largest } fn largest_char(list: &[char]) -> char { let mut largest = list[0]; for &item in list.iter() { ...
true
3b9790a489a7baead5a1d0206d0ef733825b657b
Rust
n4o847/procon-rust
/accepted/abc171_d.rs
UTF-8
444
2.5625
3
[]
no_license
use proconio::{fastout, input}; #[fastout] fn main() { input! { n: usize, a: [usize; n], q: usize, } let mut s = 0; let mut z = vec![0; 100001]; for x in a { z[x] += 1; s += x; } for _ in 0..q { input! { b: usize, c: usize, ...
true
6a25782aa47e828df0ba6fb0c52248cb4718a586
Rust
nathanfaucett/rs-gc
/src/gc_state.rs
UTF-8
3,155
2.703125
3
[ "MIT" ]
permissive
use alloc::heap; use alloc::boxed::Box; use core::mem; use core::ptr::Shared; use super::gc_box::GcBox; use super::gc_mark::GcMark; const INITIAL_THRESHOLD: usize = 128_usize; const USED_SPACE_RATIO: f64 = 0.7_f64; pub struct GcState { gc_box_root: Option<Shared<GcBox<GcMark>>>, bytes_allocated: usize, ...
true
dbb12814de5e8e47507ec0454cb522a9e6d52113
Rust
minus3theta/contest
/atcoder/abc/130/f.rs
UTF-8
3,759
2.84375
3
[]
no_license
#[allow(unused_imports)] use std::cmp; // Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let s = { use std::io::Read; let mut ...
true
58d9c97b9d84cb352b64287951027bb285b878f9
Rust
phoenicyan/wtl-rs
/src/atl/dialog_impl/dlg_msg.rs
UTF-8
61,625
2.53125
3
[]
no_license
use winapi::um::winuser::*; //use super::super::cwindow::*; use atl::consts::*; use atl::{Event,Handler,HandlerPriority}; pub struct DlgMsg <'a,T:'a> { h:&'a mut Vec<Handler<T>>, } impl<'a,T> DlgMsg<'a,T> { pub fn new(h:&'a mut Vec<Handler<T>>)->DlgMsg<'a,T>{ DlgMsg{ h:h, } } } /// ad...
true
b8e9bfc6067e7054e98970562e72538a64c45328
Rust
suppergerrie2/AdventOfCode2020
/aoc_utils/src/day_runner.rs
UTF-8
391
2.96875
3
[]
no_license
// pub trait Day { // fn part1(&self) { // eprintln!("part 1 is not implemented") // } // // fn part2(&self) { // eprintln!("Part 2 is not implemented") // } // } pub fn run_day<F1, F2>(part1: F1, part2: F2) where F1: Fn(), F2: Fn() { println!("Part 1... "); // day.part1(); ...
true
12d1b27d6798c19077a68876ebb87d1d50a49d45
Rust
postmates/yup-oauth2
/src/installed.rs
UTF-8
14,722
2.59375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright (c) 2016 Google Inc (lewinb@google.com). // // Refer to the project root for licensing information. // extern crate serde_json; extern crate url; use std::borrow::BorrowMut; use std::convert::AsRef; use std::error::Error; use std::io; use std::io::Read; use std::sync::Mutex; use std::sync::mpsc::{channel,...
true
92353cdd0d3069aa8e4e725cc9975e33a1ac7d5f
Rust
ckuenzi/AoC
/aoc_2019/src/day24.rs
UTF-8
4,078
2.78125
3
[ "Unlicense" ]
permissive
use hashbrown::{HashMap, HashSet}; #[aoc(day24, part1)] fn part1(input: &str) -> u64 { let mut eris = grid_gen(input); let mut past_states = HashSet::new(); loop { if past_states.contains(&eris) { break; } else { past_states.insert(eris.clone()); }...
true
e5816bcdb4b6df49964f4b2651ffc3cd7a3e9a64
Rust
kbalt/bytesstr
/src/lib.rs
UTF-8
5,682
3.984375
4
[ "MIT" ]
permissive
//! A thin wrapper around [Bytes](https://crates.io/crates/bytes) which guarantees UTF8 encoded content. #![no_std] extern crate alloc; use alloc::string::String; use bytes::Bytes; use core::fmt; use core::ops::Deref; use core::str::{from_utf8, from_utf8_unchecked, Utf8Error}; #[cfg(feature = "serde")] mod serde; /...
true
b0612c2282c02d58a9cc3398312da52a76e36d01
Rust
xeenypl/crab
/src/get_content.rs
UTF-8
830
2.546875
3
[ "MIT" ]
permissive
use std::fs; use std::io; use std::io::Read; use std::path::Path; use std::string::String; pub fn get(name: &str, post: Option<&str>) -> String { let error_prefix = &ansi_term::Color::Red.paint("[Connection Errer]: "); if name == "stdin" { let mut buf = String::new(); io::stdin() .l...
true
3cc50b6b32bd4f3cdc9e50bc76b15942e3667c11
Rust
winksaville/fuchsia
/src/connectivity/network/netstack3/core/src/transport/tcp.rs
UTF-8
1,975
2.703125
3
[ "BSD-3-Clause" ]
permissive
// Copyright 2018 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //! The Transmission Control Protocol (TCP). pub(crate) use self::types::*; mod types { use zerocopy::{AsBytes, FromBytes, Unaligned}; use crate...
true
c4c24174871b5bfcdba072f5ab6a63f47ac57e77
Rust
bevyengine/bevy
/crates/bevy_hierarchy/src/components/parent.rs
UTF-8
1,540
3.03125
3
[ "Apache-2.0", "MIT", "Zlib", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive" ]
permissive
use bevy_ecs::{ component::Component, entity::{Entity, EntityMapper, MapEntities}, reflect::{ReflectComponent, ReflectMapEntities}, world::{FromWorld, World}, }; use bevy_reflect::Reflect; use std::ops::Deref; /// Holds a reference to the parent entity of this entity. /// This component should only be ...
true
526f3444b8fcff2dda684b232c87df1ebd8b0866
Rust
rojo-rbx/rbx-dom
/rbx_types/src/material_colors.rs
UTF-8
8,145
3.328125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::collections::BTreeMap; use thiserror::Error; use crate::Color3uint8; use crate::Error as CrateError; #[derive(Debug, PartialEq, Clone, Default)] #[cfg_attr( feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(transparent) )] /// Represents the mapping of materials to colors u...
true
7600237514974b7c600a6d42d24717a740e12215
Rust
nibon7/moderncv-rs
/tests/test_section.rs
UTF-8
2,518
2.890625
3
[ "MIT" ]
permissive
use latex::Element; use moderncv::section::*; #[test] fn test_cventry() { let left = cventry( "2020--2021", "Degree", "Institution", "City", Some(r"\textit{Grade}"), Some("Description"), ); let right = Element::UserDefined( r"\cventry{2020--2021}{Degr...
true
9ca236f61908491f921f90f12913559f4985af57
Rust
piotr-cla/ockam
/implementations/rust/ockam/ockam_core/src/address.rs
UTF-8
1,346
3.125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::lib::{ fmt::{self, Display}, String, Vec, }; use core::ops::Deref; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Hash, Ord, PartialOrd, Eq, PartialEq, Serialize, Deserialize)] pub struct Address(Vec<u8>); impl Display for Address { fn fmt<'a>(&'a self, f: &mut fmt::Formatter) -> f...
true
4462943e9ddf5f00ddb585d66e0bd366ee8a1d4b
Rust
alaricsp/rust-workshop
/08-traits/src/main.rs
UTF-8
4,816
4.09375
4
[ "MIT", "Apache-2.0", "CC-BY-4.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
// Traits give Rust a bit of an object oriented character. Traits can be seen as interfaces in // e.g. Java. You can implement functions in traits directly or leaf them open to the implementor. // The later are called "required functions" in a trait, that have to be implemented. // // For example the `Iterator` trait h...
true
b5e0473a9b8d0a92c0f27e5540bc934ab7e70a8e
Rust
nham/hs_fri_job_prep
/11jul_recursion/sum.rs
UTF-8
479
2.96875
3
[]
no_license
fn sum(v: &[int]) -> int { if v.len() == 0 { 0 } else { *v.get(0).unwrap() + sum(v.slice_from(1)) } } fn main() { let mut v = vec!(); println!("{}", sum(v.as_slice())); v.push(1); println!("{}", sum(v.as_slice())); v.push(2); println!("{}", sum(v.as_slice())); v....
true
33626363d8d6ed2dbf5482a6522749e017bc2eba
Rust
StackDoubleFlow/RustMcServer
/src/network.rs
UTF-8
10,522
2.515625
3
[]
no_license
extern crate openssl; extern crate rand; extern crate reqwest; use crate::utils; use crate::mojang::{Mojang, MojangHasJoinedResponse}; use crate::packets::*; use crate::player::Player; use openssl::pkey::Private; use openssl::rsa::{Padding, Rsa}; use rand::Rng; use serde::{Deserialize, Serialize}; use serde_json::json;...
true
7ba85c273a50f21dea200c9d5521b6f6e6427282
Rust
rustwasm/wasm-bindgen
/crates/wasm-interpreter/src/lib.rs
UTF-8
15,341
3.1875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A tiny and incomplete wasm interpreter //! //! This module contains a tiny and incomplete wasm interpreter built on top of //! `walrus`'s module structure. Each `Interpreter` contains some state //! about the execution of a wasm instance. The "incomplete" part here is //! related to the fact that this is *only* use...
true
9a63b3cfe13dde38660e4ee07639bd2e3b4f6908
Rust
iotaledger/iota.rs
/client/examples/node_api_indexer/05_get_nft_output.rs
UTF-8
1,411
2.5625
3
[ "Apache-2.0" ]
permissive
// Copyright 2022 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 //! Calls `GET api/indexer/v1/outputs/nft/{nftId}`. //! Run: `cargo run --example node_api_indexer_get_nft_output --release -- [NODE URL] [NFT ID]`. use std::str::FromStr; use iota_client::{block::output::NftId, Client, Result}; #[tokio::main] a...
true
6b7cde1fe703a3ad7c8dc66595051f571cf3e166
Rust
killercup/rune
/crates/runestick/src/module.rs
UTF-8
31,486
2.890625
3
[ "MIT", "Apache-2.0" ]
permissive
//! Crate used for definint native *modules*. //! //! A native module is one that provides runestick functions and types //! through native code. use crate::collections::HashMap; use crate::{ Component, Future, Hash, Stack, ToValue, Type, TypeInfo, TypeOf, UnsafeFromValue, VmError, VmErrorKind, }; use std::any...
true
9d6f00a7958f1c18bea27891dd9ddefcfbdfb4ec
Rust
mdeg/dengbot
/src/runner.rs
UTF-8
7,297
2.515625
3
[ "MIT" ]
permissive
use std::sync::mpsc::{self, Receiver}; use std::thread; use storage; use diesel::pg::PgConnection; use types::*; use denghandler::DengHandler; use slack; use hyper; use command; use r2d2_diesel::ConnectionManager; use r2d2::Pool as ConnectionPool; use std::time::Duration; use rand::{Rng, thread_rng}; use std::fmt::{sel...
true
8bed2b0d810aa6e3d68d51f84acfb29221d426bc
Rust
jsz6389/bsoz-emu
/src/lda.rs
UTF-8
1,467
2.828125
3
[ "MIT" ]
permissive
/* SPDX-License-Identifier: MIT * * lda.rs * * Contains functions for performing LDA instructions * * Copyright (C) 2021 Jakob Zielinski <jakobzee3@gmail.com> */ use cpu; use mem; use address; use setflags; /* * Executes the LDA instruction * * @param cpu The cpu onto which the instruction will be executed ...
true
cf00227072f887edfe126ec7f2b2df64480aabdf
Rust
book-resources/rustlernen
/10-Benutzerdefinierte Typen/programmtext-132.rs
UTF-8
110
3.296875
3
[]
no_license
fn main() { let a: u8 = 10; let b: Option<u8> = Some(10); println!("a + b = {}", a + b); // Fehler! }
true
befd54a8109a49df334892cefef52958388cfc60
Rust
layyne/advent-of-code-2020
/day2/src/lib.rs
UTF-8
2,972
3.03125
3
[]
no_license
use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; pub fn count_valid_passwords(filename: &str) -> i32 { if let Ok(lines) = read_lines(filename) { let mut count = 0; let mut valid_count = 0; let mut buffer = String::new(); for line in lines { let line...
true
2780293157673ecf32e693c3c7fa12bb5e4c8505
Rust
skletsun/exonum
/exonum/src/node/connect_list.rs
UTF-8
6,709
2.8125
3
[ "Apache-2.0" ]
permissive
// Copyright 2019 The Exonum Team // // 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 i...
true
15e0455ae176c5407cc036fa04312ca7cb9e30b2
Rust
rwuttke/lexgen
/src/range_map.rs
UTF-8
10,526
3.65625
4
[ "MIT" ]
permissive
use std::cmp::{max, min}; /// A map of inclusive ranges, with insertion and iteration operations. Insertion allows /// overlapping ranges. When two ranges overlap, value of the overlapping parts is the union of /// values of the overlapping ranges. #[derive(Debug)] pub struct RangeMap<A> { // NB. internally we don...
true
c801bc42bea1a7c1ccb0ea7e389ef27dfed5ea99
Rust
Oyelowo/coding_practice
/rust/systems-programming/lifetime-ownerships-borrowing/src/main.rs
UTF-8
649
3.015625
3
[]
no_license
use std::cell::RefCell; trait Animal { fn live(&self); } struct Goat {} impl Animal for Goat { fn live(&self) { todo!() } } struct Human {} impl Animal for Human { fn live(&self) { todo!() } } fn main() { let k: Box<dyn Animal> = Box::new(Goat {}); let mut k: Box<dyn An...
true
12e11e1e626db526c7362bcc3844af56213f4358
Rust
fintelia/timekeeper
/src/timerset.rs
UTF-8
3,375
3.4375
3
[]
no_license
use std::collections::HashMap; use std::cmp::Eq; use std::hash::Hash; use crate::Tracker; use crate::Source; /// A timer set tracks a collection of timers, of which at most one can be /// running at any given time. #[cfg(not(feature = "disable_timekeeper"))] pub struct TimerSet<Key: Eq + Hash + Clone, T: Tracker, S:...
true
a95ce97176f1e5796f3ba780dab1b0d86c3101af
Rust
craftgear/exercism_workout
/rust/sum-of-multiples/src/lib.rs
UTF-8
175
3
3
[]
no_license
pub fn sum_of_multiples(limit: u32, factors: &[u32]) -> u32 { (0..limit) .filter(|x| factors.into_iter().filter(|&v| v > &0).any(|v| x % v == 0)) .sum() }
true
9847a7c670e5c1c740b75c26ebbd4e81997be485
Rust
najamelan/async_runtime
/examples/localpool.rs
UTF-8
1,475
3.625
4
[ "Unlicense" ]
permissive
//! In this example we make a future that is not Send. We then spawn that future on a LocalPool executor. #[ cfg(not( target_arch = "wasm32" )) ] // fn main() { use { async_runtime :: { * } , std :: { rc::Rc, cell::RefCell } , }; // RefCell is not Send // let number = Rc::new...
true
c35d85dbb664dd7437e26dd042f2d09924eff6e4
Rust
kennethlarsen/rember-cli
/src/component.rs
UTF-8
2,133
3.015625
3
[]
no_license
use fs_extra::file::write_all; use super::utils::{update_values_in_files, uppercase_first_letter}; pub fn generate_component(name: &str, component_class: bool) { // TODO: if app/components does not exist throw error write_all( format!("app/components/{}.hbs", name), "{{yield}}" ); println!("Created ap...
true
c65b73cf0ce92ef2a5d6133ed05b728c6c7b0edb
Rust
wusyong/troika
/benches/troika_benchmark.rs
UTF-8
1,187
2.53125
3
[ "MIT" ]
permissive
#[macro_use] extern crate criterion; extern crate rand; use rand::{thread_rng, Rng}; use criterion::Criterion; use troika::ftroika::Ftroika; use troika::troika::Troika; use troika::Sponge; fn basic_troika() { let mut troika = Troika::default(); let mut input = [0u8; 8019]; let mut output = [0u8; 243]; ...
true
c78395f9951ba10e3b9507019c1f470cafdb0bbd
Rust
starblue/advent_of_code
/a2018/src/bin/a201825.rs
UTF-8
1,793
2.765625
3
[]
no_license
use std::io; use std::io::Read; use std::str::FromStr; use nom::bytes::complete::tag; use nom::character::complete::char; use nom::character::complete::digit1; use nom::character::complete::line_ending; use nom::combinator::map_res; use nom::combinator::opt; use nom::combinator::recognize; use nom::multi::separated_li...
true
34ea641f8ccfb5e42c54d69ae1a7f1bb7de9a951
Rust
saturn-xiv/peony
/src/plugins/ops/crawler/models/log.rs
UTF-8
2,329
2.71875
3
[ "MIT" ]
permissive
use actix_web::http::StatusCode; use chrono::NaiveDateTime; use diesel::{ delete, dsl::{now, IntervalDsl}, insert_into, prelude::*, }; use super::super::super::super::super::{ errors::{Error, Result}, orm::postgresql::Connection, request::https_client, }; use super::super::schema::ops_crawl...
true
5c678125434827e9bfc8c6ab54ed463516e10809
Rust
devg1120/actor_test
/network/src/main.rs
UTF-8
3,134
2.71875
3
[]
no_license
/* * https://qiita.com/atsuk/items/6b620484aad019638795 * Actor model by Rust with Actix * */ extern crate actix; use actix::prelude::*; mod network; mod router; struct Ping(usize); impl Message for Ping { type Result = usize; } struct Pkt{body: String,} impl Message for Pkt { type Result = String...
true
feba76ce9ee735d7b694bd7e70a225008d56375f
Rust
nthery/practical-networked-apps-rust
/src/store_be.rs
UTF-8
7,066
2.875
3
[ "MIT" ]
permissive
use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::fs::{self, File, OpenOptions}; use std::io::{prelude::*, BufReader, BufWriter, ErrorKind, SeekFrom}; use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; use tempfile::NamedTempFile; use crate::engine::KvsEngine; use crate::error::*; ...
true
f2e06735370fa350eac66f840bc97a7981d42021
Rust
ejmahler/RustFFT
/src/sse/sse_utils.rs
UTF-8
8,112
2.859375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use core::arch::x86_64::*; // __ __ _ _ _________ _ _ _ // | \/ | __ _| |_| |__ |___ /___ \| |__ (_) |_ // | |\/| |/ _` | __| '_ \ _____ |_ \ __) | '_ \| | __| // | | | | (_| | |_| | | | |_____| ___) / __/| |_) | | |_ // |_| |_|\__,_|\__|_| |_| |____/_____|_.__/...
true
e80309db8f04bb813481f99759ec0d3ecc73503a
Rust
kuviman/trans-gen
/src/gens/typescript/mod.rs
UTF-8
10,055
2.9375
3
[ "MIT" ]
permissive
use super::*; fn conv(name: &str) -> String { name.replace("Int32", "Int") .replace("Int64", "Long") .replace("Float32", "Float") .replace("Float64", "Double") } pub struct Generator { files: HashMap<String, String>, } fn type_name(schema: &Schema) -> String { match schema { ...
true
71b4b4d5c94f80b1ee3212d4b7e73725375b7b09
Rust
ebfull/nemo
/tests/run-fail/close.rs
UTF-8
1,760
2.8125
3
[ "MIT" ]
permissive
// error-pattern:Worked! extern crate nemo; use nemo::*; use nemo::session_types::*; use nemo::peano::*; fn main() { use nemo::channels::Blocking; struct MyProtocol; type Orig = Send<usize, Recv<usize, End>>; type Other = Recv<usize, Send<usize, End>>; impl Protocol for MyProtocol { type I...
true
ccc79c3e13feda904553d58a5ecf23e375d97e78
Rust
wyattlake/rust-web-server
/src/bin/main.rs
UTF-8
1,451
2.96875
3
[]
no_license
use std::fs; use std::io::prelude::*; use std::net::TcpListener; use std::net::TcpStream; use hello::ThreadPool; fn main() { let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); let pool = ThreadPool::new(4); for stream in listener.incoming() { let stream = stream.unwrap(); pool....
true
387c80d1a8b45e981d27147dba8bb7dfa5a2540d
Rust
wawuta/wzCore
/src/task/job.rs
UTF-8
1,066
2.5625
3
[ "Apache-2.0" ]
permissive
use alloc::collections::BTreeSet; use alloc::sync::{Arc, Weak}; use crate::object::KObjectBase; use crate::task::job_policy::*; pub struct Job { base: KObjectBase, pub(super) policy: JobPolicy, parent: Option<Arc<Job>>, children: BTreeSet<Weak<Job>>, } impl Job { /// Create a new child job object...
true
4c035facb11a24b253a725de7879f491d86e829f
Rust
satanson/rust_etudes
/Longest_Palindromic_Substring/src/main.rs
UTF-8
1,894
3.234375
3
[]
no_license
struct Solution {} impl Solution { pub fn lcs(s1: &String, s2: &String) -> (usize, usize) { if s1.is_empty() || s2.is_empty() { return (0, 0); } let ss1 = s1.as_bytes(); let ss2 = s2.as_bytes(); let n1 = ss1.len(); let n2 = ss2.len(); let mut mat: Vec<Vec<i32>> = Vec::new(); let...
true
9709afbb7346ace6631b0d0fd56bb74a3bfd6d99
Rust
dtolnay/miniserde
/src/place.rs
UTF-8
923
2.96875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
/// Macro to define a "place" type compatible with deserialization. /// /// [Refer to the `miniserde::de` documentation for examples.][crate::de] /// /// This macro expands to: /// /// ```rust /// # macro_rules! make_place { /// # ($name:ident) => { /// struct $name<T> { /// out: Option<T>, /// } /// /// impl<T...
true
b011e782335f9fc3833bddd0b2d26ba140812952
Rust
deciduously/librollenspielsache
/src/interface/ffi_string.rs
UTF-8
697
3.046875
3
[ "BSD-3-Clause" ]
permissive
//! This just wraps up strings for passing over the border use super::*; /// Helper function to free strings generated by Rust. /// Clients need to call this to ensure proper cleanup. /// It is recommended to do iso in a way such that your finding performs this automatically. /// See the [Rust FFI Omnibus](http://jak...
true
117f40d90912cb2f424a4517111b9011a59718a5
Rust
polyhorn/polyhorn
/crates/polyhorn-ui/src/color/encoding.rs
UTF-8
1,182
3
3
[ "MIT" ]
permissive
//! Custom encodings for alternative color spaces. use palette::encoding::Srgb; use palette::float::Float; use palette::rgb::{Primaries, RgbSpace, RgbStandard}; use palette::white_point::{WhitePoint, D65}; use palette::{Component, Yxy}; /// This is the Display-P3 color space. #[derive(Copy, Clone, Debug, PartialEq)] ...
true
f92390d74538a9f24d797caf6632ab0e67ff9cc7
Rust
kirikaza/postgread
/src/msg/body/parse.rs
UTF-8
2,140
3.0625
3
[]
no_license
use crate::msg::type_byte::TypeByte; use crate::msg::util::decode::*; use crate::msg::parts::{Text, decode_vec}; #[derive(Clone, Debug, PartialEq)] pub struct Parse { pub prepared_statement_name: Text, pub query: Text, pub parameters_types: Vec<u32>, } impl MsgDecode for Parse { const TYPE_BYTE_OPT: O...
true
bc275e2e435f38a57e304c03d9d91c49aa11af71
Rust
pombredanne/symbolic
/symbolic-common/src/types.rs
UTF-8
30,625
2.53125
3
[ "MIT", "Apache-2.0" ]
permissive
//! Common types and errors used in `symbolic`. use std::borrow::Cow; use std::fmt; use std::str; #[cfg(feature = "serde")] use serde_::{Deserialize, Serialize}; /// Names for x86 CPU registers by register number. static I386: &[&str] = &[ "$eax", "$ecx", "$edx", "$ebx", "$esp", "$ebp", "$esi", "$edi", "$eip", "...
true
40ec324e1d28b6b16c8484d7002581254cd4e953
Rust
nasqueron/docker-registry-api
/src/registry.rs
UTF-8
7,332
3.09375
3
[ "BSD-2-Clause" ]
permissive
use lazy_static::lazy_static; use log::error; use regex::Regex; use serde_derive::{Deserialize, Serialize}; use std::fs::{DirEntry, File, read_dir}; use std::io::{Read, Result as IOResult}; use std::path::Path; /* ------------------------------------------------------------- Registry - - - - - - - - - - - ...
true
39d3b5fd1291ad0fd9f35c668b2ced18a2b6b97d
Rust
sifton/iso3166-1.rs
/src/lib.rs
UTF-8
3,860
3.34375
3
[ "ISC" ]
permissive
// ISC License (ISC) // // Copyright (c) 2016, Zeyla Hellyer <zeylahellyer@gmail.com> // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies. // // THE SO...
true
9c5c4191249f4894a5577664b7d76e7151927f6d
Rust
skeleton0/aoc2017
/day13_part2/src/firewall.rs
UTF-8
3,009
3.609375
4
[]
no_license
struct Scanner { range: u32, pos: u32, moving_forward: bool, } impl Scanner { fn new(range: u32) -> Scanner { if range <= 1 { panic!("Scanner must have a range larger than 1."); } Scanner { range, pos: 0, moving_forward: true, ...
true
1fc2da0e06932e7bbb27d506c5fd4c9b5b6d17bf
Rust
fredyw/leetcode
/src/main/rust/src/bin/problem2299.rs
UTF-8
1,534
3.6875
4
[ "MIT" ]
permissive
use std::collections::HashSet; // https://leetcode.com/problems/strong-password-checker-ii/ pub fn strong_password_checker_ii(password: String) -> bool { if password.len() < 8 { return false; } let mut set = HashSet::new(); for c in "!@#$%^&*()-+".chars() { set.insert(c); } let ...
true
acbaa391df36e09e8bf78492c02fccf2613c81ce
Rust
xuedong/leet-code
/Problems/Algorithms/113. Path Sum II/path_sum_II.rs
UTF-8
1,285
3.3125
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
118fbe30b607ea05ef5327ba16feb6e5c38d09ca
Rust
makutak/sandbox
/ods/rust/ods/tests/array_stack_test.rs
UTF-8
2,128
3.296875
3
[]
no_license
use ods_rust::array_stack::*; #[test] fn new_array_stack_n_is_zero() { let ary = ArrayStack::new(); assert_eq!(ary.n, 0); } #[test] fn new_array_stack_a_length_is_zero() { let ary = ArrayStack::new(); assert_eq!(ary.a.len(), 0); } #[test] fn array_stack_size_is_variable() { let mut ary = ArraySta...
true
1559e850a08dc0c3d4f3aac65c01be0ca628239c
Rust
dmitryvakulenko/xsdparser
/src/parser/model/mod.rs
UTF-8
229
2.984375
3
[]
no_license
use std::vec::Vec; pub struct Node { children: Vec<Node> } impl Node { pub fn new() -> Node { Node{children: Vec::new()} } pub fn add_child(&mut self, n: Node) { self.children.push(n); } }
true
e2cf73707ffb729606c5a27291b5eccd418f800a
Rust
juniuszhou/forest
/blockchain/src/message_pool/pool.rs
UTF-8
1,977
2.96875
3
[ "MIT", "Apache-2.0" ]
permissive
// Copyright 2020 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT use message::SignedMessage; trait PoolValidator { // fn validate(&self, msg: SignedMessage); } #[allow(dead_code)] /// Holds all configuration options related to nodes message pool (mpool). pub struct MessagePoolConfig { /// the ...
true
9deaf4b51ad745459eaca3051041f50f22169eba
Rust
panicbit/minesweeper
/src/try_add.rs
UTF-8
564
3.375
3
[]
no_license
pub trait TryAdd<Rhs = Self> { type Output; fn try_add(self, rhs: Rhs) -> Self::Output; } impl TryAdd for usize { type Output = Option<usize>; fn try_add(self, rhs: Self) -> Self::Output { self.checked_add(rhs) } } impl TryAdd<isize> for usize { type Output = Option<usize>; fn ...
true
e33c33354267d7dcc2575d3bd90df2be07c8d047
Rust
rbatis/fast_log
/src/bencher.rs
UTF-8
655
2.953125
3
[ "Apache-2.0" ]
permissive
pub trait TPS { fn tps(&self, total: u64); fn time(&self, total: u64); fn cost(&self); } impl TPS for std::time::Instant { fn tps(&self, total: u64) { let time = self.elapsed(); println!( "TPS: {} Iter/s", (total as u128 * 1000000000 as u128 / time.as_nanos() as ...
true
8c7d5429651c01fcd4a67d28c66456ecb8dedca7
Rust
sisshiki1969/ruruby
/ruruby-common/src/id_table.rs
UTF-8
6,817
3.109375
3
[ "MIT" ]
permissive
use fxhash::FxHashMap; use std::fmt; use std::num::NonZeroU32; use std::sync::LazyLock; use std::sync::{Arc, Mutex}; static ID: LazyLock<Arc<Mutex<IdentifierTable>>> = LazyLock::new(|| Arc::new(Mutex::new(IdentifierTable::new()))); /// /// Wrapper of ID for strings. /// #[derive(Clone, Copy, PartialEq, Eq, Hash)]...
true
fbcac2888e1f438311a9f14965c415de7ffe309b
Rust
radekvit/turn
/turn_lexer_derive/src/automata/mod.rs
UTF-8
1,430
2.703125
3
[ "MIT", "Apache-2.0" ]
permissive
mod dfsa; mod fsa; use crate::derive_parse::{InputTokenRegexes, Regex}; use dfsa::*; use fsa::*; //use nfsa::*; use syn::{Error, Ident}; struct LexerAutomata<'a> { skip: FSA<()>, items: Vec<FSA<&'a Ident>>, } enum SkipRegex<Repr> { Strict(Repr), Permissive, } struct MinimalLexerAutomaton<'a> { s...
true
c0378a109a5dc4122663227cb6c2fbd65e2bfa85
Rust
jakubdabek/gembiler
/src/code_generator/translator.rs
UTF-8
40,918
2.65625
3
[]
no_license
use crate::code_generator::intermediate::{Access, Constant, Context, Instruction, Label, UniqueVariable, Variable, VariableIndex, OperationType}; use ::virtual_machine::instruction::Instruction as VmInstruction; use std::cmp::Ordering; use std::collections::BTreeMap; #[derive(Debug, Clone, Copy, PartialEq, Eq, Partial...
true
343041c843c85b006573fafbe7cae9391fc2bb18
Rust
rust-lang/rust
/src/tools/rust-installer/src/compression.rs
UTF-8
7,034
3.125
3
[ "Apache-2.0", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "MIT", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use anyhow::{Context, Error}; use flate2::{read::GzDecoder, write::GzEncoder}; use rayon::prelude::*; use std::{convert::TryFrom, fmt, io::Read, io::Write, path::Path, str::FromStr}; use xz2::{read::XzDecoder, write::XzEncoder}; #[derive(Default, Debug, Copy, Clone)] pub enum CompressionProfile { Fast, #[defau...
true
1de86b4ab4b552c9b21d520761b6fc25fc401a90
Rust
regonn/rust-unix-command
/cat.rs
UTF-8
874
2.921875
3
[]
no_license
#![allow(unused_must_use)] use std::env; use std::io::{stdout, stderr, Write, Read, Result}; use std::fs::File; fn main() { let paths = env::args().skip(1); if paths.len() < 1 { writeln!(&mut stderr(), "file name not given\n"); } for path in paths { let res = do_cat(path); if re...
true
971ede45bf348b60ccdcb7227c18935fa3b349b5
Rust
urugang/create-lang-with-rust
/src/patch.rs
UTF-8
1,120
2.9375
3
[ "MIT" ]
permissive
use std::collections::BTreeMap; use crate::runtime::{Program, ByteOp}; #[derive(Default)] pub struct Patch { labels: BTreeMap<usize, usize> } impl Patch { pub fn run(mut self, mut program: Program) -> Program { self.fill_table(&program); self.patch(&mut program); program } ...
true
e3a45ac61a59bcc9300465f071c55be8f49f9ec1
Rust
cryptomental/lighthouse
/beacon_node/store/src/forwards_iter.rs
UTF-8
5,358
2.796875
3
[ "Apache-2.0" ]
permissive
use crate::chunked_iter::ChunkedVectorIter; use crate::chunked_vector::BlockRoots; use crate::iter::{BlockRootsIterator, ReverseBlockRootIterator}; use crate::{DiskStore, Store}; use slog::error; use std::sync::Arc; use types::{BeaconState, ChainSpec, EthSpec, Hash256, Slot}; /// Forwards block roots iterator that mak...
true
3561e6c8dffbf9713b6ca4d766ade14853ac10a1
Rust
mida-hub/hobby
/practice/rust/031_040/038_thread.rs
UTF-8
135
2.953125
3
[]
no_license
use std::thread; fn main(){ let handle = thread::spawn(||{ println!("Hello, world!"); }); dbg!(handle.join()); }
true
e8dbf13cd53d697f1f1baa81aa349160516a49d5
Rust
caiohamamura/3d_to_2d
/src/progressbar_helper.rs
UTF-8
2,206
2.8125
3
[]
no_license
extern crate indicatif; use std::path::PathBuf; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; use super::Config; const INCREMENT_STEP: u64 = 100000; pub struct ProgressBarWrapper { multiprogress: MultiProgress, style: ProgressStyle } unsafe impl Sync for ProgressBarWrapper {} i...
true
e81ee8e73e0505c2f9f5b775c9917812099ae462
Rust
de-luca/pihole-adlist-updater
/src/main.rs
UTF-8
1,586
2.6875
3
[]
no_license
mod adlists; mod db; use clap::Clap; use rusqlite::{Connection, Transaction}; /// This doc string acts as a help message when the user runs '--help' /// as do all doc strings on fields #[derive(Clap)] #[clap()] struct Opts { /// The gravity.db file path #[clap(short, long, default_value = "/etc/pihole/gravity...
true