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
dcf1702fc988149b489a839f1618420307874633
Rust
harpsword/tex-rs
/src/tex_the_program/section_0545.rs
UTF-8
4,618
3.03125
3
[ "Apache-2.0", "MIT" ]
permissive
//! @ The |lig_kern| array contains instructions in a simple programming language //! that explains what to do for special letter pairs. Each word in this array is a //! |@!lig_kern_command| of four bytes. //! //! \yskip\hang first byte: |skip_byte|, indicates that this is the final program //! step if the byte is 12...
true
7dfb68721d9984ea20b6172e1da7835f267047f6
Rust
avowkind/prisoners_dilemma
/src/lib1.rs
UTF-8
3,426
3.625
4
[]
no_license
type Choice = bool; pub struct Player { pub strat: Box<Strategy> } impl Player { fn new<T: Strategy>(s: T) -> Self { Player { strat: Box::new(s) } } } pub trait Strategy { // Static method signature; `Self` refers to the implementor type. fn new() -> Self; /// return the strategy's ne...
true
ef0490cb7fd6dbd85d1c41438b245b4d5ea40d3f
Rust
EmbarkStudios/sccache
/src/cache/gha.rs
UTF-8
2,691
2.53125
3
[ "Apache-2.0" ]
permissive
// Copyright 2022 Bitski Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
true
c6078ba4d3d7ac8ea002a32441ece04392872cf3
Rust
EmbarkStudios/raw-window-handle
/src/ios.rs
UTF-8
945
2.6875
3
[ "MIT" ]
permissive
use core::ptr; use libc::c_void; /// Raw window handle for iOS. /// /// ## Construction /// ``` /// # use raw_window_handle::ios::IOSHandle; /// let handle = IOSHandle { /// /* fields */ /// ..IOSHandle::empty() /// }; /// ``` #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct IOSHandle { pub ui_windo...
true
9ee6787445145c496ab719232ecb368d09fb16fb
Rust
colelawrence/enum-ts
/src/codegen/apply_match.rs
UTF-8
3,259
2.78125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::*; pub(super) fn generate( TSEnum { generics, name, variants, .. }: &TSEnum, src: &mut Source, ) { // ex "" or "<Ok, Err>" let braced_gen = braced_generic(&generics, None); // ex "<R>" or "<Ok, Err, R>" let braced_gen_r = braced_generic(&generics, ...
true
477f1c80fa11d69b72b16b1ada88e2849e99157a
Rust
ufabc-bcc/RisosFS
/src/main.rs
UTF-8
14,233
2.78125
3
[]
no_license
extern crate fuse; #[macro_use] extern crate serde_big_array; mod persistence; mod serialization; use fuse::{Filesystem, Request, ReplyCreate, ReplyEmpty, ReplyAttr, ReplyEntry, ReplyOpen, ReplyData, ReplyDirectory, ReplyWrite, FileType, FileAttr}; // https://www.gnu.org/software/libc/manual/html_node/Error-Codes.html...
true
292d76310602228a6856e54783f56e77725e1c1c
Rust
akuczala/4d-game
/src/vector/vec3.rs
UTF-8
3,985
3.09375
3
[]
no_license
use serde::{Deserialize, Serialize}; use std::fmt; use std::ops::{Add, Div, Index, IndexMut, Mul, Neg, Sub}; use std::slice::Iter; use super::Mat3; use crate::vector::{Field, Vec2, VecIndex, VectorTrait, FROM_ITER_ERROR_MESSAGE}; #[derive(Copy, Clone, Debug, Serialize, Deserialize)] pub struct Vec3 { arr: [Field;...
true
4dbe4d8b96629d2656fcc688d07ed353454709fd
Rust
koute/pinky
/nes/src/mapper_unrom512.rs
UTF-8
1,690
2.609375
3
[ "Apache-2.0", "MIT" ]
permissive
use emumisc::BitExtra; use rom::{NesRom, LoadError}; use generic_mapper::BankedGenericMapper; use mappers::Mapper; pub struct MapperUNROM512 { inner: BankedGenericMapper } impl MapperUNROM512 { pub fn from_rom( rom: NesRom ) -> Result< Self, LoadError > { let mut mapper = MapperUNROM512 { ...
true
b492c8b138673dbae4d0a1878d3642702ec4b07d
Rust
nklayman/tauri
/tauri/src/webview.rs
UTF-8
5,172
3.078125
3
[ "CC-BY-NC-ND-4.0", "MIT", "Apache-2.0" ]
permissive
pub(crate) mod wry; pub use crate::{api::config::WindowConfig, plugin::PluginStore}; /// An event to be posted to the webview event loop. pub enum Event { /// Run the given closure. Run(crate::SyncTask), } pub enum Message { EvalScript(String), SetWindowTitle(String), Event(Event), } /// The window builde...
true
419dbe2d7dcee385749243fcb70a50a3f342d212
Rust
knokko/bit-encoding-rs
/src/decoding/errors.rs
UTF-8
5,247
3.703125
4
[]
no_license
use crate::*; use std::error::Error; use std::fmt::Display; /// Represents an error that occurred while trying to decode the data read /// from a `BitSource`. /// /// Most of the errors in this enum indicate programming errors or a corrupted /// `BitSource`, except for the `Reading` error, which indicates that an ///...
true
469285cf755f5cfd8bdf29f2b2e50005ce67eee7
Rust
sentientforest/mirrim
/src/main.rs
UTF-8
2,047
3.109375
3
[ "MIT", "Apache-2.0" ]
permissive
extern crate image; use std::{ io::{self, Write}, }; use image::{GenericImageView, imageops}; use structopt::StructOpt; #[derive(StructOpt, Debug)] /// Given a path to an image, generates its mirror and combine the two into one output image struct Cli { #[structopt(short = "i", long = "input")] /// inpu...
true
ad6e6f1bce1afca951e70f840a0bfe6f1b5080bf
Rust
cjpearce/birb
/src/scene.rs
UTF-8
3,265
3.078125
3
[]
no_license
use crate::camera::Camera; use crate::material::Material; use crate::ray::Ray; use crate::sphere::Sphere; use nalgebra::{Point3, Vector3}; pub struct Intersection<'a> { pub hit: Point3<f64>, pub normal: Vector3<f64>, pub material: &'a Material, pub distance: f64, } struct Hit<'a> { object: &'a Sph...
true
0b8759a282fd7b816d85379931e4bdf6c610dc92
Rust
vhrdtech/vhrdcan
/src/frame.rs
UTF-8
2,415
3.1875
3
[]
no_license
use crate::id::FrameId; use core::fmt; use core::cmp::Ordering; #[derive(Eq, PartialEq)] pub struct FrameRef<'a> { pub id: FrameId, pub data: &'a [u8] } impl<'a> fmt::Debug for FrameRef<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if !f.sign_minus() { write!(f, "FrameRef...
true
cf4f88a796e59e75a9c258213d3c24f01c198e44
Rust
umgefahren/rust-image-comparer
/image_comparison/src/hash_methods.rs
UTF-8
563
2.625
3
[ "CC0-1.0" ]
permissive
use ndarray; use ndarray::Axis; pub fn calc(block: &ndarray::Array<u8, ndarray::Ix3>) -> [f64; 3] { let mut values: [u32; 3] = [0, 0, 0]; let mut counter = 0.0; for line in block.axis_iter(Axis(0)) { for pixel in line.axis_iter(Axis(1)) { values[0] += pixel[0] as u32; values...
true
ffb67829da5caab4295b73bdd9186cb51183400a
Rust
dropbox/rust-brotli
/src/enc/entropy_encode.rs
UTF-8
21,932
2.65625
3
[ "BSD-3-Clause" ]
permissive
/* Copyright 2010 Google Inc. All Rights Reserved. Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Entropy encoding (Huffman) utilities. */ #![allow(dead_code)] use super::util::brotli_max_uint32_t; #[derive(Clone, Copy)] pub struct HuffmanTree {...
true
e24370adfa8b6ca080af828ef4498e337fac3843
Rust
sudharsh/vector
/lib/file-source/src/file_server.rs
UTF-8
11,457
2.859375
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::file_watcher::FileWatcher; use bytes::Bytes; use futures::{stream, Future, Sink, Stream}; use glob::{glob, Pattern}; use std::collections::HashMap; use std::fs; use std::io::{Read, Seek, SeekFrom}; use std::path::PathBuf; use std::sync::mpsc::RecvTimeoutError; use std::time; use tracing::field; /// `FileSer...
true
e7ff5065cd0c18a1ca8f9e5e15fa245c6d9c2a38
Rust
sonicXconst1/open_midas
/src/calculators/amount_calculator.rs
UTF-8
6,073
3.171875
3
[]
no_license
use agnostic::order::Order; #[derive(Clone, Copy, Debug)] pub struct AmountCalculator { pub min_amount_threshold: f64, pub fee: f64, } #[derive(PartialEq, Debug)] pub enum Amount { PriceBased(f64), BalanceBased(f64), } impl Amount { pub fn value(&self) -> f64 { match self { Am...
true
39da5c69d149556daa8cc766eff4d3994cd040ae
Rust
muzudho/rust_kifuwarabe_igo2018
/src/position.rs
UTF-8
2,370
3.8125
4
[ "MIT" ]
permissive
/// 局面☆(^▽^) use board::Board; use ren_db::ren_database::*; /// ゲーム中にインスタンスが1つだけ存在する☆(^~^) グローバル変数みたいな便利さで使っている☆(^~^) pub struct Position { /// 枠付きの盤面。 board: Board, /// コウの番地。 pub ko: i16, /// 手番。1:黒、2:白。 pub turn: i8, /// 連のデータベース☆(^~^) ren_database: RenDatabase, } impl Positi...
true
85dc21cea58edfd30f432f82ceed3ca995ac2dfe
Rust
IamfromSpace/cube
/src/cubie_orientations_and_ud_slice.rs
UTF-8
13,764
2.984375
3
[]
no_license
/* Is a coordinate that maps just the corner and edge orientations * and the position of the UD slice (RF, BR, BL, and LF edges). * This is notably NOT a permutation and NOT invertable because * it doesn't hold enough information about the other piece * positions. * * Corner orientation support mirroring, so they...
true
7aea03a892c360cd8515252057d8fd084deec8cd
Rust
RustWorks/Draw2D_GLFW_Vulkan_FFI
/src/graphics/layer/layer_stack.rs
UTF-8
2,435
3.234375
3
[ "MIT" ]
permissive
use std::collections::HashMap; use crate::graphics::vertex::Vertex2d; use super::{Layer, LayerHandle, LayerStack}; impl LayerStack { /// Create a new stack with zero visible layers. pub fn new() -> Self { Self { layers: HashMap::new(), render_order: vec![], } } ...
true
0c159bd68c835918fa49d056b3b871ead024bcce
Rust
drmason13/pong-amethyst
/src/systems/frozen.rs
UTF-8
1,451
3.0625
3
[]
no_license
use crate::pong::Frozen; use amethyst::{ core::timing::Time, ecs::prelude::{Join, Read, System, WriteStorage, Entities}, ecs, }; /// Freezes entities (just balls currently, in practice). Frozen entities don't move but retain their velocity /// This is achieved by having the other movement systems (just mo...
true
1d12b33bf34932af989d2e4501ea85525f8fd467
Rust
spencerkohan/dirsync
/src/remote.rs
UTF-8
3,112
2.796875
3
[]
no_license
extern crate ssh2; use std::io::prelude::*; use std::net::TcpStream; use std::path::PathBuf; use ssh2::Session; use ssh2::ExtendedData; use crate::config::SessionConfig; pub struct Remote { session: ssh2::Session, root: PathBuf } impl Remote { // todo: this shouold take configuration arguemnts pub ...
true
706bf6effd66ae7c6b451ee40d36ecaa29b7346b
Rust
InputUsername/adventofcode
/2019/day03/src/main.rs
UTF-8
3,632
3.71875
4
[]
no_license
use std::fs; struct Segment { x1: i32, y1: i32, x2: i32, y2: i32, steps: i32, } struct Intersection { x: i32, y: i32, steps: i32, } impl Segment { /// Normalize a segment so it always points right or down. fn normalize(&self) -> Segment { Segment { x1: i32:...
true
da51cf81090c84918bc5d69b7c9424014585ce66
Rust
darthsteedious/lexer
/src/main.rs
UTF-8
298
2.828125
3
[]
no_license
extern crate tokenizer; use tokenizer::lexer; fn main() { let s = "\tif (i == 1)\n\t\tx = foo();\n\telse if (i == 5)\n\t\tx = i;"; let res = lexer::tokenize(s); //let res = lexer::tokenize("\tif (i == j)\n\t\tz = 1234;\n\telse\n\t\tz = 145;"); println!("tokenize - {:?}", res); }
true
b766999f1090a9298cbdd61125f8f4e5a43ee871
Rust
flier/tokio-kafka
/src/producer/record.rs
UTF-8
3,763
3.171875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::hash::Hash; use client::{PartitionRecord, TopicRecord}; use protocol::{Offset, PartitionId, Timestamp}; /// A key/value pair to be sent to Kafka. /// /// This consists of a topic name to which the record is being sent, /// an optional partition number, and an optional key and value. #[derive(Clone, Debug)] p...
true
bd19931dfc69f26eefc98cc4dad90ca9f9c0cea5
Rust
castlez/RustPractice
/Rust_Practice/projecteuler/sum_square_difference_p6/ssdp6/src/main.rs
UTF-8
548
3.203125
3
[]
no_license
//this program solve project euler question #6 //what is the different between the sum of squares up to 100 //and the sqaure of the sum of numbers up to 100 //TODO: use lambdas! use std::io::{self,Write}; fn main() { let mut r = 0..101; let mut sumos = 0; let mut squaos= 0; for x in r { //TODO...
true
da15155f4880403f965c59d10917db06c60958fc
Rust
tsukuyomi-rs/tsukuyomi-router
/src/error.rs
UTF-8
921
2.8125
3
[ "Apache-2.0", "MIT" ]
permissive
#![allow(missing_docs)] use std::{ borrow::Cow, // error, fmt, }; pub type Result<T = ()> = std::result::Result<T, Error>; #[derive(Debug)] pub struct Error(ErrorKind); #[derive(Debug)] enum ErrorKind { Msg(Cow<'static, str>), } impl From<&'static str> for Error { fn from(msg: &'static str) -> ...
true
060115b6fb6bb2f113a53a31b9f72a36afa18a51
Rust
nanoqsh/gni
/src/render/mod.rs
UTF-8
2,859
2.75
3
[]
no_license
mod draw_buffer; mod images; mod palette; mod shader_program; use crate::Window; use draw_buffer::DrawBuffer; use glow::{Context, HasContext}; use gni::Img; use images::Images; use palette::Palette; use shader_program::Program; use std::rc::Rc; pub use draw_buffer::Vertex; pub struct Render { context: Rc<Context...
true
2165a11ee26e2cb20aeb32cecdbd1d6444578acc
Rust
iCodeIN/zvm
/src/class_file/unvalidated/constant.rs
UTF-8
7,015
2.875
3
[ "0BSD" ]
permissive
use crate::class_file::unvalidated::ClassFile; use crate::class_file::unvalidated::MethodHandleBehavior; use std::fmt; #[derive(Debug)] pub enum Constant { Utf8(Vec<u8>), Integer(u32), Float(f32), Long(u64), Double(f64), Class(ConstantIdx), String(ConstantIdx), Fieldref(ConstantIdx, Co...
true
640b9477025ae7287feb1bf8f5f8a2bdfe7937a1
Rust
LinAGKar/advent-of-code-2016-rust
/day22a/src/main.rs
UTF-8
1,180
2.9375
3
[ "MIT" ]
permissive
use std::io::Read; fn main() { let mut input = String::new(); std::io::stdin().read_to_string(&mut input).unwrap(); let (mut by_used, mut by_avail): (Vec<_>, Vec<_>) = input.lines().skip(2).map(|line| { let mut words = line.split_whitespace(); let used = words.nth(2).unwrap().trim_matches(...
true
69da0839a9888733cc3c9001c14eb0f1756f7cad
Rust
zatchl/kawaiifi
/src/ies/measurement_pilot_transmission.rs
UTF-8
2,657
3.125
3
[ "MIT", "Apache-2.0" ]
permissive
use super::{Field, IeError, InformationElement}; use byteorder::ReadBytesExt; use std::io::{Cursor, Read}; #[derive(Debug, Clone, PartialEq, Eq)] pub struct MeasurementPilotTransmission { bytes: Vec<u8>, } impl MeasurementPilotTransmission { pub const MIN_LENGTH: usize = 1; pub fn new(bytes: Vec<u8>) -> ...
true
cfe052c55da8c5c2f8ff90c3e9c37f281c20be10
Rust
corderophi678/exercism-rust
/macros/main.rs
UTF-8
728
3.046875
3
[]
no_license
#![feature(trace_macros)] #![allow(unused_variables)] use std::collections::HashMap; #[macro_export] macro_rules! hashmap { () => { HashMap::new() }; ( $( $key:expr => $val:expr ), * ) => {{ hashmap!($($key => $val, )* ) }}; ( $( $key:tt => $value:tt $(,)* ), *) => { { let mut cc...
true
c1af53f19f541721b04ae29747bc07f6c33fa2ff
Rust
NiklasJonsson/rusterizer
/src/rasterizer/clipping.rs
UTF-8
14,803
3.046875
3
[ "MIT" ]
permissive
use crate::graphics_primitives::{Triangle, VertexAttribute}; use crate::math::point::*; use crate::math::vector::*; use crate::math::ClipSpace; #[derive(Debug, Clone)] pub enum ClipResult { Outside, Inside, Clipped(Vec<Triangle<ClipSpace>>), } #[derive(PartialEq, Debug, Copy, Clone)] enum Intersection { ...
true
c3292d811adddf823f4203706f8961c8aa63220b
Rust
langestefan/atsamd
/pac/atsamd51j19a/src/mclk/hsdiv.rs
UTF-8
1,397
2.84375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u8, } impl super::HSDIV { #[doc = r" Reads the contents of the register"] #[inline] pub fn read(&self) -> R { R { bits: self.register.get(), } } } #[doc = "Possible values of the field `DIV`"] #[derive(Clone, ...
true
29afd24a7a56905ed68e22640d3b8431b0fd6eec
Rust
umgefahren/rust-image-comparer
/image_comparison/src/loader.rs
UTF-8
1,681
3
3
[ "CC0-1.0" ]
permissive
use ndarray; use ndarray::Axis; use rayon::prelude::*; use std::fs::read_dir; use std::path::PathBuf; pub struct Image { image_data: ndarray::Array3<u8>, blocks: Vec<ndarray::Array<u8, ndarray::Ix3>>, pub hash_map: Vec<[f64; 3]>, pub path: PathBuf, } impl Image { pub fn calc_blocks(&mut self, b_si...
true
a9af230357bbf50772a16f12cd6f685da490831f
Rust
JohnDoneth/gfx
/src/hal/src/pso/descriptor.rs
UTF-8
7,246
3.28125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Descriptor sets and layouts. //! A descriptor is an object that describes the connection between a resource, such as //! an `Image` or `Buffer`, and a variable in a shader. Descriptors are organized into //! sets, each of which contains multiple descriptors that are bound and unbound to //! shaders as a single unit...
true
f49c52f85a4682540713e0015e311eb337d5b74e
Rust
renatocassino/2048-rust
/src/lib.rs
UTF-8
3,144
3.15625
3
[]
no_license
mod game; #[test] fn slide_array() { let mut game: [i32; 4] = [2,2,2,2]; game::slide_array(&mut game); assert!(game[0] == 4); assert!(game[1] == 4); assert!(game[2] == 0); assert!(game[3] == 0); } #[test] fn test_get_empty_blocks_list() { let mut game: [[i32; 4]; 4] = [ [2,2,2,2],...
true
f8bc3669c5ec9188d1a705aa1b0797883c4571e7
Rust
nicholas-miklaucic/scarlet
/src/colors/hslcolor.rs
UTF-8
10,248
3.671875
4
[ "Apache-2.0" ]
permissive
//! This file implements what I refer to as HSL but which would precisely be called sHSL: a simple //! transformation of sRGB that creates a cylindrical space. HSL has the same problems with //! perceptual uniformity and general unsuitability for exact psychophysically-accurate //! representation as color as sRGB does,...
true
e2356369de690631759f6b6255f8c623a007f512
Rust
fairingrey/async-compression-rs
/src/stream/mod.rs
UTF-8
1,282
2.8125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Types which operate over [`Stream`](futures::stream::Stream)`<Item = //! `[`io::Result`](std::io::Result)`<`[`Bytes`](bytes::Bytes)`>>` streams, both encoders and //! decoders for various formats. //! //! The `Stream` is treated as a single byte-stream to be compressed/decompressed, each item is a //! chunk of data...
true
b1ea7291d29802d0f0fd852cae548e2358401ba8
Rust
jswrenn/nalgebra
/src/geometry/unit_complex_conversion.rs
UTF-8
4,720
2.703125
3
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
use num::Zero; use num_complex::Complex; use alga::general::{Real, SubsetOf, SupersetOf}; use alga::linear::Rotation as AlgaRotation; use base::dimension::U2; use base::{Matrix2, Matrix3}; use geometry::{ Isometry, Point2, Rotation2, Similarity, SuperTCategoryOf, TAffine, Transform, Translation, UnitComplex }...
true
abd2cf5cc8fbc4e1b451d97aa83e0b78d10bb68e
Rust
j-rock/fortress
/fortress/src/lib/dimensions/lr_direction.rs
UTF-8
587
3.609375
4
[ "MIT" ]
permissive
use crate::math::RandGen; #[derive(Copy, Clone)] pub enum LrDirection { Left, Right } impl LrDirection { pub fn random(rng: &mut RandGen) -> Self { if rng.flip_coin(0.5) { Self::Left } else { Self::Right } } pub fn is_left(self) -> bool { match ...
true
a226fae80414c9aed9b441b6d165fd770d6aa72e
Rust
hyeonjang/toy-raytracer
/rxmath/src/lib.rs
UTF-8
3,718
2.78125
3
[]
no_license
//********************************************************* // Copyright 2020-2020 Hyeonjang An // // 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/LI...
true
cd4ffed1e5d1c641e97db56cb56fdd7656493776
Rust
mbillingr/miniKANREN
/rust-canonical/src/goals/hashmap.rs
UTF-8
2,216
3
3
[ "MIT" ]
permissive
use crate::core::structure::Structure; use crate::{Substitution, Value, Var}; use std::any::Any; use std::collections::HashMap; use std::fmt::Debug; use std::hash::Hash; use std::sync::Arc; #[macro_export] macro_rules! hashmap { () => { std::collections::HashMap::new() }; } impl<T: 'static + Debug + E...
true
05d634988a646f6db6847d1859fd32afb3ee9dcf
Rust
wezm/cc2650
/src/aux_adi4/mux0.rs
UTF-8
7,469
2.625
3
[ "Apache-2.0", "MIT" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u8, } #[doc = r" Value to write to the register"] pub struct W { bits: u8, } impl super::MUX0 { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut W)...
true
462bddfad6aa6c029fafdd3a03b1da18faf57ed5
Rust
truelossless/crocolang
/src/ast/node/not_node.rs
UTF-8
712
2.875
3
[ "MIT" ]
permissive
use crate::ast::{AstNode, AstNodeType, BackendNode}; use crate::token::CodePos; #[derive(Clone)] /// a node used to invert a boolean value pub struct NotNode { pub bottom: Option<Box<dyn BackendNode>>, pub code_pos: CodePos, } impl NotNode { pub fn new(code_pos: CodePos) -> Self { NotNode { ...
true
1e641a13eb8b0765be5d3b789dd3e6b203e9c9c0
Rust
marte/baraha
/src/client.rs
UTF-8
12,770
2.90625
3
[]
no_license
use std::thread; use std::sync::{Arc, Mutex, Condvar}; use std::io; use std::io::prelude::*; use std::net::TcpStream; use std::str::FromStr; use bots::player::{self, Status, ServerInput, UserInput, ServerOutput}; use game; use utils; pub fn play(host: String) { let (player, channel) = run_player(host); intera...
true
9d7a6615d1908945ac1bc79c893552f700cb2ab6
Rust
bsumirak/AoC
/AoC2021/src/day12.rs
UTF-8
2,260
3.21875
3
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader}; struct Cave { name: String, conn: Vec::<usize>, visited: u8 } impl Cave { pub fn new(name: String) -> Self { Self { name, conn: Vec::new(), visited: 0 } } pub fn is_small(&self) -> bool { let firstChar = self.name.chars().nth(0).un...
true
9694a025f66a86c55b8e94a53a9a1171245a3766
Rust
noirotm/fishr
/src/stack.rs
UTF-8
11,990
3.46875
3
[ "MIT" ]
permissive
#[derive(PartialEq, Debug)] pub enum Error { StackUnderflow, } pub struct Stack<T> { pub values: Vec<T>, pub register: Option<T>, } impl<T> Default for Stack<T> where T: Clone, { fn default() -> Self { Self::new() } } impl<T> Stack<T> where T: Clone, { pub fn new() -> Self { ...
true
b92c20cbe0df3d476c94a723755fc417e5e194ce
Rust
chloekek/neptune
/np_unix/src/memfd.rs
UTF-8
956
2.59375
3
[]
no_license
use std::ffi::CStr; use std::io::Error; use std::io::Result; use std::os::raw::c_char; use std::os::raw::c_int; use std::os::raw::c_uint; use std::os::unix::io::AsRawFd; use std::os::unix::io::RawFd; // memfd_create is unfortunately not yet in the libc crate. extern "C" { fn memfd_create(name: *const c_char, flags...
true
919b077fd2bc56c4fdb23ec6626e5a04da5bf004
Rust
bluecmd/aoc-2019-rust
/day2-second/src/main.rs
UTF-8
3,420
3.765625
4
[]
no_license
use std::io; #[derive(Debug, PartialEq, Eq)] enum Opcode { Add(usize, usize, usize), Multiply(usize, usize, usize), Exit(), } #[derive(Debug, PartialEq, Eq, Clone)] struct Program { data: Vec<usize>, ip: usize, } impl Program { fn from(data: &[usize]) -> Program { Program { ...
true
aa2b4e521b0f57fb4bccddfd4db217aa46370319
Rust
Phantomical/hamerkop
/metrics/src/lib.rs
UTF-8
2,793
2.875
3
[ "MIT" ]
permissive
//! mod macros; mod counter; mod ddsketch; mod gauge; mod lazy_cell; use std::{any::Any, fmt, ops::Deref}; pub use crate::counter::Counter; pub use crate::ddsketch::DDSketch; pub use crate::gauge::Gauge; pub use crate::lazy_cell::LazyCell; #[doc(hidden)] pub mod export { pub use super::{Metric, MetricEntry}; ...
true
3cbd16c0af702068e0b60556e6176e4a005edef6
Rust
Thermatix/cyber_rogue
/src/sys/element/map_list.rs
UTF-8
1,263
3.53125
4
[]
no_license
//! A representing a list of maps use super::{HashMap, Map, MapList}; use crate::sys::utils::FindBy; impl MapList { /// Returns a new map list pub fn new() -> Self { Self { maps: HashMap::new(), } } /// Inserts a new map /// Accepts the following: /// `map: Map` ...
true
49e9fd014bb2aa2ba1a129a7742edba7ce8d523a
Rust
wking/cincinnati
/vendor/regex-automata/src/byteorder.rs
UTF-8
2,104
3.140625
3
[ "Apache-2.0", "Unlicense", "MIT" ]
permissive
use core::convert::TryInto; pub trait ByteOrder { fn read_u16(buf: &[u8]) -> u16; fn read_u32(buf: &[u8]) -> u32; fn read_u64(buf: &[u8]) -> u64; fn read_uint(buf: &[u8], nbytes: usize) -> u64; fn write_u16(buf: &mut [u8], n: u16); fn write_u32(buf: &mut [u8], n: u32); fn write_u64(buf: &mu...
true
6b9e14f782a1ec7915b6d7f094063b39d722b1eb
Rust
brian-stinar/mdck
/src/error.rs
UTF-8
1,657
2.96875
3
[ "Unlicense", "LicenseRef-scancode-public-domain" ]
permissive
use std::{borrow::Cow, error::Error, fmt}; use structopt::clap; #[derive(Debug)] pub enum MdckError { Internal(String), Io(std::io::Error), FromUtf(std::string::FromUtf8Error), Clap(clap::Error), WalkDir(walkdir::Error), } impl fmt::Display for MdckError { fn fmt(&self, f: &mut fmt::Formatter)...
true
ccd5165c7866814f2186a395ccbc05f83a59c556
Rust
JordiPolo/openapi
/src/lib.rs
UTF-8
1,117
2.75
3
[ "MIT" ]
permissive
#[macro_use] extern crate error_chain; #[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; extern crate serde_yaml; use std::fs; use std::io::Read; use std::path::Path; mod schema; pub use schema::Spec; pub mod errors { error_chain!{ foreign_links { Io(::std::...
true
99e9b28b8c13fd618ba51ba89d7fcc6c1d20969a
Rust
brandonphelps/address_space
/src/address_space.rs
UTF-8
14,388
3.453125
3
[]
no_license
#![allow(dead_code)] #[derive(Debug, PartialEq, Eq)] pub struct Section { start_addr: u32, data: Vec<u8> } impl Section { pub fn new(start_addr: u32, data: Vec<u8>) -> Self { Self { start_addr: start_addr, data: data, } } /// @brief addr is aboslute, and offset will be applied intern...
true
4aee6913c7d7461f3758daf2b158b8d77ac9bc4a
Rust
IThawk/rust-project
/rust-master/src/librustc_traits/generic_types.rs
UTF-8
2,305
2.65625
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
//! Utilities for creating generic types with bound vars in place of parameter values. use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::subst::{GenericArg, SubstsRef, InternalSubsts}; use rustc::hir; use rustc::hir::def_id::DefId; use rustc_target::spec::abi; crate fn bound(tcx: TyCtxt<'tcx>, index: u32) -> Ty<'tcx>...
true
3d26b0e655ff2cd0dafeea87d43bdaf89dc0d2c3
Rust
nikitavbv/Assignments
/src/main/rust/algorithms/game/src/minimax.rs
UTF-8
1,876
2.828125
3
[ "MIT" ]
permissive
use crate::state::{GameState, derive_states, GameField, Position, get_snake_head}; use crate::eval::eval_state; use std::cmp::{max, min}; use std::time::Instant; pub fn minimax(field: &GameField, state: &GameState, depth: u32, alpha_initial: i32, beta_initial: i32, ai_turn: bool, started_at: Instant, ma...
true
23a05511b848808f9fb752ba772ade4d989dbd51
Rust
dflemstr/bmp280
/src/reg.rs
UTF-8
1,340
3.09375
3
[]
no_license
//! Definitions for BMP280 I2C registers. /// I2C registers present in a BMP280. #[repr(u8)] #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] pub enum Register { /// Digital temperature coefficient 1. DigT1 = 0x88, /// Digital temperature coefficient 1. DigT2 = 0x8a, /// Digital temper...
true
94324414e5581d02428da69415b98e141fbf198f
Rust
tempbottle/rustful
/src/context.rs
UTF-8
15,584
4
4
[ "MIT" ]
permissive
//!Handler context and request body reading extensions. //! //!#Context //! //!The [`Context`][context] contains all the input data for the request //!handlers, as well as some utilities. This is where request data, like //!headers, client address and the request body can be retrieved from and it //!can safely be picke...
true
1dd1f7d5c0dc9bb4c7daeb496939d05994d47a02
Rust
linhbngo/Reference-Solutions
/ps2/gash-starting-code.rs
UTF-8
2,732
2.96875
3
[ "MIT" ]
permissive
// // gash.rs // // Starting code for PS2 // Running on Rust 0.9 // // University of Virginia - cs4414 Spring 2014 // Weilin Xu, David Evans // Version 0.4 // extern mod extra; use std::{io, run, os}; use std::io::buffered::BufferedReader; use std::io::stdin; use extra::getopts; struct Shell { cmd_prompt: ~str, ...
true
92febdb43a88bff2f846f66e763083973f314e83
Rust
keithnoguchi/books-rs
/async-std/src/server/write.rs
UTF-8
1,691
2.90625
3
[]
no_license
//! [`Writer`] type //! //! [`writer`]: struct.Writer.html use async_std::net::TcpStream; use futures::future::FutureExt; use futures::io::AsyncWriteExt; use futures::select; use futures::stream::StreamExt; use std::sync::Arc; use super::Cancel; use super::Receiver; use super::Result; /// `Writer` waits for a message...
true
7cd3e2bfc0f93354ccecaa71f328ee8aead23321
Rust
Uniformbuffer3/gfx_external_memory_test
/src/common.rs
UTF-8
2,536
2.796875
3
[]
no_license
use gfx_hal as hal; use hal::device::Device; pub enum Resource<T: gfx_hal::Backend> { Buffer(T::Buffer), Image(T::Image) } impl<T: gfx_hal::Backend> Resource<T> { pub fn image(&self)->&T::Image { match self { Self::Image(image)=>image, _=>panic!() } } pub fn ...
true
c09b590401d444d63e0040ef0c56917ff1b681fd
Rust
jmstaley/gmail_check
/src/main.rs
UTF-8
584
2.609375
3
[]
no_license
extern crate reqwest; extern crate feed_rs; use std::env; use reqwest::Error; use feed_rs::parser; fn main() -> Result<(), Error> { let url = "https://mail.google.com/mail/feed/atom"; let args: Vec<String> = env::args().collect(); let username = &args[1]; let password = &args[2]; let response = r...
true
76e9006aedc0e325fa056a6f59e0b98c6749d4f7
Rust
jakyle/rust-algos
/src/fib.rs
UTF-8
623
3.6875
4
[ "MIT" ]
permissive
pub fn fib(n: i32) -> i32 { const SQRT5: f64 = 2.23606797749979; const PHI: f64 = (1.0 + SQRT5) / 2.0; const PSI: f64 = 1.0 - PHI; ((PHI.powf(n as f64) - PSI.powf(n as f64)) / SQRT5) as i32 } #[cfg(test)] mod fib_tests { use super::*; #[test] fn fib_test_one() { // arrange ...
true
678aae987f03291dae785575e8422862bc6b00d7
Rust
klbarrus/adventofcode2017
/aoc-2017-08/src/main.rs
UTF-8
2,663
2.96875
3
[]
no_license
// Advent of Code 2017, Day 8 use aoclib; use std::collections::HashMap; use std::io; fn lookup_reg(table: &HashMap<String, isize>, reg: &str) -> isize { match table.get(reg) { Some(val) => *val, None => 0, } } fn logic_op(val1: isize, op: &str, val2: isize) -> bool { match op { "...
true
32f97c90e7a48a56b21bbb2f42d1523d62a89fb4
Rust
EMO-VRP-Challenge/vrp
/vrp-core/tests/helpers/algorithms/nsga2/objective.rs
UTF-8
2,492
2.78125
3
[ "Apache-2.0" ]
permissive
use super::Tuple; use crate::algorithms::nsga2::{MultiObjective, Objective}; use std::cmp::Ordering; pub struct Objective1; pub struct Objective2; pub struct Objective3; impl Objective for Objective1 { type Solution = Tuple; fn total_order(&self, a: &Self::Solution, b: &Self::Solution) -> Ordering { ...
true
84b48988775c0ab0773e39c90a15f1824a2ad9a7
Rust
gnoliyil/fuchsia
/src/connectivity/wlan/lib/common/rust/src/organization.rs
UTF-8
835
2.546875
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2019 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. use zerocopy::{AsBytes, FromBytes, Unaligned}; // IEEE Std 802.11-2016, 9.4.1.32 // 24-bit organization unique identifier #[repr(C, packed)] #[derive( ...
true
710582a7d9ac48e69ddce023826c00eb8edc2eb7
Rust
trezm/templatify
/src/lib.rs
UTF-8
1,460
3.125
3
[]
no_license
// For tests extern crate bytes; #[macro_export] macro_rules! templatify { ( $head_template:expr $(;$key:expr; $template:expr)* ) => { { let mut total_length = 0; total_length += $head_template.len(); $( total_length = total_length + $key.len() + $template.len(); )* let mu...
true
387752a3a6154178428c192169cd3bdeae06282c
Rust
dimforge/nalgebra
/examples/transform_vector_point.rs
UTF-8
712
3
3
[ "Apache-2.0" ]
permissive
#[macro_use] extern crate approx; extern crate nalgebra as na; use na::{Isometry2, Point2, Vector2}; use std::f32; fn main() { let t = Isometry2::new(Vector2::new(1.0, 1.0), f32::consts::PI); let p = Point2::new(1.0, 0.0); // Will be affected by te rotation and the translation. let v = Vector2::x(); // Wi...
true
6742f145bd7a4b0b58c496d17af7caea7ebd0c0c
Rust
emiddleton/ilo
/ilo_ribcl/src/types.rs
UTF-8
25,096
2.578125
3
[ "MIT" ]
permissive
use crate::ribcl_into::RibclInto; use chrono::naive::{NaiveDate, NaiveDateTime}; use ilo_ribcl_derive::BuilderParse; use inflector::Inflector; use itertools::Itertools; use lazy_static::lazy_static; use serde::{Deserialize, Serialize}; use std::{convert::TryInto, fmt, net::Ipv4Addr, str}; use thiserror::Error; use trac...
true
c8262046344a2139a21a1558be795eadbd885560
Rust
foxbot/chip8
/src/main.rs
UTF-8
3,073
3.015625
3
[]
no_license
extern crate sdl2; mod cpu; use cpu::{Cpu, GFX_COLS, GFX_ROWS}; use sdl2::event::Event; use sdl2::keyboard::Keycode::Escape; use sdl2::pixels::Color; use sdl2::rect::Rect; use std::thread::sleep; use std::time::Duration; const WIDTH: u32 = 640; const HEIGHT: u32 = 320; const TILE_WIDTH: u32 = (WIDTH / 64); const TILE...
true
565d9dec60c7fff645ef8c4a076e6253844e9548
Rust
hooops/crypto-crawler-rs
/crypto-rest-client/src/exchanges/kucoin/kucoin_swap.rs
UTF-8
1,650
2.65625
3
[ "Apache-2.0" ]
permissive
use super::super::utils::http_get; use crate::error::Result; use std::collections::BTreeMap; const BASE_URL: &str = "https://api-futures.kucoin.com"; /// The RESTful client for KuCoin Future and Swap markets. /// /// * RESTful API doc: <https://docs.kucoin.cc/futures> /// * Trading at: <https://futures.kucoin.com/> /...
true
535d835d076d406daca870a131d774fa00fa7d73
Rust
gustavomello9600/projeto_euler
/rust/problem2.rs
UTF-8
336
3.03125
3
[]
no_license
fn main() { let mut n_current = 1; let mut n_before = 0; let mut s = 0; while n_current < 4000000 { if n_current % 2 == 1 { s += n_current; } let n_temp = n_current; n_current = n_current + n_before; n_before = n_temp; } println!("...
true
47227c00fa77e8346e6d25f6c025e82359afe4e3
Rust
felix-d/exercism
/rust/isbn-verifier/src/lib.rs
UTF-8
520
2.90625
3
[]
no_license
#[macro_use] extern crate lazy_static; extern crate regex; use regex::Regex; pub fn is_valid_isbn(isbn: &str) -> bool { lazy_static! { static ref FORMAT: Regex = Regex::new(r"^(\d-\d{3}-\d{5}-[\dX]|\d{9}[\dX])$").unwrap(); } if !FORMAT.is_match(isbn) { return false; } (1..=10).rev().zip(isbn...
true
ca5b945e3f5b8b4d83324eee4367c4f8243516c7
Rust
huwwynnjones/rosetta_code
/abbreviations_simple/src/main.rs
UTF-8
4,947
3.078125
3
[]
no_license
use std::collections::HashMap; // The plan here is to build a hashmap of all the commands keyed on the minimum number of // letters than can be provided in the input to match. For each known command it will appear // in a list of possible commands for a given string lengths. A command can therefore appear a // number ...
true
f2c8e9828eddfb0d37eb46da6dfa4f39be42dae5
Rust
JustusAdam/nom-sql
/src/delete.rs
UTF-8
3,225
2.953125
3
[ "MIT" ]
permissive
use nom::character::complete::multispace1; use std::{fmt, str}; use common::{statement_terminator, schema_table_reference}; use condition::ConditionExpression; use keywords::escape_if_keyword; use nom::bytes::complete::tag_no_case; use nom::combinator::opt; use nom::sequence::{delimited, tuple}; use nom::IResult; use ...
true
e73b8e3fc2e4d301cd685d26dfae130e2276091f
Rust
cmyr/cargo-instruments
/src/opt.rs
UTF-8
10,401
2.75
3
[ "MIT" ]
permissive
//! CLI argument handling use anyhow::Result; use cargo::core::resolver::CliFeatures; use cargo::ops::Packages; use std::fmt; use std::path::PathBuf; use structopt::StructOpt; #[derive(StructOpt)] #[structopt(bin_name = "cargo")] pub(crate) enum Cli { /// Profile a binary with Xcode Instruments. /// /// B...
true
48e743ed01f5a2ab18f5eacc42bec9a88a94dbab
Rust
haochuan/advent-of-code
/2019/rust-new/src/day01.rs
UTF-8
1,208
3.296875
3
[]
no_license
use crate::error::Error; use std::io; pub fn run<T>(mut input: T) -> Result<(), Error> where T: io::BufRead, { let mut content = Vec::new(); input.read_to_end(&mut content)?; //part 1 let mut reader = io::BufReader::new(&content[..]); run_part(&mut reader, part_one)?; //part 2 let mut...
true
74dc809196f84709c8a262db803cc56a9b37965d
Rust
A-Rehman01/PIAIC-Rust-Assignment
/Assignment 3/question1/src/main.rs
UTF-8
176
2.953125
3
[]
no_license
#[derive(Debug)] enum Student { Online(String), Onsite(String) } fn main() { println!("Q1"); let stud1=Student::Online; let stud2=Student::Onsite; }
true
7cbcc63ffc446fcf4cd74b3b46bae44a5d841a92
Rust
Azure/azure-sdk-for-rust
/services/mgmt/automanage/src/package_2021_04_30_preview/models.rs
UTF-8
30,953
2.609375
3
[ "LicenseRef-scancode-generic-cla", "MIT", "LGPL-2.1-or-later" ]
permissive
#![allow(non_camel_case_types)] #![allow(unused_imports)] use serde::de::{value, Deserializer, IntoDeserializer}; use serde::{Deserialize, Serialize, Serializer}; use std::str::FromStr; #[doc = "Data related to the report detail."] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Default)] pub struct Assignmen...
true
0f554e72ecf6976d91254cffad23de2d02bb95b0
Rust
HexColors60/r2vm
/src/emu/event.rs
UTF-8
9,664
2.859375
3
[ "Apache-2.0", "MIT" ]
permissive
//! This module handles event-driven simulation use futures::future::BoxFuture; use futures::task::ArcWake; use parking_lot::{Condvar, Mutex, MutexGuard}; use std::collections::BinaryHeap; use std::future::Future; use std::pin::Pin; use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use std::sync::Arc; use std:...
true
203589ade0451895b04337582edbf8c9c22f42a7
Rust
pest-parser/pest3
/meta/src/parser.rs
UTF-8
50,361
2.671875
3
[]
no_license
#![allow(clippy::result_large_err)] use std::{ char, fs::File, io::Read, mem, ops::{Bound, RangeBounds}, path::{Path, PathBuf}, rc::Rc, str::FromStr, }; use pest::{ error::{Error, ErrorVariant}, iterators::{Pair, Pairs}, pratt_parser::{Assoc, Op, PrattParser}, Parser, };...
true
0f411da67310d8dddaf10a90120f72730da679de
Rust
mongodb/mongo-rust-driver
/src/client/session/pool.rs
UTF-8
2,147
3.171875
3
[ "OpenSSL", "Apache-2.0" ]
permissive
use std::{collections::VecDeque, time::Duration}; use tokio::sync::Mutex; use super::ServerSession; #[cfg(test)] use crate::bson::Document; #[derive(Debug)] pub(crate) struct ServerSessionPool { pool: Mutex<VecDeque<ServerSession>>, } impl ServerSessionPool { pub(crate) fn new() -> Self { Self { ...
true
46c75871b0e234754493e0790977cc87d7398849
Rust
OlegTheCat/unlisp
/src/lexer.rs
UTF-8
6,853
3.109375
3
[ "MIT" ]
permissive
use crate::error::SyntaxError; use crate::pushback_reader::PushbackReader; use std::error::Error; use std::io; use std::io::Read; type GenResult<T> = Result<T, Box<Error>>; #[derive(Debug, PartialEq, Eq, Clone)] pub enum Token { LeftPar, RightPar, IntegerLiteral(i64), StringLiteral(String), Symbol...
true
38cccf46206eb2176316413d49ccf2449873af80
Rust
maddymakesgames/chain-bot
/src/interactions.rs
UTF-8
3,053
2.53125
3
[]
no_license
use serenity::{ async_trait, client::{Context, EventHandler}, model::interactions::{Interaction, InteractionType}, }; use crate::{database::get_or_create_user, DatabaseConn}; pub struct InteractionHandler; #[async_trait] impl EventHandler for InteractionHandler { async fn interaction_create(&self, ct...
true
54067e1793805ee47f5b71fe45a30fef89c5d4c9
Rust
horitaku1124/wait_for_rust
/src/main.rs
UTF-8
2,268
3.15625
3
[ "MIT" ]
permissive
use std::env; use std::path::Path; use std::{thread, time}; use std::net::TcpStream; fn main() -> std::io::Result<()> { let mut use_tcp = false; let mut use_file = false; let mut tcp_endpoint = "".to_string(); let mut file_name = "".to_string(); let mut skip = false; let mut wait_time = 5; ...
true
e76bf510ea33c8327b83ecf3e5fea7e1f25a1534
Rust
legeana/config
/pikaconfig/src/package/contents/is_os.rs
UTF-8
1,798
2.59375
3
[]
no_license
use std::path::Path; use crate::tera_helper; use super::args::Arguments; use super::engine::{self, ConditionBuilder}; use super::inventory; use anyhow::Result; use indoc::formatdoc; #[derive(Debug)] struct IsOs(&'static str); impl IsOs { fn check(&self) -> bool { // We don't have to check this in runti...
true
0253f6ee5ff7c4b744fc00b0e53878e0c7259e9a
Rust
pfouilloux/proc-macro-workshop
/builder/src/derive.rs
UTF-8
8,131
3.078125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use proc_macro2::{TokenStream, Ident}; use syn::{DeriveInput, Data, Field}; use quote::{quote, format_ident}; pub fn derive(input: &DeriveInput) -> TokenStream { let caller_name = &input.ident; let builder_name = &format_ident!("{}Builder", caller_name.to_string()); let builder_declaration = write_builder...
true
053ad710700b38cf4bcbd970e4e7b5a3b1a77210
Rust
ergoplatform/sigma-rust
/ergo-chain-types/src/block_id.rs
UTF-8
641
2.6875
3
[ "CC0-1.0" ]
permissive
//! Main "remote" type for [BlockId]() use derive_more::Display; use crate::DigestNError; use super::digest32::Digest32; /// Block id #[cfg_attr(feature = "json", derive(serde::Serialize, serde::Deserialize))] #[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Copy, Clone, Hash, Display)] pub struct BlockId(pub Digest...
true
f51cd9bbbf9827113afdc867ad9390788fd86c9d
Rust
kroeckx/ruma
/crates/ruma-events/src/key/verification/key.rs
UTF-8
2,066
2.5625
3
[ "MIT" ]
permissive
//! Types for the *m.key.verification.key* event. use ruma_events_macros::EventContent; use serde::{Deserialize, Serialize}; #[cfg(feature = "unstable-pre-spec")] use super::Relation; #[cfg(feature = "unstable-pre-spec")] use crate::MessageEvent; /// Sends the ephemeral public key for a device to the partner device....
true
a829cf42f481351be6ca6e22522c42a49d3c9ad2
Rust
viz-rs/viz
/viz-macros/src/lib.rs
UTF-8
3,937
2.59375
3
[ "MIT" ]
permissive
//! Macros for Viz Web Framework //! //! Generators for handler //! //! # handler //! //! ## Example //! //! ``` //! # use viz::{IntoResponse, Result}; //! # use viz_macros::handler; //! //! #[handler] //! fn about() -> impl IntoResponse { //! } //! //! #[handler] //! async fn index() -> impl IntoResponse { //! () ...
true
64e54bf0499ebdd57d797fef7623c87057e094bf
Rust
RalfNorthman/MoonZoon
/examples/timer/frontend/src/lib.rs
UTF-8
2,616
2.5625
3
[ "MIT" ]
permissive
#![no_std] use zoon::*; use std::ops::Not; blocks!{ // -- stopwatch -- #[s_var] fn seconds() -> u32 { 0 } #[s_var] fn stopwatch() -> Option<Timer> { None } #[update] fn start_stopwatch() { stopwatch().set(Some(Timer::new(1_000, increment_seconds))); ...
true
7f3f824f8c87c575f6a2abf48b463f80f06d6a79
Rust
pierrechevalier83/unicode_types
/src/generated/supplemental_arrows_b.rs
UTF-8
30,204
3.140625
3
[ "LicenseRef-scancode-unicode" ]
permissive
/// An enum to represent all characters in the SupplementalArrowsB block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum SupplementalArrowsB { /// \u{2900}: '⤀' RightwardsTwoDashHeadedArrowWithVerticalStroke, /// \u{2901}: '⤁' RightwardsTwoDashHeadedArrowWithDoubleVerticalStroke, /// \...
true
63ed9930bd0abd75ebe6d7f0d223dd991dc9a129
Rust
jstzwj/HanBLAS
/src/dotc.rs
UTF-8
2,460
2.796875
3
[ "MIT" ]
permissive
use crate::{c32, c64, HanInt}; pub fn cdotu(n: HanInt, x: &[c32], incx: HanInt, y: &[c32], incy: HanInt) -> c32 { // check array length first assert!( x.len() as HanInt >= 1 + (n - 1) * incx.abs(), "the dimension of x should greater than 1+(n-1)*abs(incx)" ); assert!( y.len() as...
true
ceed76ae35f02cd9d62e60c0eac8629d48078278
Rust
roelvanduijnhoven/adventofcode-2020
/day7/src/main.rs
UTF-8
670
2.921875
3
[]
no_license
mod bag_policy; use bag_policy::BagPolicy; use std::fs; fn main() { let content = fs::read_to_string("assets/day7.in").expect("Something went wrong reading the file"); let policy = BagPolicy::from_string(&content); { let bags = policy.get_bags(); let can_contain_shiny_gold: Vec<&String> =...
true
7900b4e67007a4765466bfd0edcc0373b2064bbc
Rust
drivasperez/mars
/src/parser/instruction.rs
UTF-8
15,278
2.921875
3
[]
no_license
use super::numeric_expr::{expr, ExprValue, NumericExpr}; use nom::{ branch::alt, bytes::complete::{tag_no_case, take_till}, character::complete::{ alpha1, alphanumeric0, char, multispace1, not_line_ending, one_of, space0, space1, }, combinator::not, combinator::{map, opt, peek, recognize...
true
6269d916eab0738db99f031649a77f16c57c1ad5
Rust
tehAnswer/rustme
/2/guessing_game/src/main.rs
UTF-8
967
3.625
4
[]
no_license
extern crate rand; use std::io; use std::cmp::Ordering; use rand::Rng; fn main() { loop { println!("Guess a number 🤔"); let mut guess = String::new(); let number = rand::thread_rng().gen_range(1, 100); io::stdin().read_line(&mut guess) .expect("Failed to read guess...");...
true
b050f376eb149355756a088732c8b4009b1af9ae
Rust
korczis/maze-rs
/src/output/ascii.rs
UTF-8
933
2.984375
3
[ "MIT" ]
permissive
use std::iter; use super::super::types::cell::Cell; use super::super::types::grid::Grid; pub fn format<T>(grid: &Grid<T>) -> String where T: Cell + Clone { let mut res = String::new(); res += "+"; res += &iter::repeat("---+").take(grid.x()).collect::<String>()[..]; res += "\n"; for y in 0..gr...
true
7924ddabc8124deef5e1460e0251029334a25d0f
Rust
ajweeks/Graphite
/graphene/src/layers/simple_shape.rs
UTF-8
4,136
2.609375
3
[ "Apache-2.0", "LicenseRef-scancode-free-unknown" ]
permissive
use glam::DAffine2; use glam::DMat2; use glam::DVec2; use kurbo::Affine; use kurbo::Shape as KurboShape; use crate::intersection::intersect_quad_bez_path; use crate::LayerId; use crate::Quad; use kurbo::BezPath; use super::style; use super::style::PathStyle; use super::LayerData; use serde::{Deserialize, Serialize}...
true