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
751a2fd63de8d440cbb843005df566800b4b1d67
Rust
Twinklebear/light_arena
/src/lib.rs
UTF-8
9,254
3.421875
3
[ "MIT" ]
permissive
//! **Temporarily a more simple memory pool for keeping stack alloc objects //! in copied into a shared heap rather than a true placement new memory arena.** //! Unfortunately the path forward for placement new in Rust does not look //! good right now, so I've reverted this crate to work more like a memory //! heap whe...
true
1dbcc26a6d8426a596e8138f0e0a47529252b843
Rust
kbknapp/usbwatch-rs
/src/state.rs
UTF-8
5,912
2.921875
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use std::{ collections::HashMap, fs::{self, File}, path::Path, }; use tracing::{self, debug, info, span, Level}; use yaml_rust::YamlLoader; use crate::{ rule::{Rule, Rules}, usb::{UsbDevice, UsbDevices, UsbPort, UsbPorts}, }; #[derive(Default)] pub struct State { ports: Vec<UsbPort>, devi...
true
e942eef8a7b54c5bea48e16e4c8115fb3e7edce2
Rust
baitcenter/gdlk
/api/src/util.rs
UTF-8
1,566
3.078125
3
[]
no_license
//! General utility functions and types. #[cfg(test)] pub use tests::*; use diesel::{r2d2::ConnectionManager, PgConnection}; /// Type aliases for DB connections pub type Pool = r2d2::Pool<ConnectionManager<PgConnection>>; pub type PooledConnection = r2d2::PooledConnection<ConnectionManager<PgConnection>>; #[cfg...
true
69b8a13cedffdf5f63a897310fe5a57949ab4a19
Rust
chromium/chromium
/third_party/rust/semver/v1/crate/src/lib.rs
UTF-8
19,858
2.828125
3
[ "GPL-1.0-or-later", "MIT", "LGPL-2.0-or-later", "Apache-2.0", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! [![github]](https://github.com/dtolnay/semver)&ensp;[![crates-io]](https://crates.io/crates/semver)&ensp;[![docs-rs]](https://docs.rs/semver) //! //! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github //! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?...
true
48d11db5ccb940b2f1803cbd9b0a3329d5c2043c
Rust
vikrem/linkerd2-proxy
/linkerd/proxy/detect/src/lib.rs
UTF-8
4,987
2.609375
3
[ "Apache-2.0" ]
permissive
use linkerd2_error::Error; use linkerd2_io::{BoxedIo, Peek}; use linkerd2_proxy_core as core; use pin_project::{pin_project, project}; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; /// A strategy for detecting values out of a client transport. pub trait Detect<T>: Clone { type Target;...
true
b6d81c360fc9e5655ca5c00740708a5d33511de0
Rust
aldhsu/fuzzy-matcher
/src/skim.rs
UTF-8
10,511
2.8125
3
[ "MIT" ]
permissive
///! The fuzzy matching algorithm used by skim ///! It focus more on path matching /// ///! # Example: ///! ```edition2018 ///! use fuzzy_matcher::skim::{fuzzy_match, fuzzy_indices}; ///! ///! assert_eq!(None, fuzzy_match("abc", "abx")); ///! assert!(fuzzy_match("axbycz", "abc").is_some()); ///! assert!(fuzzy_match("ax...
true
c32c64587b0b9c1ef7b7f2f9c2a046575b6ebf8e
Rust
lukisko/rust_chap_10
/src/main.rs
UTF-8
1,857
3.65625
4
[]
no_license
fn main() { println!("Hello, world!"); let poin = Point {x:10.0,y:20.0}; println!("x part of point is {} and distance from origin is {}.",poin.x(),poin.distance_from_origin()); } fn largest(list: &[i32]) -> i32 { let mut largest = list[0]; for &number in list { if number > largest { ...
true
74c1c06e568a2010de3eb55578c441a9c2c94dc9
Rust
SnakeSolid/rust-gantt-diagram
/src/database/mod.rs
UTF-8
4,849
2.6875
3
[ "MIT" ]
permissive
mod error; pub use self::error::DatabaseError; pub use self::error::DatabaseResult; use fallible_iterator::FallibleIterator; use postgres::params::ConnectParams; use postgres::params::Host; use postgres::Connection; use postgres::TlsMode; use time::strptime; use time::Timespec; #[derive(Debug)] pub struct PostgreSQL...
true
d7165d8f059af78c4249d911b03d72631a456a78
Rust
adcopeland/peuler
/rust/peuler/src/bin/p10.rs
UTF-8
147
2.890625
3
[]
no_license
fn main() { let mut sum: u64 = 0; for i in 1..2000000 { if peuler::is_prime(i) { sum += i as u64 } } println!("{}", sum); }
true
a863b5d07a247b004ad140a36da00e116924662e
Rust
rhysd/Shiba
/v2/src/markdown/parser.rs
UTF-8
36,182
2.546875
3
[ "MIT" ]
permissive
use super::sanitizer::{should_rebase_url, Sanitizer, SlashPath}; use crate::renderer::RawMessageWriter; use aho_corasick::AhoCorasick; use emojis::Emoji; use memchr::{memchr_iter, Memchr}; use pulldown_cmark::{ Alignment, CodeBlockKind, CowStr, Event, HeadingLevel, LinkType, MathDisplay, Options, Parser, Tag, }...
true
ea6f2d2b290899bebb21159217cfdf59f8c8008c
Rust
fnune/exercises
/linked_list/linked_list.rs
UTF-8
3,121
3.734375
4
[ "MIT" ]
permissive
#![feature(alloc)] #![feature(shared)] extern crate alloc; extern crate core; use alloc::boxed::{Box}; use core::ptr::{Shared}; struct Node<T> { content: T, next: Option<Shared<Node<T>>>, } impl<T> Node<T> { fn new(content: T) -> Self { Node { next: None, content, ...
true
daf52c17056783913857ced97bf466c4c89609f4
Rust
lain-dono/klein-rs
/glsl_shim.rs
UTF-8
4,759
3.296875
3
[]
no_license
pub fn swizzle_index(c: char) -> usize { match c { 'x' => 0, 'y' => 1, 'z' => 2, 'w' => 3, _ => unimplemented!(), } } /* #define SWIZZLE(a, b, c, d) \ swizzle<swizzle_index(#a[0]), \ swizzle_index(#b[0]), \ swizzle_index(#c[0]), \ ...
true
b6b508f2a95329f89a910c7d75cf8c779b10e643
Rust
nimiq/core-rs
/beserial/src/types.rs
UTF-8
6,198
2.96875
3
[ "Apache-2.0" ]
permissive
use crate::{Deserialize, ReadBytesExt, Serialize, SerializingError, WriteBytesExt}; use num; #[allow(non_camel_case_types)] #[derive(Ord, PartialOrd, Eq, PartialEq, Debug, Copy, Clone)] pub struct uvar(u64); impl From<uvar> for u64 { fn from(u: uvar) -> Self { u.0 } } impl From<u64> for uvar { fn from(u: u64...
true
4ae52db70e06e474eaa4596b8c39bbea4af6524a
Rust
rust-lang/rust
/library/portable-simd/crates/core_simd/src/alias.rs
UTF-8
4,097
2.859375
3
[ "Apache-2.0", "MIT", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "LicenseRef-scancode-other-permissive" ]
permissive
macro_rules! number { { 1 } => { "one" }; { 2 } => { "two" }; { 4 } => { "four" }; { 8 } => { "eight" }; { $x:literal } => { stringify!($x) }; } macro_rules! plural { { 1 } => { "" }; { $x:literal } => { "s" }; } macro_rules! alias { { $( $element_ty:ty = { ...
true
e776a4de65e77bd610a53df3de60d70b76f4baed
Rust
cGuille/adventofcode
/src/bin/2020-day4-part1.rs
UTF-8
759
3.015625
3
[]
no_license
use std::collections::HashSet; fn main() { let batch = include_str!("../../input/2020-day4.txt"); let valid_passport_count = batch .split("\n\n") .filter(|passport_str| has_required_attributes(passport_str)) .count(); println!("{}", valid_passport_count); } fn has_required_attrib...
true
6df5798a8f6e64debc86bb99cb243cd84ebb9111
Rust
guillaumebreton/ruin
/src/main.rs
UTF-8
3,674
2.71875
3
[ "MIT" ]
permissive
#[macro_use] extern crate diesel; #[macro_use] extern crate diesel_migrations; use chrono::NaiveDate; use clap::{Parser, Subcommand}; use diesel::prelude::*; use crossterm::{ event::{DisableMouseCapture, EnableMouseCapture}, execute, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, Leav...
true
7cd4f120aa60dc79f2e38c804d383a2851c17fb5
Rust
juneym/rust-lang-tutorial
/src/cli.rs
UTF-8
344
3.34375
3
[]
no_license
// sample cli's use of arguments use std::env; pub fn run() { let args: Vec<String> = env::args().collect(); let command = args[1].clone(); //why do you have to use .clone()?? println!("\nargs: {:?}", args); println!("\ncommand: {}", command); if command == "hello" { println!("Hey ...
true
1a8de1b6017c58016b2e6bb96b4df43836dc20c0
Rust
akshayknarayan/simulator
/src/node/switch/drop_tail_queue.rs
UTF-8
3,712
3.015625
3
[]
no_license
use std::collections::VecDeque; use node::Link; use node::switch::Queue; use packet::Packet; #[derive(Debug)] pub struct DropTailQueue{ limit_bytes: u32, link: Link, pkts: VecDeque<Packet>, forced_next: Option<Packet>, active: bool, paused: bool, } impl DropTailQueue { pub fn new(limit_by...
true
132709ffc8d95dd0ef2df42d5535185e7b8d1939
Rust
nigelgray/rust-audio-analyser
/src/wav_helpers.rs
UTF-8
1,689
3.03125
3
[ "MIT" ]
permissive
use std::sync::atomic::{Ordering}; // To find the RMS gain // - Calculate the RMS value of the generated audio // - Calculate the RMS value of the recorded audio // - Calculate the power between the signals, using the generated audio as the reference // (positive value means amplification, negative means attenuat...
true
88a2a4ed3d920a6b50652f055c8c530333ae91e5
Rust
sria91-rlox/cat-lox
/src/lexer/core.rs
UTF-8
5,111
3.6875
4
[ "MIT" ]
permissive
use super::token::*; pub struct Lexer { input: Vec<char>, index: usize, } impl Iterator for Lexer { type Item = Token; fn next(&mut self) -> Option<Token> { match self.advance() { None => None, // Operators Some('+') => Some(Token::Plus), Some('...
true
1e121ec8be3577093268d22579675c828345cb74
Rust
cloew/KaoBoy
/src/cpu/instructions/jump/conditions.rs
UTF-8
3,242
2.828125
3
[]
no_license
use super::super::utils::{check_half_carry}; use super::super::super::instruction_context::InstructionContext; pub fn always(context: &InstructionContext) -> bool { return true; } pub fn is_carry_flag_off(context: &InstructionContext) -> bool { return context.registers().carry_flag.get() == false; } ...
true
01efae5778d259345ebd37771f1ae6a59908cae6
Rust
aicacia/rs-lexer
/src/token.rs
UTF-8
714
2.9375
3
[ "Apache-2.0", "MIT" ]
permissive
use super::TokenMeta; #[derive(Serialize, Deserialize, Clone, PartialEq, Debug, Eq, PartialOrd, Ord, Hash)] pub struct Token<T> { meta: TokenMeta, value: T, } unsafe impl<T> Send for Token<T> where T: Send {} unsafe impl<T> Sync for Token<T> where T: Sync {} impl<T> Token<T> { #[inline(always)] pub fn new(me...
true
73dafda5b5dd20fc668be9760d08a4cdbd4a9861
Rust
chromium/chromium
/third_party/rust/getrandom/v0_2/crate/src/error.rs
UTF-8
8,110
2.640625
3
[ "MIT", "Apache-2.0", "BSD-3-Clause", "GPL-1.0-or-later", "LGPL-2.0-or-later" ]
permissive
// Copyright 2018 Developers of the Rand project. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed /...
true
454b656776ef9ea552c3c6d8a0b47eb502367581
Rust
vanhtuan0409/aoc
/2022/src/bin/day6/main.rs
UTF-8
595
2.5625
3
[]
no_license
use aoc_2022::get_input_file; use itertools::Itertools; use std::fs::File; use std::io::{self, BufRead}; fn main() { let f: io::Result<File> = get_input_file!("input1.txt"); let r = io::BufReader::new(f.unwrap()); r.lines().map(|line| line.unwrap()).for_each(|line| { println!("======"); le...
true
01839d034cd249a1e9dc8685da3c8a47731c3bf0
Rust
ErisMik/minecator
/src/minecraft/chunk.rs
UTF-8
786
2.75
3
[]
no_license
use byteorder::{BigEndian, ByteOrder}; use nbt; use std::io::Cursor; #[derive(Debug)] pub struct Chunk { timestamp: u32, blob: nbt::Blob, } impl Chunk { pub fn new(timestamp: u32, data: Vec<u8>) -> std::io::Result<Chunk> { let chunk_length = BigEndian::read_u32(&data[0..4]) as usize; let c...
true
d1827d3f85c8e79749a0f2c183e4134b86d74ae0
Rust
femnad/leth
/src/main.rs
UTF-8
2,851
2.5625
3
[]
no_license
extern crate regex; extern crate skim; extern crate structopt; use std::collections::HashMap; use std::io::Cursor; use std::io::{self, Read}; use std::process::{Command, Stdio}; use regex::Regex; use skim::prelude::*; use structopt::StructOpt; const LINE_SPLITTER: char = '='; const URL_REGEX: &str = r"(http(s)?://[a...
true
45ab8b0a952d1ebd042a38d187027ee3fb551320
Rust
DanMaycock/fortunes_algorithm_rs
/src/boundingbox.rs
UTF-8
17,186
3.359375
3
[]
no_license
use super::*; use std::f64; #[derive(Clone, Copy, PartialEq, Debug)] pub enum Side { Left, Right, Top, Bottom, None, } impl Side { // Iterates round the sides in an anti clockwise direction fn next(self) -> Side { match self { Side::Left => Side::Bottom, Sid...
true
13aae36a5299459fc447b9505026e6a796e511ad
Rust
Xudong-Huang/radiotap
/src/lib.rs
UTF-8
12,446
3.234375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A parser for the [Radiotap](http://www.radiotap.org/) capture format. //! //! # Usage //! //! The `Radiotap::from_bytes(&capture)` constructor will parse all present //! fields into a [Radiotap](struct.Radiotap.html) struct: //! //! ``` //! use radiotap::Radiotap; //! //! fn main() { //! let capture = [ //! ...
true
f44f5a594c915e78aba56d4941978cd9c394ea29
Rust
BurntSushi/rust-analyzer
/xtask/src/codegen.rs
UTF-8
2,791
2.71875
3
[ "Apache-2.0", "MIT" ]
permissive
//! We use code generation heavily in rust-analyzer. //! //! Rather then doing it via proc-macros, we use old-school way of just dumping //! the source code. //! //! This module's submodules define specific bits that we generate. mod gen_syntax; mod gen_parser_tests; mod gen_assists_docs; use std::{mem, path::Path}; ...
true
7ceb85523e95e3f83a1ecf50f5093ac8ad6e20c6
Rust
saschagrunert/craft
/src/sources/git/source.rs
UTF-8
7,727
2.6875
3
[ "MIT" ]
permissive
use std::fmt::{self, Debug, Formatter}; use url::Url; use dependency::Dependency; use package::Package; use package_id::PackageId; use registry::Registry; use source::{Source, SourceId, GitReference}; use sources::PathSource; use sources::git::utils::{GitRemote, GitRevision}; use summary::Summary; use util::hex::shor...
true
389532a8c5679f057d28fc3f24c1f7b1c992debc
Rust
JordanElButler/labyrinth
/src/render_object.rs
UTF-8
2,970
2.578125
3
[]
no_license
use crate::transform::Transform; use crate::shader::{Program}; use crate::mesh::Mesh; use crate::camera::Camera; use crate::vertex::{Vertex}; use crate::resources::{ResourceKey, Resources}; use crate::light::Light; use crate::material::{MaterialPropertyType, Material}; pub struct RenderObject { pub transform: Tran...
true
2b44b3c71892ab682c637c5588708a41a2b7c515
Rust
bevyengine/bevy
/crates/bevy_time/src/stopwatch.rs
UTF-8
6,086
3.65625
4
[ "Apache-2.0", "MIT", "Zlib", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive" ]
permissive
use bevy_reflect::prelude::*; use bevy_reflect::Reflect; use bevy_utils::Duration; /// A Stopwatch is a struct that track elapsed time when started. /// /// # Examples /// /// ``` /// # use bevy_time::*; /// use std::time::Duration; /// let mut stopwatch = Stopwatch::new(); /// assert_eq!(stopwatch.elapsed_secs(), 0.0...
true
0f31e8a6aabcc8a08dc02d42d205cd5ed2ac1a27
Rust
SnoozeTime/dicom-rs
/src/types.rs
UTF-8
18,317
3.125
3
[]
no_license
//! Types specific to Dicom. use crate::error::*; use byteorder::{BigEndian, LittleEndian, ReadBytesExt}; use chrono::NaiveDate; use std::fmt::{self, Display}; use std::io::Cursor; use nom::number::Endianness; use std::convert::TryFrom; use crate::{Tag, ValueRepresentation}; use crate::parser::sq::Item; use crate::img...
true
81670592c984bdb162a573631e1285ecd30b8e60
Rust
xiuxiu62/rust-workshop
/hangman/src/main.rs
UTF-8
219
2.546875
3
[]
no_license
mod game; use game::Session; fn main() { let mut game = Session::new("Hello World", 5); match game.guess('c') { Err(e) => std::panic::panic_any(e), Ok(_) => {} }; game.test_display(); }
true
9e5a5ce8672057617036f89259af528fd07a881a
Rust
takatori/rust-sample
/2017/rust_by_example/src/casting/casting.rs
UTF-8
1,671
3.671875
4
[]
no_license
// オーバーフローを起こすようなキャスティングによる警告を無視 #![allow(overflowing_literals)] fn main() { let decimal = 65.4321_f32; // エラー! 暗黙的な型変換はできない。 let integer: u8 = decimal; // 明示的な型変換 let integer = decimal as u8; let character = integer as char; println!("Casting: {} -> {} -> {}", decimal, integer, characte...
true
f2296bf2267f6766d5f5c50731b19674ade370d6
Rust
Urgau/rsix
/src/runtime.rs
UTF-8
2,823
2.921875
3
[ "MIT", "Apache-2.0", "LLVM-exception" ]
permissive
//! Low-level implementation details for libc-like runtime libraries. //! //! These functions are for implementing thread-local storage (TLS), //! managing threads, loaded libraries, and other process-wide resources. //! Most of rsix doesn't care about what other libraries are linked into //! the program or what they'r...
true
5ea118343273255dcb4b063a5954ddf468f7296c
Rust
ar3s3ru/poke-rs
/poke-domain/src/pokemon.rs
UTF-8
1,319
2.84375
3
[]
no_license
// Gotta use a Box<Pin<Future<Result>>> for returning an async result // from a trait for now, until we have Higher-kinded Types in stable... use futures::future::BoxFuture; use serde::Serialize; #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize)] #[serde(rename_all = "lowercase")] pub enum Element { Normal, ...
true
0d1736c07d024f35a2f7ce78ba11cbd321e9b4fd
Rust
energister/rusty_engine
/src/physics.rs
UTF-8
7,814
2.984375
3
[ "LicenseRef-scancode-unknown-license-reference", "CC0-1.0", "MIT", "Apache-2.0" ]
permissive
use crate::actor::Actor; use bevy::prelude::*; use std::{collections::HashSet, hash::Hash}; pub struct PhysicsPlugin; impl Plugin for PhysicsPlugin { fn build(&self, app: &mut AppBuilder) { app.add_event::<CollisionEvent>() .add_system(collision_detection.system()); } } #[derive(Debug, Cl...
true
8b89edd7575274a877694f1f5956d0ecc284114d
Rust
kissmikijr/caolo-backend
/sim/simulation/src/noise.rs
UTF-8
4,367
2.71875
3
[ "MIT" ]
permissive
#![allow(clippy::many_single_char_names)] pub use perlin::PerlinNoise; mod perlin { use crate::{indices::WorldPosition, prelude::Axial}; use rand::{prelude::SliceRandom, rngs::SmallRng, SeedableRng}; pub struct PerlinNoise { seed: u64, permutations: Box<[u32; 512]>, } impl Perli...
true
5e6e7de71d83cd8d5d42e4053289be0a650154bd
Rust
willcrichton/rapier
/src/dynamics/joint/revolute_joint.rs
UTF-8
2,003
2.75
3
[ "Apache-2.0" ]
permissive
use crate::math::{Point, Vector}; use crate::utils::WBasis; use na::{Unit, Vector5}; #[derive(Copy, Clone)] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] /// A joint that removes all relative motion between two bodies, except for the rotations along one axis. pub struct RevoluteJoint { /...
true
649bf95e4a46846f1101b4bcbb09c9177ba4dc6a
Rust
tanhao1410/learn_rust
/learn_actix/src/app/mod.rs
UTF-8
697
2.71875
3
[ "Apache-2.0" ]
permissive
use actix_web::{HttpServer, App, web}; mod hello; mod greet; mod fibonacci; pub fn start() { let bind_address = "0.0.0.0:8080"; HttpServer::new(|| { App::new().configure(routes) }) .bind(&bind_address) .unwrap_or_else(|_| panic!("Could not bind server to address {}", &bind_addr...
true
190b476902ab84846157cd86eb198ac67d2aeeec
Rust
mehcode/diesel
/diesel/src/query_builder/aliasing.rs
UTF-8
6,612
2.890625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use backend::Backend; use expression::{AppearsOnTable, Expression, NonAggregate, SelectableExpression}; use query_builder::{AstPass, QueryFragment, SelectStatement}; use query_source::joins::{Inner, Join, JoinOn, LeftOuter}; use query_source::{AppearsInFromClause, Column, Never, Once, QuerySource}; use result::QueryRes...
true
c0ebb0b9791be40fd8f9e08d35b7ec30431ee996
Rust
hbdgr/cybernetics
/tests/objects_api.rs
UTF-8
4,976
2.765625
3
[]
no_license
extern crate cybernetics; extern crate rocket; extern crate serde_json; mod common; use common::object_helpers; use common::rocket_helpers; use cybernetics::primitives::header::ObjectType; use rocket::http::{ContentType, Status}; use serde_json::json; #[test] fn create_object() { let obj_json = object_helpers::t...
true
f8f88b1dbde3a49d1caee4c5c3b6a2ea6a587cbd
Rust
growingspaghetti/project-euler
/rust/src/m23.rs
UTF-8
5,987
3.578125
4
[]
no_license
//! See [m21](./m21.rs) /// /// A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. /// /// A number n is called deficient if the sum of its pro...
true
e42cfa06c971b1988ac8efdd215e029f5341ecfd
Rust
Ben-Lichtman/advent_of_code_2020
/src/day11.rs
UTF-8
5,612
3.125
3
[]
no_license
use std::{fs::read_to_string, mem::swap}; #[derive(Clone, Copy, Debug)] enum Cell { Floor, Empty, Occupied, } #[derive(Debug)] struct Automata { x: usize, y: usize, state: Box<[Cell]>, next_state: Box<[Cell]>, } impl Automata { fn new(input: Vec<Vec<Cell>>) -> Self { let y = input.len(); let x = input[0]...
true
0590d62109e7efcc9961c6ac16ef8918408d9a06
Rust
incker2/luno-rust
/src/lightning.rs
UTF-8
2,970
2.578125
3
[ "MIT" ]
permissive
use serde::Deserialize; use std::collections::HashMap; use crate::{client, Currency}; #[derive(Debug, Deserialize)] pub struct LightningWithdrawal { pub invoice_id: String, pub payment_request: String, } #[derive(Debug, Deserialize)] pub struct LightningReceiveRequest { pub invoice_id: String, pub pa...
true
2a40d2a6cfd12fc115144df2271fe3da4c28f21c
Rust
GTime/cqrs-eventsourcing
/src/cqrs.rs
UTF-8
1,405
2.5625
3
[ "MIT" ]
permissive
use std::marker::PhantomData; use crate::{Aggregate, Command, DomainEvent, Error, Handlers, MetaData, Store}; // #[derive()] pub struct CQRS<A, E, ES> where A: Aggregate, E: DomainEvent<A>, ES: Store<A, E>, { handlers: Handlers<A, E>, store: ES, _a: PhantomData<A>, _e: PhantomData<E>, } i...
true
946e03413028ccf966531b1f23c2902aa0a97252
Rust
jonhoo/stuck
/src/main.rs
UTF-8
10,384
2.71875
3
[]
no_license
use futures_util::future::Either; use futures_util::stream::StreamExt; use std::collections::{BTreeMap, HashMap}; use std::io::{self}; use structopt::StructOpt; use termion::raw::IntoRawMode; use tokio::prelude::*; use tui::backend::Backend; use tui::backend::TermionBackend; use tui::layout::{Constraint, Direction, Lay...
true
79213afb4b24d22ab8fa42411b4c08b42d6586c9
Rust
MadRubicant/racer
/src/racer/ast_types.rs
UTF-8
19,394
3.046875
3
[ "MIT" ]
permissive
//! type conversion between racer types and libsyntax types use core::{self, BytePos, Match, MatchType, Scope, Session}; use matchers::ImportInfo; use nameres; use std::fmt; use std::path::{Path as FilePath, PathBuf}; use syntax::ast::{ self, GenericBound, GenericBounds, GenericParamKind, TraitRef, TyKind, WherePre...
true
61cecb1150dc92ae92a9a639bf97bbef9f872325
Rust
cwood821/zeppelin
/src/notifier.rs
UTF-8
298
2.5625
3
[]
no_license
use std::collections::HashMap; pub fn notify(message: &str, url: &str) { let mut map = HashMap::new(); map.insert("text", message); let client = reqwest::Client::new(); let res = client.post(url) .json(&map) .send(); if res.is_err() { // TODO: Do some logging } }
true
ec66ab9251caa61a7e47b337a56ccb1054088854
Rust
ram-hacks/fireplace
/src/main.rs
UTF-8
2,962
2.984375
3
[]
no_license
#![feature(globs)] extern crate getopts; extern crate ncurses; use view::*; use data::*; use ncurses::*; use std::io; use std::os; use getopts::{optopt,optflag,getopts,OptGroup,Matches}; mod view; mod data; fn print_usage(program: &str, _opts: &[OptGroup]) { println!("Usage: {} [--title <TITLE>] [--fixed [--lower ...
true
ab0360cc9616466f487478300e60ce8981a99096
Rust
danreeves/rust-tests
/src/error_handling.rs
UTF-8
377
3.015625
3
[]
no_license
extern crate rand; #[test] fn result() { fn might_error() -> Result<i32, String> { if rand::random() { return Ok(1); } Err("it borked".to_string()) } let did_it_work = might_error(); if let Ok(num) = did_it_work { assert_eq!(num, 1); } else { as...
true
a0c2f1bba343d9480c9b50f1404f922314c58ede
Rust
rocallahan/object
/src/pe.rs
UTF-8
7,924
2.578125
3
[ "MIT", "Apache-2.0" ]
permissive
use std::slice; use alloc::borrow; use alloc::vec::Vec; use goblin::pe; use {DebugFileInfo, Machine, Object, ObjectSection, ObjectSegment, SectionKind, Symbol, SymbolKind, SymbolMap}; /// A PE object file. #[derive(Debug)] pub struct PeFile<'data> { pe: pe::PE<'data>, data: &'data [u8], } /// An iterat...
true
f51b2b00d3b1d707978cfbf0bdc4974065ceaeb4
Rust
samgwise/555nm-soundscape
/src/config/config_tests.rs
UTF-8
4,993
2.515625
3
[ "MIT" ]
permissive
#[cfg(test)] mod config_test { use config::*; use ::epochsy; fn test_config() -> Soundscape { Soundscape { listen_addr: Address { host: "127.0.0.1".to_string(), port: 4000 }, subscribers: vec![ Address { host: "127.0.0.1".to_string(), port: 4000 } ], ...
true
41f2b9c157dec8e601692ef1159cb941a230d904
Rust
mesalock-linux/crates-sgx
/vendor/bincode/src/config/trailing.rs
UTF-8
1,146
2.796875
3
[ "MIT", "Apache-2.0" ]
permissive
use std::prelude::v1::*; use de::read::SliceReader; use {ErrorKind, Result}; /// A trait for erroring deserialization if not all bytes were read. pub trait TrailingBytes { /// Checks a given slice reader to determine if deserialization used all bytes in the slice. fn check_end(reader: &SliceReader) -> Result<(...
true
582d004ba85cfae2591a2e616a056528786873b5
Rust
suhassrivats/Data-Structures-And-Algorithms-Implementation
/Grokking-the-Coding-Interview-Patterns-for-Coding-Questions/13. Pattern Top 'K' Elements/Top 'K' Numbers (easy).py
UTF-8
1,962
3.859375
4
[]
no_license
''' Problem Statement Given an unsorted array of numbers, find the ‘K’ largest numbers in it. Note: For a detailed discussion about different approaches to solve this problem, take a look at Kth Smallest Number. Example 1: Input: [3, 1, 5, 12, 2, 11], K = 3 Output: [5, 12, 11] Example 2: Input: [5, 12, 11, -1, 12]...
true
adcc6357695e78405d87562986d2d1b9b39a224f
Rust
basiliqio/basiliq
/src/basiliq_store/store/config/mod.rs
UTF-8
4,591
2.734375
3
[ "Apache-2.0", "MIT" ]
permissive
use super::*; mod builder_config; mod errors; mod mergeable; pub use errors::{BasiliqStoreConfigError, BasiliqStoreConfigErrorSource}; use itertools::EitherOrBoth; use itertools::Itertools; pub use mergeable::BasiliqStoreConfigMergeable; /// Top level of the Store configuration /// /// Contains a list of accepted res...
true
8ed0568e475af2e083fd0f452378efaad6677c53
Rust
fratorgano/advent_of_code_2020
/day13/src/main.rs
UTF-8
874
2.703125
3
[]
no_license
use std::time::Instant; fn main() { let time = 1006401; let buses = vec!["17","x","x","x","x","x","x","x","x","x","x","37","x", "x","x","x","x","449","x","x","x","x","x","x","x","23", "x","x","x","x","13","x","x","x","x","x","19","x","x", "x","x","...
true
3499fba56824998f21fd127615d133f480aca620
Rust
paul-sud/bigbed-jaccard
/src/bin/bigbed_jaccard_similarity_matrix.rs
UTF-8
3,025
2.546875
3
[ "MIT" ]
permissive
use bigbed_jaccard::bed::{get_offset_data, IntervalQuery}; use bigbed_jaccard::bottom_k::{compute_k_minhashes, jaccard, BoundedPriorityQueue}; use bigbed_jaccard::request::download_to_tempfile; use bigtools::bbiread::BBIRead; use bigtools::bigbedread::BigBedRead; use csv::{Writer, WriterBuilder}; use itertools::Iter...
true
a699ac46ddcb5fdf5f0a43972be571787b63fd0d
Rust
EFanZh/LeetCode
/src/problem_1078_occurrences_after_bigram/mod.rs
UTF-8
722
3.34375
3
[]
no_license
pub mod iterative; pub trait Solution { fn find_ocurrences(text: String, first: String, second: String) -> Vec<String>; } #[cfg(test)] mod tests { use super::Solution; pub fn run<S: Solution>() { let test_cases = [ ( ("alice is a good girl she is a good student", "a", ...
true
d2c5437de57ac5cc26bde91862b7e4f9e2bdf0f2
Rust
emmanueltouzery/zbus
/zvariant/src/framing_offset_size.rs
UTF-8
4,001
3.40625
3
[ "MIT" ]
permissive
use crate::{Error, Result}; use byteorder::{ByteOrder, WriteBytesExt, LE}; // Used internally for GVariant encoding and decoding. // // GVariant containers keeps framing offsets at the end and size of these offsets is dependent on // the size of the container (which includes offsets themselves. #[derive(Copy, Clone, ...
true
d28e0fa481e7813b853ef2adc45260a8126cc3e1
Rust
io12/pwninit
/src/unstrip_libc.rs
UTF-8
2,889
2.640625
3
[ "MIT" ]
permissive
use crate::elf; use crate::libc_deb; use crate::libc_version::LibcVersion; use std::io::copy; use std::io::stderr; use std::io::stdout; use std::io::Write; use std::path::Path; use std::process::Command; use std::process::ExitStatus; use colored::Colorize; use ex::fs::File; use ex::io; use snafu::ResultExt; use snafu...
true
c3e1834244fb5b4de7cff6658eb0a6e70c8b47bc
Rust
Riey/kes-rs-blog
/org/20200213/instruction-future.rs
UTF-8
420
2.546875
3
[]
no_license
pub trait InstAlloc<'s, 'c> { fn alloc_str(&'c self, text: &'s str) -> &'c str; } impl<'s, 'c> InstAlloc<'s, 'c> for Bump { #[inline(always)] fn alloc_str(&'c self, text: &'s str) -> &'c str { self.alloc_str(text) } } pub struct DirectInstAlloc; impl<'s> InstAlloc<'s, 's> for DirectInstAlloc ...
true
98df4f7852f4a44ace4e417cf31f84aa1ae17fb7
Rust
darkdarkfruit/zou
/src/http_version.rs
UTF-8
580
2.78125
3
[ "MIT" ]
permissive
use hyper::version::HttpVersion; /// Trait used to check HTTP Version /// /// This trait is used to validate that a given HTTP Version match specific need. pub trait ValidateHttpVersion { /// Validate that the current HttpVersion is at least 1.1 to be able to download chunks. fn greater_than_http_11(&self) -> ...
true
14856a6562a0dd1030fc6f95d6a5f3e57ba4f744
Rust
winksaville/fuchsia
/third_party/rust_crates/vendor/failure/src/error/mod.rs
UTF-8
8,437
3.390625
3
[ "Apache-2.0", "MIT", "BSD-3-Clause" ]
permissive
use core::fmt::{self, Display, Debug}; use {Causes, Fail}; use backtrace::Backtrace; use context::Context; use compat::Compat; #[cfg(feature = "std")] use box_std::BoxStd; #[cfg_attr(feature = "small-error", path = "./error_impl_small.rs")] mod error_impl; use self::error_impl::ErrorImpl; #[cfg(feature = "std")] us...
true
29ceec4842657f13e33917b43243a69ab8685f2a
Rust
sbstp/kubie
/src/cmd/meta.rs
UTF-8
3,956
2.75
3
[ "Zlib" ]
permissive
use clap::Parser; use crate::settings::ContextHeaderBehavior; #[derive(Debug, Parser)] #[clap(version)] pub enum Kubie { /// Spawn a shell in the given context. The shell is isolated from other shells. /// Kubie shells can be spawned recursively without any issue. #[clap(name = "ctx")] Context { ...
true
c8623c7476eef9f3d822cfcd8a9dd1d30ecba3e7
Rust
TimoFreiberg/framework-comparison-2020
/rocket/src/api.rs
UTF-8
1,612
2.515625
3
[]
no_license
use rocket_contrib::json::Json; use rocket::http::Status; use crate::{ footballer::{Footballer, NewFootballer}, footballer_repository::FootballerRepository, PgDatabase, }; use diesel::result::Error; use rocket::{delete, get, post, response::content}; #[get("/footballers?<position>")] pub fn footballers_s...
true
6a5cc3a4dac954b244f1e3c8f358b0e7375cf39a
Rust
caklimas/rust-nes
/src/ppu/frame.rs
UTF-8
1,681
2.875
3
[]
no_license
use std::fmt::{Debug, Formatter, Result}; use crate::display; use super::colors::Color; const BYTES_PER_COLUMN: usize = display::PIXEL_SIZE * display::BYTES_PER_COLOR; const BYTES_PER_ROW: usize = BYTES_PER_COLUMN * display::SCREEN_WIDTH; const BYTE_WIDTH: usize = BYTES_PER_COLUMN * display::SCREEN_WIDTH; const BYTE_H...
true
7841e9999be6c7bfd0d6ba92bca927f08d2229f0
Rust
tuzz/game-loop
/examples/using_wasm/src/main.rs
UTF-8
858
2.828125
3
[ "MIT" ]
permissive
use wasm_bindgen::prelude::*; use game_loop::game_loop; #[wasm_bindgen(start)] pub fn main() { let game = Game::new(); game_loop(game, 240, 0.1, |g| { g.game.your_update_function(); }, |g| { g.game.your_render_function(); }); } struct Game { span: web_sys::Element, counter: u3...
true
c6740b3e4b8229174410076902fa5902ef7186bb
Rust
martin-danhier/nolfaris
/src/error/types.rs
UTF-8
3,427
3.234375
3
[]
no_license
use std::fmt::{Debug, Display}; use crate::utils::locations::{NodeLocation, InFileLocation}; use colored::Colorize; #[derive(Debug)] pub enum ErrorVariant { Syntax, Semantic, /// Error related to a dysfunction of the compiler. Compiler, } impl Display for ErrorVariant { fn fmt(&self, f: &mut std::f...
true
ee3f41b4e170cd13d261f86eb52d182dedc41503
Rust
ycd/soda
/src/lib.rs
UTF-8
8,943
2.671875
3
[ "Apache-2.0" ]
permissive
use std::{ borrow::{Borrow, BorrowMut}, fs::File, io::{ErrorKind, Write}, }; use std::fs::OpenOptions; use std::io::prelude::*; use fern::Dispatch; use log::{debug, error, info, trace, warn}; use pyo3::prelude::*; use pyo3::types::{PyLong, PyUnicode}; #[pymodule] fn soda(_py: Python, m: &PyModule) -> Py...
true
0da80069d9653cc22b140b853fd0f1eb3d46665c
Rust
Frodo45127/rpfm
/rpfm_lib/src/schema/v4.rs
UTF-8
14,326
2.515625
3
[ "MIT" ]
permissive
//---------------------------------------------------------------------------// // Copyright (c) 2017-2023 Ismael Gutiérrez González. All rights reserved. // // This file is part of the Rusted PackFile Manager (RPFM) project, // which can be found here: https://github.com/Frodo45127/rpfm. // // This file is licensed un...
true
97bd363245b7035e03169e569518b9c43c85060f
Rust
mejk/grafen
/src/bin/main.rs
UTF-8
8,792
2.625
3
[ "Unlicense" ]
permissive
//! Create graphene and other substrates for use in molecular dynamics simulations. extern crate colored; extern crate dialoguer; extern crate serde; extern crate serde_json; extern crate structopt; #[macro_use] extern crate structopt_derive; extern crate grafen; extern crate mdio; mod error; mod output; mod ui; us...
true
5c675ac42c5d9f7898aae6c4d7c8ac5f3f1c9d9c
Rust
projectacrn/acrn-hypervisor
/misc/config_tools/configurator/packages/configurator/src-tauri/src/configurator.rs
UTF-8
13,561
2.828125
3
[ "BSD-3-Clause" ]
permissive
use std::borrow::Borrow; use std::ops::Add; use std::path::{Path, PathBuf}; use glob::{glob_with, MatchOptions}; use itertools::Itertools; use serde::{Deserialize, Serialize}; use tauri::Window; use std::fs::{self, File}; use std::io; use std::io::prelude::*; #[derive(Serialize, Deserialize, Clone, Copy, Debug)] #[r...
true
944408b0c1d294b9ecda815f0fa967c5023cc185
Rust
glittershark/achilles
/src/parser/mod.rs
UTF-8
5,010
2.828125
3
[]
no_license
use nom::character::complete::{multispace0, multispace1}; use nom::error::{ErrorKind, ParseError}; use nom::{alt, char, complete, do_parse, many0, named, separated_list0, tag, terminated}; #[macro_use] mod macros; mod expr; mod type_; use crate::ast::{Arg, Decl, Fun, Ident}; pub use expr::expr; pub use type_::type_; ...
true
d6dd2892ac2435b54c9772b546df4d63bf258bdb
Rust
gifnksm/ProjectEulerRust
/src/bin/p027.rs
UTF-8
1,341
3.1875
3
[ "MIT" ]
permissive
//! [Problem 27](https://projecteuler.net/problem=27) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use prime::PrimeSet; // p(n) = n^2 + an + b is prime for n = 0 .. N // p(0) = b => b must be prime // p(1) = 1...
true
11c2e167326c1be90e0c40ca6e7b7bbb7b328b2a
Rust
dakom/awsm-renderer
/demo/src/ui/primitives/button/state.rs
UTF-8
629
3.0625
3
[ "MIT", "Apache-2.0", "BSD-2-Clause" ]
permissive
use crate::prelude::*; use crate::ui::primitives::image::Image; pub struct Button { pub style: ButtonStyle, } #[derive(Clone, Debug, PartialEq, Eq)] pub enum ButtonStyle { Color(ButtonColor), Image(Rc<Image>) } #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum ButtonColor { Primary, Green, ...
true
d6980ea432ec378bbc95e7574b63dd3010e6af66
Rust
lnds/Ogu
/ogu-lang/src/backend/modules/tests/test_lets_wheres.rs
UTF-8
3,228
2.703125
3
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
use crate::backend::compiler::default_sym_table; use crate::backend::modules::tests::make_module; use crate::backend::modules::types::basic_type::BasicType; use crate::backend::modules::types::func_type::FuncType; use indoc::indoc; use crate::backend::modules::types::trait_type::TRAIT_UNKNOWN; use crate::backend::scope...
true
7433cfb3994ffdf32aa9c168fcda8128d76eb529
Rust
datariot/msgpack-rust
/rmp/src/encode.rs
UTF-8
31,159
2.984375
3
[]
no_license
//! Provides various functions and structs for MessagePack encoding. use std::convert::From; use std::error::Error; use std::fmt; use std::io; use std::io::Write; use std::result::Result; use byteorder; use byteorder::WriteBytesExt; use super::Marker; #[path = "encode/value_ref.rs"] pub mod value_ref; /// Represen...
true
08ec5c239dffdd97f60dbd4626bdc17d47a58919
Rust
ia7ck/competitive-programming
/AtCoder/abc236/src/bin/b/main.rs
UTF-8
799
2.625
3
[]
no_license
use input_i_scanner::InputIScanner; fn main() { let stdin = std::io::stdin(); let mut _i_i = InputIScanner::from(stdin.lock()); macro_rules! scan { (($($t: ty),+)) => { ($(scan!($t)),+) }; ($t: ty) => { _i_i.scan::<$t>() as $t }; (($($t: ty),...
true
bc492c7fdf6e5ca89ed2ee68298e1afafc3dab07
Rust
isgasho/slipstream
/src/types.rs
UTF-8
6,637
2.578125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![allow(missing_docs)] //! Type aliases of the commonly used vector types. //! //! While the vector types are created from the [`Packed?`][Packed2] by setting the base type and //! length, this is seldom done in downstream code. Instead, this module provides the commonly used //! types as aliases, like [u16x8]. See th...
true
a755bb0294f1342b6e36aaddba6227af3b572f28
Rust
jayped007/wasm-game-of-life
/src/lib.rs
UTF-8
10,985
2.859375
3
[ "MIT", "Apache-2.0" ]
permissive
// lib.rs -- RUST wasm interface for Conways game of life mod utils; use quad_rand; use js_sys; use wasm_bindgen::prelude::*; // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global // allocator. #[cfg(feature = "wee_alloc")] #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeA...
true
c6b9a7f55dcae3240ec8fac5328390db1a67f656
Rust
LordSentox/othello
/src/srv/gamehandler.rs
UTF-8
4,011
3.078125
3
[]
no_license
use std::sync::{Arc, Weak, Mutex}; use super::{Game, NetHandler}; use packets::*; use std::collections::{HashSet, VecDeque}; pub struct GameHandler { nethandler: Arc<NetHandler>, games: Vec<Weak<Game>>, /// All pending requests the first id is the requester, the second the requestee who has not /// yet...
true
5b76dbaffc58d2525992c546a43f073b2109f399
Rust
nguyenvanquanthinh97/rust-1
/data_structures/src/unions.rs
UTF-8
920
3.78125
4
[]
no_license
// union will take memory depend on the largest part // This will take 32 bits == 4 bytes // The problem of union is not about initiate or update value of union // The problem is about "How we get the value of union" // For instance: // we can update and changing value of iof // as iof.i = 40 or iof.f = 30.5 // However...
true
3085f148e21034a259869f8cdb5817f7413c972e
Rust
ChristianBeilschmidt/geo-processing-incubator
/mappers/src/errors.rs
UTF-8
708
2.625
3
[]
no_license
use gdal::errors::Error as GdalError; use serde_json::error::Error as SerdeJsonError; error_chain! { types { Error, ErrorKind, ResultExt, Result; } foreign_links { Io(::std::io::Error); SerdeJson(SerdeJsonError); GdalError(GdalError); } errors { ...
true
f45981357305b0289fd4be3c598205f45dbb07b1
Rust
digitalarche/rustdns
/dig/main.rs
UTF-8
8,348
2.890625
3
[ "Apache-2.0" ]
permissive
// Simple dig style command line. // rustdns {record} {domain} mod util; use http::method::Method; use rustdns::clients::Exchanger; use rustdns::clients::*; use rustdns::types::*; use std::env; use std::fmt; use std::io; use std::net::SocketAddr; use std::net::ToSocketAddrs; use std::process; use std::str::FromStr; us...
true
c49f6989799b87e9bd0d36c147938d5faaaf6f92
Rust
Drumato/asmpeach
/src/assembler/tests/sib_byte_tests.rs
UTF-8
595
2.90625
3
[ "MIT" ]
permissive
#[cfg(test)] mod format_tests { use crate::assembler::resource::*; #[test] fn display_sib_byte_test() { let byte = SIBByte { base_reg: 0, index_reg: 2, scale: 4, }; assert_eq!("SIB(0b10010000)", format!("{}", byte).as_str()) } #[test] ...
true
f4f355ab9e7cd22f420ce0e5c5809ebd16cef766
Rust
katticot/data-loader
/src/bin/server.rs
UTF-8
3,666
2.546875
3
[]
no_license
use actix_web::{get, web, App, HttpResponse, HttpServer, Responder}; extern crate database; use crate::database::{elastic, mongo, postgres, Connectable, Load, Push}; use dotenv::dotenv; use std::env; use std::time::{Duration, Instant}; #[actix_web::main] async fn main() -> std::io::Result<()> { HttpServer::new(|| ...
true
21dd2f6389b757dfa58a8eac1be914337f282c46
Rust
dennisss/dacha
/pkg/executor/src/linux/channel.rs
UTF-8
717
2.90625
3
[ "Apache-2.0" ]
permissive
use common::async_std::channel; pub struct Channel<T> { sender: channel::Sender<T>, receiver: channel::Receiver<T>, } impl<T> Channel<T> { pub fn new() -> Self { let (sender, receiver) = channel::bounded(1); Self { sender, receiver } } pub async fn try_send(&self, value: T) -> boo...
true
9aaf77fd99264885c6a52831978c354fa22a0c86
Rust
luizinhoab/order-risk-assessment-ms
/src/interface/documents.rs
UTF-8
1,577
2.859375
3
[ "MIT" ]
permissive
use crate::app::domain::models::Risk; use regex::Regex; use uuid::Uuid; use validator::Validate; lazy_static! { static ref ISO8601: Regex = Regex::new(r"^([1][9][0-9]{2}|[2][0-9]{3})-([1-9]|([0][1-9]|[1][0-2]))-(([0][1-9]|[1][0-9]|[2][0-9]|[3][0-1])) (\d{2}):(\d{2}):(\d{2})$").unwrap(); } #[derive(Debug, Clone, V...
true
f31f57dce2d5a9be8ea7f3fe741060be432ee062
Rust
luksab/cargo_bot_simulator
/src/main.rs
UTF-8
1,806
2.765625
3
[]
no_license
use std::time::Instant; // TODO: stack optimieren (max größe, ältestes löschen) // TODO: brute force use cargo_bot_simulator::{CbInterpret, FinishState, StepState}; fn main() { // let mut cb = CbInterpret::<5>::new("q.a>q1", "yy,n,n,n,n", "y,n,n,n,y").unwrap(); // let mut cb = CbInterpret::<4>::new("q.a>q1", "...
true
685a6613f853d001e958de0c43a455ae3cc35467
Rust
alamont/rustray
/src/aarect.rs
UTF-8
2,194
2.9375
3
[]
no_license
use crate::aabb::AABB; use crate::hittable::{HitRecord, Hittable}; use crate::material::Material; use crate::ray::Ray; use crate::vec::{vec, vec3}; use nalgebra::{Vector2, Vector3}; use std::f32; use std::sync::Arc; pub enum AARectType { XY, XZ, YZ, } pub struct AARect { pub xy0: Vec...
true
2bef356503e59ede790cc39244e0f4349d25b2f5
Rust
Lapz/tox
/parser/src/parser/expressions/unary.rs
UTF-8
1,017
3
3
[ "MIT" ]
permissive
use syntax::T; use crate::parser::pratt::{Precedence, PrefixParser}; use crate::parser::{Parser, Restrictions}; use crate::SyntaxKind::*; impl<'a> Parser<'a> { pub(crate) fn parse_unary_op(&mut self) { match self.current() { T![-] | T![!] => self.bump(), _ => self.error( ...
true
8351e8d2ff0eedba463a542cf4ba8e8db0eacafa
Rust
xpader/rust-web-scaffolding
/src/base/rand.rs
UTF-8
138
2.625
3
[]
no_license
use rand::Rng; pub fn gen_rand(low: usize, high: usize) -> usize { let mut rng = rand::thread_rng(); rng.gen_range(low, high+1) }
true
309d0168fa7af99bfc469eec4308041b4144f21a
Rust
passcod/reasonable.kiwi
/active-ttl-cache/src/lib.rs
UTF-8
4,093
3.109375
3
[ "Artistic-2.0" ]
permissive
use std::hash::Hash; use std::collections::HashMap; use crossbeam_channel::{Sender, bounded, unbounded}; use std::marker::PhantomData; use std::time::Duration; use std::thread::{sleep, spawn}; use std::ops::Deref; pub struct Entry<K: Clone, V> { notice: Sender<Event<K, V>>, inner: V, key: K, } impl<K, V> ...
true
73c678d9f190c4f8e49880eae527d56ea137b7e5
Rust
QPC-database/ion-rust
/src/binary/uint.rs
UTF-8
6,445
3.75
4
[ "Apache-2.0" ]
permissive
use std::io::Write; use std::mem; use crate::data_source::IonDataSource; use crate::result::{decoding_error, IonResult}; type UIntStorage = u64; const MAX_UINT_SIZE_IN_BYTES: usize = mem::size_of::<UIntStorage>(); /// Represents a fixed-length unsigned integer. See the /// [UInt and Int Fields](http://amzn.github.io...
true
cb20125375a5212c095471be9bc5b8e48a381fcc
Rust
reem/transfer
/src/rt/metadata.rs
UTF-8
419
2.859375
3
[]
no_license
use rt::Executor; use std::sync::Arc; use std::fmt; /// Runtime Metadata /// /// Metadata needed by the runtime to execute actions in other contexts, /// usually on other threads. #[derive(Clone)] pub struct Metadata { pub executor: Arc<Box<Executor>> } impl fmt::Debug for Metadata { fn fmt(&self, f: &mut fmt...
true
624517d5d6d05503bb2377ac79dda279c17b40d0
Rust
TheAlgorithms/Rust
/src/math/sine.rs
UTF-8
1,529
3.671875
4
[ "MIT" ]
permissive
// Calculate Sine function. // Formula: sine(x) = x - x^3/3! + x^5/5! - x^7/7! + ... // Where: x = angle in randians. // It is not a real function so I will just do 9 loops, it's just an approximation. // Source: // https://web.archive.org/web/20221111013039/https://www.homeschoolmath.net/teaching/sine_calculator.p...
true
e85281cc82dd0a35df8d334663ad254421736a08
Rust
gengteng/rust-http2
/src/data_or_headers_with_flag.rs
UTF-8
5,084
2.71875
3
[ "MIT" ]
permissive
use futures::stream; use futures::stream::Stream; use bytes::Bytes; use crate::data_or_headers::DataOrHeaders; use crate::data_or_trailers::DataOrTrailers; use crate::error; use crate::misc::any_to_string; use crate::result; use crate::solicit::end_stream::EndStream; use crate::solicit::header::Headers; use crate::so...
true
c4ab0a7c611e4285dd97dc1d25c782457e3ec5fd
Rust
sowetocon/sowetocon.github.io
/crate/src/pages/home.rs
UTF-8
1,168
2.5625
3
[ "MIT" ]
permissive
use yew::prelude::*; use yew_styles::layouts::{ container::{Container, Direction, Wrap}, item::{Item, ItemLayout}, }; pub struct Home; impl Component for Home { type Message = (); type Properties = (); fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self { Home {} } fn ...
true