text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: manojgop/sawtooth-poet path: /core/src/service.rs * 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 re...
code_fim
hard
{ "lang": "rust", "repo": "manojgop/sawtooth-poet", "path": "/core/src/service.rs", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|> let correlation_id = msg.take_correlation_id(); let mut msg = Message::new(); msg.set_message_type(response_type); msg.set_correlation_id(correlation_id); msg.set_content(response.write_to_bytes().unwrap()); socket .send_multipart(&[&connection_i...
code_fim
hard
{ "lang": "rust", "repo": "manojgop/sawtooth-poet", "path": "/core/src/service.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_prefix|>// repo: manojgop/sawtooth-poet path: /core/src/service.rs ensed 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...
code_fim
hard
{ "lang": "rust", "repo": "manojgop/sawtooth-poet", "path": "/core/src/service.rs", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|> // input is not standarized, hack an early return if it is just 0 ada if rewards_str.starts_with("0 ada") { return Ok(0); } sscanf::scanf!(rewards_str.trim_end(), "${} in ada", String) // trim all . or , in between numbers .map(|mut s: String| { s.retain...
code_fim
hard
{ "lang": "rust", "repo": "QuasarChains/catalyst-toolbox", "path": "/src/ideascale/models/de.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: QuasarChains/catalyst-toolbox path: /src/ideascale/models/de.rs use serde::de::Error; use serde::{Deserialize, Deserializer}; use std::fmt::{Display, Formatter}; #[derive(Debug, Deserialize, Clone, Ord, PartialOrd, Eq, PartialEq)] pub struct AdaRewards(#[serde(deserialize_with = "deserialize_re...
code_fim
hard
{ "lang": "rust", "repo": "QuasarChains/catalyst-toolbox", "path": "/src/ideascale/models/de.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let rewards_str = String::deserialize(deserializer)?; // input is not standarized, hack an early return if it is just 0 ada if rewards_str.starts_with("0 ada") { return Ok(0); } sscanf::scanf!(rewards_str.trim_end(), "${} in ada", String) // trim all . or , in between ...
code_fim
hard
{ "lang": "rust", "repo": "QuasarChains/catalyst-toolbox", "path": "/src/ideascale/models/de.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn simple_hashin() { // Here we're mapping menu items to prices in dollars let mut map = HashMap::new(); map.insert("Eggs on Toast".to_string(), 6); map.insert("Bowl of Cereal".to_string(), 4); map.insert("Broken Glass".to_string(), 2); map.insert("Alec Baldwin".to_string(), 3); ...
code_fim
hard
{ "lang": "rust", "repo": "adeck/rusty-sandbox", "path": "/book/chapters/08/hashmaps/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adeck/rusty-sandbox path: /book/chapters/08/hashmaps/src/main.rs use std::collections::HashMap; fn main() { simple_hashin(); zippin_tuples(); iteratin(); } fn iteratin() { let line = "we like things like that"; let mut word_count = HashMap::new(); for word in line.spli...
code_fim
hard
{ "lang": "rust", "repo": "adeck/rusty-sandbox", "path": "/book/chapters/08/hashmaps/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mapbased/html-parser path: /tests/websites.rs use html_parser::Dom; use indoc::indoc; #[test] fn it_can_parse_simple() { let html = indoc!( r#" <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> ...
code_fim
hard
{ "lang": "rust", "repo": "mapbased/html-parser", "path": "/tests/websites.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[ignore] #[test] fn it_can_parse_nytimes() { let resp = reqwest::blocking::get("https://www.nytimes.com/") .unwrap() .text() .unwrap(); assert!(Dom::parse(&resp).is_ok()); } #[ignore] #[test] fn it_can_parse_wikipedia() { let resp = reqwest::blocking::get("https://en....
code_fim
hard
{ "lang": "rust", "repo": "mapbased/html-parser", "path": "/tests/websites.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Serialize)] struct ProductCsvExport { id: String, active: String, name: String, stock: Option<u32>, price: f64, price_cost: Option<f64>, vendor_name: String, description: String, category: String, subcategory: String, picture1: String, pictur...
code_fim
hard
{ "lang": "rust", "repo": "giggio/iluria-export", "path": "/src/exporter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: giggio/iluria-export path: /src/exporter.rs use serde::Serialize; use std::fs; pub fn save_enriched_products_to_file( products: Vec<crate::run::Product>, products_file: Option<String>, variations_file: Option<String>, ) -> Result<(), String> { let mut i: u32 = 0; let (produc...
code_fim
hard
{ "lang": "rust", "repo": "giggio/iluria-export", "path": "/src/exporter.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let benchmark_result = benchmark.start().await; if benchmark_result.is_success() { log::info!( "Success / Score: {} ({} - {})", benchmark_result.total_score(), benchmark_result.total_gain(), benchmark_result.total_lose() ); ...
code_fim
hard
{ "lang": "rust", "repo": "yukihir0/bench_rs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yukihir0/bench_rs path: /src/main.rs extern crate bench_rs; #[macro_use] extern crate clap; extern crate crossbeam_channel; extern crate env_logger; use anyhow::Result; use async_std; use bench_rs::agent::*; use bench_rs::benchmark::scenario::*; use bench_rs::benchmark::step::*; use bench_rs::b...
code_fim
hard
{ "lang": "rust", "repo": "yukihir0/bench_rs", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut load_scenario2 = BenchmarkScenario::new("load_scenario2"); load_scenario2.add_benchmark_step(load_step); let mut validation_scenario = BenchmarkScenario::new("validation_scenario"); validation_scenario.add_benchmark_step(validation_step); let mut benchmark = Benchmark::new(ag...
code_fim
hard
{ "lang": "rust", "repo": "yukihir0/bench_rs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let initial_isometry = na::Isometry3::identity(); Ok(Dice { transform: initial_isometry, texture, texture_normals, program, material: p_material, buffers: Buffers::new(gl, &mesh), debug_tangent_no...
code_fim
hard
{ "lang": "rust", "repo": "rexhent/rust-and-opengl-lessons", "path": "/lesson-23-x/src/dices/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn update(&mut self, _delta: f32) { loop { let action = self .selectable_aabb .as_ref() .and_then(|s| s.drain_pending_action()); match action { Some(selection::Action::Click) => { ...
code_fim
hard
{ "lang": "rust", "repo": "rexhent/rust-and-opengl-lessons", "path": "/lesson-23-x/src/dices/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rexhent/rust-and-opengl-lessons path: /lesson-23-x/src/dices/mod.rs use failure; use gl; use nalgebra as na; use crate::render_gl::{self, DebugLines}; use crate::resources::Resources; use crate::selection::{self, SelectableAABB, Selectables}; mod buffers; mod dice_material; use self:...
code_fim
hard
{ "lang": "rust", "repo": "rexhent/rust-and-opengl-lessons", "path": "/lesson-23-x/src/dices/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if md.is_dir() { let logs = fs::read_dir(file).unwrap(); rwritedir(zip, logs); }else{ zip.start_file(file, options).expect("not file"); } } }<|fim_prefix|>// repo: garebareDA/zip path: /src/main.rs use zip::write::FileOptions; use std::fs::m...
code_fim
hard
{ "lang": "rust", "repo": "garebareDA/zip", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: garebareDA/zip path: /src/main.rs use zip::write::FileOptions; use std::fs::metadata; use std::fs; extern crate zip; fn main() { std::process::exit(start()); } fn start() -> i32 { let args: Vec<_> = std::env::args().collect(); if args.len() < 2 { println!("Usage: {} <filen...
code_fim
medium
{ "lang": "rust", "repo": "garebareDA/zip", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> zip.add_directory(filepath, options)?; rwritedir(& mut zip, logs); zip.finish()?; Ok(()) } fn rwritedir(zip: & mut zip::ZipWriter<std::fs::File>, logs: std::fs::ReadDir) { let options = FileOptions::default().compression_method(zip::CompressionMethod::Stored).unix_permissions(0o755); ...
code_fim
hard
{ "lang": "rust", "repo": "garebareDA/zip", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} /// Command marker trait to indicate it has associated input to be sent to the SCSI device. pub trait Input { } /// Command marker trait to indicate it has associated output to be received from the SCSI device. pub trait Output { } /// Command marker trait to indicate it has no associated input or ou...
code_fim
hard
{ "lang": "rust", "repo": "adisney3000/Rust-SCSI", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adisney3000/Rust-SCSI path: /src/lib.rs //#![warn(missing_docs)] /*! Abstraction layer for issuing commands through the Linux [`SG_IO`] interface. Users will still need to understand the SCSI standard to know how to setup Command Descriptor Blocks (CDB) and get the desired results. # Usage Ge...
code_fim
hard
{ "lang": "rust", "repo": "adisney3000/Rust-SCSI", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cscheid/loom path: /src/phong.rs // "phong": this is just a disgusting approximation to a glossy material // glossiness: 0 is metal // 1 is lambertian use material::*; use vector::Vec3; use vector; use ray::Ray; use hitable::*; use sampling; <|fim_suffix|> // lambertian ...
code_fim
hard
{ "lang": "rust", "repo": "cscheid/loom", "path": "/src/phong.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn is_emitter(&self) -> bool { false } } impl Phong { pub fn new(albedo: &Vec3, glossiness: f64) -> Box<Material> { Box::new(Phong { albedo: *albedo, glossiness: glossiness }) } }<|fim_prefix|>// repo: cscheid/loom path: /src/phong.rs // "phong": this ...
code_fim
hard
{ "lang": "rust", "repo": "cscheid/loom", "path": "/src/phong.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: santokalayil/karaoke-rs path: /frontend/src/agents/api.rs use crate::{ agents::toast::{Msg as ToastAgentMsg, ToastAgent}, components::toast::{ToastBody, ToastStatus}, model::{ApiResponse, Artist, Config, DataType, PostSong, RequestParams, Song}, }; use anyhow::{format_err, Error}; us...
code_fim
hard
{ "lang": "rust", "repo": "santokalayil/karaoke-rs", "path": "/frontend/src/agents/api.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn fetch_file( &mut self, who: HandlerId, request_type: RequestType, file_name: String, ) -> fetch::FetchTask { let callback = self.link .callback(move |response: fetch::Response<Result<Vec<u8>, Error>>| { let ...
code_fim
hard
{ "lang": "rust", "repo": "santokalayil/karaoke-rs", "path": "/frontend/src/agents/api.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, who: HandlerId, request_type: RequestType, file_name: String, ) -> fetch::FetchTask { let callback = self.link .callback(move |response: fetch::Response<Result<Vec<u8>, Error>>| { let (parts, body) = res...
code_fim
hard
{ "lang": "rust", "repo": "santokalayil/karaoke-rs", "path": "/frontend/src/agents/api.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brandonedens/stm32l4x6 path: /src/adc123_common/csr.rs (&self) -> bool { self.bits } #[doc = r" Returns `true` if the bit is clear (0)"] #[inline] pub fn bit_is_clear(&self) -> bool { !self.bit() } #[doc = r" Returns `true` if the bit is set (1)"] ...
code_fim
hard
{ "lang": "rust", "repo": "brandonedens/stm32l4x6", "path": "/src/adc123_common/csr.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>b fn awd3_mst(&self) -> AWD3_MSTR { let bits = { const MASK: bool = true; const OFFSET: u8 = 9; ((self.bits >> OFFSET) & MASK as u32) != 0 }; AWD3_MSTR { bits } } #[doc = "Bit 10 - JQOVF_MST"] #[inline] pub fn jqovf_mst(...
code_fim
hard
{ "lang": "rust", "repo": "brandonedens/stm32l4x6", "path": "/src/adc123_common/csr.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brandonedens/stm32l4x6 path: /src/adc123_common/csr.rs e field as raw bits"] #[inline] pub fn bit(&self) -> bool { self.bits } #[doc = r" Returns `true` if the bit is clear (0)"] #[inline] pub fn bit_is_clear(&self) -> bool { !self.bit() } ...
code_fim
hard
{ "lang": "rust", "repo": "brandonedens/stm32l4x6", "path": "/src/adc123_common/csr.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: plyhun/plygui path: /api/src/members.rs pub type MemberId = &'static str; pub const MEMBER_ID_APPLICATION: MemberId = "PlyguiApplication"; pub const MEMBER_ID_WINDOW: MemberId = "PlyguiWindow"; pub const<|fim_suffix|>pub const MEMBER_ID_PROGRESSBAR: MemberId = "PlyguiProgressBar"; pub cons...
code_fim
hard
{ "lang": "rust", "repo": "plyhun/plygui", "path": "/api/src/members.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub const MEMBER_ID_PROGRESSBAR: MemberId = "PlyguiProgressBar"; pub const MEMBER_ID_LIST: MemberId = "PlyguiList"; pub const MEMBER_ID_TREE: MemberId = "PlyguiTree";<|fim_prefix|>// repo: plyhun/plygui path: /api/src/members.rs pub type MemberId = &'static str; pub const MEMBER_ID_APPLICATION: Memb...
code_fim
hard
{ "lang": "rust", "repo": "plyhun/plygui", "path": "/api/src/members.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> write!(f, "ast file \"{}\" load error", &self.ast_file) } }<|fim_prefix|>// repo: cat-in-136/clangastana path: /src/clangastana/error.rs use std::fmt::{Display, Formatter}; #[derive(Fail, Debug)] pub struct AstFileLoadError { ast_file: String, } impl AstFileLoadError { pub fn new(as...
code_fim
medium
{ "lang": "rust", "repo": "cat-in-136/clangastana", "path": "/src/clangastana/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cat-in-136/clangastana path: /src/clangastana/error.rs use std::fmt::{Display, Formatter}; #[derive(Fail, Debug)] pub struct AstFileLoadError { ast_file: String, } <|fim_suffix|>impl Display for AstFileLoadError { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { write!(f,...
code_fim
medium
{ "lang": "rust", "repo": "cat-in-136/clangastana", "path": "/src/clangastana/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let noisy_modules = &[ "hyper", "mio", "tokio_core", "tokio_reactor", "tokio_threadpool", "fuse::request", "rusoto_core", "want", "tantivy", ]; let log_level = match level { //0 => log::Level::Error, 0 => ...
code_fim
hard
{ "lang": "rust", "repo": "scottschroeder/btcprice", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: scottschroeder/btcprice path: /src/main.rs use argparse::CliOpts; mod argparse; mod price; fn main() -> anyhow::Result<()> { color_backtrace::install(); let args = argparse::get_args(); setup_logger(args.verbose); // cli::setup_logger(args.occurrences_of("verbosity")); log:...
code_fim
hard
{ "lang": "rust", "repo": "scottschroeder/btcprice", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhuxindaba/y-crdt path: /yrs/src/updates/decoder.rs use crate::*; use lib0::decoding::Read; use lib0::{any::Any, decoding::Cursor}; pub trait Decode: Sized { fn decode<D: Decoder>(decoder: &mut D) -> Self; /// Helper function for decoding fn decode_v1(data: &[u8]) -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "zhuxindaba/y-crdt", "path": "/yrs/src/updates/decoder.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.cursor.read(len) } } impl<'a> Decoder for DecoderV1<'a> { fn reset_ds_cur_val(&mut self) { /* no op */ } fn read_ds_clock(&mut self) -> u32 { self.read_uvar() } fn read_ds_len(&mut self) -> u32 { self.read_uvar() } fn read_left_id(&m...
code_fim
hard
{ "lang": "rust", "repo": "zhuxindaba/y-crdt", "path": "/yrs/src/updates/decoder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] #[ignore] fn cli_set_command() {} #[test] #[ignore] fn cli_rm_command() {} #[test] #[ignore] fn get_stored_value() {} #[test] #[ignore] fn overwrite_value() {} #[test] #[ignore] fn get_non_existent_value() {} #[test] #[ignore] fn remove_key() {}<|fim_prefix|>// repo: poppindouble/mini-bitcas...
code_fim
hard
{ "lang": "rust", "repo": "poppindouble/mini-bitcask", "path": "/tests/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: poppindouble/mini-bitcask path: /tests/tests.rs use kvs::constants as Constants; use std::process::Command; use assert_cmd::prelude::*; #[test] fn cli_without_argument() { Command::cargo_bin(env!("CARGO_PKG_NAME")) .unwrap() .assert() .failure(); } #[test] fn cli_...
code_fim
hard
{ "lang": "rust", "repo": "poppindouble/mini-bitcask", "path": "/tests/tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn cli_invalid_set_command() { Command::cargo_bin(env!("CARGO_PKG_NAME")) .unwrap() .args(&[Constants::SUBCOMMAND_SET]) .assert() .failure(); Command::cargo_bin(env!("CARGO_PKG_NAME")) .unwrap() .args(&[Constants::SUBCOMMAND_SET, "missing_fi...
code_fim
hard
{ "lang": "rust", "repo": "poppindouble/mini-bitcask", "path": "/tests/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(3, Solution::min_moves(vec![1, 2, 3])); assert_eq!(0, Solution::min_moves(vec![1, 1, 1])); assert_eq!(0, Solution::min_moves(vec![1])); }<|fim_prefix|>// repo: czyczk/LeetCode path: /rust/lc-453/src/main.rs mod solution; use solution::Solution; <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "czyczk/LeetCode", "path": "/rust/lc-453/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: czyczk/LeetCode path: /rust/lc-453/src/main.rs mod solution; use solution::Solution; <|fim_suffix|> assert_eq!(3, Solution::min_moves(vec![1, 2, 3])); assert_eq!(0, Solution::min_moves(vec![1, 1, 1])); assert_eq!(0, Solution::min_moves(vec![1])); }<|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "czyczk/LeetCode", "path": "/rust/lc-453/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Delegator; pub struct SimpleDelegator;<|fim_prefix|>// repo: ifyouseewendy/artichoke path: /artichoke-backend/src/extn/stdlib/delegate.rs use crate::load::LoadSources; use crate::Artichoke; use crate::ArtichokeError; <|fim_middle|>pub fn init(interp: &Artichoke) -> Result<(), ArtichokeError> ...
code_fim
hard
{ "lang": "rust", "repo": "ifyouseewendy/artichoke", "path": "/artichoke-backend/src/extn/stdlib/delegate.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ifyouseewendy/artichoke path: /artichoke-backend/src/extn/stdlib/delegate.rs use crate::load::LoadSources; use crate::Artichoke; use crate::ArtichokeError; <|fim_suffix|>pub struct Delegator; pub struct SimpleDelegator;<|fim_middle|>pub fn init(interp: &Artichoke) -> Result<(), ArtichokeError> ...
code_fim
hard
{ "lang": "rust", "repo": "ifyouseewendy/artichoke", "path": "/artichoke-backend/src/extn/stdlib/delegate.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> Range<'a> { pub fn new(start_key: &'a [u8], end_key: &'a [u8]) -> Range<'a> { Range { start_key, end_key } } }<|fim_prefix|>// repo: innerr/tikv path: /components/engine_traits/src/range.rs // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. <|fim_middle|>/// A ra...
code_fim
hard
{ "lang": "rust", "repo": "innerr/tikv", "path": "/components/engine_traits/src/range.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: innerr/tikv path: /components/engine_traits/src/range.rs // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. <|fim_suffix|>impl<'a> Range<'a> { pub fn new(start_key: &'a [u8], end_key: &'a [u8]) -> Range<'a> { Range { start_key, end_key } } }<|fim_middle|>/// A ra...
code_fim
hard
{ "lang": "rust", "repo": "innerr/tikv", "path": "/components/engine_traits/src/range.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shunding/genco path: /src/go.rs //! Specialization for Go code generation. use std::collections::BTreeSet; use std::fmt::{self, Write}; use {Cons, Custom, Formatter, Quoted, Tokens}; const SEP: &str = "."; /// Name of an imported type. #[derive(Debug, Clone, Hash, PartialOrd, Ord, PartialEq, ...
code_fim
hard
{ "lang": "rust", "repo": "shunding/genco", "path": "/src/go.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn format(&self, out: &mut Formatter, extra: &mut Self::Extra, level: usize) -> fmt::Result { use self::Go::*; match *self { Type { name: Name { ref module, ref name, ...
code_fim
hard
{ "lang": "rust", "repo": "shunding/genco", "path": "/src/go.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub async fn mailbox( &self, key: &ReplicaKey, ) -> Option<Sender<LeaderReplicaControllerCommand>> { self.mailboxes.read().await.get(key).cloned() } } impl ReplicaLeadersState<FileReplica> { /// write records to response /// /// # Arguments /// /// ...
code_fim
hard
{ "lang": "rust", "repo": "vijaylaxmid/fluvio", "path": "/src/spu/src/controllers/leader_replica/leaders_state.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> use std::time::Duration; use async_channel::Sender; use async_channel::Receiver; use async_channel::bounded as channel; use futures_util::future::join; use futures_util::StreamExt; use fluvio_future::timer::sleep; use fluvio_future::test_async; async fn receiver_tst(...
code_fim
hard
{ "lang": "rust", "repo": "vijaylaxmid/fluvio", "path": "/src/spu/src/controllers/leader_replica/leaders_state.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vijaylaxmid/fluvio path: /src/spu/src/controllers/leader_replica/leaders_state.rs use std::sync::Arc; use std::collections::HashMap; use chashmap::CHashMap; use chashmap::ReadGuard; use chashmap::WriteGuard; use async_channel::Sender; use async_channel::SendError; use async_rwlock::RwLock; use ...
code_fim
hard
{ "lang": "rust", "repo": "vijaylaxmid/fluvio", "path": "/src/spu/src/controllers/leader_replica/leaders_state.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let no_reps = |s: &str| day4::is_pass_non_repeaty(s); let no_anas = |s: &str| day4::contains_no_anagrams(s); println!("not gold {}", day4::count_valid(&passes, &no_reps)); println!("gold {}", day4::count_valid(&passes, &no_anas)); }<|fim_prefix|>// repo: subsidel/advent_again path: /day4...
code_fim
hard
{ "lang": "rust", "repo": "subsidel/advent_again", "path": "/day4/src/bin.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: subsidel/advent_again path: /day4/src/bin.rs extern crate day4; use std::fs::File; use std::io::Read; fn main() { <|fim_suffix|> let mut passes = String::new(); pass_file .read_to_string(&mut passes) .expect("you dun goofed"); let no_reps = |s: &str| day4::is_pass_non...
code_fim
medium
{ "lang": "rust", "repo": "subsidel/advent_again", "path": "/day4/src/bin.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let x = MyBox::new(5); assert_eq!(5, *x); // 實際上編譯器這邊會編譯成 *(x.deref()) } /// 解引用之強制轉型(多型) fn deref_coercions() { let m: MyBox<String> = MyBox::new(String::from("Rust")); hello(&m); // 由於 Deref trait, Rust 通過 deref coercions // &MyBox<String> -> &String, 標準庫中 &String deref -> &s...
code_fim
medium
{ "lang": "rust", "repo": "shengLin-alex/rust-exercise", "path": "/use-deref/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shengLin-alex/rust-exercise path: /use-deref/src/main.rs use std::ops::Deref; fn main() { deref_coercions(); } #[test] fn dereference() { let x = 5; let y = &x; assert_eq!(5, x); // * 解引用, 類似於 c/c++ de-pointer assert_eq!(5, *y); } <|fim_suffix|> assert_eq!(5, x); ...
code_fim
medium
{ "lang": "rust", "repo": "shengLin-alex/rust-exercise", "path": "/use-deref/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// Will output a human readable String pub fn readable(prefix: &[u8], raw: &[u8]) -> String { let (mut key, mut output) = (Vec::new(), Vec::new()); key.extend_from_slice(prefix); key.extend_from_slice(&raw); let checksum = &double_sha(&key)[..CHECKSUM_LENGTH]; output.extend_from_slice(...
code_fim
hard
{ "lang": "rust", "repo": "kompendium-ano/factom-rust-client", "path": "/examples/ecaddresses.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kompendium-ano/factom-rust-client path: /examples/ecaddresses.rs use factom::*; use sha2::{Digest, Sha256}; // Example will get the Entry Credit addresses for a certain chain in the last block // In this case it will be the pegnet chain // Pegnet Tx Chain const TX_CHAIN: &str = "cffce0f409ebba...
code_fim
medium
{ "lang": "rust", "repo": "kompendium-ano/factom-rust-client", "path": "/examples/ecaddresses.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, index_entry: &IndexEntry<'index>, ) -> Vec<IndexGraphEdge> { let mut edges = Vec::new(); let mut known_ancestors = HashSet::new(); for parent in index_entry.parents() { let parent_position = parent.position(); self.consume_to(p...
code_fim
hard
{ "lang": "rust", "repo": "martinvonz/jj", "path": "/lib/src/default_revset_graph_iterator.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: martinvonz/jj path: /lib/src/default_revset_graph_iterator.rs // Copyright 2021 The Jujutsu Authors // // 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 // // https://w...
code_fim
hard
{ "lang": "rust", "repo": "martinvonz/jj", "path": "/lib/src/default_revset_graph_iterator.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mishajw/gridwm path: /src/command_handler.rs extern crate libc; use std::ffi::CString; use std::fs::File; use std::io::BufRead; use std::io::BufReader; use std::path::Path; use base_wm::BaseWm; use error::*; use external_commands::ExternalCommand; pub fn run(fifo_path: &Path, wm: &BaseWm) -> ...
code_fim
hard
{ "lang": "rust", "repo": "mishajw/gridwm", "path": "/src/command_handler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } fn mkfifo(path: &Path) { unsafe { // TODO: Use nix::mkfifo once it has been released let path_str = path.to_str().expect("Path is not unicode"); let c_path = CString::new(path_str).unwrap(); libc::mkfifo(c_path.as_ptr(), 0o666); } }<|fim_prefix|>// rep...
code_fim
hard
{ "lang": "rust", "repo": "mishajw/gridwm", "path": "/src/command_handler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: victordeleau/rust-plinth path: /generative/game_of_life/src/main.rs use rand::Rng; use std::{thread, time}; use std::vec::Vec; use ansi_escapes::*; // specific characters const GRID_SIZE: (usize, usize) = (52, 52); const PROBABILITY: f32 = 0.4; const FPS: f32 = 10.0; fn print_grid(grid_size:...
code_fim
hard
{ "lang": "rust", "repo": "victordeleau/rust-plinth", "path": "/generative/game_of_life/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("\n\n Welcome to the game of life !\n"); let mut current_grid = initialize_grid(PROBABILITY); let mut new_grid: Vec<Vec<char>>=vec![vec![' '; GRID_SIZE.1]; GRID_SIZE.0]; let delay = time::Duration::from_millis((1.0/FPS * 1000.0) as u64); loop...
code_fim
hard
{ "lang": "rust", "repo": "victordeleau/rust-plinth", "path": "/generative/game_of_life/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if grid[cell.0-1][cell.1] == '\u{2588}' { nb_alive_neighbor += 1; } // check top right if cell.1 != grid[0].len()-1 { if grid[cell.0-1][cell.1+1] == '\u{2588}' { nb_alive_neighbor += 1; } } // check top left if cell...
code_fim
hard
{ "lang": "rust", "repo": "victordeleau/rust-plinth", "path": "/generative/game_of_life/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>lassifier](neighbors/knn_classifier/index.html) to a dataset that is defined as standard Rust vector: //! //! ``` //! // DenseMatrix defenition //! use smartcore::linalg::naive::dense_matrix::*; //! // KNNClassifier //! use smartcore::neighbors::knn_classifier::*; //! // Various distance metrics //! use s...
code_fim
hard
{ "lang": "rust", "repo": "z1queue/smartcore", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: z1queue/smartcore path: /src/lib.rs #![allow( clippy::type_complexity, clippy::too_many_arguments, clippy::many_single_char_names, clippy::unnecessary_wraps )] #![warn(missing_docs)] #![warn(missing_doc_code_examples)] //! # SmartCore //! //! Welcome to SmartCore, the most advan...
code_fim
hard
{ "lang": "rust", "repo": "z1queue/smartcore", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn _2048us(self) -> &'a mut W { self.variant(SAMPLEPER_A::_2048US) } #[doc = "4096 us"] #[inline(always)] pub fn _4096us(self) -> &'a mut W { self.variant(SAMPLEPER_A::_4096US) } #[doc = "8192 us"] #[inline(always)] pub fn _8192us(self) -> &'a mut W { ...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf52832-pac", "path": "/src/qdec/sampleper.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nrf-rs/nrf52832-pac path: /src/qdec/sampleper.rs #[doc = "Reader of register SAMPLEPER"] pub type R = crate::R<u32, super::SAMPLEPER>; #[doc = "Writer for register SAMPLEPER"] pub type W = crate::W<u32, super::SAMPLEPER>; #[doc = "Register SAMPLEPER `reset()`'s with value 0"] impl crate::ResetVa...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf52832-pac", "path": "/src/qdec/sampleper.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: n3phtys/rustix-bl path: /src/lib.rs // An attribute to hide warnings for unused code. #![allow(dead_code)] #![allow(unused_imports)] #![allow(unused_variables)] #[macro_use] extern crate typescriptify_derive; extern crate typescriptify; #[macro_use] pub extern crate derive_builder; pub extern ...
code_fim
hard
{ "lang": "rust", "repo": "n3phtys/rustix-bl", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub extern crate bincode; #[macro_use] pub extern crate serde_derive; #[macro_use] pub extern crate quick_error; pub mod left_threaded_avl_tree; pub mod datastore; pub mod rustix_backend; pub mod persistencer; pub mod rustix_event_shop; pub mod errors; pub mod config; use std::collections::HashS...
code_fim
hard
{ "lang": "rust", "repo": "n3phtys/rustix-bl", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tyleo/libflo path: /dep/libflo_func/src/serialization/platform_serde.rs use serialization::OsSerde; <|fim_suffix|>impl PlatformSerde { pub fn destructure(self) -> (OsSerde, String) { (self.os, self.path) } }<|fim_middle|>#[derive(Clone, Debug, Deserialize, Eq, PartialEq)] pub st...
code_fim
medium
{ "lang": "rust", "repo": "tyleo/libflo", "path": "/dep/libflo_func/src/serialization/platform_serde.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl PlatformSerde { pub fn destructure(self) -> (OsSerde, String) { (self.os, self.path) } }<|fim_prefix|>// repo: tyleo/libflo path: /dep/libflo_func/src/serialization/platform_serde.rs use serialization::OsSerde; <|fim_middle|>#[derive(Clone, Debug, Deserialize, Eq, PartialEq)] pub st...
code_fim
medium
{ "lang": "rust", "repo": "tyleo/libflo", "path": "/dep/libflo_func/src/serialization/platform_serde.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn add() { unsafe { let mut list = generate_list(6); let mut first: *mut bw::AiTown = &mut list[0]; validate_list(first, 6); let mut new: bw::AiTown = mem::zeroed(); ListEntry::add(&mut new, &mut first); valida...
code_fim
hard
{ "lang": "rust", "repo": "neivv/aise", "path": "/src/list.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: neivv/aise path: /src/list.rs use crate::bw; pub trait ListEntry: Sized { unsafe fn next(x: *mut Self) -> *mut *mut Self; unsafe fn prev(x: *mut Self) -> *mut *mut Self; // Remove cfg filters if these happen to be needed unsafe fn remove(value: *mut Self, list_head: *mut *mut S...
code_fim
hard
{ "lang": "rust", "repo": "neivv/aise", "path": "/src/list.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { let mut list = generate_list(6); let mut first: *mut bw::AiTown = &mut list[0]; validate_list(first, 6); let mut new: bw::AiTown = mem::zeroed(); ListEntry::add(&mut new, &mut first); validate_list(first, 7); ...
code_fim
hard
{ "lang": "rust", "repo": "neivv/aise", "path": "/src/list.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> deserialize_primitive(tag_name, stack, |s| Ok(i64::from_str(&s).unwrap())) } } #[allow(dead_code)] struct BytesScannedDeserializer; impl BytesScannedDeserializer { #[allow(dead_code, unused_variables)] fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<i64, XmlPars...
code_fim
hard
{ "lang": "rust", "repo": "jmfiaschi/surf_bucket_select", "path": "/src/model/select_object_content.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jmfiaschi/surf_bucket_select path: /src/model/select_object_content.rs use rusoto_core::event_stream::{DeserializeEvent}; use rusoto_core::proto::xml::util::{Next, Peek, XmlParseError, XmlResponse, find_start_element, deserialize_elements, deserialize_primitive, skip_tree}; use rusoto_core::{Rus...
code_fim
hard
{ "lang": "rust", "repo": "jmfiaschi/surf_bucket_select", "path": "/src/model/select_object_content.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: angusholder/compiler path: /src/parser.rs use ast::{ StmtRef, Stmt, ExprRef, Expr, Lit, UnaryOpKind, BinOpKind, Block, Ast }; use ast_printer::{ ExprFormatter, StmtFormatter }; use entity::{ PrimaryMap, EntityMap }; use lexer::Lexer; use result::{ Span, CompileResult }; use tokens::{ TokenKind, ...
code_fim
hard
{ "lang": "rust", "repo": "angusholder/compiler", "path": "/src/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use tokens::TokenKind::*; let (led, bp): (LeftDenotation, i32) = { let token = if let Some(token) = self.lexer.peek()? { token } else { return Ok(true); // No tokens left, terminate expression. }; match token...
code_fim
hard
{ "lang": "rust", "repo": "angusholder/compiler", "path": "/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sastels/advent-of-code-2020 path: /src/day22.rs use crate::utils::join_lines; pub fn deal(decks: &mut Vec<String>) -> (Vec<usize>, Vec<usize>) { // bottom of deck is first value. so to get top you pop() let deck2: Vec<usize> = decks .pop() .unwrap() .replace("Pla...
code_fim
hard
{ "lang": "rust", "repo": "sastels/advent-of-code-2020", "path": "/src/day22.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// return the winning player and change the decks (changing the decks needed for final score) pub fn recursive_combat(round: usize, deck1: &mut Vec<usize>, deck2: &mut Vec<usize>) -> usize { let mut previous_rounds: Vec<String> = vec![]; loop { let round_description = format!("P1 {:?} P2 ...
code_fim
hard
{ "lang": "rust", "repo": "sastels/advent-of-code-2020", "path": "/src/day22.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(target_arch = "wasm32")] extern crate ring_wasmable as ring; #[macro_use] mod der; mod calendar; mod cert; mod end_entity; mod error; mod name; mod signed_data; mod time; mod trust_anchor; mod verify_cert; pub use { end_entity::EndEntityCert, error::Error, name::{DnsNameRef, InvalidD...
code_fim
hard
{ "lang": "rust", "repo": "Phala-Network/phala-blockchain", "path": "/vendor/webpki/src/lib.rs", "mode": "spm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "alloc")] #[allow(unknown_lints, clippy::upper_case_acronyms)] #[deprecated(note = "Use DnsName")] pub type DNSName = DnsName; #[deprecated(note = "use DnsNameRef")] #[allow(unknown_lints, clippy::upper_case_acronyms)] pub type DNSNameRef<'a> = DnsNameRef<'a>; #[deprecated(note = "use Tl...
code_fim
hard
{ "lang": "rust", "repo": "Phala-Network/phala-blockchain", "path": "/vendor/webpki/src/lib.rs", "mode": "spm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Phala-Network/phala-blockchain path: /vendor/webpki/src/lib.rs // Copyright 2015 Brian Smith. // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice ap...
code_fim
hard
{ "lang": "rust", "repo": "Phala-Network/phala-blockchain", "path": "/vendor/webpki/src/lib.rs", "mode": "psm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_suffix|> if !runner.stop_reason.is_some() { let length: usize = rules_array_length as usize; let ffi_rules: &[*mut FFIRule] = slice::from_raw_parts(rules_array_ptr, length); let mut ffi_tuples: Vec<(&str, &str, &str)> = vec![]; let mut ffi_strings: Vec<(Strin...
code_fim
hard
{ "lang": "rust", "repo": "oflatt/herbie", "path": "/egg-herbie/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oflatt/herbie path: /egg-herbie/src/lib.rs pub mod math; pub mod rules; use egg::{Id, Iteration}; use math::*; use std::cmp::min; use std::ffi::{CStr, CString}; use std::os::raw::c_char; use std::time::Duration; use std::{slice, sync::atomic::Ordering}; unsafe fn cstring_to_recexpr(c_string: ...
code_fim
hard
{ "lang": "rust", "repo": "oflatt/herbie", "path": "/egg-herbie/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(ctx.iteration, 0); let result = match cstring_to_recexpr(expr) { None => EGraphAddResult { id: 0, successp: false, }, Some(rec_expr) => { runner = runner.with_expr(&rec_expr); le...
code_fim
hard
{ "lang": "rust", "repo": "oflatt/herbie", "path": "/egg-herbie/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_regs() { assert_eq!(regs("[0, 1, 2, 3]\n"), Ok(("\n", Regs(vec![0, 1, 2, 3])))); } #[test] fn test_instr() { assert_eq!(instr("0 1 2 3\n"), Ok(("", Instr(vec![0, 1, 2, 3])))); } #[test] fn test_sample() { let before = Regs(vec![0, 1...
code_fim
hard
{ "lang": "rust", "repo": "starblue/advent_of_code", "path": "/a2018/src/bin/a201816a.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: starblue/advent_of_code path: /a2018/src/bin/a201816a.rs use std::io; use std::io::Read; use std::str::FromStr; use nom::bytes::complete::tag; use nom::character::complete::char; use nom::character::complete::digit1; use nom::character::complete::line_ending; use nom::character::complete::multi...
code_fim
hard
{ "lang": "rust", "repo": "starblue/advent_of_code", "path": "/a2018/src/bin/a201816a.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> cells.allocate(font, 4, 4, 2.0); let expected = Cells::from_vec(vec![ vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0], vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0], vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0], vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0], vec![0, 0, 0, 0, 1, 1, 1, 1, 0, 0], ...
code_fim
hard
{ "lang": "rust", "repo": "YuichiroSato/banner-of-life", "path": "/src/cells.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YuichiroSato/banner-of-life path: /src/cells.rs use fonts::*; use primes::*; #[repr(u8)] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Cell { Dead = 0, Alive = 1, } #[derive(Clone, Debug, PartialEq, Eq)] pub struct Cells { pub size_x: usize, pub size_y: usize, pub c...
code_fim
hard
{ "lang": "rust", "repo": "YuichiroSato/banner-of-life", "path": "/src/cells.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fisherdarling/rslisp path: /rslisp-derives/tests/hello.rs use im::Vector; use rslisp::types::{BuiltinFunction, BuiltinMacro, Scope, Type}; use rslisp_derive::builtin; <|fim_suffix|>#[test] fn it_works() { let add_fn = add_builtin(); assert_eq!(add_fn.name(), "add"); assert_eq!( ...
code_fim
hard
{ "lang": "rust", "repo": "fisherdarling/rslisp", "path": "/rslisp-derives/tests/hello.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let add_fn = add_builtin(); assert_eq!(add_fn.name(), "add"); assert_eq!( add( Vector::new(), &mut Scope::new(std::collections::HashMap::new()) ), Type::Int(0) ); }<|fim_prefix|>// repo: fisherdarling/rslisp path: /rslisp-derives/tests/hell...
code_fim
medium
{ "lang": "rust", "repo": "fisherdarling/rslisp", "path": "/rslisp-derives/tests/hello.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TeXitoi/navitia_model path: /src/ntfs.rs use std::path; use csv; use serde; use objects::*; use collection::{Collection, Id}; use {Collections, PtObjects}; fn make_collection<T>(path: &path::Path, file: &str) -> Collection<T> where T: Id<T>, for<'de> T: serde::Deserialize<'de>, { l...
code_fim
hard
{ "lang": "rust", "repo": "TeXitoi/navitia_model", "path": "/src/ntfs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn read<P: AsRef<path::Path>>(path: P) -> PtObjects { let path = path.as_ref(); let mut collections = Collections::default(); collections.commercial_modes = make_collection(path, "commercial_modes.txt"); collections.networks = make_collection(path, "networks.txt"); collections.line...
code_fim
hard
{ "lang": "rust", "repo": "TeXitoi/navitia_model", "path": "/src/ntfs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>where D: ::serde::Deserializer<'de>, { use serde::Deserialize; let i = i32::deserialize(deserializer)?; Ok(if i == 0 { true } else { false }) } #[derive(Serialize, Deserialize, Debug, Clone)] struct Stop { #[serde(rename = "stop_id")] id: String, #[serde(rename = "stop_name")] nam...
code_fim
hard
{ "lang": "rust", "repo": "TeXitoi/navitia_model", "path": "/src/ntfs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl AntiDdos { pub fn evaluate(&mut self,ip : IpAddr) { if self.suspicious.contains_key(&ip) { *self.suspicious.get_mut(&ip).unwrap() += 1; if self.suspicious.get_mut(&ip).unwrap() > &mut 100 { let mut cmd = "block ".to_string(); ...
code_fim
medium
{ "lang": "rust", "repo": "pluxtore/maze-server", "path": "/maze_gameserver/src/aluminium/antiddos.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pluxtore/maze-server path: /maze_gameserver/src/aluminium/antiddos.rs use std::net::IpAddr; use std::collections::HashMap; use std::process::Command; <|fim_suffix|>impl AntiDdos { pub fn evaluate(&mut self,ip : IpAddr) { if self.suspicious.contains_key(&ip) { *self....
code_fim
medium
{ "lang": "rust", "repo": "pluxtore/maze-server", "path": "/maze_gameserver/src/aluminium/antiddos.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }