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
caf6f74287a6a65281f311989ca1153c1e0fc7f2
Rust
ruabmbua/rinvaders
/src/entites/explosion.rs
UTF-8
2,114
3.359375
3
[ "MIT" ]
permissive
//! Explosion entity module. //! //! The explosion spawns every time a enemy is destroyed on the position of the destroyed enemy / the involved projectile. //! In comparison to some other entities, the explosing has an animation cycle with 2 animation steps. //! The explosion lasts only for a specific time, and will be...
true
6405f90531d26c59d422c2aa928179cebba83fe0
Rust
FliegendeWurst/fend
/core/src/error.rs
UTF-8
2,422
3.0625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::{convert, fmt}; pub(crate) trait Error: fmt::Display {} pub(crate) type Never = convert::Infallible; pub(crate) enum IntErr<E, I: Interrupt> { Interrupt(I::Int), Error(E), } #[allow(clippy::use_self)] impl<E, I: Interrupt> IntErr<E, I> { pub(crate) fn expect(self, msg: &'static str) -> IntErr<N...
true
0fc273f0a4a1322efff965d3fd157a9c5db184de
Rust
chop0/aski
/src/compiler.rs
UTF-8
12,442
2.640625
3
[]
no_license
use crate::parser::{ScopeImpl, ScopeImplType, Statement, Expression}; use crate::tokenizer::{ Type, Identifier, Literal, Operator, }; use std::str::from_utf8; pub(crate) struct Program { pub header: Vec<u8>, pub text: Vec<u8>, pub ro_data: Vec<u8>, pub bss: Vec<u8>, } impl Program { ...
true
00e003a52b4e7ba9ddf78a0aac27ac82733d1ac6
Rust
litao91/tree-nvim-rs
/src/errors.rs
UTF-8
632
2.765625
3
[]
no_license
use std::error::Error; use std::fmt; macro_rules! define_error { ($($err:ident)*) => { $( #[derive(Debug)] pub struct $err { details: String, } impl $err { pub fn new(msg: &str) -> Self { Self { details: msg.to_string(), } } pub fn from_string(details: String) -> Self ...
true
db40dc7af8762401dcd25dcc9d1023691ac97f3c
Rust
ubnt-intrepid/handlebars-rust
/src/value.rs
UTF-8
3,439
3.53125
4
[ "MIT" ]
permissive
use serde::Serialize; use serde_json::value::{to_value, Value as Json}; /// A JSON wrapper designed for handlebars internal use case /// /// * Constant: the JSON value hardcoded into template /// * Context: the JSON value referenced in your provided data context /// * Derived: the owned JSON value computed during re...
true
7d61d5e114b412a6ebf2ffa81cb189f230d548b8
Rust
dgoldsb/advent-of-code-2016
/days/src/day_02.rs
UTF-8
3,905
3.53125
4
[]
no_license
use aoc::parse_chars; use std::collections::HashMap; fn part_a(inputs: &Vec<char>) -> String { let mut digit: i8 = 5; let mut code: String = "".to_string(); for chr in inputs { digit = match chr { 'U' => { if digit > 3 { digit - 3 } e...
true
523df1b6353930360d5f65ac2fda6b35bfd70af3
Rust
Voidsans/miratope-rs
/src/polytope/off.rs
UTF-8
16,341
2.984375
3
[ "MIT" ]
permissive
use petgraph::{graph::NodeIndex, visit::Dfs, Graph}; use std::{collections::HashMap, io::Result, path::Path, str::FromStr}; use super::{Abstract, Concrete, Element, ElementList, Point, Polytope, RankVec}; /// Gets the name for an element with a given rank. fn element_name(rank: isize) -> String { match super::ELE...
true
4456c1c76e78526a60a3f1a2d189f935d59c5cc0
Rust
nanlong/arithmetic_rs
/src/graph/edge.rs
UTF-8
1,592
3.921875
4
[]
no_license
use std::cmp::Ordering; use std::f32; // 加权图中的边 #[derive(Debug, Eq, PartialEq)] pub struct Edge { v: usize, w: usize, weight: u32, } impl Edge { pub fn new(v: usize, w: usize, weight: f32) -> Self { Edge {v, w, weight: weight.to_bits()} } // 权重 pub fn weight(&self) -> f32 { ...
true
b24fb1ec8b571a51a9be591fc9d8b829ea2bd702
Rust
nyantec/sensorlog
/src/logfile_config.rs
UTF-8
2,227
2.671875
3
[ "MirOS" ]
permissive
/** * Copyright © 2018 nyantec GmbH <oss@nyantec.com> * Authors: * Paul Asmuth <asm@nyantec.com> * * Provided that these terms and disclaimer and all copyright notices * are retained or reproduced in an accompanying document, permission * is granted to deal in this work without restriction, including un‐ * lim...
true
d5a54395ba65ef781abdb39551134ff401ac42a8
Rust
gnoliyil/fuchsia
/tools/jq5/src/traverser.rs
UTF-8
16,973
2.9375
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. use anyhow; use json5format::*; use std::mem::discriminant; /// A recursive function that takes in two references to `json5format::Value`s, /// and modifi...
true
a28277b2a33bcd9648e75fc19045f59c939f7229
Rust
jeffreybolle/ironcast
/src/net/message.rs
UTF-8
2,273
3.046875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use tokio::net::TcpStream; use std::sync::Arc; use tokio::sync::{Mutex, mpsc}; use tokio::io::{WriteHalf, AsyncWriteExt}; use crate::net::utils::*; pub enum Downstream { TcpStream(WriteHalf<TcpStream>), #[allow(dead_code)] Channel(mpsc::Sender<Vec<u8>>) } impl Downstream { async fn write(&mut self, pe...
true
96d45ac0c52424570c03a3236a223c9c8e3d161d
Rust
thomas9911/timeseries
/src/traits.rs
UTF-8
2,787
3.03125
3
[]
no_license
use core::borrow::Borrow; use core::ops::RangeBounds; use std::collections::HashMap; use crate::enums::IndexOrColumn; use crate::TableError; use std::collections::btree_map::{Entry, Iter, IterMut, Keys, Range, RangeMut, Values, ValuesMut}; /// Trait that passes the methods from the [BTreeMap](https://doc.rust-lang.or...
true
ba1b71b41c54463a891bf1674bd5357ef6feeb20
Rust
andrewhalle/aoc2020
/src/days/day01.rs
UTF-8
1,226
3.25
3
[]
no_license
use crate::Solution; use std::collections::HashSet; /// Finds two items in a HashSet of u32 which sum to n. fn find_two_sum_n(nums: &HashSet<u32>, n: u32) -> Option<(u32, u32)> { for i in nums.iter().filter(|x| **x <= n) { let j = n - i; if nums.contains(&j) { return Some((*i, j)); ...
true
2ee43f5f6698851c8ec16a6f1254b303096a65a9
Rust
iCodeIN/zig-bn
/bench/fac/crate-fac-rs/src/main.rs
UTF-8
345
2.75
3
[ "MIT" ]
permissive
extern crate num_bigint; extern crate num_traits; use num_bigint::BigInt; use num_traits::One; const TARGET: u32 = 50000; fn main() { let mut f: BigInt = One::one(); let mut c: BigInt = One::one(); let one: BigInt = One::one(); for _ in 0..TARGET { f = &f * &c; c = &c + &one; } ...
true
fa689df00c5074ef19e4565feed39bb5df4844ce
Rust
julianandrews/adventofcode
/2021/rust/src/bin/day13.rs
UTF-8
4,306
3.15625
3
[]
no_license
use std::collections::HashSet; use aoc::aoc_error::AOCError; use aoc::utils::{get_input, parse_fields}; type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; fn main() -> Result<()> { let input = get_input()?; let (points_part, folds_part) = input .trim() .split_once("\n\n") ...
true
34eff0a7d9185e23ac7f9c068968f338648df9b5
Rust
rymdhund/adventofcode
/11/src/main.rs
UTF-8
1,299
3.15625
3
[]
no_license
use std::env; fn inc(s: &mut [u8]) { for i in (0..s.len()).rev() { s[i] += 1; if s[i] > 'z' as u8 { s[i] = 'a' as u8; } else if s[i] == 'i' as u8 || s[i] == 'o' as u8 || s[i] == 'l' as u8 { // optimization that skips ranges of invalid strings s[i] += 1; ...
true
a1685cf231cf324658895a093e6d5988add54119
Rust
mdiflorio/torrenter
/src/queue.rs
UTF-8
1,494
3.203125
3
[]
no_license
use std::collections::VecDeque; use crate::utils::torrents::{BLOCK_LEN, Torrent}; #[derive(Debug, Copy, Clone)] pub struct PieceBlock { pub index: u64, pub begin: u64, pub length: Option<u64>, } /// Job queue which tracks the blocks and pieces that need to be downloaded from a given peer pub struct Queue...
true
329939031e73dc1afee7fa1289b4c3a1e66d4165
Rust
Ventmere/walmart-partner-api
/walmart-partner-api/src/utils.rs
UTF-8
1,332
3.375
3
[ "MIT" ]
permissive
use chrono::{DateTime, TimeZone, Utc}; use serde::de; use serde::Deserializer; use std::fmt; /// Walmart serialize Date to a milliseconds since January 1, 1970 0:00:00 UTC, /// It's not a standard unix timestamp, so we need to impl custom unserialize struct TimestampVistor; impl<'de> de::Visitor<'de> for TimestampVist...
true
a9d4ab27c693dc2dfd09aaa5550a966ca0bf1a5d
Rust
0xd34d10cc/nox-rs
/src/statement/init_pass.rs
UTF-8
7,886
3.078125
3
[ "MIT" ]
permissive
use std::collections::{HashMap, HashSet}; use super::expr::Expr; use super::program::{Error, Result, Warning}; use crate::syntax::{self, Statement}; use crate::types::Var; struct VariableState { initialized: bool, referenced: bool, } impl VariableState { fn initialized() -> Self { VariableState {...
true
c03d13cebcc750b3af3ace9dc2372f21559e68cc
Rust
AlexNav73/Rust
/IOFS/lab1/src/help.rs
UTF-8
1,675
3.734375
4
[]
no_license
use std::collections::HashMap; /// /// Count words entry in text /// /// Return: /// count of words in text /// HashMap witch contains word and count of this words in text /// pub fn parse_text(text: String) -> (usize, HashMap<String, u32>) { let mut hash: HashMap<String, u32> = HashMap::new(); let n...
true
7b2827b351cdc892d669e60d382ec5a3159364c1
Rust
IThawk/rust-project
/rust-master/src/test/run-fail/str-overrun.rs
UTF-8
197
2.859375
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// error-pattern:index out of bounds: the len is 5 but the index is 5 fn main() { let s: String = "hello".to_string(); // Bounds-check panic. assert_eq!(s.as_bytes()[5], 0x0 as u8); }
true
a5458b37a230be35ff7cc2cbbd0ddc0422d90719
Rust
github/stack-graphs
/stack-graphs/tests/it/arena.rs
UTF-8
9,256
2.90625
3
[ "Apache-2.0", "MIT" ]
permissive
// -*- coding: utf-8 -*- // ------------------------------------------------------------------------------------------------ // Copyright © 2021, stack-graphs authors. // Licensed under either of Apache License, Version 2.0, or MIT license, at your option. // Please see the LICENSE-APACHE or LICENSE-MIT files in this d...
true
ff8bb709707460e000a39e3215f9d806328f88e0
Rust
qinsoon/zebu
/src/compiler/backend/peephole_opt.rs
UTF-8
8,476
2.625
3
[ "Apache-2.0" ]
permissive
// Copyright 2017 The Australian National University // // 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 applicab...
true
9c34a44cd26d4ff5e21ff647a591d99b086da758
Rust
stephanwilliams/rust386
/src/reg.rs
UTF-8
10,501
2.578125
3
[ "MIT" ]
permissive
use std::fmt::{ Debug }; use numlib::traits::{ FromPrimitive, ToPrimitive }; use num::{ Num, Size }; bitflags! { pub flags EFlags: u32 { const EFLAGS_CF = 0b00000000000000000000000000000001, const EFLAGS_RESERVED1 = 0b00000000000000000000000000000010, const EFLAGS_PF = 0b0...
true
cf0178274f84486b1f3a1857bf8168102a5b8028
Rust
colrdavidson/tilepaste
/src/tile.rs
UTF-8
3,662
2.921875
3
[]
no_license
use std::io::Cursor; use std::fmt; use image; use glium; use glium::Surface; use vert::Vert; pub struct Tile<'a> { pub tex_id: u32, pub atlas: &'a TileAtlas, } impl<'a> fmt::Debug for Tile<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Tile: {}", self.tex_id) } } impl<...
true
8f8a2c2d1be5732ab4b8a836448e0d2a5b791261
Rust
emseibert/RustCompletion
/rust_src/libstd/sync/arc.rs
UTF-8
7,343
2.984375
3
[]
no_license
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
true
76e4d85e9d867e2decf95d4aa801e1f34c8c1c55
Rust
iacsa/exercism-solutions
/rust/bowling/src/lib.rs
UTF-8
2,310
3.421875
3
[ "Unlicense" ]
permissive
pub struct BowlingGame { half_frames_completed: u32, score: u32, bonus_for_1: u32, bonus_for_2: u32, bonus_rolls: u32, pins_remaining: u32, } #[derive(PartialEq, Debug)] pub enum Error { GameComplete, NotEnoughPinsLeft, } impl BowlingGame { pub fn new() -> Self { BowlingGam...
true
3eaecfd2fc38de2697199e35b4acff1b81b2b5fa
Rust
iggy-rs/iggy
/server/src/http/topics.rs
UTF-8
2,508
2.578125
3
[ "MIT" ]
permissive
use crate::http::error::CustomError; use crate::http::mapper; use axum::extract::{Path, State}; use axum::http::StatusCode; use axum::routing::get; use axum::{Json, Router}; use iggy::identifier::Identifier; use iggy::models::topic::{Topic, TopicDetails}; use iggy::topics::create_topic::CreateTopic; use iggy::validatab...
true
67659028124932285192b75a881aced584d9d156
Rust
neqcold/rust-stuff
/iterators_and_closures/lazy_evaluation.rs
UTF-8
1,247
3.3125
3
[]
no_license
use std::env; struct Cacher<T> where T: Fn(f64) -> f64 { calculation: T, value: Option<f64>, } impl<T> Cacher<T> where T: Fn(f64) -> f64 { fn new(calculation: T) -> Cacher<T> { Cacher { calculation, value: None } } fn value(&mut self, arg: f64) -...
true
4a96b8ab4a8b076ff1ade4a1b5d0aae47ceca16d
Rust
zdebra/advent-of-code-2020
/day08/src/main.rs
UTF-8
2,995
3.4375
3
[]
no_license
use simple_error::SimpleError; use std::collections::HashMap; use std::env; use std::fmt; use std::fs::File; use std::io::{self, BufRead}; use std::str::FromStr; fn main() { println!("Hello, world from day 8!"); let args: Vec<String> = env::args().collect(); let filename = &args[1]; let file = File::op...
true
0e8dfb8d8c3a170b73d01c8daf32e8598048a19f
Rust
hessifer/Rust
/more_vectors/src/main.rs
UTF-8
2,428
3.796875
4
[]
no_license
/* * 1. Ask the user to enter 6 colors * 2. Add those colors to a vector * 3. Ask user for a pattern * 4. Display all colors with specified pattern, or indicate no matches * 5. Display all colors with an even number length */ use std::io::Write; fn main() { let colors = collect_colors(); let pattern = get_patt...
true
0126adf19a6166e9040e18b9afd67b22a5f3425d
Rust
juanmorenomotta/rust-primeros-pasos
/ejemplo5_3.rs
UTF-8
887
3.203125
3
[]
no_license
/* * enum */ enum Lenguaje{ // definimos un enum RUST, // miembro GO, CSHARP, C, CPP, JAVA, PHP, } fn programa( parametro: Lenguaje ){ // recibimos un parametro de tipo Lenguaje match parametro{ Lenguaje::RUST => println!("RUST puesto 18 en TIOBE"), Lenguaje::GO => prin...
true
8515d232aad7936e5cffd1e19dafd0a8598e3a2c
Rust
gamsb/nettu-scheduler
/scheduler/crates/utils/src/lib.rs
UTF-8
843
3.515625
4
[ "MIT" ]
permissive
extern crate rand; use rand::Rng; const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz\ 0123456789"; pub fn create_random_secret(secret_len: usize) -> String { let mut rng = rand::thread_rng(); (0..secret_len) .map(|_...
true
00ad6880c14956554e0a52dbd43dba5ec9907fa3
Rust
parkerziegler/rust-book
/hashmaps/src/main.rs
UTF-8
2,884
3.984375
4
[]
no_license
// Note that HashMap must be explicitly used. // It is not included in the prelude of the standard library. use std::collections::HashMap; fn main() { // To create a hash map in Rust, use HashMap::new. // You can use generics to specify the key-value types, // but Rust can also infer them from the inserts ...
true
8184eecda66ae4a7469b7505fdc121b8589310f1
Rust
hessifer/Rust
/rust_learning_lab/working_with_strings/src/main.rs
UTF-8
952
3.875
4
[]
no_license
fn main() { let last_name = String::from("Charles"); // string array owns the data, mutable let first_name = "bob"; // ptr to data, no ownership and immutable for i in first_name.chars() { print!("{} ", i.to_lowercase()); } println!("\n"); for c in last_name.chars() { print!("...
true
ca2fb787e9201d9e3aced2c00534637638f30b36
Rust
Lex98/raytracer
/raytracer/src/camera.rs
UTF-8
1,908
3.03125
3
[ "MIT" ]
permissive
use rand::prelude::*; use crate::base::point3::Point3; use crate::base::vec3::{Vec3, Vec3Operations}; use crate::base::XYZ; use crate::ray::Ray; #[derive(Debug, Clone, Default)] pub struct Camera<T> { upper_left_corner: Point3<T>, horizontal: Vec3<T>, vertical: Vec3<T>, pub origin: Point3<T>, u: V...
true
95e7091bfe1c154566e3ae8ad680ca6d85de3849
Rust
balajisivaraman/aoc2018-rust
/src/utils.rs
UTF-8
242
2.609375
3
[]
no_license
use std::io::BufReader; use std::fs::File; use std::io; use std::io::prelude::*; pub fn read_input(file_path: &str) -> io::Result<Vec<String>> { let file = File::open(file_path)?; BufReader::new(file).lines().into_iter().collect() }
true
29b7fcf27093bd513228c0ad484ccaa714e4a2d2
Rust
olegnn/union
/union/src/lib.rs
UTF-8
22,692
3.640625
4
[ "MIT" ]
permissive
//! # `union!` //! //! `union!` - one macro to rule them all. Provides useful shortcut combinators, combines sync/async chains, transforms tuple of results in result of tuple, supports single and multi thread (sync/async) step by step execution of branches. //! //! ## Combinators //! //! - Map: `|>` expr - `value`.map(...
true
e65e91d30ac27273d28e2889b388a1a4e91a1028
Rust
arnau/blot
/blot-lib/src/multihash/blake2.rs
UTF-8
3,071
2.546875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2018 Arnau Siches // // Licensed under the MIT license <LICENSE or http://opensource.org/licenses/MIT>. // This file may not be copied, modified, or distributed except according to // those terms. //! Blot implementation for blake2. use super::{Harvest, Multihash, MultihashError}; use crypto_blake2 as di...
true
1168ad8f5fb0f9f8533de099f2c97df2ed6e73d7
Rust
Nukesor/pueue
/pueue/src/daemon/network/follow_log.rs
UTF-8
4,913
3.125
3
[ "MIT" ]
permissive
use std::io::Read; use std::path::Path; use std::time::Duration; use anyhow::Result; use pueue_lib::log::*; use pueue_lib::network::message::*; use pueue_lib::network::protocol::{send_message, GenericStream}; use pueue_lib::state::SharedState; /// Handle the continuous stream of a message. pub async fn handle_follow...
true
e60192454734e3bf3f936357db7fc51b8dc9418e
Rust
Jasopaum/rust_browser_engine
/src/render.rs
UTF-8
3,024
2.671875
3
[]
no_license
use crate::layout; use crate::dom; use crate::css; extern crate find_folder; extern crate piston_window; use piston_window::*; use textwrap::wrap_iter; pub fn render_layout_tree(layout_tree: &layout::LayoutBox) { let mut window: PistonWindow = WindowSettings::new("Hello Piston!", (640, 480)) .exit_on_esc...
true
d7b6828fd9f099a5a7d1d8bf80836fed0c2dc897
Rust
dandavison/misc
/ansi_preserving_slice.rs
UTF-8
1,541
3.328125
3
[]
no_license
use console; use std::cmp::min; use itertools::Itertools; /// Return string formed from a byte slice starting at byte position `start`, where the index skips /// bytes in ANSI escape sequences. pub fn ansi_preserving_slice(s: &str, start: usize) -> String { console::AnsiCodeIterator::new(s) .scan(0, |i, (...
true
012e82c52490c64899f83afaf61dca8bc18bbf7f
Rust
la10736/z2p
/src/configuration.rs
UTF-8
5,333
3.09375
3
[]
no_license
use serde_with::{serde_as, DisplayFromStr, DurationSecondsWithFrac}; use std::{convert::TryInto, time::Duration}; #[derive(serde::Deserialize, Default, Clone, Debug)] pub struct Settings { pub database: DatabaseSettings, pub application: ApplicationSettings, } #[serde_as] #[derive(serde::Deserialize, Default,...
true
5233270800b868fc23437f181c0a321c3b84b6bd
Rust
pengt/defi_projects
/layer2/zksync/core/lib/types/src/tx/change_pubkey.rs
UTF-8
7,826
2.625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{ helpers::{is_fee_amount_packable, pack_fee_amount}, AccountId, Nonce, }; use crate::account::PubKeyHash; use anyhow::ensure; use num::BigUint; use serde::{Deserialize, Serialize}; use zksync_basic_types::{Address, TokenId}; use zksync_crypto::{ params::{max_account_id, max_token_id}, Priva...
true
267ccac93456093453ef0b10b1782216da2b85ab
Rust
dimo414/advent-2018
/src/aoc16.rs
UTF-8
8,369
3.25
3
[]
no_license
use std::fs; use regex::Regex; use crate::device::{Device,Instruction,Opcode,Program}; pub fn advent() { let (samples, raw_instructions) = read_data(); let mut three_plus = 0; for Sample(before, instruction, after) in samples.iter() { let mut finder = Finder::new(); let count = finder.cons...
true
460604b54f53983dec8edd998dd2c0a9c8151513
Rust
dmarcuse/dynamic_ocl
/src/safe/kernel/mod.rs
UTF-8
4,849
3.109375
3
[ "Apache-2.0" ]
permissive
//! Kernels mod types; use crate::program::Program; use crate::raw::*; use crate::util::sealed::OclInfoInternal; use crate::Result; use std::ffi::{c_void, CStr}; use std::fmt::{self, Debug, Formatter}; use std::pin::Pin; pub use types::*; /// An OpenCL kernel, with arguments not yet set #[derive(PartialEq, Eq, Hash)...
true
e6dd80c3852a87a3d46e3ac44fe84fc31d337bea
Rust
Keats/tera
/examples/basic/main.rs
UTF-8
1,530
2.65625
3
[ "MIT" ]
permissive
#[macro_use] extern crate tera; #[macro_use] extern crate lazy_static; extern crate serde_json; use std::collections::HashMap; use serde_json::value::{to_value, Value}; use std::error::Error; use tera::{Context, Result, Tera}; lazy_static! { pub static ref TEMPLATES: Tera = { let mut tera = match Tera::n...
true
9dd9fa67f718d8c7cb6144a6217ea504311d3775
Rust
pepyakin/chetyre
/servant/nrf51822/src/radio/test.rs
UTF-8
8,040
2.859375
3
[]
no_license
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::TEST { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut ...
true
add469c897f1f8eb5f20ebc926d3dc9876aa3488
Rust
thea0032/resourcetext
/src/ui/menu/game/resources.rs
UTF-8
866
2.625
3
[]
no_license
use crate::{ resources::ResourceID, save::Package, ui::menu::{config::Config, constants, options::OptionTable}, }; impl Package { pub fn select_resources(&mut self, config: &mut Config, res: Option<Vec<u64>>) -> Vec<u64> { let mut res: Vec<u64> = res.unwrap_or(vec![0; self.rss.len()]); ...
true
77428b6a61d618c0a13c441787d71c01934eab42
Rust
mb64/smol_stack_machine
/vm/src/decoder.rs
UTF-8
1,518
3
3
[ "MIT" ]
permissive
//! Decoder //! //! Turns instructions into `StackAction`s and `IMemAction`s use crate::alu; use crate::{AluAction, IMemAction, SendAction, StackAction}; #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct Action { pub stack: StackAction, pub imem: IMemAction, pub send: SendAction, } impl Action { ...
true
9ff4cc571536d68fa4fe8b9d0c945c980d376aeb
Rust
thomas9911/timeseries
/src/utils.rs
UTF-8
1,470
2.515625
3
[]
no_license
#[cfg(feature = "csv")] extern crate csv; #[cfg(feature = "chrono")] extern crate chrono; #[cfg(all(feature = "chrono", feature = "csv"))] use crate::{Table, TableMetaTrait, TableReadError}; #[cfg(all(feature = "chrono", feature = "csv"))] pub fn read_csv_to_datetable<R, U, F, Y>( rdr: &mut csv::Reader<R>, i...
true
782fe5082489efb928c8b751f5d81387cfef5c4e
Rust
iffyio/rustub
/src/storage/disk_manager.rs
UTF-8
5,816
3.1875
3
[]
no_license
use crate::storage::page::Page; use log; use std::error::Error; use std::fs::{File, OpenOptions}; use std::io::{Error as IOError, ErrorKind, Read, Seek, SeekFrom, Write}; use std::path::Path; type PageOffset = u64; /// Back pages with underlying storage using a single file on disk. pub struct DiskManager { page_f...
true
b32fb9c8fb4c7871c38ba589107d57248c44db36
Rust
Lol3rrr/rizm
/compiler/src/backend/function/variables/vars.rs
UTF-8
1,585
2.640625
3
[]
no_license
use crate::{ backend::{ function::{VarOffset, VariableMetaData, VariableSize}, internal, }, ir, }; /// Calculates the Offsets for the Varialbes used in the Function itself pub fn offsets(statements: &[ir::Statement], vars: &mut VarOffset, final_offset: &mut u8) { for tmp in statements.i...
true
8b0f2c4a5055c31713b954f52356cfca0b5d63a5
Rust
book-resources/rustlernen
/10-Benutzerdefinierte Typen/programmtext-135.rs
UTF-8
134
3.203125
3
[]
no_license
fn match_option(opt: Option<u8>) { match opt { None => println!("None") // Fehler, weil kein Fall fuer "Some" existiert } }
true
1b185a6b0cb226f788ec1f7f06403cdbcd59769d
Rust
avanish-patel/Rust_Basics
/arrays.rs
UTF-8
478
3.78125
4
[]
no_license
fn main() { let numbers = [14,83,38,8,81]; for i in numbers.iter() { println!("{}",i); } for i in 0..numbers.len() { println!("{}", numbers[i]); } // array of type i32 and has length 6 let another_numbers : [i32;6] = [1,2,3,4,5,6]; println!("legnth : {}", another_numb...
true
65a9a9b2541cb094de90aa6a7e04bb6963dbab3c
Rust
compiler-errors/cheshire-simple
/src/parser/ast.rs
UTF-8
21,938
2.96875
3
[]
no_license
use util::FileReader; use analyzer::{Ty, TY_NOTHING, VarId, StringId, ObjId, TraitId, MemberId}; #[derive(Debug)] /// A file that is being parsed, along with the associated /// parsed functions that are contained in the file. pub struct ParseFile<'a> { pub file: FileReader<'a>, pub functions: Vec<AstFunction>,...
true
d182c35930901ac23482eaea45068aa22099c01d
Rust
nicmr/rustis100
/src/tis100/emu.rs
UTF-8
1,960
3.328125
3
[]
no_license
use crate::tis100::{Node, Instruction, NodeState}; pub fn tick_all_n(mut nodes: Vec<Node>, ticks: usize) -> Vec<Node> { for node in &mut nodes { let new_state = tick_n(&node.state, &node.instructions, ticks); node.state = new_state; } nodes } pub fn tick_n(state: &NodeState, instructions:...
true
a1e7d4e747e375f439b33a8eabcb5a3a0c7b2850
Rust
0ndorio/advent-of-code
/2018/aoc08/src/main.rs
UTF-8
2,536
3.484375
3
[ "Unlicense" ]
permissive
use std::{ error::Error, io::{self, Read}, str::FromStr, }; type Result<ContentT> = std::result::Result<ContentT, Box<dyn Error>>; fn main() -> Result<()> { let mut input = String::new(); io::stdin().read_to_string(&mut input)?; let root: Node = input.parse()?; let sum = root.sum_meta_da...
true
a4ea436e64bca503a567d501624781ea7461fdf0
Rust
brucelevis/rl
/src/console.rs
UTF-8
2,834
3.234375
3
[ "MIT" ]
permissive
use tetra::graphics::{self, Color, DrawParams, Rectangle, Texture}; use tetra::math::Vec2; use tetra::Context; #[derive(Clone)] struct ConsoleCell { glyph: char, foreground: Color, background: Color, } pub struct Console { font: Texture, cells: Vec<ConsoleCell>, cell_size: f32, } impl Console...
true
a3a1278755c340a6c6a226c9e2e3b9257bd6cca6
Rust
Leo1003/rust-osshkeys
/src/keys/mod.rs
UTF-8
21,954
2.890625
3
[ "MIT" ]
permissive
use crate::cipher::Cipher; use crate::error::*; use crate::format::ossh_privkey::*; use crate::format::ossh_pubkey::*; use crate::format::parse_keystr; use crate::format::pem::*; use crate::format::pkcs8::*; use digest::{Digest, FixedOutputReset}; use md5::Md5; use openssl::pkey::{Id, PKey, PKeyRef, Private, Public}; u...
true
0ab78ded732f2c72cabc30ec39fecd1b4dbbb6d6
Rust
jhnesk/advent-of-code
/2020/src/day_01.rs
UTF-8
853
3.34375
3
[ "Unlicense" ]
permissive
use std::usize; use std::fs::File; use std::io::{BufRead, BufReader}; fn parse(input: BufReader<File>) -> Vec<usize> { return input.lines() .filter_map(|result| result.ok()) .filter_map(|s| s.parse::<usize>().ok()) .collect::<Vec<usize>>(); } pub fn a(input: BufReader<File>) { let inpu...
true
6d1a5ce5fede62cc9533a237e65a554d231ce91a
Rust
miller-time/rust-warrior
/src/engine/systems/shooter.rs
UTF-8
1,888
3.28125
3
[ "MIT" ]
permissive
//! contains system for archer and wizard enemy AI use std::cmp; use crate::{engine::world::World, unit::UnitType}; /// This system acts as an enemy AI, attacking the player if an archer or /// wizard exists and can attack the [`Warrior`](crate::warrior::Warrior). /// The difference from the sludge is that the arche...
true
2b835152f0dd137f04a31b4d575035476243329b
Rust
DragonFrai/DSaA_Labs
/lab_3/src/play15old2.rs
UTF-8
10,542
3.03125
3
[]
no_license
use ndarray::Array2; use rand::Rng; use std::borrow::Borrow; use std::cmp::Ordering; use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque}; use std::fmt::{Display, Formatter}; pub const WIDTH: usize = 4; pub const HEIGHT: usize = 4; #[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)] pub struct Board([[u8; WI...
true
64c650844d2b94a6f357d193b81c32651e300d3c
Rust
GrandmasterTash/nails
/src/routes/admin/health.rs
UTF-8
2,041
2.65625
3
[ "MIT" ]
permissive
use serde::Serialize; use serde_json::json; use std::collections::HashMap; use actix_web::{HttpResponse, dev::HttpResponseBuilder, http::StatusCode}; use crate::utils::{context::{RequestContext}, errors::InternalError, http::get, mongo, rabbit}; #[derive(Serialize)] struct Health { healthy: bool, #[serde(skip...
true
29bb231bed47907d05fd07f43b548f42a663d98e
Rust
wezm/crossterm
/crossterm_style/src/enums/attribute.rs
UTF-8
5,463
3.53125
4
[ "MIT" ]
permissive
use std::fmt::Display; use std::io::stdout; use std::io::Write; /// These are all the attributes which **could** be apply to font. /// There are few things to note /// - Not all attributes are supported, some of them are only supported on Windows some only on Unix, /// and some are only very rarely supported. /// - I ...
true
74217f0e59473aa3815fd0f340fb6e961af13cbf
Rust
IgaguriMK/time-display
/src/main.rs
UTF-8
4,167
2.890625
3
[ "MIT", "Apache-2.0" ]
permissive
mod display; mod time; use std::fs::create_dir_all; use std::io::{stdin, stdout, BufRead, Write}; use std::path::PathBuf; use clap::{App, Arg, ArgMatches, SubCommand}; use tiny_fail::{Fail, FailExt}; use display::Display; use time::Time; fn main() { if let Err(e) = w_main() { eprintln!("ERROR: {}", e); ...
true
15da0791c23b52e023debe3c6dca039a7452c349
Rust
paveloom-university/Stellar-Astronomy-Laboratory-Workshop-S09-2021
/src/orbit/calc/simulate.rs
UTF-8
4,433
3.21875
3
[ "MIT" ]
permissive
//! This module provides routines for the Monte Carlo simulation use rand::prelude::*; use rand_distr::{Distribution, Normal}; use rand_xoshiro::Xoshiro256PlusPlus; use std::path::Path; use crate::orbit::calc::models::Model; use crate::{Orbit, F, I}; /// Calculate the distance using R and Z coordinates fn dist(r: F,...
true
c9e4c23c805e7faf0eda073808bc517d96bca642
Rust
wangchao0502/rust-leetcode
/src/p321_max_number.rs
UTF-8
3,127
3.671875
4
[]
no_license
#![allow(dead_code)] // use mods use std::cmp::max; use std::collections::VecDeque; pub struct Solution {} // problem description // Given two arrays of length m and n with digits 0-9 representing two numbers. // Create the maximum number of length k <= m + n from digits of the two. // The relative order of the digi...
true
61f0b3f32c79e79a2ef15ac1e0db11133e731e6a
Rust
mtsr/ecs-rs
/src/aspect.rs
UTF-8
2,358
3.5625
4
[ "MIT" ]
permissive
//! A filter for entities based on their components. use ComponentId; use Entity; use World; /// A filter for entities base on their components. #[deriving(Clone)] pub struct Aspect { all: Vec<ComponentId>, any: Vec<ComponentId>, none: Vec<ComponentId>, } impl Aspect { /// Create an empty `Aspect` t...
true
a93aa0d8794f0bf0cc807f88ad8d19d1ecc1a8d7
Rust
5l1v3r1/myodine
/src/dns_coding/encoding.rs
UTF-8
3,987
3.484375
3
[]
no_license
use std::iter::IntoIterator; use std::mem::size_of; /// Encode an object as binary data using an Encoder implementation. pub fn dns_encode<T: Encoder>(x: &T) -> Result<Vec<u8>, String> { let mut packet = EncPacket::new(); x.dns_encode(&mut packet)?; Ok(packet.0) } /// A buffer into which Encoders write th...
true
58ca8fff68f6b1abfcb412e8846ded1aa57b7e5d
Rust
R1tschY/xdg-desktop-entry-rs
/src/errors.rs
UTF-8
203
2.5625
3
[]
no_license
/// Desktop file parsing error. #[derive(Debug, Clone, PartialEq)] pub enum ParseError { InvalidLine(String) } /// Result of the desktop file parser. pub type ParseResult<T> = Result<T, ParseError>;
true
a7bd646f8c526522bb3aa40bc2e6ce19956d7f21
Rust
shift-crops/x64emu
/src/hardware/memory.rs
UTF-8
4,711
3.03125
3
[ "MIT" ]
permissive
extern crate libc; use libc::c_void; use thiserror::Error; #[derive(Debug, Error)] pub enum MemoryError { #[error("Out of range : {0:x}")] OutOfRange(usize), } #[derive(Clone, Copy)] pub enum MemDumpSize { Word, DWord, QWord } pub struct Memory(Vec<u8>); impl Memory { pub fn new(size: usize) -> Self { ...
true
71d3f3afcf36336e265aeb3f3d7873bf389eec82
Rust
AldaronLau/pix
/src/pixel.rs
UTF-8
8,177
3.078125
3
[ "Apache-2.0", "MIT" ]
permissive
// pixel.rs Pixel format. // // Copyright (c) 2018-2020 Douglas P Lau // Copyright (c) 2019-2020 Jeron Aldaron Lau // use crate::alpha::{self, Mode as _}; use crate::gamma::{self, Mode as _}; use crate::ColorModel; use std::any::{Any, TypeId}; /// Pixel format determines [color model], bit depth, [alpha mode] an...
true
20449306fbf3f45ffcabd8c00104adfc56c247f8
Rust
rushmorem/domain
/src/resolv/core.rs
UTF-8
2,186
2.953125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! The core of the resolver. use std::fmt; use std::io; use std::sync::Arc; use tokio_core::reactor; use super::conf::{ResolvConf, ResolvOptions}; use super::request::ServiceHandle; use super::tcp::tcp_service; use super::udp::udp_service; //------------ Core --------------------------------------------------------...
true
aa6131aef417126695fb0224f5555753735efd6d
Rust
aylei/leetcode-rust
/src/solution/s0060_permutation_sequence.rs
UTF-8
1,549
3.40625
3
[ "Apache-2.0" ]
permissive
/** * [60] Permutation Sequence * * The set [1,2,3,...,n] contains a total of n! unique permutations. * * By listing and labeling all of the permutations in order, we get the following sequence for n = 3: * * <ol> * "123" * "132" * "213" * "231" * "312" * "321" * </ol> * * Given n ...
true
4272aa76bd37557db7fbfcd5be51c2f1db53f17e
Rust
m-labs/compiler-builtins
/src/float/pow.rs
UTF-8
677
3.140625
3
[ "MIT", "NCSA" ]
permissive
use int::Int; /// Returns `a` raised to the power `b` macro_rules! pow { ($a: expr, $b: expr) => ({ let (mut a, mut b) = ($a, $b); let recip = b < 0; let mut r = 1.0; loop { if (b & 1) != 0 { r *= a; } b = b.aborting_div(2); ...
true
590b5c05f277734b0f610918c2dbd5dad71656d5
Rust
vishpat/lisp-rs
/src/object.rs
UTF-8
2,019
3.03125
3
[ "MIT" ]
permissive
use crate::env::*; use std::cell::RefCell; use std::fmt; use std::rc::Rc; #[derive(Debug, Clone, PartialEq)] pub enum Object { Void, If, Keyword(String), BinaryOp(String), Integer(i64), Float(f64), Bool(bool), String(String), Symbol(String), ListData(Vec<Object>), Lambda(Vec...
true
af24c97bb774674adfee21987f67c73a1320a8af
Rust
jacklund/matrix-rs
/src/db/mod.rs
UTF-8
1,813
3.125
3
[]
no_license
use std::fmt; use toml; pub mod mock_db; pub mod memory; pub trait DB where Self: Sync { fn add_user_auth(&mut self, user: String, password: String) -> Result<(), String>; fn lookup_user_by_3pid(&self, medium: &str, address: &str) -> Result<Option<String>, String>; fn lookup_user_by_user_id(&self, use...
true
7cb142c3daa8e58929ce691d110c237a62693559
Rust
jakyle/rust-algos
/src/remove_duplicates.rs
UTF-8
268
3.078125
3
[ "MIT" ]
permissive
pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 { nums.dedup(); nums.len() as i32 } #[cfg(test)] mod remove_duplicates_tests { use super::*; #[test] fn remove_test_one() { assert_eq!(2, remove_duplicates(&mut vec![1, 1, 2])) } }
true
762e9aa3447dbda479bcfa7766b26f61fb185310
Rust
vtavernier/hyperion.rs
/src/instance/muxer/effect_runner.rs
UTF-8
7,638
2.578125
3
[ "MIT" ]
permissive
use slotmap::SlotMap; use thiserror::Error; use tokio::sync::mpsc; use crate::{ api::json::message::EffectRequest, effects::{self, EffectDefinitionError, EffectRunHandle, RunEffectError}, global::Global, instance::muxer::MuxedMessageData, }; use super::MuxedMessage; #[derive(Debug, Error)] pub enum S...
true
5932efbf4e452a122562e55b3b8327bea051f739
Rust
nilsmartel/pos-in-doc
/src/main.rs
UTF-8
1,109
3.046875
3
[]
no_license
const ERROR: &'static str = "pos-in-doc author: Nils Martel Usage: pos-in-doc <pos> <file> "; fn exit(s: &str) -> ! { eprintln!("{}", s); std::process::exit(1); } fn main() { let mut args = std::env::args().skip(1); let pos = match args.next() { Some(arg) => match arg.parse::<usize>() { ...
true
6fe23cf9997484f108d7a977e91571374f742e1f
Rust
tyranron/deadpool
/src/managed/hooks.rs
UTF-8
1,713
3.296875
3
[ "MIT", "Apache-2.0" ]
permissive
//! This module contains hooks which allow to run code when //! creating and/or recycling objects. use std::fmt; use super::Manager; /// This errors can be returned by hooks which will abort the /// creation and/or recycling of objects. #[derive(Debug)] pub enum HookError<E> { /// The hook failed for some other r...
true
02cf2714f0e811ac43db0a5cf70ea40d9c434aa5
Rust
wschella/rstat
/src/univariate/exponential.rs
UTF-8
2,437
2.890625
3
[ "MIT" ]
permissive
use crate::prelude::*; use ndarray::Array2; use rand::Rng; use spaces::real::PositiveReals; use std::{fmt, ops::Not}; pub use crate::params::Rate; new_dist!(Exponential<Rate<f64>>); macro_rules! get_lambda { ($self:ident) => { ($self.0).0 } } impl Exponential { pub fn new(lambda: f64) -> Result<Exponential,...
true
d4292739103e60de304423b1148bf0c0868334a6
Rust
VeyronSakai/bevy_snake
/src/main.rs
UTF-8
5,122
2.8125
3
[]
no_license
mod snake; mod common; mod food; use bevy::prelude::*; use bevy::render::pass::ClearColor; use bevy::core::FixedTimestep; fn main() { App::build() // ウインドウの生成 .insert_resource(WindowDescriptor { title: "Snake!".to_string(), width: 500.0, height: 500.0, ...
true
9928ab39d788f727caa9a8f929be989c1afda74f
Rust
windoze/tokengen-rs
/src/profile/mod.rs
UTF-8
10,594
2.734375
3
[]
no_license
use std::collections::HashMap; use std::fs::{create_dir_all, File}; use std::process::exit; use chrono::{DateTime, NaiveDateTime, Utc}; use dirs::cache_dir; use reqwest::blocking::{Client, Response}; use serde::{Deserialize, Serialize}; pub use app_profile::AppProfile; pub use user_profile::UserProfile; use crate::p...
true
5dae9bc6ab5b3e09d2fdd66d5cd6409d74d17cbd
Rust
tikv/yatp
/src/queue/single_level.rs
UTF-8
7,224
2.609375
3
[ "Apache-2.0" ]
permissive
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. //! A single level work stealing task queue. //! //! The instant when the task cell is pushed into the queue is recorded //! in the extras. use super::{Pop, TaskCell}; use crossbeam_deque::{Injector, Steal, Stealer, Worker}; use rand::prelude::*; use...
true
04811ca69e45dafcf0bcc46a7216512eaa7011eb
Rust
navinkarkera/overapi
/src/handlers.rs
UTF-8
659
2.875
3
[]
no_license
use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::path::PathBuf; use std::str; #[derive(Debug, Deserialize)] pub struct AppInput { pub arguments: String, pub working_directory: PathBuf, pub env_vars: HashMap<String, String>, } #[derive(Serialize)] pub struct AppOutput { stdo...
true
d20bc4ac2b9904b79c886aef76467477b38337c3
Rust
michaelkirk/rust-geo
/geo/src/algorithm/frechet_distance.rs
UTF-8
4,030
3.578125
4
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::euclidean_distance::EuclideanDistance; use crate::{LineString, Point}; use num_traits::{Float, FromPrimitive}; /// Determine the similarity between two `LineStrings` using the [Frechet distance]. /// /// Based on [Computing Discrete Frechet Distance] by T. Eiter and H. Mannila. /// /// [Frechet distance]: h...
true
0cd9570c3042ed31cfd8e5b042a4bebfedcd3d90
Rust
manhtai/exercism-rust
/parallel-letter-frequency/src/lib.rs
UTF-8
1,439
3.265625
3
[]
no_license
use std::cmp; use std::collections::HashMap; use std::thread; pub fn frequency(input: &[&str], worker_count: usize) -> HashMap<char, usize> { // Init concurrent vec let mut children = vec![]; // Calculate each worker load let str_len = input.len(); if str_len == 0 { return HashMap::new(); ...
true
5582821d3abf03055ff8bc45411902d9739ac9ca
Rust
lizhizhong1992/reconstruct_mito_genome
/mito_assembler/src/bin/whatshap_to_tsv.rs
UTF-8
1,500
2.859375
3
[]
no_license
use bio_utils::fasta; use std::collections::HashMap; fn main() -> std::io::Result<()> { let args: Vec<_> = std::env::args().collect(); let reads: HashMap<String, bool> = fasta::parse_into_vec(&args[1])? .into_iter() .map(|read| { let id = read.id().to_string(); let is_ref...
true
87de4ee9ab46d60ccf52a63b4a8cb5a9f45eee30
Rust
JIghtuse/dailyprogrammer
/rust/graph_node_degrees/src/main.rs
UTF-8
844
3.34375
3
[]
no_license
use std::io; use std::io::prelude::*; fn get_number<T>(stdin: &io::Stdin) -> Option<T> where T: std::str::FromStr { let mut s = String::new(); match stdin.read_line(&mut s) { Err(_) => None, Ok(_) => s.trim().parse::<T>().ok(), } } fn main() { let stdin = io::stdin(); let n: us...
true
9d8384738cc689aae4ddb2683bde0e41b8d944f9
Rust
feifeigd/rust
/hello_actix_web/src/main.rs
UTF-8
1,196
3.046875
3
[]
no_license
mod users; use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder}; #[get("/")] async fn index(data: web::Data<AppState>) -> impl Responder { let app_name = &data.app_name; format!("Hello {app_name}!") } #[post("/echo")] async fn echo(req_body: String) -> impl Responder { HttpResponse::...
true
7619cffff3791df87d1798236cef850f5dd8f195
Rust
sorrowed/Advent-2019
/src/day11/mod.rs
UTF-8
5,217
3.578125
4
[]
no_license
use std::collections::HashMap; use crate::common::*; use crate::cpu::*; #[derive(PartialEq, Copy, Clone)] enum Direction { UP = 0, LEFT = 1, DOWN = 2, RIGHT = 3, } #[derive(PartialEq, Copy, Clone)] enum Color { BLACK = 0, WHITE = 1, } impl Default for Color { fn default() -> Self { ...
true
b16402a001cf7cb8322905c9aaff5ecc22124fec
Rust
hyone/rust-wc
/src/count.rs
UTF-8
3,767
3.359375
3
[]
no_license
use std::ops; use bytecount; pub struct Options { pub bytes: bool, pub chars: bool, pub words: bool, pub lines: bool, } #[derive(Debug, PartialEq)] pub struct CountStat { pub bytes: usize, pub chars: usize, pub words: usize, pub lines: usize, } impl CountStat { pub fn empty() -> C...
true
5f645684c9bcff5100de5454d7429563dd204c7b
Rust
maximbaz/advents-of-code
/src/year2020/day16.rs
UTF-8
3,386
3.359375
3
[ "ISC" ]
permissive
use super::super::*; use regex::Regex; use std::ops::RangeInclusive; pub struct Task; pub type Rule = Vec<RangeInclusive<usize>>; pub type Ticket = Vec<usize>; pub struct Tickets { rules: Vec<Rule>, my: Ticket, nearby: Vec<Ticket>, } impl Solution for Task { type Input = Tickets; type Output = u...
true
ce18a44bfea2824d009e2588ad2fb28280a07a60
Rust
Kixiron/kugelblitz.rs
/src/commands/utils.rs
UTF-8
1,416
2.859375
3
[]
no_license
use serenity::{ client::Context, framework::standard::{Args, CommandError}, model::{channel::Message, id::UserId, user::User}, }; pub fn avatar_url(user: &User) -> String { user.avatar_url() .unwrap_or_else(|| user.default_avatar_url()) } pub fn get_mentioned_user_or_sender( ctx: &Context,...
true
bb4a296f323bab69914d813e6df9bf20f15b5d49
Rust
inferiorhumanorgans/sam3x8e-fork
/src/dmac/ebcimr.rs
UTF-8
14,182
2.609375
3
[]
no_license
#[doc = r" Value read from the register"] pub struct R { bits: u32, } impl super::EBCIMR { #[doc = r" Reads the contents of the register"] #[inline] pub fn read(&self) -> R { R { bits: self.register.get(), } } } #[doc = r" Value of the field"] pub struct BTC0R { bits:...
true
07201b43635ddf9b20dfd8deef63808f0952430d
Rust
cvetelinast/BrickBreaker
/src/gameplay_entities.rs
UTF-8
10,736
2.875
3
[]
no_license
use ggez::graphics; use ggez::mint::{Point2, Vector2}; use ggez::{Context, GameError, GameResult}; use crate::assets::Assets; use crate::math::{circle_collides_rect, Collision}; pub struct GameplayState { pub skateboard: Skateboard, pub bricks_wall: BricksWall, pub ball: Ball, } #[derive(Debug)] pub stru...
true
db071ec8223688b835983caa8269120773385434
Rust
SINHASantos/rust-rocks
/src/persistent_cache.rs
UTF-8
3,000
2.71875
3
[ "Apache-2.0" ]
permissive
//! Persistent cache interface for caching IO pages on a persistent medium. use std::fmt; use std::path::Path; use std::ptr; use std::slice; use std::str; use rocks_sys as ll; use crate::env::{Env, Logger}; use crate::to_raw::ToRaw; use crate::{Error, Result}; /// Persistent cache interface for caching IO pages on ...
true
36588bfc8aaca78ae37a503421202b645baa035b
Rust
marco-c/gecko-dev-comments-removed
/third_party/rust/tokio-stream/tests/stream_fuse.rs
UTF-8
1,109
3.1875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use tokio_stream::{Stream, StreamExt}; use std::pin::Pin; use std::task::{Context, Poll}; struct Alternate { state: i32, } impl Stream for Alternate { type Item = i32; fn poll_next(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Option<i32>> { let val = self.state; self.state +...
true