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
c0f5851a839fcd9abf82b551b7af97fbe616823d
Rust
ciruz/next.js
/packages/next-swc/crates/next-core/src/env.rs
UTF-8
2,347
2.5625
3
[ "MIT" ]
permissive
use anyhow::Result; use indexmap::indexmap; use turbopack_binding::{ turbo::tasks_env::{ CustomProcessEnvVc, EnvMapVc, FilterProcessEnvVc, ProcessEnv, ProcessEnvVc, }, turbopack::env::EmbeddableProcessEnvVc, }; use crate::next_config::NextConfigVc; /// Creates a ProcessEnvVc safe to use in JS, by ...
true
6ebb0a203940cf712a214aafff687772b1972759
Rust
hsk/rucc
/src/lexer.rs
UTF-8
25,350
2.90625
3
[ "MIT" ]
permissive
use std::fs::OpenOptions; use std::io::prelude::*; use std::iter; use std::str; use std::collections::VecDeque; use std::path; use std::process; use std::collections::{HashSet, HashMap}; use error; use parser; use MACRO_MAP; #[derive(Debug)] pub enum Macro { // Vec<Token> -> macro body Object(Vec<Token>), ...
true
af36764468f8999eb0220aaaacc400ddca547e24
Rust
bobmcwhirter/defmt
/defmt/src/encoding/mod.rs
UTF-8
3,671
3
3
[ "Apache-2.0", "MIT" ]
permissive
#[cfg(all(feature = "encoding-raw", feature = "encoding-rzcobs"))] compile_error!("Multiple `encoding-*` features are enabled. You may only enable one."); #[cfg_attr(feature = "encoding-raw", path = "raw.rs")] #[cfg_attr(not(feature = "encoding-raw"), path = "rzcobs.rs")] mod inner; // This wrapper struct is to avoid...
true
69806a9ea01f1a870fa621405b37d5f28c5c03bd
Rust
maciejhirsz/logos
/logos/src/lib.rs
UTF-8
13,793
3.75
4
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! <img src="https://raw.githubusercontent.com/maciejhirsz/logos/master/logos.svg?sanitize=true" alt="Logos logo" width="250" align="right"> //! //! # Logos //! //! _Create ridiculously fast Lexers._ //! //! **Logos** has two goals: //! //! + To make it easy to create a Lexer, so you can focus on more complex problems...
true
33e545a021bfd7dc8317ca4e8f15e3fd8807abfd
Rust
aidanhs/ayzim
/src/parser.rs
UTF-8
39,063
2.765625
3
[]
no_license
// Pure parsing. Calls methods on a Builder (template argument) to actually // construct the AST // // XXX All parsing methods assume they take ownership of the input string. This // lets them reuse parts of it. You will segfault if the input string cannot be // reused and written to. // RSTODO: nom parser? use std::...
true
f19a0baf870b410c50ca09a55e5dd0bc227a5c90
Rust
12101111/nettest
/src/tcping.rs
UTF-8
1,389
2.828125
3
[]
no_license
use crate::{Measurement, Task}; use anyhow::{anyhow, Context, Result}; use log::info; use std::net::{SocketAddr, TcpStream, ToSocketAddrs}; use std::time::{Duration, Instant}; pub struct TcpingTask { target: SocketAddr, timeout: Duration, seq: u16, } impl TcpingTask { pub fn new(addr: &str, timeout: u...
true
6730c434f57e8def618296beb6f9dfb10f5092bd
Rust
lattice0/rust-ffmpeg-1
/src/util/cvec.rs
UTF-8
992
2.96875
3
[ "WTFPL" ]
permissive
use std::{ptr, slice}; use libc::{c_uchar}; /* extern "C" { fn allocate_data(data_ptr: *mut *const c_uchar, data_len: *mut i32); fn deallocate_data(data_ptr: *const c_uchar); } */ //fn deallocate_data(data_ptr: *const c_uchar); pub struct CVec { ptr: *const c_uchar, len: usize, } impl CVec{ pub ...
true
0f68608edea1ee937f281cabf119c8495538753c
Rust
willcrichton/rapier
/src/dynamics/mass_properties.rs
UTF-8
16,276
2.90625
3
[ "Apache-2.0" ]
permissive
use crate::math::{AngVector, AngularInertia, Isometry, Point, Rotation, Vector}; use crate::utils; use num::Zero; use std::ops::{Add, AddAssign, Sub, SubAssign}; #[cfg(feature = "dim3")] use {na::Matrix3, std::ops::MulAssign}; #[derive(Copy, Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde-serialize", derive(Seri...
true
d4d2d337cfce55b36f02d7cb0dafc25705c3d0e0
Rust
ges0909/rust-examples
/result/main.rs
UTF-8
640
3.921875
4
[]
no_license
fn myfunc(n: isize) -> Result<isize, String> { if n % 2 == 0 { return Result::Ok(n); // returns Ok } Result::Err(format!("odd number {}", n)) // returns Err } fn main() { // explicit match let r = match myfunc(2) { Ok(num) => num, // r = num Err(msg) => panic!(msg)...
true
14e23ed6c2f723e5b29d45af9200cb03f4f885b3
Rust
indo-dev-0/icu4x
/components/provider/src/lib.rs
UTF-8
3,870
2.90625
3
[ "Apache-2.0", "ICU", "MIT", "LicenseRef-scancode-unicode" ]
permissive
// This file is part of ICU4X. For terms of use, please see the file // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/master/LICENSE ). //! `icu_provider` is one of the [`ICU4X`] components. //! //! It defines traits and structs for transmitting data t...
true
364352193ea29f18ec16657d30f6d427a7d989f4
Rust
bodoni/font
/src/format/opentype/character.rs
UTF-8
2,140
2.828125
3
[ "Apache-2.0", "MIT" ]
permissive
use std::collections::HashMap; use std::io::Result; use std::ops::RangeInclusive; use opentype::truetype::character_mapping::{CharacterMapping, Encoding}; use opentype::truetype::GlyphID; use typeface::Tape; use crate::format::opentype::cache::Cache; /// Unicode code points. pub type Characters = Vec<RangeInclusive<...
true
79d79455e4e32b934785e15c2ef80ad476b1384d
Rust
mersinvald/akkadia
/akkadia-vfs/src/test.rs
UTF-8
8,706
2.78125
3
[]
no_license
use super::{VfsInternal, Change, FileLoader, File, Error, make_line_indices}; use Span; use span::{Row, Column}; use std::path::{Path, PathBuf}; struct MockFileLoader; impl FileLoader for MockFileLoader { fn read<U>(file_name: &Path) -> Result<File<U>, Error> { let text = format!("{}\nHello\nWorld\nHello,...
true
48564b8ec94f9ba8ee348ca22f16d37d285e8357
Rust
garethkcjones/rays
/src/texture/chequer.rs
UTF-8
1,055
3.34375
3
[]
no_license
use super::Texture; use crate::{Colour, Vec3}; use std::sync::Arc; /** * Type for representing a chequered texture. */ #[derive(Debug)] pub struct Chequer { scale: Vec3, even: Arc<dyn Texture>, odd: Arc<dyn Texture>, } impl Chequer { #[must_use] pub fn new( scale: Vec3, even: imp...
true
0dd5e99d568629b8a830ff94c5a6764902a4b936
Rust
void-dragon/runjit
/src/executor.rs
UTF-8
6,916
3.25
3
[]
no_license
//! //! AST executor //! use std::collections::BTreeMap; use std::rc::Rc; use std::cell::RefCell; use std::ops::Deref; use ast::*; use types::*; pub struct Context { pub parent: Option<Rc<Context>>, pub values: RefCell<BTreeMap<String, Rc<Value>>>, pub statements: Vec<Ast>, } impl Context { pub fn ...
true
c2ca4988c4cf1e2ddcecdf70cbdad3f9e7367d0e
Rust
HiraokaTakuya/bitboard_bench
/rust_version/src/main.rs
UTF-8
2,576
3.4375
3
[]
no_license
struct Square(i32); struct Bitboard { v: [u64; 2], } impl Iterator for Bitboard { type Item = Square; fn next(&mut self) -> Option<Self::Item> { self.pop_lsb() } } impl Bitboard { const ALL: Bitboard = Bitboard { v: [0x7fff_ffff_ffff_ffff, 0x7fff_ffff_ffff_ffff], }; fn val...
true
83afdcc05baaed0558869a7d5e121347c9bb8cd2
Rust
scoopr/gfx
/src/hal/src/pso/mod.rs
UTF-8
6,289
2.703125
3
[ "Apache-2.0" ]
permissive
//! Raw Pipeline State Objects //! //! This module contains items used to create and manage a raw pipeline state object. Most users //! will want to use the typed and safe `PipelineState`. See the `pso` module inside the `gfx` //! crate. use {device, pass}; use std::error::Error; use std::fmt; mod compute; mod descri...
true
dbfa6e28934ec9fd7520f68a5b98ea54166cec59
Rust
fitzgen/preduce
/src/reducers.rs
UTF-8
23,970
2.78125
3
[]
no_license
//! Concrete implementations of `preduce::traits::Reducer`. use error; use is_executable::IsExecutable; use preduce_ipc_types::{FastForwardRequest, NewRequest, NextOnInterestingRequest, NextRequest, ReduceRequest, Request}; use preduce_ipc_types::{FastForwardResponse, NewResponse, NextOnInteres...
true
aa408b00f27242d9ea15c991ff1ac6fe99cb620e
Rust
PacktPublishing/Hands-On-Functional-Programming-in-Rust
/Chapter07/lazy_pattern.rs
UTF-8
8,499
3.09375
3
[ "MIT" ]
permissive
use std::rc::Rc; use std::sync::{Arc,Mutex}; #[derive(Clone)] struct LazyList<A: Clone> { buffer: Rc<Vec<A>>, index: usize } impl<A: Clone> LazyList<A> { fn new(buf: Vec<A>) -> LazyList<A> { LazyList { buffer: Rc::new(buf), index: 0 } } fn next(&self) -> Option<(LazyList<A>...
true
74d550809aeee1417eb570131aa332a4b66acf3d
Rust
jvff/pegast
/src/rules/zero_or_more.rs
UTF-8
769
2.625
3
[]
no_license
use { crate::{input::Input, ParseError, PegAstNode}, std::{borrow::Cow, iter}, }; impl<R: PegAstNode> PegAstNode for Vec<R> { fn parse(input: &mut impl Input) -> Result<Self, ParseError> { Ok(iter::from_fn(|| R::parse(input).ok()).collect()) } fn parsed_string(&self) -> Cow<'_, str> { ...
true
e3abc5a65545fc43cd52f9e0547a977ef5e336ef
Rust
SINHASantos/tunapanel
/src/panel.rs
UTF-8
3,871
3
3
[ "MIT", "Apache-2.0" ]
permissive
//! Definition of a panel. use serde::de::DeserializeOwned; use templates::{HTML, HANDLEBARS}; /// Trait for panels. /// /// You should not need to implement this yourself. /// The `impl`s are generated by the `tunapanel!` macro. pub trait Panel: DeserializeOwned { fn title() -> &'static str; fn widgets() -...
true
40705375880d340089571086d490da33c448d0ec
Rust
AntoineGagne/crypt3
/rust_src/crypt3_nif/src/bindings.rs
UTF-8
824
2.875
3
[ "BSD-2-Clause", "BSD-3-Clause" ]
permissive
use std::ffi::{CStr, CString}; use std::os::raw::c_char; pub enum EncodedField { Key, Salt, } pub enum EncryptionError { Encoding(EncodedField), Decoding(String), } pub fn encrypt(key: String, salt: String) -> Result<String, EncryptionError> { unsafe { let key_ = CString::new(key) ...
true
235004e719ed0bc788194148a40f019feaeb8d4a
Rust
theotherphil/rtiow
/src/camera.rs
UTF-8
1,881
3.203125
3
[]
no_license
use rand::prelude::*; use std::f32::consts::PI; use crate::ray::*; use crate::vec3::*; fn random_point_in_unit_disk() -> Vec3 { let mut rng = thread_rng(); loop { let p = 2.0 * Vec3::new(rng.gen(), rng.gen(), 0.0) - Vec3::new(1.0, 1.0, 0.0); if dot(p, p) < 1.0 { return p; } ...
true
506cd68377aa8745061cffe49c611c9eb04e5b3a
Rust
rcore-os/arceos
/crates/slab_allocator/src/lib.rs
UTF-8
10,968
2.9375
3
[ "Apache-2.0", "AGPL-3.0-only", "LicenseRef-scancode-mulanpubl-2.0", "AGPL-3.0-or-later", "GPL-3.0-only", "MulanPSL-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-mulanpsl-2.0-en" ]
permissive
//! Slab allocator for `no_std` systems. It uses multiple slabs with blocks of //! different sizes and a [buddy_system_allocator] for blocks larger than 4096 //! bytes. //! //! It's based on <https://github.com/weclaw1/slab_allocator>. //! //! [buddy_system_allocator]: https://docs.rs/buddy_system_allocator/latest/budd...
true
ff3e387d1543cd5afb1198e11de7de23cac1b970
Rust
onelson/destiny2-api-rs
/codegen/src/models/destiny_entities_vendors_destiny_vendor_sale_item_component.rs
UTF-8
7,540
2.921875
3
[]
no_license
/* * Bungie.Net API * * These endpoints constitute the functionality exposed by Bungie.net, both for more traditional website functionality and for connectivity to Bungie video games and their related functionality. * * OpenAPI spec version: 2.0.0 * Contact: support@bungie.com * Generated by: https://github.com...
true
8785590146f5077fbceb054e74fffd5e4df9f7ad
Rust
mitchmindtree/RustFFT
/src/algorithm/good_thomas_algorithm.rs
UTF-8
6,625
3.15625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use std::sync::Arc; use num_complex::Complex; use common::{FFTnum, verify_length, verify_length_divisible}; use math_utils; use array_utils; use ::{Length, IsInverse, FFT}; /// Implementation of the [Good-Thomas Algorithm (AKA Prime Factor Algorithm)](https://en.wikipedia.org/wiki/Prime-factor_FFT_algorithm) /// //...
true
be9f35df5ca322c6ab6c6d2b37768fac06206086
Rust
padenot/monome-rs
/examples/gradient.rs
UTF-8
1,018
2.546875
3
[ "MIT", "Apache-2.0" ]
permissive
extern crate env_logger; extern crate monome; use std::{thread, time}; use monome::Monome; fn main() { env_logger::init(); let mut monome = Monome::new("/prefix".to_string()).unwrap(); println!("{:?}", monome); let mut v = [0; 64]; let mut sp: isize = 1; let mut dir: isize = 1; loop {...
true
4b774fcd96443abc4e61625a9231c4a1c17f8b77
Rust
Gekkio/gb-hardware-db
/site/src/template/site_header.rs
UTF-8
2,908
2.53125
3
[ "MIT", "CC0-1.0" ]
permissive
// SPDX-FileCopyrightText: 2017-2023 Joonas Javanainen <joonas.javanainen@gmail.com> // // SPDX-License-Identifier: MIT use gbhwdb_backend::Console; use percy_dom::{html, IterableNodes, View, VirtualNode}; use crate::site::SiteSection; #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct SiteHeader { pub sect...
true
d47a912895f2b01162b0ab34d0be9d97165fd5b1
Rust
fazo96/rust-game
/src/game/player.rs
UTF-8
2,914
3.140625
3
[]
no_license
use super::position::*; use super::{Game, GameState}; use super::Entity; use super::render::RenderInfo; use super::rpg::CharacterStats; use rustbox::{Color,Key}; #[derive(Clone)] pub struct Player { position: Position, cursor_position: Position, render_info: RenderInfo, character_stats: CharacterStats ...
true
e4e2230712a4ad4283a567e1ce6aca83c896677f
Rust
cjburkey01/citymonopolis
/amazintosh_rs/src/render/shader.rs
UTF-8
9,646
2.921875
3
[ "MIT" ]
permissive
use super::inner_gl; use super::inner_gl::types::{GLchar, GLint, GLuint}; use crate::render::{Gl, RenderHandler}; use nalgebra::{Matrix2, Matrix3, Matrix4, Vector2, Vector3, Vector4}; use std::collections::HashMap; use std::ffi::CString; use std::fmt::{Debug, Display, Formatter}; macro_rules! gl_error_check { ($gl...
true
78d29ccb4b41266a60591d02e40ff76d3bd269f2
Rust
compactcode/exercism
/rust/rotational-cipher/src/lib.rs
UTF-8
445
3.484375
3
[]
no_license
pub fn rotate(input: &str, key: u8) -> String { input .chars() .map(|c| rotate_char(c, key)) .collect() } fn rotate_char(c: char, key: u8) -> char { match c { 'a'...'z' => rotate_from_base(c as u8, 'a' as u8, key), 'A'...'Z' => rotate_from_base(c as u8, 'A' as u8, key), ...
true
2270702da79ab416afa9f4f8754f1ab5975ae738
Rust
irbis-labs/rsmorphy
/src/container/word.rs
UTF-8
619
3.484375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::sync::Arc; #[derive(Debug, Clone, PartialEq)] pub struct WordStruct { is_known: bool, word: Arc<String>, } impl WordStruct { pub fn new<W: Into<String>>(word: W, is_known: bool) -> Self { let word = Arc::new(word.into()); WordStruct { word, is_known } } pub fn known<W: In...
true
1306d2509ed69b4ccea0c2154dd2e933f4807678
Rust
belfz/piston_snake
/src/lib.rs
UTF-8
3,455
2.890625
3
[ "MIT" ]
permissive
extern crate piston_window; extern crate rand; mod board; mod direction; mod food; mod snake; use board::Board; use direction::Direction; use food::Food; use snake::Snake; use piston_window::*; use std::time::Instant; const ONE_HUNDRED_MS: u32 = 100000000; static WHITE: [f32; 4] = [1.0, 1.0, 1.0, 1.0]; static RED: ...
true
e089f3b8d6753d4f01dda2453c00d7d28b7dc800
Rust
jonwingfield/atsamd09-rs
/atsamd09d14a/dmac/crcctrl/mod.rs
UTF-8
10,004
2.859375
3
[]
no_license
#[doc = r" Value read from the register"] pub struct R { bits: u16, } #[doc = r" Value to write to the register"] pub struct W { bits: u16, } impl super::CRCCTRL { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w m...
true
16c16c81c3d2ace7155a2f90b14eb9caa6f6bedc
Rust
tokio-rs/tokio
/tokio/tests/uds_stream.rs
UTF-8
10,976
2.640625
3
[ "MIT" ]
permissive
#![cfg(feature = "full")] #![warn(rust_2018_idioms)] #![cfg(unix)] use std::io; use std::task::Poll; use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest}; use tokio::net::{UnixListener, UnixStream}; use tokio_test::{assert_ok, assert_pending, assert_ready_ok, task}; use futures::future::{poll_fn, try_join}; #[tok...
true
467c036ae586d515adc3c8ba142e800b7b754f00
Rust
SuneelFreimuth/boa
/boa/src/builtins/map/ordered_map.rs
UTF-8
4,174
3.3125
3
[ "MIT", "Unlicense" ]
permissive
use crate::gc::{custom_trace, Finalize, Trace}; use indexmap::{map::IntoIter, map::Iter, map::IterMut, IndexMap}; use std::{ collections::hash_map::RandomState, fmt::Debug, hash::{BuildHasher, Hash}, }; /// A newtype wrapping indexmap::IndexMap #[derive(Clone)] pub struct OrderedMap<K, V, S = RandomState>(...
true
73d5d3a4251123e59cbc1b644b9d3c74eabb6bb5
Rust
isgasho/linux_commands_rewritten_in_rust
/src/bin/chmod.rs
UTF-8
958
2.796875
3
[]
no_license
//! chmod (GNU coreutils) #![warn(clippy::nursery, clippy::pedantic)] use linux_commands_rewritten_in_rust::errno::last_errno_message; fn main() { let args = std::env::args().collect::<Vec<_>>(); if args.len() != 3 { eprintln!("usage_example: chmod 777 main.rs"); return; } let permiss...
true
c1d963b524fc795852f62d8c5684bba001321d8e
Rust
bundleofbytes/libstripe
/src/resources/core/customer_taxid.rs
UTF-8
3,078
2.71875
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::resources::common::object::Object; use crate::resources::common::path::UrlPath; use crate::resources::core::customer::Customer; use crate::util::{Deleted, Expandable, List}; use crate::Client; #[derive(Serialize, Deserialize, Debug, PartialEq)] pub struct CustomerTaxID { pub id: String, pub object: ...
true
12980e07fe52d28ef8f51963637414ccdbfcc9de
Rust
jFransham/simple-game
/src/gameobjects/player/ship.rs
UTF-8
14,174
2.90625
3
[]
no_license
use ::gameobjects::*; use ::events::*; use ::view::*; use ::graphics::sprites::{ VisibleComponent, VisibleRect, Sprite, }; use ::time::*; use ::set::Intersects; use super::*; use super::command_builder::CommandBuilder; use std::convert::TryInto; use std::collections::HashMap; use sdl2::pixels::Color; use ...
true
5796a79eccd49ad1e80e67c3f08a1e0679fa2968
Rust
Palaxx/rust-polygon-map-generator
/src/terrains/snow.rs
UTF-8
215
2.703125
3
[]
no_license
use crate::terrains::terrain::Terrain; pub struct Snow { } impl Terrain for Snow { fn get_color(&self) -> [u8; 3] { [221,221,228] } fn get_name(&self) -> &'static str { "snow" } }
true
47b0da06291c8a4713214d272dff32da90bac62a
Rust
anchnk/delta
/src/options/option_value.rs
UTF-8
2,917
3.109375
3
[ "MIT" ]
permissive
use crate::config::delta_unreachable; /// A value associated with a Delta command-line option name. pub enum OptionValue { Boolean(bool), Float(f64), OptionString(Option<String>), String(String), Int(usize), } /// An OptionValue, tagged according to its provenance/semantics. pub enum ProvenancedOp...
true
b650007e6ec551d812dfafbb1a5d34886356a8d9
Rust
algebraicdb/algebraicdb
/channel_stream/src/lib.rs
UTF-8
4,114
3.09375
3
[]
no_license
use pin_utils::pin_mut; use staticvec::StaticVec; use std::future::Future; use std::io::Write; use std::pin::Pin; use std::task::{Context, Poll}; use tokio::io::{self, AsyncRead, AsyncWrite}; use tokio::sync::mpsc; const CHANNEL_CAP: usize = 255; const BUFFER_CAP: usize = 255; type Chunk = StaticVec<u8, BUFFER_CAP>; ...
true
7731ae67c381924dc03405913665a844485c8853
Rust
BabylonAS/multi-ipc-test
/src/client.rs
UTF-8
3,961
2.890625
3
[ "Unlicense" ]
permissive
/* multi-ipc-test/src/client.rs: multi-program IPC test client * This is free and unencumbered software released into the public domain. * * Anyone is free to copy, modify, publish, use, compile, sell, or * distribute this software, either in source code form or as a compiled * binary, for any purpose, commercial ...
true
2ba37fe753ec95cff881fe89a97de8976a7ddb7f
Rust
zxk7516/hellors
/src/bin/a3.rs
UTF-8
726
2.71875
3
[]
no_license
#![allow(warnings)] #[macro_use] extern crate crossbeam_channel; use crossbeam_channel::bounded; use crossbeam_utils::thread; fn main() { let people = vec!["Anna", "Bob", "Cody", "Dave", "Eva"]; let (s, r) = bounded(1); let seek = |name, s, r| { select! { recv(r) -> peer => println!("...
true
6e20212ae8fa4d00d8628942f5985c849ac8889d
Rust
pierreyoda/rustboycolor
/src/gpu/registers.rs
UTF-8
3,366
3.015625
3
[ "MIT" ]
permissive
use super::GpuMode; pub const CONTROL: usize = 0xFF40; // LCD Control pub const STAT: usize = 0xFF41; // LCD Controller status pub const SCY: usize = 0xFF42; pub const SCX: usize = 0xFF43; pub const LY: usize = 0xFF44; // read-only pub const LYC: usize = 0xFF45; pub const BGP: usize = 0xFF47; // ignored in CGB mode pu...
true
4fab0d24cc6865f5c3da7966578557c224c6d209
Rust
Aetf/fit2
/src/adaptor.rs
UTF-8
2,037
2.5625
3
[ "MIT", "Apache-2.0" ]
permissive
use futures::task::{Context, Poll}; pub use http; use hyper::{body::Bytes, http::HeaderValue, HeaderMap}; use lambda_http::Body as LambdaBody; use std::convert::Infallible; use tokio::macros::support::Pin; pub trait IntoHyperBody: Sized { fn into_bytes(self) -> Bytes; fn into_hyper_body(self) -> hyper::Body { ...
true
ac827f697c2732b2f83365c175844f8f5b903bca
Rust
gnzlbg/is_sorted
/src/lib.rs
UTF-8
18,133
3.375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Extends `Iterator` with three algorithms, `is_sorted`, `is_sorted_by`, and //! `is_sorted_by_key` that check whether the elements of an `Iterator` are //! sorted in `O(N)` time and `O(1)` space. //! //! To enable explicitly-vectorized implementations enable the `unstable` //! nightly-only feature and use the typed ...
true
4c60d0bfab5ed63d064c3d28694de52d5f245011
Rust
rust-lang/rust
/tests/ui/did_you_mean/issue-114112.rs
UTF-8
203
2.765625
3
[ "Apache-2.0", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
enum E<T> { A(T) } fn main() { match E::<i32>::A(1) { E<i32>::A(v) => { //~ ERROR generic args in patterns require the turbofish syntax println!("{v:?}"); }, } }
true
300c0893c18fef97990d2bf22f0b5e3d95f2f2db
Rust
kb10uy/derky
/weavy_crab/src/parser.rs
UTF-8
15,568
2.828125
3
[ "Apache-2.0" ]
permissive
use crate::{ mtl::{Material, MaterialProperty}, obj::{FaceIndexPair, Group, Object}, Error, Result, WavefrontObj, }; use std::{ collections::HashMap, io::{prelude::*, BufReader}, mem::{replace, take}, path::{Path, PathBuf}, str::FromStr, }; use log::warn; use ultraviolet::{Vec2, Vec3};...
true
ad04e7514ff6ba5b03db0ed2b196354e15d51980
Rust
crowlKats/devcode
/src/renderer/code_view/code.rs
UTF-8
7,314
2.875
3
[ "MIT" ]
permissive
use super::super::input::{max_line_length, Cursor}; use super::super::rectangle::Rectangle; use crate::renderer::Dimensions; use std::cell::RefCell; use std::rc::Rc; use wgpu_glyph::ab_glyph::FontArc; use wgpu_glyph::{GlyphPositioner, Layout, Section, SectionGeometry, Text}; use winit::dpi::{PhysicalPosition, PhysicalS...
true
187855326dec3df4d98462fd3b28a2978b801142
Rust
qryxip/atcoder
/dwacon5th-prelims/src/bin/b.rs
UTF-8
984
2.578125
3
[]
no_license
use proconio::input; #[allow(unused_imports)] use proconio::marker::*; #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; #[allow(unused_imports)] use std::f64::consts::*; #[allow(unused)] const INF: usize = std::usize::MAX / 4; #[allow(unused)] const M: usize = 1000000007; fn...
true
4d869a2a359ce8595fbbcf64c60d0fbe5a569341
Rust
skrap/aoc_rust_2018
/src/bin/13a.rs
UTF-8
4,864
3.4375
3
[]
no_license
#[derive(Clone)] enum Dir { Up, Down, Left, Right, } impl Dir { fn turn(&self, turn : &NextTurn) -> Dir { match turn { NextTurn::Left => { match self { Dir::Up => Dir::Left, Dir::Left => Dir::Down, Dir::...
true
cb932a5819c5e23ca8aaf85a1e8adbb2470b3859
Rust
CNife/leetcode
/rust/finished/src/sqrtx.rs
UTF-8
246
3.265625
3
[]
no_license
pub fn my_sqrt(x: i32) -> i32 { (x as f64).sqrt().floor() as i32 } #[test] fn test() { let cases = vec![(0, 0), (1, 1), (4, 2), (8, 2), (2147395599, 46339)]; for (x, expect) in cases { assert_eq!(my_sqrt(x), expect); } }
true
f5761c5da135f52958d40729bacf2d17ba7642e6
Rust
RodionKovalenko/rustCrates
/src/mouse_clicks/click_events.rs
UTF-8
2,370
2.53125
3
[]
no_license
#[macro_use] use enigo::*; use std::process::Command; use std::thread; use std::time::Duration; use std::time::Instant; use webbrowser; use rand::Rng; pub fn simulate_click_events() { let mut enigo = Enigo::new(); let mut now = Instant::now(); let number_of_accounts:i32 = 7; let search_items = ["backpr...
true
86f822d39139cb24bc254a8e2080dfbb9928ef33
Rust
stackcats/leetcode
/algorithms/easy/flood_fill.rs
UTF-8
925
3.046875
3
[ "MIT" ]
permissive
use std::collections::LinkedList; impl Solution { pub fn flood_fill(mut image: Vec<Vec<i32>>, sr: i32, sc: i32, new_color: i32) -> Vec<Vec<i32>> { let mut queue = LinkedList::new(); let mut opt = vec![vec![0; image[0].len()]; image.len()]; queue.push_back((sr as usize, sc as usize)); ...
true
cad8af54498a14da9a72dba51df389867f97a3b9
Rust
theinfinitytimes/theinfinitytimes-api-rust
/src/models/user.rs
UTF-8
1,926
3.203125
3
[ "MIT" ]
permissive
use wither::Model; use mongodb::bson::oid::ObjectId; use serde::{Serialize, Deserialize}; use chrono::prelude::{DateTime, Utc}; use url_serde::SerdeUrl; use bcrypt::{DEFAULT_COST, hash, verify}; use crate::theinfinitytimes_lib::{PreSaveMut}; use std::ops::Deref; /// This is the user model, which is the base object ///...
true
5ee090160a6a6e0384348591db2fda49aeffaf49
Rust
Iniesta8/aoc2019
/src/bin/day05.rs
UTF-8
457
2.640625
3
[]
no_license
use aoc2019::intcode::IntCodeCpu; use std::io; fn main() -> io::Result<()> { let mut code = String::new(); io::stdin().read_line(&mut code)?; let mut cpu = IntCodeCpu::from_code(&code); cpu.input.push_back(1); cpu.run(); println!("p1: {}", cpu.output.pop_back().unwrap()); cpu = IntCodeC...
true
a6b9cf8bcc5b3592388a4e64c542d3795a134789
Rust
remram44/dhstore
/src/memory_index.rs
UTF-8
18,747
3.015625
3
[]
no_license
//! Implementation of an object indexer that stores everything in memory. //! //! This loads all the objects from disk into memory. Objects added to the index //! are immediately written to disk as well. //! //! This is very inefficient and should be backed by proper database code at //! some point. use std::collectio...
true
250971409d42faeaf6f106cf4406f2b1aca7c02b
Rust
automerge/automerge
/rust/automerge/src/storage/columns/column_specification.rs
UTF-8
7,705
3.046875
3
[ "MIT" ]
permissive
/// An implementation of column specifications as specified in [1] /// /// [1]: https://alexjg.github.io/automerge-storage-docs/#column-specifications #[derive(Eq, PartialEq, Clone, Copy)] pub(crate) struct ColumnSpec(u32); impl ColumnSpec { pub(crate) fn new(id: ColumnId, col_type: ColumnType, deflate: bool) -> S...
true
d2b7a55f491a0446e167b2b431b544b007df61a4
Rust
pombredanne/rustfst
/rustfst/src/algorithms/lazy/cache/simple_hash_map_cache.rs
UTF-8
4,838
2.875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use std::collections::HashMap; use std::sync::Mutex; use crate::algorithms::lazy::cache::cache_internal_types::{CachedData, StartState}; use crate::algorithms::lazy::{CacheStatus, FstCache}; use crate::semirings::Semiring; use crate::{StateId, Trs, TrsVec, EPS_LABEL}; #[derive(Debug)] pub struct SimpleHashMapCache<W:...
true
01f783fb5a5840c7a3d28c311fca1e04c1e42e3c
Rust
Meptl/epd-waveshare
/src/color.rs
UTF-8
574
2.96875
3
[ "ISC" ]
permissive
#[derive(Clone, Copy, PartialEq, Debug)] pub enum Color { Black, White, } impl From<u8> for Color { fn from(value: u8) -> Self { match value & 0x01 { 0x00 => Color::Black, 0x01 => Color::White, _ => unreachable!(), } } } impl Into<u8> for Color { ...
true
5598125a711e0430b981920eb9e39b16ce1e5e95
Rust
meloket/move-parachain
/pallets/sp-mvm/src/event.rs
UTF-8
1,246
2.515625
3
[ "Unlicense" ]
permissive
use sp_std::prelude::*; use frame_support::decl_event; use move_vm::data::EventHandler; use move_core_types::language_storage::TypeTag; decl_event!( pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId, { // Event documentation should end with an array that provides des...
true
b16be52672e0ee64cf5109ca8f25bbd885720d5d
Rust
MaikKlein/Rust-Learning-Game
/examples/demo1.rs
UTF-8
1,571
2.6875
3
[]
no_license
extern mod rlg; extern mod sdl; use rlg::game::*; struct MyActor<'self>{ actor: GameActor<'self>, b_dir: bool } impl <'self> MyActor<'self> { fn new(actor: GameActor<'self>)-> MyActor<'self>{ MyActor {actor: actor, b_dir: false} } fn travel(&mut self) { if self...
true
c3e97404e091dd59ebbf8b3304fa42b872fa6812
Rust
Celeo/CoD_dice_roller
/src/commands/help.rs
UTF-8
1,036
3.21875
3
[ "MIT" ]
permissive
use serenity::{ client::Context, framework::standard::{CommandResult, macros::command}, model::channel::Message, utils::MessageBuilder, }; const HELP: &str = "Chronicles of Darkness dice roller bot To use, type '!roll # <mod>', where # is a positive number or 'chance', and <what> is one of: * 9again ...
true
0e0e94b2bcb5d0756a649b027e46435b9a76a85f
Rust
EarlGray/language-incubator
/js/slothjs/src/ast/stmt.rs
UTF-8
6,284
3.421875
3
[ "BSD-3-Clause" ]
permissive
//! AST definitions for JavaScript statements. //! //! The main struct here is [`Statement`], which wraps [`Stmt`] enum. use crate::prelude::*; use crate::source; use super::expr::{ Expression, FunctionExpression, Identifier, Pattern, }; /// `Statement` represents an [`Stmt`] together with its sourc...
true
c890c6c7c8f78ab8557fa858985b153f397c29c8
Rust
bznein/AoC-2019
/Day12/src/main.rs
UTF-8
2,687
3.5
4
[]
no_license
use num::integer::lcm; #[derive(Clone)] struct Moon { p: Vec<i64>, v: Vec<i64>, } impl Moon { pub fn new(p: Vec<i64>) -> Moon { Moon { p: p, v: vec![0, 0, 0], } } pub fn is_equal_dir(&self, m: &Moon, dir: usize) -> bool { self.p[dir] == m.p[dir] && ...
true
c5d934ee26830e246dd37ab736c26af41d8d860b
Rust
torkleyy/rocket_auth
/src/language/es.rs
UTF-8
683
2.65625
3
[ "Apache-2.0", "MIT" ]
permissive
use super::*; use Error::*; impl Language { pub fn es_message(error: Error) -> &'static str { match error { UnsafePasswordTooShort => "La clave debe tener al menos 8 caracteres.", UnauthenticatedClientError => "El cliente no esta autentificado.", UnauthorizedError => "...
true
ba2190edd3768b4d94d17e2b7755217bfacf0441
Rust
qidian99/generals-rs
/src/core/common.rs
UTF-8
13,293
3.71875
4
[]
no_license
use std::collections::HashSet; pub type PlayerId = usize; /// Represent a player during a game. #[derive(Serialize, Clone, Debug, PartialEq)] pub struct Player { /// An integer that uniquely identifies each player during a game pub id: PlayerId, /// Number of tiles the player currently owns #[serde(s...
true
f460b803e8c6ae1a3a83ba03aea31aab113ac449
Rust
phlopsi/allocator
/src/u/v4.rs
UTF-8
3,886
2.9375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[cfg(test)] mod tests; use crate::align128::Align128; use std::cell::UnsafeCell; use std::mem::MaybeUninit; use std::ops::Deref; use std::ops::DerefMut; use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering::{ AcqRel, Acquire, Relaxed, Release, SeqCst, }; #[derive...
true
27f76012d9c22c511aca35c73dea48a4532d34cb
Rust
Globidev/advent-of-code
/2018/rust/src/day13.rs
UTF-8
6,225
3.1875
3
[]
no_license
use hashbrown::HashSet; const RAW_INPUT: &[u8] = include_bytes!("../../inputs/day13.txt"); pub fn day13() -> ((u16, u16), (u16, u16)) { let (world, trains) = parse_input(RAW_INPUT); (part1(&world, &trains), part2(&world, &trains)) } pub fn part1(world: &World, trains: &Trains) -> (u16, u16) { let mut tr...
true
8a033cdc1671ff9cec603fcc5c893f11124e9a73
Rust
iCodeIN/assert2ify
/assert2ify-macros/src/macro_parsing/assertion.rs
UTF-8
1,101
3.484375
3
[ "BSD-2-Clause" ]
permissive
use syn::Expr; /// An intermediate structure which helps parsing assert use cases and variants /// from the std lib and can translate them into assert2 assertions. pub enum Assertion { /// The binary assertions `std::assert_eq!` and `std::assert_ne` /// Those are transalated into the equivalent assertion of th...
true
1d73217b83065a2ad8cf7bc0583fbe8833eda762
Rust
qeda/qeda-cli
/src/symbols/mod.rs
UTF-8
1,266
2.859375
3
[ "MIT" ]
permissive
mod capacitor; mod ic; use std::collections::HashMap; use std::fmt::{self, Debug}; use crate::config::Config; use crate::error::*; use crate::symbol::Symbol; use capacitor::CapacitorSymbol; use ic::IcSymbol; pub trait SymbolHandler { fn draw(&self, comp_cfg: &Config, lib_cfg: &Config) -> Result<Symbol>; } impl...
true
a7be615f68d47cb1a8394b95619f09cbec42f7c1
Rust
AngelOnFira/advent-of-code
/2021/src/day18.rs
UTF-8
7,572
3.46875
3
[]
no_license
use itertools::Itertools; use regex::Regex; #[aoc_generator(day18)] pub fn input_generator(input: &str) -> Vec<String> { input.lines().map(|s| s.to_string()).collect() } fn test_explode(input: String) -> Option<String> { let mut bracket_count = 0; for (i, char) in input.chars().enumerate() { match...
true
341c8e6441d4f39e489b1d26ff469d9e49a2011b
Rust
bs-community/blessing-skin-shell
/src/shell/executable.rs
UTF-8
4,907
2.890625
3
[ "MIT" ]
permissive
use super::transform::Transformer; use super::{Arguments, Executables, Vars}; use crate::parser::ast::Parameters; use crate::stdio::Stdio; use crate::terminal::Terminal; use futures::channel::oneshot::{channel, Sender}; use js_sys::{Function, Promise, Reflect}; use std::cell::Cell; use std::rc::Rc; use wasm_bindgen::pr...
true
5ccc4dbecd1eea03db48f42ce92893f8273080a2
Rust
reinterpretcat/vrp
/vrp-core/src/models/problem/fleet.rs
UTF-8
6,212
2.953125
3
[ "Apache-2.0" ]
permissive
#[cfg(test)] #[path = "../../../tests/unit/models/problem/fleet_test.rs"] mod fleet_test; use crate::models::common::*; use crate::utils::short_type_name; use hashbrown::{HashMap, HashSet}; use std::cmp::Ordering::Less; use std::fmt::{Debug, Formatter}; use std::hash::{Hash, Hasher}; use std::sync::Arc; /// Represent...
true
23a15760565a8b08858ad28df77fdeacd9c8ae7d
Rust
lamaboy2018/ritual
/qt_ritual/crate_templates/qt_core/tests/models_and_casts.rs
UTF-8
1,907
2.546875
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use cpp_utils::{ConstRef, DynamicCast, Ref, StaticUpcast}; use qt_core::{ ItemDataRole, QAbstractItemModel, QAbstractListModel, QAbstractTableModel, QString, QStringList, QStringListModel, }; #[test] fn models_and_casts() { unsafe { let mut string_list = QStringList::new(); string_list.appe...
true
8b6ebc9b457c53304b7adb104a455c7b8537b16e
Rust
666666t/mergesort-rust
/src/main.rs
UTF-8
2,963
3.484375
3
[]
no_license
#![feature(test)] extern crate test; use std::cmp::Ordering; extern crate rand; use rand::seq::SliceRandom; use rand::thread_rng; //Lines 1 and 2 are for test featuries. //Ordering is used for the merge function. //rand uses SliceRandom and thread_rng to shuffle the initial vector. fn main() { let mut sort_vec:...
true
bddc58ccf92d7107625b89a84c235068adab8fc5
Rust
gnoliyil/fuchsia
/src/developer/ffx/plugins/setui/utils/src/lib.rs
UTF-8
4,592
2.921875
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2021 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. //! This library contains helper functions for common operations throughout the setui ffx plugins. use anyhow::Error; use futures::{TryFutureExt, TryStrea...
true
ff4274104d38abb13b302c2a121ba6b218a39d12
Rust
Eonm/scaffold-rs
/src/path_parent/mod.rs
UTF-8
1,973
3.359375
3
[ "MIT" ]
permissive
pub fn replace_with_parent_dir (path: String) -> String { let splited_path = path.split("/").map(|p| p.to_string()).collect::<Vec<String>>(); let return_value : Vec<String> = splited_path.iter().fold(vec!(),|mut acc, p| { if p.contains("[*]") { match acc.clone().last() { Some...
true
8732f0a138317d4c60d7c243e69b0eb4c76a9635
Rust
bevyengine/bevy
/crates/bevy_reflect/src/enums/mod.rs
UTF-8
18,999
3.234375
3
[ "Apache-2.0", "MIT", "Zlib", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive" ]
permissive
mod dynamic_enum; mod enum_trait; mod helpers; mod variants; pub use dynamic_enum::*; pub use enum_trait::*; pub use helpers::*; pub use variants::*; #[cfg(test)] mod tests { use crate as bevy_reflect; use crate::*; #[derive(Reflect, Debug, PartialEq)] enum MyEnum { A, B(usize, i32), ...
true
fe9bd43b9b9e15c469edb663b42ba5e17e774e4e
Rust
shadow/shadow
/src/lib/vasi/src/lib.rs
UTF-8
4,297
2.90625
3
[ "LicenseRef-scancode-public-domain" ]
permissive
#![no_std] // https://github.com/rust-lang/rfcs/blob/master/text/2585-unsafe-block-in-unsafe-fn.md #![deny(unsafe_op_in_unsafe_fn)] // For use by code generated by vasi_macro::VirtualAddressSpaceIndependent; #[doc(hidden)] pub use static_assertions::assert_impl_all; pub use vasi_macro::VirtualAddressSpaceIndependent; ...
true
1f3067976293e5d1bb1f58a3a6cced1598e70209
Rust
SCappella/exercism
/rust/isogram/src/lib.rs
UTF-8
324
2.609375
3
[ "MIT" ]
permissive
pub fn check(candidate: &str) -> bool { let letters: Vec<_> = candidate .chars() .filter(|c| c.is_ascii_alphabetic()) .map(|c| c.to_ascii_lowercase()) .collect(); let letters_dedup: std::collections::BTreeSet<_> = letters.iter().collect(); letters.len() == letters_dedup.len(...
true
2fc71d095e024d67b54f9d0f6d33c2f8dffef1d7
Rust
hairyhum/ockam
/implementations/rust/ockam/ockam/src/profile/profile_change_event.rs
UTF-8
1,257
2.78125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{EventIdentifier, ProfileChange, ProfileChangeProof}; pub type Changes = Vec<ProfileChange>; /// [`Profile`]s are modified using change events mechanism. One event may have 1 or more [`ProfileChange`]s /// Proof is used to check whether this event comes from a party authorized to perform such updated /// I...
true
eaf13fc022de8e491368d9fc6c17ae29dd0311bb
Rust
mdinger/rules
/tests/range_set/symmetric_difference.rs
UTF-8
2,132
3.09375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::generate; #[test] fn partial_overlap() { let set = generate(vec![('3', '6')]); let low = generate(vec![('1', '4')]); let high = generate(vec![('5', '9')]); let other_low = generate(vec![('1', '2'), ('5', '6')]); let other_high = generate(vec![('3', '4'), ('7', '9')]); assert_eq!...
true
09596d21f6be2b7ff374d3dc8fb753abb1128e61
Rust
justinliew/leaderboard
/src/listings.rs
UTF-8
2,419
2.875
3
[]
no_license
use fastly::http::StatusCode; use fastly::{Error,Response}; use uuid::Uuid; use std::time::{Duration,SystemTime}; use serde::{Deserialize,Serialize}; use serde::de::DeserializeOwned; use crate::valkeyrie::{get_raw,write_raw}; #[derive(Serialize,Deserialize,Debug,PartialOrd,PartialEq,Clone)] pub struct ListingEntry { ...
true
998bce2685ff322330a444e64e19927b6e767a69
Rust
Michael-F-Bryan/MIPS
/src/bin/mips_emulator.rs
UTF-8
2,215
3.34375
3
[ "MIT" ]
permissive
//! A MIPS emulator written entirely in Rust. #![warn(missing_docs)] #![feature(plugin)] #![plugin(docopt_macros)] extern crate byteorder; extern crate rustc_serialize; extern crate docopt; #[macro_use] extern crate log; extern crate env_logger; extern crate mips; use mips::Processor; use std::fs::File; use std::i...
true
b3c6689f0c7f9ec97e9895f63faac7eacd8a6bef
Rust
jieyouxu/propositional-tableau-solver-rs
/src/tableaux_solver/tableau.rs
UTF-8
4,263
3.90625
4
[]
no_license
//! A `Tableau` is a collection of `Theory`-ies. This corresponds to the entire propositional //! tableau tree, where each `Theory` is a branch (from the root node to each leaf). use std::collections::VecDeque; use crate::formula::PropositionalFormula; use super::Theory; /// A `Tableau` is a collection of `Theory`-...
true
c674910c72dbd97d215c00143ac77229148bd53b
Rust
danieldk/conllx-utils
/src/bin/conllx-projectivize.rs
UTF-8
1,525
2.703125
3
[]
no_license
use std::env::args; use std::io::BufWriter; use conllx::{Deprojectivize, HeadProjectivizer, Projectivize, WriteSentence}; use conllx_utils::or_exit; use getopts::Options; use stdinout::{Input, Output}; fn print_usage(program: &str, opts: Options) { let brief = format!("Usage: {} [options] [INPUT_FILE] [OUTPUT_FIL...
true
6288976cab381b1f0aba8a009c64477d12a87031
Rust
nambrosini/adventofcode
/2020/src/day14.rs
UTF-8
3,777
3.0625
3
[]
no_license
use std::collections::HashMap; #[aoc_generator(day14)] fn generator(input: &str) -> Vec<String> { input.lines().map(|l| l.to_owned()).collect() } fn get_masked_value(mask: &str, value: i64) -> i64 { let mut bits: Vec<i64> = vec![0; mask.len()]; let mut v = value; let mut counter = bits.len() - 1; ...
true
14306a84637b08a08af03a1131c60f6c89ee5b44
Rust
SergeevPavel/adventofcode2019
/src/day5.rs
UTF-8
3,979
3.140625
3
[]
no_license
use std::fs::{read_to_string}; use std::ops::{Rem}; type Program = Vec<i32>; fn read_param(program: &Program, instr: &[i32], arg_num: u8) -> Result<i32, String> { assert!((arg_num as usize) < instr.len()); let op = instr[0]; let mode = (op / i32::pow(10, 2 + (arg_num - 1) as u32)).rem(10); match mode ...
true
f56665e5ea0585e747a2336034ae5669740b22c6
Rust
kirikaza/postgread
/src/msg/body/initial.rs
UTF-8
4,224
3.125
3
[]
no_license
use crate::msg::type_byte::TypeByte; use crate::msg::util::decode::*; use ::std::fmt::{self, Debug, Formatter}; #[derive(Clone, Debug, PartialEq)] pub enum Initial { Cancel(Cancel), TLS, Startup(Startup), } #[derive(Clone, Debug, PartialEq)] pub struct Cancel { pub process_id: u32, pub secret_key:...
true
0272d6ff100ceac00b21bc500d12e10393df945e
Rust
LinAGKar/advent-of-code-2019-rust
/day23a/src/main.rs
UTF-8
1,004
3.078125
3
[ "MIT" ]
permissive
fn main() { let mut input = String::new(); std::io::stdin().read_line(&mut input).unwrap(); let initial_memory: Vec<_> = input.trim().split(',').map(|x| x.parse().unwrap()).collect(); let mut computers: Vec<_> = (0..50).map(|i| { let mut computer = intcode::IntCode::new(initial_memory.clone());...
true
463e9d26b681bc721ad08d788c9d10f4b20e2f3a
Rust
disco0/watchexec
/lib/src/action/workingdata.rs
UTF-8
7,992
3.171875
3
[ "Apache-2.0" ]
permissive
use std::{ fmt, sync::{Arc, Weak}, time::Duration, }; use atomic_take::AtomicTake; use once_cell::sync::OnceCell; use tokio::{ process::Command, sync::{Mutex, OwnedMutexGuard}, }; use crate::{command::Shell, event::Event, filter::Filterer, handler::Handler}; use super::Outcome; /// The configuration of the [ac...
true
0d54c4b2155cbe96bb8f773ec3af615fa38ca256
Rust
bvaisvil/zenith
/src/util.rs
UTF-8
4,664
2.84375
3
[ "MIT" ]
permissive
#![allow(dead_code)] /** * Copyright 2019-2020, Benjamin Vaisvil and the zenith contributors */ use crate::constants::DEFAULT_TICK; use crossterm::{event, event::Event as CEvent, event::KeyCode as Key, event::KeyEvent}; use signal_hook::consts::signal::{SIGABRT, SIGINT, SIGTERM}; use signal_hook::iterator::Signals; u...
true
1e52197ac95019d525d3ef5d7c1b40ad3302569f
Rust
Tubbz-alt/lrad
/lrad-lib/src/config.rs
UTF-8
2,082
2.640625
3
[ "MIT" ]
permissive
use std::net::IpAddr; use std::collections::HashMap; use crate::dns::CloudflareConfig; use crate::ipfs::IpfsApiServerConfig; use std::fs::File; use std::io::{Read, Write}; use std::path::{Path, PathBuf}; use git2::Repository; use crate::error::Result; #[derive(Deserialize, Serialize, Default)] pub struct CliConfig {...
true
dff1ad7e05d52fc0f4504dc4cc9d332782500928
Rust
atsamd-rs/atsamd
/hal/src/sercom/spi/pads_thumbv7em.rs
UTF-8
10,801
2.765625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Define a container for a set of SERCOM pads //! //! See the [spi module](super) documentation for more details on declaring and //! instantiating a [`Pads`] type. use core::marker::PhantomData; use crate::gpio::AnyPin; use crate::sercom::*; use crate::typelevel::{NoneT, Sealed}; use super::{Capability, Duplex, R...
true
c0e8fe0b72cc4d203214b201be08f364a0b3c540
Rust
1r3n33/ucdp
/gateway/src/ucdp/dal/partners.rs
UTF-8
19,050
2.71875
3
[]
no_license
use crate::ucdp::dal::aerospike_dao::{AerospikeDao, AerospikeDaoBuilder, AerospikeDaoError}; use crate::ucdp::dal::ethereum_dao::{EthereumDao, EthereumDaoBuilder, EthereumDaoError}; use crate::ucdp::dal::in_memory_dao::{InMemoryDao, InMemoryDaoBuilder, InMemoryDaoError}; use async_trait::async_trait; use log::trace; us...
true
49cab71cfa2b492e190c9e47d04d93f525bda5f1
Rust
gperetin/clutch
/src/main.rs
UTF-8
2,820
2.875
3
[]
no_license
extern crate chrono; extern crate hipchat_client; extern crate serde; extern crate toml; #[macro_use] extern crate serde_derive; use std::env; use std::fs::File; use std::io::prelude::*; use std::io::{self, Write}; use std::path::Path; use chrono::prelude::*; use hipchat_client::Client as HipchatClient; use hipchat_...
true
6973fa5a2e8ab4638bf3f9205aa94a057b3d59e8
Rust
kedia-project/stellar-base-rs
/src/error.rs
UTF-8
3,763
2.765625
3
[ "Apache-2.0" ]
permissive
//! Error and Result definitions. use xdr_rs_serialize::error::Error as XdrError; pub type Result<T> = std::result::Result<T, Error>; #[derive(thiserror::Error, Debug)] pub enum Error { /// Error that can occur when parsing a key. #[error("invalid str key")] InvalidStrKey, /// Invalid version byte in ...
true
c9fa9f5b013501543aaefdf82413d54e5892f1c1
Rust
damienstanton/learning-rust
/operator_overloading/src/main.rs
UTF-8
392
3.265625
3
[ "MIT" ]
permissive
use std::ops; struct Foo; struct Bar; #[derive(Debug, PartialEq)] struct FooBar; impl ops::Add<Bar> for Foo { type Output = FooBar; fn add(self, _rhs: Bar) -> FooBar { FooBar } } fn main() { println!("Foo + Bar = {:?}", Foo + Bar); } #[cfg(test)] mod tests { use super::*; #[test] ...
true
220161e79c9baab23ebd3ae72e5999de96b216f1
Rust
icewind1991/steam-vent
/src/serverlist.rs
UTF-8
3,051
2.703125
3
[]
no_license
use reqwest::{Client, Error}; use serde::Deserialize; use std::net::SocketAddr; use thiserror::Error; use tracing::debug; #[derive(Debug, Error)] pub enum ServerDiscoveryError { #[error("Failed send discovery request: {0:#}")] Network(reqwest::Error), #[error("steam returned an empty server list")] NoS...
true