text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> if watched.len() > 0 { let mut history = w::Column::new(); history = history.push(w::text("Watch history")); for ((n, watch), c) in watched.enumerate().zip(&self.remove_watches) { let mut row = w::Row::new(); row = row.push( ...
code_fim
hard
{ "lang": "rust", "repo": "udoprog/ontv", "path": "/src/comps/movie_item.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: udoprog/ontv path: /src/comps/movie_item.rs use crate::component::{Component, ComponentInitExt}; use crate::comps; use crate::model::{MovieId, Watched}; use crate::params::{GAP, POSTER_HINT, SMALL_SIZE, SPACE}; use crate::prelude::*; #[derive(Debug, Clone)] pub(crate) enum Message { RemoveL...
code_fim
hard
{ "lang": "rust", "repo": "udoprog/ontv", "path": "/src/comps/movie_item.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Noah2610/hello-amethyst-platformer path: /src/main.rs extern crate deathframe; extern crate amethyst; #[macro_use] extern crate amethyst_editor_sync; extern crate json; extern crate regex; extern crate ron; #[macro_use] extern crate serde; extern crate serde_json; extern crate tap; mod game; m...
code_fim
hard
{ "lang": "rust", "repo": "Noah2610/hello-amethyst-platformer", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Create GameDataBuilder let game_data = CustomGameData::<DisplayConfig>::new() .dispatcher("startup")? .dispatcher("ingame")? .dispatcher("paused")? .custom(display_config) .with_core_bundle(transform_bundle)? .with_core_bundle(render_bundle)? ...
code_fim
hard
{ "lang": "rust", "repo": "Noah2610/hello-amethyst-platformer", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ketralnis/secrets path: /src/utils.rs use std::io; use std::io::Write; use chrono::{Local, TimeZone}; use regex; #[macro_export] macro_rules! simple_err_impl { ($root_type:ident, $variant_name:ident, $source_error:ty) => { impl From<$source_error> for $root_type { fn fr...
code_fim
hard
{ "lang": "rust", "repo": "ketralnis/secrets", "path": "/src/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn validate_host(name: &str, value: &str) -> Result<(), String> { re_validator(name, r"[a-zA-Z0-9.-]+(:[0-9]{1,5})?", value) } pub fn re_validator( name: &str, re_expr: &'static str, value: &str, ) -> Result<(), String> { let re = regex::Regex::new(re_expr).unwrap(); if re.is_...
code_fim
hard
{ "lang": "rust", "repo": "ketralnis/secrets", "path": "/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: potocpav/lv2 path: /src/ontology/classes/xsd.rs > {} impl<'g, G: 'g> ontology::properties::rdfs::Comment<'g> for resource::IRI<'g, Int<'g, G>> where G: graph::Graph<'g> {} impl<'g, G: 'g> ontology::properties::rdfs::IsDefinedBy<'g> for Int<'g, G> where G: graph::Graph<'g> {} impl<'g, G: 'g> onto...
code_fim
hard
{ "lang": "rust", "repo": "potocpav/lv2", "path": "/src/ontology/classes/xsd.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|>class!( /// **xsd:nonNegativeInteger** :"http://www.w3.org/2001/XMLSchema#nonNegativeInteger", NonNegativeInteger, 124); impl<'g, G: 'g> ontology::properties::owl::DatatypeComplementOf<'g> for NonNegativeInteger<'g, G> where G: graph::Graph<'g> {} impl<'g, G: 'g> ontology::properties::owl::DatatypeComplem...
code_fim
hard
{ "lang": "rust", "repo": "potocpav/lv2", "path": "/src/ontology/classes/xsd.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: potocpav/lv2 path: /src/ontology/classes/xsd.rs graph::Graph<'g> {} impl<'g, G: 'g> ontology::properties::rdfs::Label<'g> for resource::IRI<'g, Decimal<'g, G>> where G: graph::Graph<'g> {} impl<'g, G: 'g> ontology::properties::rdfs::Member<'g> for Decimal<'g, G> where G: graph::Graph<'g> {} imp...
code_fim
hard
{ "lang": "rust", "repo": "potocpav/lv2", "path": "/src/ontology/classes/xsd.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danlkv/quantTechLab path: /corr/src/main.rs use std::env; use std::io::{BufRead, BufReader}; use std::fs::File; use std::collections::VecDeque; fn sum_a_file(filename:&String, corr_len:usize) -> std::io::Result<i32> { let file = File::open(filename).unwrap(); let mut sum : i128 = 0; ...
code_fim
hard
{ "lang": "rust", "repo": "danlkv/quantTechLab", "path": "/corr/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(n)=> { let mut n = n as i128; if n>10000{ continue } if n==12{ n=0; }else{ n=1; } counter +=1; if iter%...
code_fim
hard
{ "lang": "rust", "repo": "danlkv/quantTechLab", "path": "/corr/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("AZ_IOT_ID_SCOPE={}", id_scope); println!("AZ_IOT_REGISTRATION_ID_SAS={}", registration_id); println!("AZ_IOT_PROVISIONING_SAS_KEY={}", "***"); println!( "AZ_IOT_PROVISIONING_SAS_KEY_DURATION_MINUTES={}", sas_key_duration ); println!("AZ_IOT_DEVICE_X509_TRU...
code_fim
hard
{ "lang": "rust", "repo": "idavis/azure-iot-sdk-for-rust", "path": "/sdk/iot/examples/provisioning-sas/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: idavis/azure-iot-sdk-for-rust path: /sdk/iot/examples/provisioning-sas/main.rs extern crate paho_mqtt as mqtt; use std::process; pub const DEFAULT_MQTT_CONNECT_PORT: i32 = 8883; pub const DEFAULT_MQTT_CONNECT_KEEPALIVE_SECONDS: u64 = 240; extern crate azure_sdk_for_rust_iot; use azure_sdk_for_r...
code_fim
hard
{ "lang": "rust", "repo": "idavis/azure-iot-sdk-for-rust", "path": "/sdk/iot/examples/provisioning-sas/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let sas_key_duration = option_env!("AZ_IOT_PROVISIONING_SAS_KEY_DURATION_MINUTES").unwrap_or("120"); let trust_store = option_env!("AZ_IOT_DEVICE_X509_TRUST_PEM_FILE"); println!( "AZ_IOT_DEVICE_X509_TRUST_PEM_FILE={}", global_provisioning_endpoint ); println!(...
code_fim
hard
{ "lang": "rust", "repo": "idavis/azure-iot-sdk-for-rust", "path": "/sdk/iot/examples/provisioning-sas/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andysalerno/reversi_rust path: /src/game/game_agent.rs use game::board::Piece; use game::game_rules::GameRules; // pub trai<|fim_suffix|>board: &BoardState<T>, choices: &'a [GameMove<T>]) -> &'a GameMove<T>; // fn color(&self) -> PlayerColor; // } pub trait GameAgent { }<|fim_middle|>t Ga...
code_fim
medium
{ "lang": "rust", "repo": "andysalerno/reversi_rust", "path": "/src/game/game_agent.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // fn color(&self) -> PlayerColor; // } pub trait GameAgent { }<|fim_prefix|>// repo: andysalerno/reversi_rust path: /src/game/game_agent.rs use game::board::Piece; use game::game_rules::GameRules; // pub trai<|fim_middle|>t GameAgent<T> // where T: Piece<T> { // fn pick_move<'a>(&self, boar...
code_fim
medium
{ "lang": "rust", "repo": "andysalerno/reversi_rust", "path": "/src/game/game_agent.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reitermarkus/msp432p401r-pac path: /src/rtc_c/rtcdate.rs #[doc = "Reader of register RTCDATE"] pub type R = crate::R<u16, super::RTCDATE>; #[doc = "Writer for register RTCDATE"] pub type W = crate::W<u16, super::RTCDATE>; #[doc = "Register RTCDATE `reset()`'s with value 0"] impl crate::ResetValu...
code_fim
hard
{ "lang": "rust", "repo": "reitermarkus/msp432p401r-pac", "path": "/src/rtc_c/rtcdate.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>s 8:11 - Month (1 to 12)"] #[inline(always)] pub fn month(&self) -> MONTH_R { MONTH_R::new(((self.bits >> 8) & 0x0f) as u8) } } impl W { #[doc = "Bits 0:4 - Day of month (1 to 28, 29, 30, 31)"] #[inline(always)] pub fn day(&mut self) -> DAY_W { DAY_W { w: self } ...
code_fim
hard
{ "lang": "rust", "repo": "reitermarkus/msp432p401r-pac", "path": "/src/rtc_c/rtcdate.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stevenroose/hal-elements path: /src/tx.rs use elements::encode::serialize; use elements::{ bitcoin, confidential, AssetIssuance, PeginData, PegoutData, Transaction, TxIn, TxInWitness, TxOut, TxOutWitness, Txid, Wtxid, Script, Address, }; use elements::secp256k1_zkp::{RangeProof, SurjectionProo...
code_fim
hard
{ "lang": "rust", "repo": "stevenroose/hal-elements", "path": "/src/tx.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|>impl GetInfo<OutputWitnessInfo> for TxOutWitness { fn get_info(&self, _network: Network) -> OutputWitnessInfo { OutputWitnessInfo { surjection_proof: self.surjection_proof.as_ref().map(|p| SurjectionProof::serialize(p).into()), rangeproof: self.rangeproof.as_ref().map(|p| RangeProof::serialize(p)...
code_fim
hard
{ "lang": "rust", "repo": "stevenroose/hal-elements", "path": "/src/tx.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn executor_form() -> std::collections::HashMap< String, wca::Routine > { std::collections::HashMap::from( [ ( "each".to_owned(), wca::Routine::new_with_ctx( commands::each::each ) ), ( "crate.info".to_owned(), wca::Routine::new_with_ctx( commands::package::info::info ) ), ...
code_fim
medium
{ "lang": "rust", "repo": "dmvict/wTools", "path": "/rust/impl/willbe/commands/init.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dmvict/wTools path: /rust/impl/willbe/commands/init.rs /// Internal namespace. pub( crate ) mod private { use crate::commands; /// /// Form CA commands grammar. /// pub fn grammar_form() -> Vec< wca::Command > { vec! [ commands::each::each_command(), commands::p...
code_fim
medium
{ "lang": "rust", "repo": "dmvict/wTools", "path": "/rust/impl/willbe/commands/init.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Elinvynia/bot path: /src/commands/roles.rs pub mod addjoinrole; pub mod addreactrole; pub m<|fim_suffix|>se removejoinrole::*; pub use removereactrole::*;<|fim_middle|>od removejoinrole; pub mod removereactrole; pub use addjoinrole::*; pub use addreactrole::*; pub u
code_fim
medium
{ "lang": "rust", "repo": "Elinvynia/bot", "path": "/src/commands/roles.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>se removejoinrole::*; pub use removereactrole::*;<|fim_prefix|>// repo: Elinvynia/bot path: /src/commands/roles.rs pub mod addjoinrole; pub mod addreactrole; pub m<|fim_middle|>od removejoinrole; pub mod removereactrole; pub use addjoinrole::*; pub use addreactrole::*; pub u
code_fim
medium
{ "lang": "rust", "repo": "Elinvynia/bot", "path": "/src/commands/roles.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TheBlueMatt/Angora path: /fuzzer/src/track/fparser.rs use super::filter; use crate::{ cond_stmt::{CondState, CondStmt}, mut_input, }; use angora_common::{defs, tag::TagSeg}; use runtime::get_log_data; use std::{collections::HashMap, io, path::Path}; pub fn read_and_parse( out_f: &Pa...
code_fim
hard
{ "lang": "rust", "repo": "TheBlueMatt/Angora", "path": "/fuzzer/src/track/fparser.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> cond_list.push(cond); } Ok((cond_list, max_offset)) } fn get_offsets_and_variables( m: &HashMap<u32, Vec<TagSeg>>, cond: &mut CondStmt, magic_bytes: &Option<(Vec<u8>, Vec<u8>)>, ) { let empty_offsets: Vec<TagSeg> = vec![]; let offsets1 = m.get(&cond.base.lb1).unwrap_or...
code_fim
hard
{ "lang": "rust", "repo": "TheBlueMatt/Angora", "path": "/fuzzer/src/track/fparser.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GuilloteauQ/tex-rs path: /src/latex_file.rs /// File implementing the LatexFile type use std::fs::File; use std::io::BufWriter; use std::io::{self, Write}; // pub type LatexFile = File; pub struct LatexFile { /// The file where everything will be written file: File, /// The title o...
code_fim
hard
{ "lang": "rust", "repo": "GuilloteauQ/tex-rs", "path": "/src/latex_file.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Adds a package pub fn add_package<T: AsRef<str>>(&mut self, package: T) { self.packages.push(package.as_ref().to_string()); } /// Adds a list of packages pub fn add_package_list<T: AsRef<str>>(&mut self, packages: Vec<T>) { for package in packages.iter() { ...
code_fim
hard
{ "lang": "rust", "repo": "GuilloteauQ/tex-rs", "path": "/src/latex_file.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: srithon/samplex path: /src/audio.rs use rodio::source::SamplesConverter; use rodio::buffer::SamplesBuffer; use rodio::decoder::Decoder; use rodio::Source; use rodio::Sample; use std::time::Duration; use std::sync::Arc; use std::borrow::Borrow; use rodio::Device; use rodio::Sink; use std::io:...
code_fim
hard
{ "lang": "rust", "repo": "srithon/samplex", "path": "/src/audio.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>struct AudioFileIterator { // made usize from u32 to prevent casting for vector access current_index: usize, audio_file: Arc<AudioFile> } impl AudioFileIterator { pub fn new(audio_file: Arc<AudioFile>) -> AudioFileIterator { AudioFileIterator { current_index: 0, ...
code_fim
hard
{ "lang": "rust", "repo": "srithon/samplex", "path": "/src/audio.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> None } } pub struct AudioPlayer { sink: Sink, // output_device: Device } impl AudioPlayer { pub fn new() -> Result<AudioPlayer> { let output_device = rodio::default_output_device(); if output_device.is_none() { return Err(Error::new(ErrorKind::Other, "...
code_fim
hard
{ "lang": "rust", "repo": "srithon/samplex", "path": "/src/audio.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let glb = Glb::from_slice(glb_data).unwrap(); let unvalidated = Gltf::from_glb(&glb).unwrap(); let gltf = unvalidated.validate_completely(); let message = format!("{:#?}", gltf); CString::new(message.as_str()) .unwrap() .into_raw() }<|fim_prefix|>// repo: alteous/gltf-validator-web path: /sr...
code_fim
medium
{ "lang": "rust", "repo": "alteous/gltf-validator-web", "path": "/src/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alteous/gltf-validator-web path: /src/main.rs use std::os::raw::c_char; use std::ffi::CString; extern crate gltf; use gltf::{Glb, Gltf}; <|fim_suffix|>#[no_mangle] pub fn validate_gltf(glb_data: *const u8, len: i32) -> *mut c_char { let glb_data: &[u8] = unsafe { std::slice::from_raw_parts(...
code_fim
medium
{ "lang": "rust", "repo": "alteous/gltf-validator-web", "path": "/src/main.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> fn draw_title_actor_description(&mut self, x: int, y: int, actor: Actor) { self.con.put_char_ex(x, y, actor.glyph, actor.color.to_tcod_color(), util::Color::black().to_tcod_color()); self.con.print_ex(x + 2, y , BackgroundFlag::None, TextAlignment::Left, actor.name.as_slice()); } pub fn draw_worl...
code_fim
hard
{ "lang": "rust", "repo": "devilbuddy/rrl", "path": "/src/renderer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: devilbuddy/rrl path: /src/renderer.rs extern crate tcod; use tcod::{Console, BackgroundFlag, TextAlignment}; use actor::Actor; use world::World; use util; pub struct Panel { x: uint, y: uint, width: uint, height: uint, con: Console } impl Panel { pub fn new(x: uint, y: uint, width: u...
code_fim
hard
{ "lang": "rust", "repo": "devilbuddy/rrl", "path": "/src/renderer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub enum Argument { /// Path: Required file, got directory FileRequired(PathBuf), }<|fim_prefix|>// repo: Dentosal/brain-opt path: /src/error.rs use std::io; use std::path::PathBuf; #[must_use] pub type Result<T> = std::result::Result<T, Error>; #[derive(Debug)] pub enum Error ...
code_fim
medium
{ "lang": "rust", "repo": "Dentosal/brain-opt", "path": "/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Dentosal/brain-opt path: /src/error.rs use std::io; use std::path::PathBuf; #[must_use] pub type Result<T> = std::result::Result<T, Error>; <|fim_suffix|> Error::Io(error) } } #[derive(Debug)] pub enum Argument { /// Path: Required file, got directory FileRequired(PathBuf),...
code_fim
hard
{ "lang": "rust", "repo": "Dentosal/brain-opt", "path": "/src/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pola-rs/polars path: /crates/polars-core/src/chunked_array/ops/decimal.rs use crate::prelude::*; impl Utf8Chunked { /// Convert an [`Utf8Chunked`] to a `Series` of [`DataType::Decimal`]. /// The parameters needed for the decimal type are inferred. /// /// If the decimal `precisi...
code_fim
hard
{ "lang": "rust", "repo": "pola-rs/polars", "path": "/crates/polars-core/src/chunked_array/ops/decimal.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>t mut valid_count = 0; while let Some(Some(v)) = iter.next() { if let Some(scale_value) = polars_arrow::compute::decimal::infer_scale(v.as_bytes()) { scale = std::cmp::max(scale, scale_value); valid_count += 1; if valid_count == infer_len...
code_fim
hard
{ "lang": "rust", "repo": "pola-rs/polars", "path": "/crates/polars-core/src/chunked_array/ops/decimal.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Solution { pub fn range_sum_bst(root: Option<Rc<RefCell<TreeNode>>>, l: i32, r: i32) -> i32 { let mut sum = 0; let mut stack: Vec<Rc<RefCell<TreeNode>>> = Vec::new(); match &root { Some(x) => stack.push(Rc::clone(&x)), None => return 0, }; ...
code_fim
hard
{ "lang": "rust", "repo": "accierro/leetcode-solutions", "path": "/easy/binary_tree/range_sum_of_bst/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: accierro/leetcode-solutions path: /easy/binary_tree/range_sum_of_bst/src/main.rs // Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive). // The binary search tree is guaranteed to have unique values. // Example 1: // Input:...
code_fim
hard
{ "lang": "rust", "repo": "accierro/leetcode-solutions", "path": "/easy/binary_tree/range_sum_of_bst/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match *b / *p { 1.0 => "w", 0.75 => "2.", 0.5 => "2", 0.375 => "4.", 0.25 => "4", 0.2875 => "8.", 0.125 => "8", 0.09375 => "16.", 0.0625 => "16", 0.046875 => "32.", 0...
code_fim
hard
{ "lang": "rust", "repo": "Cynlic/strangers", "path": "/src/noteTree.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Cynlic/strangers path: /src/noteTree.rs /* Context-free grammar for tuplets? start => (prob pulse or tuplet or rest) tuplet => (prob of all tuplets) pulse => (prob of all pulses) rest => (prob of all rests) */ use rand; pub enum NonTerminal { Start, Tuplet, Pulse, Rest, ...
code_fim
hard
{ "lang": "rust", "repo": "Cynlic/strangers", "path": "/src/noteTree.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_new() { let blockchain = Blockchain::new(1); assert_eq!(blockchain.chain.len(), 1); assert_eq!(blockchain.transactions.len(), 1); } #[test] fn test_add_transaction() { let mut blockchain = Blockchain::new(1); blockchain.add_bloc...
code_fim
hard
{ "lang": "rust", "repo": "justjapann/ASB", "path": "/src/blockchain.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: justjapann/ASB path: /src/blockchain.rs //! A simple blockchain. use crate::block::Block; /// `Blockchain` object. /// /// The `Blockchain` stores: /// * A `Vec` containing all `Block`s /// * A difficulty level which will impact time spent mining/generating proof of work (the nonce) /// * A `...
code_fim
hard
{ "lang": "rust", "repo": "justjapann/ASB", "path": "/src/blockchain.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod test_blockchain { use super::*; #[test] fn test_new() { let blockchain = Blockchain::new(1); assert_eq!(blockchain.chain.len(), 1); assert_eq!(blockchain.transactions.len(), 1); } #[test] fn test_add_transaction() { let mut blockc...
code_fim
hard
{ "lang": "rust", "repo": "justjapann/ASB", "path": "/src/blockchain.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn handle_dir_request(path: PathBuf, stream: &mut TcpStream) { let paths = fs::read_dir(path).unwrap(); let list = paths.map(|entry| { let entry = entry.unwrap(); let mut name = entry.file_name().to_string_lossy().into_owned(); if entry.file_type().unwrap().is_dir() { ...
code_fim
hard
{ "lang": "rust", "repo": "WLBF/static-server", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let paths = fs::read_dir(path).unwrap(); let list = paths.map(|entry| { let entry = entry.unwrap(); let mut name = entry.file_name().to_string_lossy().into_owned(); if entry.file_type().unwrap().is_dir() { name.push('/'); } format!("<li><a href=...
code_fim
hard
{ "lang": "rust", "repo": "WLBF/static-server", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WLBF/static-server path: /src/main.rs extern crate httparse; mod thread_pool; use thread_pool::ThreadPool; use std::io::prelude::*; use std::net::TcpListener; use std::net::TcpStream; use std::fs; use std::path::PathBuf; use std::env; fn main() { let listener = TcpListener::bind("127.0.0...
code_fim
hard
{ "lang": "rust", "repo": "WLBF/static-server", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Add further named keys and assert that each is returned in `list_named_keys()`. let new_named_keys: NamedKeys = runtime::get_named_arg(ARG_NEW_NAMED_KEYS); let mut expected_named_keys = expected_initial_named_keys; for (key, value) in new_named_keys { runtime::put_key(&key, val...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/smart_contracts/contracts/test/list-named-keys/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nguyenminhhieu12041996/casper-node path: /smart_contracts/contracts/test/list-named-keys/src/main.rs #![no_std] #![no_main] extern crate alloc; use alloc::{string::String, vec::Vec}; use casper_contract::contract_api::runtime; use casper_types::contracts::NamedKeys; <|fim_suffix|>#[no_mangle...
code_fim
medium
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/smart_contracts/contracts/test/list-named-keys/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tiborschneider/bgpsim path: /src/test/test_router.rs use crate::bgp::BgpSessionType::{EBgp, IBgpClient, IBgpPeer}; use crate::bgp::{BgpEvent, BgpRoute}; use crate::event::{Event, EventQueue}; use crate::router::*; use crate::{AsId, Prefix}; use crate::{IgpNetwork, NetworkDevice}; use maplit::{ha...
code_fim
hard
{ "lang": "rust", "repo": "tiborschneider/bgpsim", "path": "/src/test/test_router.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let exp = &expected_forwarding_table; let acq = &a.igp_forwarding_table; for target in vec![&a, &b, &c, &d, &e] { assert_eq!(exp.get(&target.router_id()), acq.get(&target.router_id())); } b.write_igp_forwarding_table(&net).unwrap(); let expected_forwarding_table = hashma...
code_fim
hard
{ "lang": "rust", "repo": "tiborschneider/bgpsim", "path": "/src/test/test_router.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> b.write_igp_forwarding_table(&net).unwrap(); let expected_forwarding_table = hashmap! { a.router_id() => Some((a.router_id(), 1.0)), b.router_id() => Some((b.router_id(), 0.0)), c.router_id() => Some((c.router_id(), 1.0)), d.router_id() => Some((c.router_id(), 2.0)...
code_fim
hard
{ "lang": "rust", "repo": "tiborschneider/bgpsim", "path": "/src/test/test_router.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dotcypress/llhd-sim path: /src/engine.rs .into(), )) } ShiftInst(dir, ref ty, ref target, ref insert, ref amount) if ty.is_array() => { let amount = resolve_value(amount); let amount = amount.unwrap_const().unw...
code_fim
hard
{ "lang": "rust", "repo": "dotcypress/llhd-sim", "path": "/src/engine.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Modify a value according to a pointer. fn modify_pointed_value<T>(ptr: &ValuePointer<T>, current: &ValueRef, new: ValueRef) -> ValueRef { let new = if ptr.discard != (0, 0) { let (left, right) = ptr.discard; // trace!("discard ({}, {}) of {:?}", left, right, new); match new...
code_fim
hard
{ "lang": "rust", "repo": "dotcypress/llhd-sim", "path": "/src/engine.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dotcypress/llhd-sim path: /src/engine.rs t::Const(ref k) => k.clone(), ref x => panic!( "expected value {:?} to resolve to a constant/aggregate, got {:?}", vr, x ), }, } };...
code_fim
hard
{ "lang": "rust", "repo": "dotcypress/llhd-sim", "path": "/src/engine.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Apu { pub fn new(mapper: Mapper) -> Shared<Apu> { shared(Apu { cycle: 0, irq: false, sample_step: 0f32, samples: Vec::with_capacity(SAMPLES_PER_FRAME as usize), pulse1: Pulse::new(SweepNegator::Pulse1), pulse2: Pulse:...
code_fim
hard
{ "lang": "rust", "repo": "hydrosquall/nes", "path": "/src/apu/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hydrosquall/nes path: /src/apu/mod.rs use crate::common::{Shared, shared, Clocked, CLOCKS_PER_FRAME, SAMPLES_PER_FRAME, Irq}; use crate::apu::pulse::Pulse; use crate::apu::triangle::Triangle; use crate::apu::components::SweepNegator; use crate::apu::noise::Noise; use crate::apu::dmc::Dmc; use cr...
code_fim
hard
{ "lang": "rust", "repo": "hydrosquall/nes", "path": "/src/apu/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pmacciacchera/MySniffer path: /src/args/mod.rs mod capture; mod parse; use clap::{crate_authors, crate_description, crate_name, crate_version, App}; use crate::args::capture::CaptureSubcommand; use crate::args::parse::ParseSubcommand; use crate::lib::packet_capture::*; <|fim_suffix|> if let...
code_fim
hard
{ "lang": "rust", "repo": "pmacciacchera/MySniffer", "path": "/src/args/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(sub) = matches.subcommand_matches("capture") { if sub.subcommand_matches("list").is_some() { device_list(); } else if let Some(run_args) = sub.subcommand_matches("run") { let capture_device = capture_subcommand.set_args(run_args); let dev...
code_fim
hard
{ "lang": "rust", "repo": "pmacciacchera/MySniffer", "path": "/src/args/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.#field_name = std::option::Option::Some(#field_name); self } } } } /// Generate a validation call that a field was set fn gen_validation(f: &Field) -> GeneratedTokenStream { let field_name = f.ident.as_ref().unwrap(); let message = form...
code_fim
hard
{ "lang": "rust", "repo": "jbalint/proc-macro-workshop", "path": "/builder/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// TODO : doc me fn get_type_with_single_argument(ty: &Type) -> Option<(String, &Type)> { if let Type::Path(path) = ty { if let Some(first_segment) = path.path.segments.first() { if let PathArguments::AngleBracketed(type_args) = &first_segment.arguments { if let Som...
code_fim
hard
{ "lang": "rust", "repo": "jbalint/proc-macro-workshop", "path": "/builder/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jbalint/proc-macro-workshop path: /builder/src/lib.rs ///! My implementation of the `builder` example ///! ///! I felt that as the successive requirements were addressed, there ///! developed an increased opportunity for refactoring the code which ///! I didn't do fully. extern crate proc_macro...
code_fim
hard
{ "lang": "rust", "repo": "jbalint/proc-macro-workshop", "path": "/builder/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: actix/actix-web path: /actix-web/src/resource.rs :new(MyData { count: Default::default() })) /// .route(web::get().to(handler)) /// ); /// ``` #[doc(alias = "manage")] pub fn app_data<U: 'static>(mut self, data: U) -> Self { self.app_data .get_or_i...
code_fim
hard
{ "lang": "rust", "repo": "actix/actix-web", "path": "/actix-web/src/resource.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Box::pin(async move { let default = default_fut.await?; let routes = factory_fut .await .into_iter() .collect::<Result<Vec<_>, _>>()?; Ok(ResourceService { routes, default }) }) } } pub struct Resourc...
code_fim
hard
{ "lang": "rust", "repo": "actix/actix-web", "path": "/actix-web/src/resource.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> web::resource("/test3").route(web::get().to(|| async { "hello" })) } App::new() .service(my_resource_1()) .service(my_resource_2()) .service(my_resource_3()); } #[actix_rt::test] async fn test_middleware() { let srv = in...
code_fim
hard
{ "lang": "rust", "repo": "actix/actix-web", "path": "/actix-web/src/resource.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: backup22143/monolith path: /src/tests/url/percent_encode.rs // ██████╗ █████╗ ███████╗███████╗██╗███╗ ██╗ ██████╗ // ██╔══██╗██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔════╝ // ██████╔╝███████║███████╗███████╗██║██╔██╗ ██║██║ ███╗ // ██╔═══╝ ██╔══██║╚════██║╚════██║██║██║╚██╗██║██║ ██║ //...
code_fim
medium
{ "lang": "rust", "repo": "backup22143/monolith", "path": "/src/tests/url/percent_encode.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(url::percent_encode(str!("'")), "%27"); } }<|fim_prefix|>// repo: backup22143/monolith path: /src/tests/url/percent_encode.rs // ██████╗ █████╗ ███████╗███████╗██╗███╗ ██╗ ██████╗ // ██╔══██╗██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔════╝ // ██████╔╝███████║███████╗███████╗██║█...
code_fim
medium
{ "lang": "rust", "repo": "backup22143/monolith", "path": "/src/tests/url/percent_encode.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lislis/workshop-rust-games path: /src/game/snacks.rs use ggez::{Context, GameResult}; use ggez::graphics; use rand; use nalgebra as na; type Point2 = na::Point2<f32>; type Vector2 = na::Vector2<f32>; use crate::game::config::{SCREEN_H, SCREEN_W, SNACK_W}; <|fim_suffix|> pub fn draw(&self, ...
code_fim
hard
{ "lang": "rust", "repo": "lislis/workshop-rust-games", "path": "/src/game/snacks.rs", "mode": "psm", "license": "CC-BY-3.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn collides_with(&mut self, other: Point2) -> bool { /* * TODO: * Check whether the snack has collided with something, * providing it's active */ false } } pub fn spawn_snacks(num: usize) -> Vec<Snack> { /* * TODO: * Ge...
code_fim
hard
{ "lang": "rust", "repo": "lislis/workshop-rust-games", "path": "/src/game/snacks.rs", "mode": "spm", "license": "CC-BY-3.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lnds/desafios-programando.org path: /2019-12-29/poker/tests/poker.rs use poker::manos_ganadoras; use std::collections::HashSet; fn hs_from<'a>(input: &[&'a str]) -> HashSet<&'a str> { let mut hs = HashSet::new(); for item in input.iter() { hs.insert(*item); } hs } /// T...
code_fim
hard
{ "lang": "rust", "repo": "lnds/desafios-programando.org", "path": "/2019-12-29/poker/tests/poker.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // with multiple decks, both hands have a full house with the same triplet, tie goes to the pair test(&["5C 5P 5D 9P 9D", "5C 5P 5D 8P 8D"], &["5C 5P 5D 9P 9D"]) } #[test] #[ignore] fn test_four_of_a_kind_beats_full_house() { test(&["4P 5C 4D 5D 4C", "3P 3C 2P 3D 3T"], &["3P 3C 2P 3D 3T"]) } ...
code_fim
hard
{ "lang": "rust", "repo": "lnds/desafios-programando.org", "path": "/2019-12-29/poker/tests/poker.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pjmore/arrow2 path: /src/io/parquet/write/boolean.rs use parquet2::{ compression::create_codec, encoding::{hybrid_rle::bitpacked_encode, Encoding}, metadata::ColumnDescriptor, read::{CompressedPage, PageHeader}, schema::DataPageHeader, statistics::{serialize_statistics, B...
code_fim
hard
{ "lang": "rust", "repo": "pjmore/arrow2", "path": "/src/io/parquet/write/boolean.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let header = PageHeader::V1(DataPageHeader { num_values: array.len() as i32, encoding: Encoding::Plain, definition_level_encoding: Encoding::Rle, repetition_level_encoding: Encoding::Rle, statistics, }); Ok(CompressedPage::new( header, b...
code_fim
hard
{ "lang": "rust", "repo": "pjmore/arrow2", "path": "/src/io/parquet/write/boolean.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bastienbot/csml-engine path: /csml_interpreter/src/data/msg.rs use crate::data::hold::Hold; use crate::data::message::Message; use crate::data::Memories; <|fim_suffix|>//////////////////////////////////////////////////////////////////////////////// // STATIC FUNCTIONS //////////////////////////...
code_fim
hard
{ "lang": "rust", "repo": "bastienbot/csml-engine", "path": "/csml_interpreter/src/data/msg.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub enum MSG { Memory(Memories), Message(Message), Hold(Hold), Next { flow: Option<String>, step: Option<String>, }, Error(Message), } //////////////////////////////////////////////////////////////////////////////// // STATIC FUNCTIONS ////////////...
code_fim
hard
{ "lang": "rust", "repo": "bastienbot/csml-engine", "path": "/csml_interpreter/src/data/msg.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eklein09/ctci_rust_lesson1 path: /src/main.rs use counter::Counter; use std::collections::HashSet; mod compression; mod urlify; mod rotation; mod common_prefix; <|fim_suffix|> let mut encountered: HashSet<char> = HashSet::new(); let mut unique: bool = true; for c in s.chars() { ...
code_fim
medium
{ "lang": "rust", "repo": "eklein09/ctci_rust_lesson1", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn is_anagram(a: &str, b: &str) -> bool { let count_a = a.chars().collect::<Counter<_>>(); let count_b = b.chars().collect::<Counter<_>>(); count_a == count_b } #[cfg(test)] mod tests { // Note this useful idiom: importing names from outer (for mod tests) scope. use super::*; #[t...
code_fim
hard
{ "lang": "rust", "repo": "eklein09/ctci_rust_lesson1", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tuffing/adventofcode2015 path: /aoc2015/src/main.rs extern crate regex; mod loadinput; mod day01; mod day02; mod day03; mod day04; mod day05; mod day06; mod day07; mod day08; mod day09; mod day10; mod day11; mod day12; mod day13; mod day14; mod day15; mod day16; mod day17; mod day18; mod day19; ...
code_fim
hard
{ "lang": "rust", "repo": "tuffing/adventofcode2015", "path": "/aoc2015/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (part1, part2) = day23::solution::run(); println!("Day 23 ---- Part1: {}, Part2: {}", part1, part2); let (part1, part2) = day24::solution::run(); println!("Day 24 ---- Part1: {}, Part2: {}", part1, part2); let (part1, part2) = day25::solution::run(); println!("Day 25 ---- Par...
code_fim
hard
{ "lang": "rust", "repo": "tuffing/adventofcode2015", "path": "/aoc2015/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (part1, part2) = day18::solution::run(); println!("Day 18 ---- Part1: {}, Part2: {}", part1, part2); let (part1, part2) = day19::solution::run(); println!("Day 19 ---- Part1: {}, Part2: {}", part1, part2); let (part1, part2) = day20::solution::run(); println!("Day 20 ---- Par...
code_fim
hard
{ "lang": "rust", "repo": "tuffing/adventofcode2015", "path": "/aoc2015/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ArchName { /// Determine the default assembler syntax for a given platform. /// /// Some architectures don't have an assembler implemented yet, so this /// lookup may fail. pub fn default_asm(self) -> Option<asm::AssemblerName> { match self { ArchName::Sm83 => ...
code_fim
hard
{ "lang": "rust", "repo": "kmeisthax/retrogram", "path": "/src/arch/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kmeisthax/retrogram path: /src/arch/mod.rs //! Implementations of processor architectures that Retrogram can analyze. //! //! Each architecture is implemented as a child module to this one. At a bare //! minimum, the architectures must implement at least one function, called //! "disassemble", a...
code_fim
hard
{ "lang": "rust", "repo": "kmeisthax/retrogram", "path": "/src/arch/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(test)] Self::Test => "Test Architecture", } } } impl str::FromStr for ArchName { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { match s.to_ascii_lowercase().as_ref() { "sm83" => Ok(ArchName::Sm83), "lr359...
code_fim
hard
{ "lang": "rust", "repo": "kmeisthax/retrogram", "path": "/src/arch/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlexEne/wasm_interp path: /wasm/src/core/executor/store_access.rs use crate::core::{stack_entry::StackEntry, Callable, FuncType, Global, Memory, Table}; use anyhow::Result; use std::{ cell::{Ref, RefMut}, marker::PhantomData, ops::{Deref, DerefMut}, }; pub trait LifetimeToRef<'a, T>...
code_fim
hard
{ "lang": "rust", "repo": "AlexEne/wasm_interp", "path": "/wasm/src/core/executor/store_access.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn set_global_value(&mut self, idx: usize, value: StackEntry) -> Result<()> { self.global_idx_mut(idx)?.set_value(value) } fn read_data(&self, mem_idx: usize, offset: usize, data: &mut [u8]) -> Result<()> { self.mem_idx(mem_idx)?.get_data(offset, data) } fn write_data...
code_fim
hard
{ "lang": "rust", "repo": "AlexEne/wasm_interp", "path": "/wasm/src/core/executor/store_access.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Dieg0Code/RestApi.rs path: /src/model/mod.rs use serde:: {Deserialize, Serialize}; <|fim_suffix|>b title: String, pub genre: String }<|fim_middle|>// data model #[derive(Clone, Serialize, Deserialize)] pub struct Movie { pu
code_fim
medium
{ "lang": "rust", "repo": "Dieg0Code/RestApi.rs", "path": "/src/model/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>Deserialize)] pub struct Movie { pub title: String, pub genre: String }<|fim_prefix|>// repo: Dieg0Code/RestApi.rs path: /src/model/mod.rs use serde:: {Deserialize, Serialize}; <|fim_middle|>// data model #[derive(Clone, Serialize,
code_fim
easy
{ "lang": "rust", "repo": "Dieg0Code/RestApi.rs", "path": "/src/model/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>b title: String, pub genre: String }<|fim_prefix|>// repo: Dieg0Code/RestApi.rs path: /src/model/mod.rs use serde:: {Deserialize, Serialize}; <|fim_middle|>// data model #[derive(Clone, Serialize, Deserialize)] pub struct Movie { pu
code_fim
medium
{ "lang": "rust", "repo": "Dieg0Code/RestApi.rs", "path": "/src/model/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>s //~| NOTE expected (), found integer //~| NOTE expected type `()` }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/if/if-let-arm-types.rs fn main() { if let Some(b) = None { //~^ NOTE if and else have i<|fim_middle|>ncompatible types () //~^...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/if/if-let-arm-types.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/if/if-let-arm-types.rs fn main() { if let Some(b) = None { //~^ NOTE if and else have incompatible types () //~^ NOTE expected because of this }<|fim_suffix|>s //~| NOTE expected (), found integer //~| NOT...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/if/if-let-arm-types.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reinterpretcat/vrp path: /vrp-pragmatic/tests/features/multjob/basic_service.rs use crate::format::problem::*; use crate::format::solution::*; use crate::format_time; use crate::helpers::*; #[test] fn can_assign_service_job() { let problem = Problem { plan: Plan { jobs: ...
code_fim
hard
{ "lang": "rust", "repo": "reinterpretcat/vrp", "path": "/vrp-pragmatic/tests/features/multjob/basic_service.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tagantroy/marathon-benchmark path: /src/devices/local_emulator_provider.rs use crate::devices::provider::Provider; use async_trait::async_trait; use std::collections::HashMap; use tokio::process::{Child, Command}; <|fim_suffix|> async fn connect(&self) -> Result<(), Box<dyn std::error::Error...
code_fim
hard
{ "lang": "rust", "repo": "tagantroy/marathon-benchmark", "path": "/src/devices/local_emulator_provider.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> async fn connect(&self) -> Result<(), Box<dyn std::error::Error>> { Ok(()) } async fn terminate(&mut self) -> Result<(), Box<dyn std::error::Error>> { for (_key, child) in self.processes.iter_mut() { child.kill().await?; } Ok(()) } }<|fim_prefix...
code_fim
hard
{ "lang": "rust", "repo": "tagantroy/marathon-benchmark", "path": "/src/devices/local_emulator_provider.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[async_trait] impl Provider for LocalEmulatorProvider { async fn prepare(&mut self) -> Result<(), Box<dyn std::error::Error>> { for i in 0..self.number_of_emulators { self.start_emulator(i).await?; } Ok(()) } async fn connect(&self) -> Result<(), Box<dyn s...
code_fim
hard
{ "lang": "rust", "repo": "tagantroy/marathon-benchmark", "path": "/src/devices/local_emulator_provider.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Flourish3/NEAT-rust path: /genome/src/unit_test.rs //use connect_gene::Connect_gene; use node::Node; #[test] fn test_node_output_0(){ <|fim_suffix|>#[test] fn test_node_output_positive(){ assert!(Node::produce_output(5_f64) > 0_f64); } #[test] fn test_node_output_negative(){ assert!(No...
code_fim
easy
{ "lang": "rust", "repo": "Flourish3/NEAT-rust", "path": "/genome/src/unit_test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_node_output_positive(){ assert!(Node::produce_output(5_f64) > 0_f64); } #[test] fn test_node_output_negative(){ assert!(Node::produce_output(-5_f64) < 0_f64); }<|fim_prefix|>// repo: Flourish3/NEAT-rust path: /genome/src/unit_test.rs //use connect_gene::Connect_gene; use node::No...
code_fim
easy
{ "lang": "rust", "repo": "Flourish3/NEAT-rust", "path": "/genome/src/unit_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_node_output_negative(){ assert!(Node::produce_output(-5_f64) < 0_f64); }<|fim_prefix|>// repo: Flourish3/NEAT-rust path: /genome/src/unit_test.rs //use connect_gene::Connect_gene; use node::Node; #[test] fn test_node_output_0(){ assert_eq!(0_f64, Node::produce_output(0_f64)); } ...
code_fim
easy
{ "lang": "rust", "repo": "Flourish3/NEAT-rust", "path": "/genome/src/unit_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thomasmatecki/jq2rs path: /jq2rs/src/modules/oniguruma/src/st.rs e_entry>() as libc::c_ulong) as *mut libc::c_char as *mut *mut st_table_entry; if (*tbl).bins.is_null() { free(tbl as *mut libc::c_void); return 0 as *mut st_table } return tbl; } #[no_mangle...
code_fim
hard
{ "lang": "rust", "repo": "thomasmatecki/jq2rs", "path": "/jq2rs/src/modules/oniguruma/src/st.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }