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
4a6cf30312eb0d896dc13c8a900d0d79636b24ac
Rust
faradayio/geochunk
/src/errors.rs
UTF-8
936
3.046875
3
[]
no_license
//! A module to hold `Error`, etc., types generated by `error-chain`. use csv; use std::io; error_chain! { foreign_links { Csv(csv::Error); Io(io::Error); } errors { NoSuchColumn(name: String) { description("Cannot find specified CSV column") display("No CS...
true
864f1bd413d4db9010d3fc009a18f3d6ad838ac1
Rust
CrackerCat/fuchsia
/src/proc/bin/starnix/fs/tree.rs
UTF-8
6,081
2.609375
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 once_cell::sync::OnceCell; use parking_lot::{RwLock, RwLockUpgradableReadGuard, RwLockWriteGuard}; use std::collections::HashMap; use std::sync::{Arc, W...
true
0ae3d688457c4612c79114d0b777efd85afc7c9f
Rust
mosmeh/uclock
/uclock-cli/src/main.rs
UTF-8
522
2.640625
3
[ "MIT" ]
permissive
use futures::{future, StreamExt}; use std::io::Write; use structopt::StructOpt; use uclock::Color; #[derive(StructOpt)] struct Opt { #[structopt(short, long, default_value = "white")] color: Color, } #[tokio::main] async fn main() { let opt = Opt::from_args(); let out = std::io::stdout(); let mut...
true
f00eaeb7b422851a7323aeb6849294ceff4763ca
Rust
Nanoteck137/nano_os
/kernel/src/lib.rs
UTF-8
3,032
2.625
3
[ "MIT" ]
permissive
#![feature(asm, ptr_internals, panic_info_message)] #![no_std] extern crate rlibc; extern crate multiboot2; extern crate rangeset; use rangeset::{Range, RangeSet}; #[macro_use] mod vga_buffer; mod panic; mod arch; mod memory; #[no_mangle] fn kernel_entry(multiboot_address: usize) -> ! { { // Get the loc...
true
4ea23cbdd3b0d028e40c530c8f2834ab19eb4e6c
Rust
irekf/rusty-csv-diff
/src/main.rs
UTF-8
10,481
2.6875
3
[ "MIT" ]
permissive
extern crate docopt; #[macro_use] extern crate serde_derive; use docopt::Docopt; #[macro_use] extern crate log; use log::{Level, LevelFilter, Metadata, Record}; use std::collections::{HashMap, HashSet}; use std::fs::File; use std::io::{BufRead, BufReader, Seek, SeekFrom}; use std::path::Path; static MY_LOGGER: Simp...
true
b4b7e7f739e15d18bce3852142f0b479596eb89e
Rust
doctorwidget/rust_book_examples
/11_modules/src/main.rs
UTF-8
10,684
3.328125
3
[]
no_license
/** * Rust's module/package system is *very* fully-featured and rich. * It's worth revisiting the rust book chapter, which is chock full of * special-case details, synonyms, tricks and tips. * * https://doc.rust-lang.org/book/ch07-00-packages-crates-and-modules.html * * * Here are a few of the highest-le...
true
b573176b8b1ea52fa18cde04467d6d43bae71e19
Rust
DasEtwas/rapier
/benchmarks3d/joint_ball3.rs
UTF-8
2,164
2.640625
3
[ "Apache-2.0" ]
permissive
use na::Point3; use rapier3d::dynamics::{BallJoint, BodyStatus, JointSet, RigidBodyBuilder, RigidBodySet}; use rapier3d::geometry::{ColliderBuilder, ColliderSet}; use rapier_testbed3d::Testbed; pub fn init_world(testbed: &mut Testbed) { /* * World */ let mut bodies = RigidBodySet::new(); let mut ...
true
be5ceb70a886e10c8bfa216dc8bdf98df199598b
Rust
szabgab/slides
/rust/examples/hashes/split_string_create_hash.rs
UTF-8
654
3.703125
4
[]
no_license
use std::collections::HashMap; fn main() { let text = String::from("apple banana"); println!("The original '{text}'"); let mut data = HashMap::new(); //let parts = text.split(" "); let parts = text.split_whitespace(); // return an iterator //println!("{:?}", parts); //for part in parts {...
true
9b5a4e2eb28bc41c9d1f9b850fc8d2c2e7a12536
Rust
ricardopieper/fdeb-rs
/src/fdeb_utils.rs
UTF-8
4,509
2.90625
3
[]
no_license
use crate::fdeb::*; use std::fs::File; use std::io::prelude::*; use serde::Deserialize; pub fn read_graphml(file: &str) -> (Vec<Vertex2D>, Vec<Edge>) { use roxmltree::*; let mut xml_str = String::new(); File::open(file) .unwrap() .read_to_string(&mut xml_str) .unwrap();...
true
c9d490dedb6ae1a7b2ae7b6f8f46d3daed5ee8c2
Rust
baurls/POI-Extraktion-mit-erweiterter-Area-Centroid-Bestimmung
/Code/Calculation(Rust)/src/centroid_calculation/skeleton_centerpoint/skeleton_graph_generation/mod.rs
UTF-8
15,250
2.703125
3
[]
no_license
/**************************************************************************** * ++ LUKAS BAUR, Bachelorarbeit 2018/2019 ++ * * This module calculates skeleton graphs based on a given triangulation * *****************************************************************************/ extern crate poly2tri; //-------------...
true
9706ffeaddca07f226a109cb66ccd3269923ea73
Rust
TuckerBMorgan/Mars
/src/scene/cube.rs
UTF-8
1,928
3.171875
3
[]
no_license
use crate::scene::{Hitable, MaterialID, HitRecord, HitableID}; use crate::math::Ray; use crate::glam::Vec3; pub struct Cube { center:Vec3, radius: f32, material_id: MaterialID, radius_sqrd: f32, id: HitableID } impl Cube { pub fn new(center:Vec3, radius: f32, material_id: MaterialID) -> Cube ...
true
71232f5da0b1777980a35f963959bca04cb95821
Rust
cdouglass/samara
/src/structures/mod.rs
UTF-8
4,782
3.140625
3
[]
no_license
use std::fmt; use std::fmt::Debug; use std::fmt::Formatter; use std::str::FromStr; pub mod sums; pub mod patterns; use self::Op::*; use self::patterns::Pattern; /* Misc convenience functions */ pub fn arrow(t1: Type, t2: Type) -> Type { Type::Arrow(Box::new(t1), Box::new(t2)) } /* Enums + structs */ #[derive(...
true
9a10dfd58a9d2521d810c332821ef97053d9e49a
Rust
lljxx1/rust-study
/simpleredis/src/cmd/mod.rs
UTF-8
2,178
3.109375
3
[]
no_license
use mini_redis::{Connection, Frame}; use crate::parse::Parse; use crate::Error; // use tracing::{debug, instrument}; use bytes::Bytes; #[derive(Debug)] pub struct Unknown { comand_name: String, } impl Unknown { pub fn new(key: impl ToString) -> Unknown { Unknown { comand_name: key.to_s...
true
8613af0eb5eec6ae106cb6c07f271b5cda598481
Rust
phaylon/textkind
/src/traits.rs
UTF-8
11,078
3.765625
4
[ "MIT" ]
permissive
use std::borrow; use std::rc; use std::sync; /// Value verification trait. /// /// This trait must be implemented for a type for it to act as `Check` type for a `Kind`. /// /// # Examples /// /// Basic usage: /// /// ``` /// extern crate textkind; /// # fn main() { example().expect("no errors") } /// # fn example() -...
true
8806083202149dc83c7b9923ed5fe11c7bd818ed
Rust
xenowing/wideboi
/src/model.rs
UTF-8
4,819
2.734375
3
[]
no_license
use crate::compiler::*; use crate::instructions::*; pub fn model( program: &CompiledProgram, input_stream_bindings: &[&[i32]], uniform_data: &[i32], num_threads: u32, ) -> (Vec<Vec<i32>>, u32) { let instructions = program.instructions.iter().map(|&i| Instruction::decode(i).unwrap()).collect::<Vec<_...
true
3a41b99764e298194b939ecd2dd1fc31f3fdb37f
Rust
trust-rust/rust-ownership
/src/ex08.rs
UTF-8
208
3.421875
3
[ "Apache-2.0", "MIT" ]
permissive
crate fn ex08_mutable_reference() { let mut x = String::from("try to change me"); change_it(&mut x); println!("x is '{}'", x); } fn change_it(x: &mut String) { x.push_str(", fine I will"); }
true
8d65cc837d62d861477503075fa8fca4b2506794
Rust
baghayi/acampaign
/src/commands/mod.rs
UTF-8
2,828
3.78125
4
[]
no_license
use std::collections::HashMap; use std::cmp::PartialEq; #[derive(Debug, PartialEq)] pub enum Error { UndefinedCommand, } pub trait Command { fn name(&self) -> &'static str; fn run(&mut self); } pub struct Commands { list: HashMap<&'static str, Box<dyn Command>>, } impl Commands { pub fn new() ->...
true
32415e01fba4ddccab202fd3803db3f0f7d70769
Rust
tfachmann/clean-snake-wasm
/snake_client/src/lib.rs
UTF-8
34,449
2.578125
3
[]
no_license
use instant::Instant; use lazy_static; use num_traits::Num; use rand::{thread_rng, Rng}; use std::sync::Mutex; use std::{collections::VecDeque, rc::Rc, time::Duration}; use wasm_bindgen::convert::FromWasmAbi; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use web_sys::{ Blob, Document, Element, EventTarget...
true
e16df9591fdc522fed6668b1b2f2b0052b9ae4a3
Rust
VersBinarii/spike
/src/db/user.rs
UTF-8
1,000
2.53125
3
[]
no_license
use actix::prelude::*; use diesel::prelude::*; use crate::db::DbExecutor; use crate::models; use crate::utils::SpikeError; #[derive(Debug)] pub struct FetchUser { pub username: String, } impl Message for FetchUser { type Result = Result<models::User, SpikeError>; } impl Handler<FetchUser> for DbExecutor { ...
true
c8850b3139c9c08469649d7e553935bd438fa85f
Rust
lonski/tgs
/src/thumb.rs
UTF-8
3,569
3.421875
3
[]
no_license
extern crate image; extern crate num_cpus; use self::image::DynamicImage; use self::image::GenericImage; use self::image::FilterType; use std::path::Path; use std::fs::File; use threadpool::ThreadPool; use std::sync::mpsc::channel; /// # Generates thumbnails from given files in parallel. /// /// ## Arguments: /// * f...
true
f8d7d731da49995b38538d7e3d59bec4fbe8401c
Rust
baitcenter/blitz-money
/src/backend/tags.rs
UTF-8
4,732
3.25
3
[ "MIT" ]
permissive
/// /// Blitz Money /// /// Backend of module for manange tags /// /// Copyright 2018 Luis Fernando Batels <luisfbatels@gmail.com> /// use backend::storage::*; use json::JsonValue; #[derive(Default, Clone, Debug)] pub struct Tag { pub uuid: String, pub name: String, } impl Model for Tag { fn new(row: Json...
true
4c1f93c41166b7c589cd809279d85db053c00697
Rust
seandewar/challenge-solutions
/leetcode/easy/sum-of-all-odd-length-subarrays.rs
UTF-8
344
3.15625
3
[]
no_license
// https://leetcode.com/problems/sum-of-all-odd-length-subarrays // // Complexity: runtime O(n^2), space O(1). impl Solution { pub fn sum_odd_length_subarrays(arr: Vec<i32>) -> i32 { (1..=arr.len()) .step_by(2) .map(|n| arr.windows(n).map(|s| s.iter().sum::<i32>()).sum::<i32>()) ...
true
38120c60b0c75fd84862ef5956a28351b2ca6ecb
Rust
Shock-1/teensy4-rs
/imxrt1062-pac/imxrt1062-snvs/src/lpcr.rs
UTF-8
34,178
2.59375
3
[ "Apache-2.0", "MIT" ]
permissive
#[doc = "Reader of register LPCR"] pub type R = crate::R<u32, super::LPCR>; #[doc = "Writer for register LPCR"] pub type W = crate::W<u32, super::LPCR>; #[doc = "Register LPCR `reset()`'s with value 0x20"] impl crate::ResetValue for super::LPCR { type Type = u32; #[inline(always)] fn reset_value() -> Self::...
true
f46e50602c90657ffd03ca1841601640d76b4ef0
Rust
ashigirl96/ice-cube
/examples/pusher/src/main.rs
UTF-8
2,232
3.234375
3
[]
no_license
use iced::{ button, Background, Button, Color, Column, Element, HorizontalAlignment, Row, Sandbox, Settings, Text, Vector, }; fn main() -> iced::Result { Pusher::run(Settings::default()) } struct Pusher { button: button::State, block_size: usize, } #[derive(Debug, Clone)] pub enum Message { P...
true
7923308f31e799cc6d1cd9171d56e25957977b52
Rust
WJackKing/prokaryote
/src/orf/mod.rs
UTF-8
1,698
3.09375
3
[]
no_license
use io::dna_io::Dnaio; pub struct Orf<'a> { dna_io: &'a mut Dnaio, buf: [u8; 4096], start: usize, end: usize, index: usize, } impl<'a> Orf<'a> { pub fn new(dna_io: &mut Dnaio, record_index: usize) -> Result<Orf, &'static str> { let mut buf = [0u8; 4096]; let n = dna_io.read_rec...
true
23c64f040844c470511c01fe17fe07e2761e3301
Rust
Ainevsia/Leetcode-Rust
/782. Transform to Chessboard/src/main.rs
UTF-8
5,944
2.84375
3
[ "BSD-2-Clause" ]
permissive
fn main() { assert_eq!(Solution::moves_to_chessboard( vec![ vec![0,0,1,0,1,0,1,1], vec![1,1,0,1,0,1,0,0], vec![0,0,1,0,1,0,1,1], vec![1,1,0,1,0,1,0,0], vec![1,1,0,1,0,1,0,0], vec![0,0,1,0,1,0,1,1], vec![0,0,1,0,1,0,1,1], vec![1,1,0,1,0,1,0,0]] ...
true
e0279722537142bb6b18c6fbf189fbfb4df35714
Rust
stevenroose/hal
/src/bin/hal/cmd/block.rs
UTF-8
3,961
2.609375
3
[ "CC0-1.0" ]
permissive
use std::io::Write; use bitcoin::consensus::encode::{deserialize, serialize}; use bitcoin::{Block, BlockHeader}; use hal::block::{BlockHeaderInfo, BlockInfo}; use crate::prelude::*; use crate::cmd::tx::create_transaction; pub fn subcommand<'a>() -> clap::App<'a, 'a> { cmd::subcommand_group("block", "manipulate bloc...
true
85517fe4c4da34515aa255aa6099aad5f580750f
Rust
DougLau/mvt
/src/lib.rs
UTF-8
1,757
2.890625
3
[ "Apache-2.0", "MIT" ]
permissive
// lib.rs mvt crate. // // Copyright (c) 2019-2021 Minnesota Department of Transportation // //! A library for encoding [mapbox vector tiles]. //! //! A [tile] is composed of one or more [layer]s. Each layer can have any number //! of [feature]s, which contain the geometry to be rendered. They can also have //!...
true
1e150f2b7c7cbb1cebc79ba1a15fc5dc98c63d9c
Rust
brentward/bwos
/aarch64/src/sp.rs
UTF-8
502
2.71875
3
[]
no_license
pub struct _SP; impl _SP { /// Returns the current stack pointer. #[inline(always)] pub fn get(&self) -> usize { let rtn: usize; unsafe { asm!("mov {}, sp", out(reg) rtn, options(nomem, nostack)); } rtn } /// Set the current stack pointer with an passed a...
true
e2cd7de453febb56ba1c0a346b28ca52a7dce821
Rust
supcmd/identity.rs
/identity-core/src/crypto/key/pair.rs
UTF-8
2,293
3.171875
3
[ "Apache-2.0" ]
permissive
// Copyright 2020-2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 use zeroize::Zeroize; use crate::crypto::KeyRef; use crate::crypto::KeyType; use crate::crypto::PublicKey; use crate::crypto::SecretKey; use crate::error::Result; use crate::utils::generate_ed25519; /// A convenient type for representing a p...
true
91bfe8cd290d801a126a8c22b4bd000625baf81c
Rust
PistonDevelopers/backend
/src/lib.rs
UTF-8
1,504
2.609375
3
[ "MIT" ]
permissive
#![deny(missing_docs)] //! A macro library for backend agnostic design. /// Used to expand items into valid Rust AST. #[macro_export] macro_rules! backend_macro_items { ($($x:item)+) => ($($x)+) } /// Creates a `Backend` and a `OfBackend` trait with associated types. #[macro_export] macro_rules! backend { ($( $x...
true
f5e128be5278e6af4dcbdc920de9234751846df8
Rust
mmmpa/eight_px_uint_eight
/src/eight_px_uint_eight.rs
UTF-8
2,346
2.875
3
[]
no_license
use crate::*; use core::cmp::min; pub trait EightPxUintEight { type EightData: EightData; fn width(&self) -> usize; fn height(&self) -> usize; fn eight_length(&self) -> usize; fn eight_data(&self) -> &Self::EightData; fn eight_data_mut(&mut self) -> &mut Self::EightData; fn draw(&mut self...
true
9e425978741fc419e8541b211c0d20ab9919cfa9
Rust
phaylon/html5-fuser
/src/event.rs
UTF-8
21,627
3
3
[ "MIT" ]
permissive
//! Basic functionality for events and event streams. //! //! Besides some common error definitions, the only item a library user might have to //! interact with is the `IntoStream` trait that is used when content is injected into //! another stream. use std::rc; use std::cell; use std::fmt; use std::error; use std::...
true
ea2bbd2c670eb36496229584d8ea1e2325c460e6
Rust
atsushi130/Cryptor
/src/cryptor/algorithm/base64/base64.rs
UTF-8
917
2.65625
3
[ "MIT", "Apache-2.0" ]
permissive
// Copyright (c) 2017 Atsushi Miyake // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or http://apache.org/licenses/LICENSE-2.0> // or the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // This file may not be copied, modified, or distributed except according to t...
true
3d68aad286567732690b6ba394d402a1d967dc20
Rust
exogress/exogress
/src/config_core/query.rs
UTF-8
9,270
2.703125
3
[ "Apache-2.0" ]
permissive
use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use smol_str::SmolStr; use std::{collections::BTreeMap, fmt}; use regex::Regex; use serde::{ de, de::{IntoDeserializer, SeqAccess, Visitor}, ser::SerializeSeq, Deserializer, Serializer, }; use crate::{ config_core::path::{ANY_SEGMENTS_...
true
4c83c07fa87450afd680cd004a5de46529f89516
Rust
abhishekbasu/abstreet
/game/src/edit/roads.rs
UTF-8
2,559
2.890625
3
[ "Apache-2.0" ]
permissive
use map_gui::tools::PromptInput; use map_model::{Direction, LaneSpec, LaneType, Road}; use widgetry::{EventCtx, State}; use crate::app::{App, Transition}; use crate::edit::apply_map_edits; /// Specify the lane types for a road using a text box. This is a temporary UI to start /// experimenting with widening roads. It...
true
6d6f4fc96f950216df40db3be877a9ddeb4471bd
Rust
Richard70NL/dialogue
/src/tests/test_client.rs
UTF-8
4,038
2.828125
3
[ "MIT" ]
permissive
/************************************************************************************************/ use crate::tests::util::split_line; use rich_lib::lines::*; use std::io::BufRead; use std::io::BufReader; use std::io::BufWriter; use std::io::Write; use std::net::TcpStream; /*******************************************...
true
27ae7efad2534af2fa1f144d73259942b824274c
Rust
yskang/AlgorithmPractice
/baekjoon/rust/two_solution_2470.rs
UTF-8
1,583
2.921875
3
[ "MIT" ]
permissive
// Title: 두 용액 // Link: https://www.acmicpc.net/problem/2470 use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Write}; macro_rules! read_to_tuple { ($buffer:expr, $($t:ty),+) => {{ let mut line = String::new(); let buffer = &mut $buffer; buffer.read_line(&mut line).unwra...
true
b2d9b5ba68d6e5bfcaa3cde7a8209815e8caa2d8
Rust
hamadatakaki/kuragecc
/src/codegen/code.rs
UTF-8
5,965
3.4375
3
[]
no_license
use super::super::operators::Operator; use super::super::types::Type; use super::expression::{AsCode, Expression, Symbol}; #[derive(Debug, Clone)] pub enum Code { // function FuncDefineOpen(Symbol, Vec<Type>), FuncDefineClose, // declare, assign Alloca(Symbol), Store(Expression, Symbol), // (va...
true
6a7a2ce90ad9d973d2e0fee7bcb21e31592478b4
Rust
timxor/cilk
/src/ir/opcode.rs
UTF-8
2,553
3.265625
3
[ "MIT" ]
permissive
use super::{basic_block::*, module::*, types::*, value::*}; use id_arena::*; pub type InstructionId = Id<Instruction>; #[derive(Clone, Debug)] pub struct Instruction { pub opcode: Opcode, pub ty: Type, } #[derive(Clone, Debug)] pub enum Opcode { Alloca(Type), Load(Value), Add(Value, Value), S...
true
1143ad3b3dd6dc45f846cb345f15e16b12433619
Rust
edg-l/teestatus
/src/util.rs
UTF-8
3,587
3.25
3
[ "MIT" ]
permissive
use bytes::{BufMut, BytesMut}; use rand::Rng; #[derive(Debug, PartialEq, Eq)] pub enum PacketType { // Packets sent. GetCount, GetList, GetInfo, GetInfo64Legacy, // Packets received Count, List, Info, Info64Legacy, InfoExtended, InfoExtendedMore, } impl PacketType { ...
true
66541c8537965aca8cb2f3a795eb856d12905ebd
Rust
kammitama5/9_14_16_RustDocumentationworkingthrough
/thirtyfive.rs
UTF-8
227
3.0625
3
[]
no_license
fn main() { let v = vec![1, 2, 3, 4, 5]; // v : Vec<i32> println!("The third element of v is {}", v[2]); let x = vec![0; 10]; // x //vector containing ten zeros println!("The fourth element of x is {}", x[3]); }
true
448ac7094b09d6f7cf9bc0caca6a69ae61e74a46
Rust
redsnapper2006/leetcode-cn
/F/888-fair-candy-swap/main.rs
UTF-8
635
3.25
3
[]
no_license
struct Solution {} use std::collections::HashSet; impl Solution { pub fn fair_candy_swap(a: Vec<i32>, b: Vec<i32>) -> Vec<i32> { let mut suma = 0; let mut sumb = 0; let mut m: HashSet<i32> = HashSet::new(); for i in &a { suma += i; } for i in &b { sumb += i; m.insert(*i); ...
true
dfb6edf7048ac858f500071e6d95a780d9364da6
Rust
disoul/rust-aesgl
/src/support/mod.rs
UTF-8
2,191
2.578125
3
[]
no_license
extern crate glium; use glium::{glutin}; use glium::backend::Facade; use glium::index::PrimitiveType; use std::env; /* pub fn build_display() -> glium::Display { let version = parse_version(); let display = if env::var("GLIUM_HEADLESS_TESTS").is_ok() { glutin::HeadlessRendererBuilder::new(1024, 768)...
true
4bac82fb04fb443437bf2bd15aceaa98293fb7b1
Rust
scutdk/rocky
/src/router.rs
UTF-8
497
2.859375
3
[]
no_license
use std::collections::HashMap; use request::Request; use response::Response; pub struct Router { pub routers: HashMap<String, fn(Request)->Response>, } impl Router { pub fn new() -> Router { let routers: HashMap<String, fn(Request)->Response> = HashMap::new(); Router { routers: routers } }...
true
d93b0239bdd6bd3359f404f639b182a33d61a6a9
Rust
janeshchhabra/dfinity-team-14
/src/tftp-server/examples/server.rs
UTF-8
4,145
2.875
3
[ "MIT" ]
permissive
extern crate env_logger; extern crate getopts; extern crate log; extern crate tftp_server; use getopts::Options; use reqwest::Url; use std::env; use std::fs::File; use std::io::Write; use std::net::SocketAddr; use std::path::PathBuf; use std::str::FromStr; use tftp_server::server::TftpServerBuilder; fn download_urls(...
true
dd788e9f6641859493cbb943df9f8bca73c913a9
Rust
MrHuxu/leetcode150
/rust/src/question_58.rs
UTF-8
971
3.625
4
[]
no_license
struct Solution; impl Solution { pub fn length_of_last_word(s: String) -> i32 { let mut pre_word_len = 0; let mut word_len = 0; for byte in s.as_bytes() { match *byte as char { ' ' => { if word_len != 0 { pre_word_len ...
true
e28db813d0384118d3919b58695d6425273db6a9
Rust
qbit-org-ua/seabattle-judge
/src/board.rs
UTF-8
17,161
2.96875
3
[]
no_license
use std::convert::TryFrom; use futures_util::stream::StreamExt as _; use tokio::codec::FramedRead; use tokio::stream::StreamExt as _; use crate::cells::{GameBoardCell, GameBoardCellState}; use crate::position::Position; use crate::{InvalidInputError, GAME_BOARD_SIZE}; #[derive(Debug, Copy, Clone)] pub enum GameBoard...
true
37d126540868aa8fd3edefffcb177c270519cbf2
Rust
Komdosh/rust-scratch
/src/dispatch.rs
UTF-8
1,481
3.953125
4
[]
no_license
trait Printable { fn format(&self) -> String; } impl Printable for i32 { fn format(&self) -> String { format!("i32: {}", *self) } } impl Printable for String { fn format(&self) -> String { format!("string: {}", *self) } } pub(crate) fn static_dispatch() { fn print_it<T: Print...
true
752391e114b9839f1f7d53ccccb8b52b221494f6
Rust
chinedufn/landon
/blender-armature/src/action/action_keyframes/action_keyframes_serde/serialize.rs
UTF-8
891
2.734375
3
[ "MIT" ]
permissive
use crate::action::action_keyframes::ActionKeyframes; use serde::ser::SerializeSeq; use serde::{Serialize, Serializer}; impl Serialize for ActionKeyframes { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { let mut seq = serializer.serialize_seq(Some(se...
true
a63dce13a991a6fb4b292dcaa02208d51756d236
Rust
Dynisious/curry
/src/curry/curry2.rs
UTF-8
4,044
3.046875
3
[]
no_license
//! Author --- DMorgan //! Last Moddified --- 2021-03-01 use core::ops::CoerceUnsized; /// A curried binary function. /// /// ```rust /// use curry::*; /// /// let f = Curry2(|a, b| a + b); /// assert_eq!(f(1, 2), 3); /// assert_eq!(f(1)(2), 3); /// ``` #[repr(transparent,)] #[derive(PartialEq, Eq, Clone, Copy, D...
true
de51177e98a46459b84db951a476aaa5128d3cbd
Rust
DrMetallius/movie-nexus
/src/byte_range.rs
UTF-8
2,331
2.796875
3
[]
no_license
use nom::{ character::complete::{char, digit1}, bytes::complete::{tag, take_while}, branch::alt, IResult, combinator::{map, map_res, opt, value}, error::{context, ContextError, FromExternalError, ParseError}, multi::{many0_count, separated_list1}, sequence::{preceded, tuple}, }; use std:...
true
f8adcdb514aa9117921af2ab748efdc2594aa17d
Rust
iCodeIN/rayon_croissant
/tests/producer.rs
UTF-8
1,042
2.71875
3
[ "MIT", "Apache-2.0" ]
permissive
extern crate rayon; extern crate rayon_croissant; use rayon::prelude::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator}; use rayon_croissant::ParallelIteratorExt; #[test] fn test_zip_rev() { let ingredients = &["jambon", "beurre", "fromage", "baguette"]; let scores = &[0, 1, 2, 3]; let...
true
c4cd91335fd27b36d86bbfc308ca106460f74622
Rust
utilForever/BOJ
/Rust/9012 - Parenthesis.rs
UTF-8
926
3.65625
4
[ "MIT" ]
permissive
use std::io; fn input_integers() -> Vec<i64> { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); let values: Vec<i64> = s .as_mut_str() .split_whitespace() .map(|s| s.parse().unwrap()) .collect(); values } fn main() { let t = input_integers()[0];...
true
9eb73be3a7da100349efa1322f02d5456de879df
Rust
scotow/advent-of-code
/2016/src/bin/day_07.rs
UTF-8
1,561
2.890625
3
[]
no_license
advent_of_code_2016::main!(); #[derive(Clone, Default, Debug)] struct Ip { outs: Vec<String>, brackets: Vec<String>, } fn generator(input: &str) -> Vec<Ip> { input .lines() .map(|l| { let mut ip = Ip::default(); l.split(&['[', ']'][..]).enumerate().for_each(|(i, p)|...
true
0deb1103abc840c0ab6f01e6d9dd569cdef89e03
Rust
ids1024/rsforth
/src/dictionary.rs
UTF-8
1,984
3.453125
3
[ "MIT" ]
permissive
use crate::builtins::Builtin; use crate::parser::parse; use crate::state::InterpState; use crate::word::Word; use enum_iterator::IntoEnumIterator; use std::collections::HashMap; /// Represents the Forth dictionary, which maps words (Strings) to their /// implementations (the Word type) pub struct Dictionary { item...
true
95c4fc21b2446d6ffbe5cbd456df170b26354734
Rust
saintdev/itad-api
/src/api/game.rs
UTF-8
21,682
3.046875
3
[]
no_license
use std::{borrow::Cow, collections::BTreeSet, fmt::Display}; use derive_builder::Builder; use http::Method; use serde::Serialize; use super::endpoint::Endpoint; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] pub enum IdentifierOptions { Title, } impl IdentifierOptions { fn as_str(&self) -> &'static...
true
4a0e0537063c1c51e34c9fe5815664a682721ea9
Rust
QPC-database/snocat
/snocat/src/util/vtdroppable.rs
UTF-8
6,646
2.8125
3
[ "BSL-1.0", "Apache-2.0", "Unlicense", "MIT", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-generic-cla" ]
permissive
// Copyright (c) Microsoft Corporation. // Licensed under the MIT license OR Apache 2.0 #[repr(C)] pub struct VTDroppable { data: *mut (), drop_vtable: unsafe extern "C" fn(*mut ()), type_id: std::any::TypeId, } unsafe impl Send for VTDroppable {} impl Drop for VTDroppable { fn drop(&mut self) { let data ...
true
5ef550b7e935ac9f5bab244689a7a39a61ef654e
Rust
Raz-Hemo/SpaceWarSupreme
/src/engine/systems/static_mesh.rs
UTF-8
2,714
2.921875
3
[]
no_license
use std::collections::HashMap; use specs::{ReadStorage, Entity, Entities}; use crate::engine::components::{StaticMeshComponent, MouseComponent, TransformComponent}; #[derive(Clone, Copy)] pub struct MeshInstance { pub world_matrix: [[f32; 4]; 4], pub entity: u32, } glium::implement_vertex!(MeshInstance, world_...
true
3617fe3bc932f137dd4562bee4174518fdeafb24
Rust
zhuzhenping/ctp-rs
/ctp-trader/examples/password_update.rs
UTF-8
3,263
2.515625
3
[]
no_license
use ctp_trader::*; use serde::Deserialize; use simple_error::{try_with, SimpleResult}; #[derive(Deserialize)] #[derive(Clone, Debug, PartialEq, Eq)] pub struct Config { pub trader_front: String, pub broker_id: String, pub user_id: String, pub old_password: String, pub new_password: String, pub ...
true
a189bc490808c1eaf936d6cb04eea2233f4d967a
Rust
TGElder/rust
/pioneer/src/single_downhill_map.rs
UTF-8
2,705
3.0625
3
[]
no_license
use commons::*; use downhill_map::DownhillMap; use rand::prelude::*; pub trait SingleDownhillMap { fn get_direction(&self, x: i32, y: i32) -> usize; } pub struct MockDownhillMap { directions: Vec<Vec<usize>>, } impl MockDownhillMap { pub fn new(directions: Vec<Vec<usize>>) -> MockDownhillMap { Mo...
true
443b45b0f21ab7353138ff31ea99fff91652715d
Rust
mitsuhiko/minijinja
/minijinja/src/output.rs
UTF-8
5,073
3.34375
3
[ "Apache-2.0" ]
permissive
use std::{fmt, io}; use crate::error::{Error, ErrorKind}; use crate::utils::AutoEscape; use crate::value::Value; /// How should output be captured? #[derive(Debug, Clone, Copy, Eq, PartialEq)] #[cfg_attr(feature = "unstable_machinery_serde", derive(serde::Serialize))] pub enum CaptureMode { Capture, #[allow(u...
true
faad0313df997fd73219f7b86dd94cfffba55d30
Rust
burakbayramli/books
/Practical_System_Programming_for_Rust_Developers_Eshwarla/Chapter04/miscellaneous/snippet3.rs
UTF-8
183
2.640625
3
[ "MIT" ]
permissive
use std::thread::sleep; use std::time::{Duration, Instant}; fn main() { let now = Instant::now(); sleep(Duration::new(3, 0)); println!("{:?}", now.elapsed().as_secs()); }
true
a14843d9e54cf75d6c149c251dcfcef4a2294fe7
Rust
geom3trik/tooro-editor
/src/ui/multi/fx.rs
UTF-8
2,644
2.5625
3
[ "MIT" ]
permissive
//! Section containing the multi fx parameters use iced::{pick_list, slider, Column, Container, Element, Text}; use crate::messages::Message; use crate::params::{GetValue, MultiParameter, MultiParameterValues}; use crate::ui::elements::{ fx_mode_list::{fx_mode_list, FXMode}, slider::multi_slider_with_labels, ...
true
138628708d07396697953d2197e9da17a36a8037
Rust
jaketarnow/schema_registry_converter
/src/schema_registry.rs
UTF-8
19,248
2.875
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
//! This module contains the code specific for the schema registry. use avro_rs::Schema; use core::fmt; use curl::easy::{Easy2, Handler, List, WriteError}; use serde_json::{Map as JsonMap, Value as JsonValue}; use std::error::Error; use std::fmt::Display; use std::ops::Deref; use std::str; use url::Url; /// Because w...
true
712e1fb34dc856443ab893f0a09eedb959159fa5
Rust
hotelzululima/zebra
/zebra-network/src/config.rs
UTF-8
2,485
2.96875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::{ collections::HashSet, net::{SocketAddr, ToSocketAddrs}, string::String, time::Duration, }; use zebra_chain::parameters::Network; /// Configuration for networking code. #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(deny_unknown_fields, default)] pub struct Config { /// The addr...
true
aa290b18780331d24d043f64c89f515797a1da9e
Rust
veltzer/demos-rust
/src/multi_threading/simple.rs
UTF-8
706
3.515625
4
[ "Apache-2.0" ]
permissive
// This is a simple exapmle of multh-threading in rust // you usually want to join your threads and not leave them // in a detached state. use std::thread; use std::time::Duration; fn print_type_of<T>(_: &T) { println!("{}", std::any::type_name::<T>()) } fn do_thread() { for i in 1..10 { println!("hi...
true
e93701ae89a0b9aedcd138d0d3c89befcbd799a5
Rust
hobofan/nmr-contours
/src/main.rs
UTF-8
2,887
2.5625
3
[]
no_license
use contour::ContourBuilder; use palette::Srgb; use palette::{ named::{BLACK, WHITE}, Gradient, }; use plotters::prelude::*; use ucsf_nmr::UcsfFile; fn single_contour(polygon: &Vec<Vec<Vec<f64>>>) -> Vec<(i32, i32)> { polygon[0] .clone() .into_iter() .map(|n| ((n[0] * 2f64) as i32, ...
true
a425baf63d29984e32ad82da15eb8dd435cc9a55
Rust
jeffreyrosenbluth/flock
/src/boid.rs
UTF-8
3,014
3.015625
3
[]
no_license
use crate::quadtree::*; use nannou::prelude::*; pub const MAXFORCE: f32 = 0.06; pub const MAXSPEED: f32 = 2.5; pub const ZERO2: Vector2 = Vector2 { x: 0.0, y: 0.0 }; #[derive(Clone, PartialEq)] pub(crate) struct Boid { pub position: Point2, pub velocity: Vector2, pub acceleration: Vector2, pub highlig...
true
7030fe778ad6fbe2ccc4ab3d84430ff17e5bf20e
Rust
glechelon/exhaustMeServerRust
/src/users/user_repository.rs
UTF-8
1,180
2.875
3
[]
no_license
use super::user::User; use sqlx::mysql::MySqlDone; use sqlx::{query, query_as, Error, MySql, Pool}; #[derive(Clone)] pub struct UserRepository{ pub db_pool : Box<Pool<MySql>> } impl UserRepository{ pub async fn get_user(&self, id: &str) -> Result<User, Error> { query_as::<_, User>("SELECT * FROM USERS WHERE...
true
aa6c67c700081f7afba83930c4f91e894c1c3601
Rust
fisherdarling/nfamatch-rs
/nfamatch/src/row.rs
UTF-8
2,395
3.515625
4
[]
no_license
use log::*; #[derive(Debug, Default)] pub struct Row { accepting_state: bool, from_id: usize, to_id: usize, transitions: Vec<char>, } impl Row { fn new(accepting_state: bool, from_id: usize, to_id: usize, transitions: Vec<char>) -> Self { Self { accepting_state, fro...
true
4fdc7513f32e964d5f234bb1417dedbfba1b6e4f
Rust
starcrossedRadio/ClearVM
/src/vm/opcodes.rs
UTF-8
2,648
3.4375
3
[ "MIT" ]
permissive
#[derive(Copy, Clone, Debug, PartialEq)] pub enum OpCode{ Halt, Add, Sub, Mult, Div, Xor, Or, And, Shl, Shr, Mov, MovImediate, Push, PushImediate, Pop, LoadMemory, LoadMemoryImediate, LoadData, LoadDataImediate, LoadOffset, Jmp, Cmp...
true
d769db0d28c5afd7202e2a34acda0718a72cdfe5
Rust
not-much-io/distrunner
/distrunner/src/process/mod.rs
UTF-8
2,550
3.1875
3
[]
no_license
use std::process::{Child, Command, Stdio}; use anyhow::{anyhow, Result}; pub enum Process { LocalProcess { cmd: Command, }, LocalDockerProcesss { cmd: String, container: String, }, RemoteProcess {}, RemoteDockerProcess {}, } impl Process { pub fn new_local(cm...
true
7e88e7479c96c6c90efa3c8179108289e561ecfb
Rust
ktmckean/adventofcode2020
/day10/src/main.rs
UTF-8
4,029
3.296875
3
[]
no_license
#![allow(non_snake_case)] use std::fs::File; use std::io::{BufReader, BufRead}; use std::vec::Vec; // use std::collections::HashSet; // use std::collections::HashMap; fn readLines(path :&str) -> std::vec::Vec<String>{ let file = File::open(path); let file = match file { Ok(file) => file, Err(e...
true
3eea3b5c9240bf66b892a29877f1ab82701d4db9
Rust
Pandinosaurus/point_cloud_viewer
/sdl_viewer/src/terrain_drawer/layer.rs
UTF-8
8,654
2.6875
3
[ "Apache-2.0" ]
permissive
use crate::graphic::tiled_texture_loader::TiledTextureLoader; use crate::graphic::{GlMovingWindowTexture, GlProgram, GlUniform}; use crate::terrain_drawer::read_write::Metadata; use image::{ImageBuffer, LumaA, Rgba}; use nalgebra::{Isometry3, Matrix4, Point3, Vector2, Vector3}; use std::convert::TryInto; use std::io; u...
true
b1ebebb1257a7018a1d990b1e0b2d53cfe33d54c
Rust
ykafia/la-rete-rs
/src/json/js_value_heq/js_value_eq.rs
UTF-8
3,831
3.3125
3
[ "MIT" ]
permissive
use json_utils::json::JsMap; use json_utils::json::JsValue; pub fn js_value_eq(left: &JsValue, right: &JsValue) -> bool { match (left, right) { (JsValue::Null, JsValue::Null) => true, (JsValue::Bool(left), JsValue::Bool(right)) => left == right, (JsValue::String(left), JsValue::String(right...
true
72ea59640595e19a7b6406b25ba0a0e732f2f6e4
Rust
KeenS/nslfmt
/src/parser.rs
UTF-8
11,771
3
3
[ "MIT" ]
permissive
use lexer::*; use token::*; use ast::*; #[derive(Debug, Clone, PartialEq)] pub enum ASTError { EndOfProgram, UnExpectedToken, } pub struct Parser<'a> { lexer: &'a mut Lexer<'a>, } impl<'a> Parser<'a> { pub fn new(lexer: &'a mut Lexer<'a>) -> Parser<'a> { Parser { lexer: lexer, ...
true
3cdf2396ebb00e6a17a13f6adcc66d5d0f7e0a1e
Rust
Byron/gitoxide
/gix-filter/tests/ident/mod.rs
UTF-8
3,331
3.09375
3
[ "MIT", "Apache-2.0" ]
permissive
mod undo { use bstr::{ByteSlice, B}; #[test] fn no_id_changes_nothing() { let mut buf = Vec::new(); let changed = gix_filter::ident::undo(B("hello"), &mut buf); assert!(!changed, "the buffer is not touched"); assert_eq!(buf.len(), 0); } #[test] fn empty() { ...
true
310ac228b7f1f9c331cfe27c6500215e31ab0ead
Rust
milesmcc/turtle-lang
/src/spec/mod.rs
UTF-8
1,732
2.71875
3
[ "MIT" ]
permissive
use crate::{parse, CallSnapshot, Environment, Exception, Expression}; use crate::Locker; fn exec(code: &str) -> Result<Expression, Exception> { let root = Locker::new(Environment::root()); let expressions = parse(code, "<test module>")?; let mut ret = Expression::nil(); for expression in expressions {...
true
edd9070997ab0400eeacd8aee4f0e45d559cd1c7
Rust
makers-for-life/makair-control-ui
/src/chip/settings/mod.rs
UTF-8
3,755
2.640625
3
[ "Unlicense", "LicenseRef-scancode-public-domain" ]
permissive
// MakAir Control UI // // Copyright: 2020, Makers For Life // License: Public Domain License #[macro_use] mod macros; pub mod advanced; pub mod end_of_line; pub mod mode; pub mod preset; pub mod run; pub mod snooze; use std::ops::RangeInclusive; use makair_telemetry::control::{ControlMessage, ControlSetting}; use...
true
390c365b6b48fb5a2b70c42ecd4fe74927d6b080
Rust
eyeplum/rust-unic
/unic/emoji/char/src/emoji_presentation.rs
UTF-8
4,693
2.765625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2017 The UNIC Project Developers. // // See the COPYRIGHT file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, a...
true
d6c8fa4b34567920e92fd3944d43300918810d8d
Rust
iotanbo/rust_playground
/BASICS/r03_ofbook/src/iterators.rs
UTF-8
485
2.890625
3
[ "MIT" ]
permissive
// https://doc.rust-lang.org/book/ch13-02-iterators.html // * all iterators implement a trait named Iterator // pub trait Iterator { // type Item; // <= associated type definition // fn next(&mut self) -> Option<Self::Item>; // // methods with default implementations elided // } fn basic_iterator_...
true
5d1a54608e614cd24729859339af7f1aabd70d2b
Rust
Karuma303/rs_sdf
/tests/distance.rs
UTF-8
3,819
2.828125
3
[ "Apache-2.0" ]
permissive
#[cfg(test)] mod tests { use rs_sdf::data::{Cell, CellLayer, CellPosition}; use rs_sdf::distance::cartesian::CartesianDistance; use rs_sdf::distance::chebyshev::ChebyshevDistance; use rs_sdf::distance::euclid::{EuclideanDistance, EuclideanDistanceSquared}; use rs_sdf::distance::nearest_cell::{NearestCellPosition, ...
true
b2d1045689973aa789859e706a145809d472ebe7
Rust
corvinux/formicarium
/src/entity/grid.rs
UTF-8
2,110
2.75
3
[ "MIT" ]
permissive
use ggez::graphics; use semeion::*; use crate::{entity, game}; /// A static grid of squared cells. pub struct Grid<'e> { id: entity::Id, context: &'e game::Context, } impl<'e> Grid<'e> { /// Constructs a new Grid. pub fn new(context: &'e game::Context) -> Box<Self> { let id = context.unique_i...
true
0da233863062681e93b0dea6f496df3d2a473b76
Rust
JVehaun/gb-emu
/src/tests.rs
UTF-8
638
2.609375
3
[ "MIT" ]
permissive
use std::fs::File; use std::io::prelude::*; use crate::gb::GB; // #[test] // fn load_app_rom_only() { // let mut gb = gb::GB::new(); // if !gb.load_application(&args[1]){ // panic!("failed load rom"); // } // let mut file = File::open("tetris.gb").expect("File error"); // let fsize = file...
true
50bf23c728530fdaff890146a61a9074cf1decbf
Rust
SatioO/rust-practices
/src/match.rs
UTF-8
1,663
3.828125
4
[]
no_license
#![allow(dead_code)] #[derive(Debug)] enum Direction { Up(Point), Down(Point), Right(Point), Left(Point), } impl Direction { fn match_direction(&self) -> &Point { match self { Direction::Up(point) => point, Direction::Down(point) => point, Direction::Rig...
true
dee997033163a0eeb24407f61dc67d6a5edbd371
Rust
cechmanek/learning-rust
/packages/restaurant/src/lib.rs
UTF-8
1,729
3.375
3
[]
no_license
mod front_of_house; // implementation of front_of_house module is is 'front_of_house.rs' mod back_of_house; fn eat_at_restuarant() { // call function of module by specifying absolute path crate::front_of_house::hosting::add_to_waitlist(); // call function by specifying relative path front_of_house::h...
true
ee20a8e8e714676d6a36f7c58bf2f649ec1be07f
Rust
caibirdme/leetcode_rust
/src/prob_5232.rs
UTF-8
3,462
3.328125
3
[ "MIT" ]
permissive
use std::cmp::min; macro_rules! idx { ($i: expr) => { (match $i as char { 'Q' => 0, 'W' => 1, 'E' => 2, 'R' => 3, _ => unreachable!(), }) as usize }; } impl Solution { pub fn balanced_string(s: String) -> i32 { let n = s.len(); ...
true
5df302cec8184774f1dbd8b08136dcc80c7232f6
Rust
RobJenks/advent-of-code
/2020/rust/src/day16/mod.rs
UTF-8
6,702
2.734375
3
[]
no_license
mod criteria; mod ticket; use super::common; use crate::day16::criteria::{Criteria, FieldCriteria, InclusiveRange}; use itertools::Itertools; use crate::day16::ticket::Ticket; use std::collections::HashSet; use crate::common::nvec::Vec3; pub fn run() { println!("Part 1 result: {}", part1()); println...
true
5149034ed0e8a06c4d0f0fbcf31828fc9a5823ac
Rust
will07c5/cryptopals-rs
/src/bin/c22.rs
UTF-8
866
2.640625
3
[]
no_license
extern crate common; extern crate rand; use std::time::{SystemTime, UNIX_EPOCH}; use common::mtrng::MTRNG; use rand::Rng; fn main() { let start = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(); println!("Start time: {}", start); let mut rng = MTRNG::new(start as u32); let wait_time...
true
276e39b00619609fc57bb55dc55231492ee8357e
Rust
jabcross/My-CtCI-Solutions
/rust/src/chapter_17/ex17_09.rs
UTF-8
914
3.625
4
[]
no_license
// 17.9 Kth Multiple // Set + heap, add 3x, 5x, 7x every iteration. O(nlogn) time, O(n) extra space. use std::collections::HashSet; use std::collections::BinaryHeap; fn kth_multiple(index: usize) -> usize { if index == 0 { return 1; } let mut ordered = vec![]; let mut heap = BinaryHeap::new...
true
759e195c7ea2f63cfb3c7f8c306d2ee1f9c39a8f
Rust
Wattyyy/LeetCode
/submissions/trapping-rain-water/solution.rs
UTF-8
1,131
2.78125
3
[ "MIT" ]
permissive
impl Solution { pub fn trap(height: Vec<i32>) -> i32 { let N = height.len(); if N == 0 { return 0 } let mut water = vec![0; N]; let mut l_idx = 0; let mut st = 0; let mut l_height = 0; for i in 0..N { ...
true
1a422220b66eb2389d3c40b979ffcf4f63d295f2
Rust
metajack/diem-devtools
/quick-junit/src/report.rs
UTF-8
20,703
2.953125
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright (c) The diem-devtools Contributors // SPDX-License-Identifier: MIT OR Apache-2.0 use crate::serialize::serialize_report; use chrono::{DateTime, FixedOffset}; use indexmap::map::IndexMap; use std::{borrow::Cow, io, iter, time::Duration}; /// The root element of a JUnit report. #[derive(Clone, Debug)] pub ...
true
4ee882f1924e6173a73f9b2f6e8bc078ef32aab0
Rust
indutny/bulk-gcd
/src/lib.rs
UTF-8
6,277
3.46875
3
[ "MIT" ]
permissive
//! # bulk-gcd //! //! This crate computes GCD of each integer in moduli list with the product of //! all integers in the same list using [fast algorithm][bernstein] by //! D. Bernstein. //! //! See: [this paper][that paper] for more details and motivation. //! //! Usage example: //! ```rust //! extern crate bulk_gcd; ...
true
25cc18abe12e64c43eedcaf94fed0e3f86f65bc5
Rust
AngryLawyer/rust-sdl2-engine-helpers
/src/event_bus.rs
UTF-8
413
3.3125
3
[ "MIT" ]
permissive
pub struct EventBus<T> { items: Vec<T> } impl<T> EventBus<T> { pub fn new() -> EventBus<T> { EventBus { items: vec![] } } pub fn enqueue(&mut self, event: T) { self.items.push(event); } pub fn next(&mut self) -> Option<T> { if self.items.is_empty() ...
true
4bc02f2da52e2d4e801553d6a3911c7b406d3d7f
Rust
butla/experiments
/practice/rust_scratchpad/src/main.rs
UTF-8
766
3.53125
4
[ "MIT" ]
permissive
use std::cmp::Ordering; use std::io; fn main() { loop { println!("Put a word in!"); let mut word = String::new(); io::stdin().read_line(&mut word).expect("Put a word in!"); let word = word.trim(); let word_to_compare = "kaczka"; let outcome = match word_to_compare....
true
64090481bbba373aa87a8b321fc9548184e5ce79
Rust
raimundomartins/forum
/src/lib.rs
UTF-8
1,806
3.0625
3
[]
no_license
use std::collections::HashMap; use tokio::sync::{mpsc, watch}; pub mod fanout; use fanout::FanOut; pub struct Forum { backpressure: usize, topics: HashMap<core::any::TypeId, Box<dyn core::any::Any>>, } impl Forum { pub fn new(backpressure: usize) -> Self { Self { backpressure, ...
true
1ba4b8fcf05ec6e33ada21a0c54696bd7644d097
Rust
jussiniinikoski/wasm-pdf
/crates/wasm-pdf-gen/src/pdf/models.rs
UTF-8
20,188
3.1875
3
[ "MIT", "Apache-2.0" ]
permissive
#![allow(dead_code)] use super::canvas::Canvas; use super::font::{get_font, Font}; use super::styles::{CellStyle, Color, ImageStyle, ParagraphStyle, PathStyle, TableStyle}; use super::text::TextSpan; use super::units::Point; use super::json::{ get_bool_from_js, get_number_from_js, get_text_from_js, JsContent, JsDo...
true
f87d12edddf2a21b01082d3be2ddf87593c92403
Rust
emirayka/nia_interpreter_core
/src/interpreter/stdlib/builtin_objects/list/reverse.rs
UTF-8
2,375
3.359375
3
[ "MIT" ]
permissive
use crate::interpreter::environment::EnvironmentId; use crate::interpreter::error::Error; use crate::interpreter::interpreter::Interpreter; use crate::interpreter::value::Value; use crate::interpreter::library; pub fn reverse( interpreter: &mut Interpreter, _environment: EnvironmentId, values: Vec<Value>,...
true
6f3e1e4beff64a7a624b370bfa004ef438aea29f
Rust
jkaessens/TheVault
/src/samplesheet.rs
UTF-8
16,669
3
3
[]
no_license
//! This module contains tools to build sample sheets from lists of samples, //! and to export sample sheets to ARResT-compatible formats. use std::{collections::HashMap, convert::TryInto, fs::File, io::Write, path::{Path, PathBuf}}; use std::error::Error; use crate::{models, vaultdb::MatchStatus}; use calamine::{Re...
true