text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: iorveth/ritcoin path: /src/cli.rs use crate::errors::*; use crate::miner_cli; use crate::wallet_cli; use crate::*; pub use std::fs::{self, File}; pub use std::io::prelude::*; use std::io::stdin; pub const ADDRESS_PATH: &str = "data/address.txt"; pub const PRIVATE_KEY_PATH: &str = "data/private_...
code_fim
hard
{ "lang": "rust", "repo": "iorveth/ritcoin", "path": "/src/cli.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>tr>>()[1]; wallet_cli::broadcast(serialized_tx, prepared_transactions, true) } _ => { let serialized_tx = broadcast_parameters[1]; wallet_cli::broadcast(serialized_tx, prepared_transactions, false) ...
code_fim
hard
{ "lang": "rust", "repo": "iorveth/ritcoin", "path": "/src/cli.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } command if command.starts_with("add node") => { let node = command.split_ascii_whitespace().collect::<Vec<&str>>()[2]; miner_cli::add_node(node, ritcoin_state) } "mine" => miner_cli::mine(ritcoin_state), "consensus" => miner_cli:...
code_fim
hard
{ "lang": "rust", "repo": "iorveth/ritcoin", "path": "/src/cli.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xenzh/learn-rust path: /associated_types/src/main.rs fn main() { // associating types with the trait. // helps to avoid everything related with original trait // to be generic over associated types. trait Graph { type Node; type Edge; fn has_edge(&self, &Self::Nod...
code_fim
medium
{ "lang": "rust", "repo": "xenzh/learn-rust", "path": "/associated_types/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // providing actual assoc types for trait objects: let graph = MyGraph; let _obj = Box::new(graph) as Box<Graph<Node=Node, Edge=Edge>>; }<|fim_prefix|>// repo: xenzh/learn-rust path: /associated_types/src/main.rs fn main() { // associating types with the trait. // helps to avoid every...
code_fim
hard
{ "lang": "rust", "repo": "xenzh/learn-rust", "path": "/associated_types/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32h5/src/stm32h573/dcache/cmdreaddrr.rs #[doc = "Register `CMDREADDRR` reader"] pub type R = crate::R<CMDREADDRR_SPEC>; #[doc = "Register `CMDREADDRR` writer"] pub type W = crate::W<CMDREADDRR_SPEC>; #[doc = "Field `CMDENDADDR` reader - end address of range ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h5/src/stm32h573/dcache/cmdreaddrr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>s register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."] pub struct CMDREADDRR_SPEC; impl crate::RegisterSpec for CMDREADDRR_SPEC { type Ux = u32; } #[doc = "`read()` method returns [`cmdreaddrr::R`](R) reader structure"] impl crate::Readable for CMDREADDRR_SPEC {} #[doc = "`write(|...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h5/src/stm32h573/dcache/cmdreaddrr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn seeded_assert_evolution( start: Vec<&str>, inputs: Vec<ferris_base::core::direction::Direction>, end: Vec<&str>, seed: Option<[u8; 32]>, ) -> bool { let inputs_as_options = inputs.iter().map(|&dir| Some(dir)).collect(); seeded_assert_evolution_with_pauses(start, inputs_as_o...
code_fim
hard
{ "lang": "rust", "repo": "mfred488/ferris-is-you", "path": "/ferris-base/tests/utils/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> seeded_assert_evolution_with_pauses(start, inputs_as_options, end, seed) } pub fn assert_evolution( start: Vec<&str>, inputs: Vec<ferris_base::core::direction::Direction>, end: Vec<&str>, ) -> bool { seeded_assert_evolution(start, inputs, end, None) }<|fim_prefix|>// repo: mfred488/fe...
code_fim
hard
{ "lang": "rust", "repo": "mfred488/ferris-is-you", "path": "/ferris-base/tests/utils/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mfred488/ferris-is-you path: /ferris-base/tests/utils/mod.rs use ferris_base; pub fn seeded_assert_evolution_with_pauses( start: Vec<&str>, inputs: Vec<Option<ferris_base::core::direction::Direction>>, end: Vec<&str>, seed: Option<[u8; 32]>, ) -> bool { let start_one_line = ...
code_fim
hard
{ "lang": "rust", "repo": "mfred488/ferris-is-you", "path": "/ferris-base/tests/utils/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tmikus/game-boy-rust path: /client/src/core/memory.rs use { core::{ emulator::Emulator, gpu::PALETTE, interrupt::Interrupt, registers::Registers, keys::Keys, }, rand, std::{ ptr, }, }; pub const CART_SIZE: usize = 0x8000; pub const SRAM_SIZE: usize = 0x2000; pu...
code_fim
hard
{ "lang": "rust", "repo": "tmikus/game-boy-rust", "path": "/client/src/core/memory.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn read_short_from_stack(&self) -> u16 { let emulator = unsafe { &mut *self.emulator }; let value = self.read_short(emulator.registers.sp); emulator.registers.sp += 2; value } pub fn write_byte(&mut self, address: u16, value: u8) { if address >= 0xA000 && address <= 0xBFFF {...
code_fim
hard
{ "lang": "rust", "repo": "tmikus/game-boy-rust", "path": "/client/src/core/memory.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn boss_tweets_counter(&self, name: &LangString) -> LangMetric<Self::Metric>; fn boss_subscriptions_gauge(&self, name: &LangString) -> Self::Metric; fn websocket_connections_gauge(&self) -> &Self::Metric; fn write_per_boss_metrics(&self, metrics: &PerBossMetrics<'_, Self::Metric>) -> Sel...
code_fim
hard
{ "lang": "rust", "repo": "walfie/petronel-graphql", "path": "/src/metrics/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn set(&self, value: usize); } pub struct PerBossMetrics<'m, M: Metric> { pub boss_tweets_counters: Vec<&'m LangMetric<M>>, pub boss_subscriptions_gauges: Vec<&'m M>, } pub trait MetricFactory { type Metric: Metric; type Output; fn boss_tweets_counter(&self, name: &LangString) -...
code_fim
medium
{ "lang": "rust", "repo": "walfie/petronel-graphql", "path": "/src/metrics/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: walfie/petronel-graphql path: /src/metrics/mod.rs mod prometheus; pub use crate::metrics::prometheus::{PrometheusMetric, PrometheusMetricFactory}; use crate::model::{LangString, Language}; pub trait Metric: Clone { fn get(&self) -> usize; fn inc(&self); fn dec(&self); fn set(&s...
code_fim
hard
{ "lang": "rust", "repo": "walfie/petronel-graphql", "path": "/src/metrics/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Schenk75/Learn-Rust path: /leetcode-by-rust/LCOF/lcof10-2-青蛙跳台阶问题/src/main.rs pub fn num_ways(n: i32) -> i32 { if n == 0 {return 1;} if n == 1 {return 1;} let mut a = 1; let mut b = 1; let mut temp; <|fim_suffix|> fn main() { println!("{}", num_ways(48)); println!("{...
code_fim
medium
{ "lang": "rust", "repo": "Schenk75/Learn-Rust", "path": "/leetcode-by-rust/LCOF/lcof10-2-青蛙跳台阶问题/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{}", num_ways(48)); println!("{}", num_ways(5)); }<|fim_prefix|>// repo: Schenk75/Learn-Rust path: /leetcode-by-rust/LCOF/lcof10-2-青蛙跳台阶问题/src/main.rs pub fn num_ways(n: i32) -> i32 { if n == 0 {return 1;} if n == 1 {return 1;} let mut a = 1; let mut b = 1; let mut t...
code_fim
easy
{ "lang": "rust", "repo": "Schenk75/Learn-Rust", "path": "/leetcode-by-rust/LCOF/lcof10-2-青蛙跳台阶问题/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(version) = new_lock_version { let mut dependency = dep.clone(); lock_file_updated = true; dependency.version = version; lock.dependencies.insert(dep.name.clone(), dependency); } } if lock_file_updated { save_confi...
code_fim
hard
{ "lang": "rust", "repo": "dmgolembiowski/derpy", "path": "/src/cmds/upgrade.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dmgolembiowski/derpy path: /src/cmds/upgrade.rs use derpyfile::{DerpyFile, load_config, save_config}; use acquire::{acquire, AcquireMode, AcquireOutcome}; use consts::{CONFIG_FILE, CONFIG_LOCK_FILE}; use std::collections::BTreeMap; use dependency::Dependency; use cmds::CommandContext; use error:...
code_fim
hard
{ "lang": "rust", "repo": "dmgolembiowski/derpy", "path": "/src/cmds/upgrade.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for (pos, _) in self.inputs.iter().enumerate() { let index = Index::from(pos); args.push(Pat::Verbatim(quote! { self.args.#index })) } args } pub fn iter_arg_types(&self) -> Result<Type> { let mut args = self.ar...
code_fim
hard
{ "lang": "rust", "repo": "brace-rs/brace-hook", "path": "/crates/brace-hook-gen/src/signature.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brace-rs/brace-hook path: /crates/brace-hook-gen/src/signature.rs use std::iter::FromIterator; use quote::quote; use syn::parse::{Error, Parse, ParseStream, Result}; use syn::punctuated::Punctuated; use syn::token::{Comma, Paren}; use syn::visit_mut::VisitMut; use syn::{ braced, parenthesiz...
code_fim
hard
{ "lang": "rust", "repo": "brace-rs/brace-hook", "path": "/crates/brace-hook-gen/src/signature.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Copy, Clone, PartialEq)] pub enum IqType { Get, Set, Result, Error, } impl FromStr for IqType { type Err = io::Error; fn from_str(s: &str) -> Result<Self, Self::Err> { match s.to_lowercase().as_ref() { "get" => Ok(IqType::Get), "set"...
code_fim
hard
{ "lang": "rust", "repo": "chrisballinger/xmpp-rs", "path": "/proto/src/events/interface.rs", "mode": "spm", "license": "LicenseRef-scancode-other-permissive", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chrisballinger/xmpp-rs path: /proto/src/events/interface.rs use std::io; use std::fmt; use std::str::FromStr; use std::fmt::Debug; use elementtree::Element; pub trait FromGeneric { type Generic; type Out; fn from_generic(event: &Self::Generic) -> Result<Self::Out, io::Error>; } #[d...
code_fim
hard
{ "lang": "rust", "repo": "chrisballinger/xmpp-rs", "path": "/proto/src/events/interface.rs", "mode": "psm", "license": "LicenseRef-scancode-other-permissive", "source": "the-stack-v2" }
<|fim_suffix|> match self { IqType::Get => "get".to_string(), IqType::Set => "set".to_string(), IqType::Result => "result".to_string(), IqType::Error => "error".to_string(), } } } impl fmt::Display for IqType { // This trait requires `fmt` with thi...
code_fim
hard
{ "lang": "rust", "repo": "chrisballinger/xmpp-rs", "path": "/proto/src/events/interface.rs", "mode": "spm", "license": "LicenseRef-scancode-other-permissive", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dCubelic/AdventOfCode-2019 path: /5/Rust/1.rs use std::io::{self, BufRead}; fn get_param(v: &mut Vec<i32>, i: usize, n: u32) -> i32 { let op_type = v[i] / 10_i32.pow(1+n) % 10; let param = if op_type == 0 { v[v[i+(n as usize)] as usize] } else { v[i+(n as usize)] }; param } <|fim_s...
code_fim
hard
{ "lang": "rust", "repo": "dCubelic/AdventOfCode-2019", "path": "/5/Rust/1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut i = 0; loop { let opcode = v[i] % 100; if opcode == 99 { break } match opcode { 1 => { let param1 = get_param(&mut v, i, 1); let param2 = get_param(&mut v, i, 2); let three = v[i+3]; v[three...
code_fim
hard
{ "lang": "rust", "repo": "dCubelic/AdventOfCode-2019", "path": "/5/Rust/1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: c-liang/leetcode path: /src/main.rs pub fn large_group_positions(s: String) -> Vec<Vec<i32>> { if s.len() < 3 { return vec![]; } let bytes = s.as_bytes(); let mut ans = vec![]; ans.push(vec![0, 1]); let mut pre_c = bytes[0]; let mut start = 0; let mut end ...
code_fim
medium
{ "lang": "rust", "repo": "c-liang/leetcode", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!( "{:?}", split_array_into_fibonacci_sequence::Solution::split_into_fibonacci("0123".into()) ); println!("Hello, world!"); }<|fim_prefix|>// repo: c-liang/leetcode path: /src/main.rs pub fn large_group_positions(s: String) -> Vec<Vec<i32>> { if s.len() < 3 { ...
code_fim
medium
{ "lang": "rust", "repo": "c-liang/leetcode", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ifyouseewendy/artichoke path: /artichoke-backend/src/convert/fixnum.rs use std::convert::TryFrom; use crate::convert::{Convert, Error, TryConvert}; use crate::sys; use crate::types::{Int, Ruby, Rust}; use crate::value::Value; use crate::Artichoke; impl Convert<u8> for Value { type From = R...
code_fim
hard
{ "lang": "rust", "repo": "ifyouseewendy/artichoke", "path": "/artichoke-backend/src/convert/fixnum.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[quickcheck] fn roundtrip_err(b: bool) -> bool { let interp = crate::interpreter().expect("init"); let value = Value::convert(&interp, b); let value = unsafe { Int::try_convert(&interp, value) }; let expected = Err(Error { from: Ruby::Bool, ...
code_fim
hard
{ "lang": "rust", "repo": "ifyouseewendy/artichoke", "path": "/artichoke-backend/src/convert/fixnum.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let interp = crate::interpreter().expect("init"); let value = Value::convert(&interp, b); let value = unsafe { Int::try_convert(&interp, value) }; let expected = Err(Error { from: Ruby::Bool, to: Rust::SignedInt, }); value == expected...
code_fim
hard
{ "lang": "rust", "repo": "ifyouseewendy/artichoke", "path": "/artichoke-backend/src/convert/fixnum.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tailhook/stator path: /src/redis/receiver.rs use std::io::Cursor; use std::sync::Arc; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering::SeqCst; use rotor_redis; use rotor_redis::Message; use cbor::Encoder; use inner::{MANAGER, SockId}; pub struct Receiver(SockId, usize, Arc...
code_fim
hard
{ "lang": "rust", "repo": "tailhook/stator", "path": "/src/redis/receiver.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Receiver { pub fn next_id(&mut self) -> usize { self.2.fetch_add(1, SeqCst) } } impl rotor_redis::Receiver for Receiver { fn receive(&mut self, msg: &Message) { let mut enc = Encoder::new(Cursor::new(Vec::new())); enc.u64(self.1 as u64).unwrap(); write_mes...
code_fim
hard
{ "lang": "rust", "repo": "tailhook/stator", "path": "/src/redis/receiver.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> room.add_word("not"); room.add_word("a"); room.add_word("real"); room.add_word("room"); assert!(room.is_real()); } #[test] fn parsed_sample4() { let mut room = Room::new(200, "decoy"); room.add_word("totally"); room.add_word("real"); room.add_word("room"); asser...
code_fim
hard
{ "lang": "rust", "repo": "gobanos/adventofcode-2016", "path": "/src/day4/problem1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> room.add_word("a"); room.add_word("b"); room.add_word("c"); room.add_word("d"); room.add_word("e"); room.add_word("f"); room.add_word("g"); room.add_word("h"); assert!(room.is_real()); } #[test] fn parsed_sample3() { let mut room = Room::new(404, "oarel"); ro...
code_fim
hard
{ "lang": "rust", "repo": "gobanos/adventofcode-2016", "path": "/src/day4/problem1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gobanos/adventofcode-2016 path: /src/day4/problem1.rs use std::collections::HashMap; use regex::Regex; struct Room { id: usize, letters: HashMap<char, usize>, checksum: String, } impl Room { fn new(id: usize, checksum: &str) -> Room { Room { id: id, ...
code_fim
hard
{ "lang": "rust", "repo": "gobanos/adventofcode-2016", "path": "/src/day4/problem1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if cfg!(feature = "bundled") || pkg_config::find_library("sqlite3").is_err() { cc::Build::new() .file("source/sqlite3.c") .compile("libsqlite3.a"); } }<|fim_prefix|>// repo: fd/sqlite3-src path: /build.rs extern crate cc; extern crate pkg_config; <|fim_middle|>fn ...
code_fim
easy
{ "lang": "rust", "repo": "fd/sqlite3-src", "path": "/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fd/sqlite3-src path: /build.rs extern crate cc; extern crate pkg_config; <|fim_suffix|> if cfg!(feature = "bundled") || pkg_config::find_library("sqlite3").is_err() { cc::Build::new() .file("source/sqlite3.c") .compile("libsqlite3.a"); } }<|fim_middle|>fn ...
code_fim
easy
{ "lang": "rust", "repo": "fd/sqlite3-src", "path": "/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `ENRL` writer - Enables the rising edge or level interrupt for each pin interrupt. Bit n configures the pin interrupt selected in PINTSELn. 0 = Disable rising edge or level interrupt. 1 = Enable rising edge or level interrupt."] pub struct ENRL_W<'a> { w: &'a mut...
code_fim
hard
{ "lang": "rust", "repo": "lpc55/lpc55-pac", "path": "/src/pint/ienr.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> &mut self.0 } } impl From<crate::W<IENR_SPEC>> for W { #[inline(always)] fn from(writer: crate::W<IENR_SPEC>) -> Self { W(writer) } } #[doc = "Field `ENRL` reader - Enables the rising edge or level interrupt for each pin interrupt. Bit n configures the pin interrupt selecte...
code_fim
hard
{ "lang": "rust", "repo": "lpc55/lpc55-pac", "path": "/src/pint/ienr.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lpc55/lpc55-pac path: /src/pint/ienr.rs #[doc = "Register `IENR` reader"] pub struct R(crate::R<IENR_SPEC>); impl core::ops::Deref for R { type Target = crate::R<IENR_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<IENR_SPEC>> fo...
code_fim
hard
{ "lang": "rust", "repo": "lpc55/lpc55-pac", "path": "/src/pint/ienr.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emabee/rust-hdbconnect path: /hdbconnect/tests/test_029_arrays.rs extern crate serde; mod test_utils; use flexi_logger::LoggerHandle; use hdbconnect::{Connection, HdbResult, HdbValue}; #[test] // cargo test --test test_029_arrays -- --nocapture pub fn test_029_arrays() -> HdbResult<()> { ...
code_fim
hard
{ "lang": "rust", "repo": "emabee/rust-hdbconnect", "path": "/hdbconnect/tests/test_029_arrays.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let value = connection .query("select val from TEST_STRING_ARRAYS where id = 2")? .into_single_row()? .into_single_value()?; if let HdbValue::ARRAY(vec) = value { assert_eq!(vec.len(), 7); let vec: Vec<String> = vec .into_iter() .map...
code_fim
hard
{ "lang": "rust", "repo": "emabee/rust-hdbconnect", "path": "/hdbconnect/tests/test_029_arrays.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> log_handle .parse_new_spec("info, hdbconnect::protocol::parts::hdb_value = debug") .unwrap(); let value = connection .query("select val from TEST_INTEGER_ARRAYS where id = 3")? .into_single_row()? .into_single_value()?; if let HdbValue::ARRAY(vec) = va...
code_fim
hard
{ "lang": "rust", "repo": "emabee/rust-hdbconnect", "path": "/hdbconnect/tests/test_029_arrays.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cloudhead/nakamoto path: /p2p/src/fsm.rs _common::block::time::{LocalDuration, LocalTime}; use nakamoto_common::block::tree::{self, BlockReader, BlockTree, ImportResult}; use nakamoto_common::block::{BlockHash, Height}; use nakamoto_common::block::{BlockTime, Transaction}; use nakamoto_common::n...
code_fim
hard
{ "lang": "rust", "repo": "cloudhead/nakamoto", "path": "/p2p/src/fsm.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn timer_expired(&mut self) { trace!("Received wake"); self.invmgr.received_wake(&self.tree); self.syncmgr.received_wake(&self.tree); self.pingmgr.received_wake(); self.addrmgr.received_wake(); self.peermgr.received_wake(&mut self.addrmgr); self...
code_fim
hard
{ "lang": "rust", "repo": "cloudhead/nakamoto", "path": "/p2p/src/fsm.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cloudhead/nakamoto path: /p2p/src/fsm.rs o, &peermgr::Connection)) -> Self { Self { addr: conn.socket.addr, local_addr: conn.local_addr, link: conn.link, since: conn.since, height: peer.height, services: peer.service...
code_fim
hard
{ "lang": "rust", "repo": "cloudhead/nakamoto", "path": "/p2p/src/fsm.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: quininer/sp800-185 path: /src/cshake.rs use tiny_keccak::{ Keccak, XofReader }; use ::utils::left_encode; /// The customizable SHAKE function. /// /// The two variants of `cSHAKE`—`cSHAKE128` and `cSHAKE256`—are defined in terms of the /// `SHAKE` and `KECCAK[c]` functions specified in FIPS 20...
code_fim
medium
{ "lang": "rust", "repo": "quininer/sp800-185", "path": "/src/cshake.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn init(&mut self, name: &[u8], custom: &[u8], rate: usize) { let mut encbuf = [0; 9]; let pos = left_encode(&mut encbuf, rate as u64); self.0.absorb(&encbuf[pos..]); // left_encode(rate) let pos = left_encode(&mut encbuf, name.len() as u64 * 8); self.0.absorb...
code_fim
medium
{ "lang": "rust", "repo": "quininer/sp800-185", "path": "/src/cshake.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: intdxdt/geom-2d path: /src/wkt.rs use crate::{GeomType, Point}; #[derive(Clone, Debug)] pub struct WKT { pub geom_type: GeomType, pub coordinates: Vec<Vec<Point>>, pub success: bool, pub message: String, } pub fn parse_wkt(s: &str) -> WKT { let geom_type; let mut wkt; ...
code_fim
hard
{ "lang": "rust", "repo": "intdxdt/geom-2d", "path": "/src/wkt.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let extract_coordinates = |coords: &Vec<wkt::types::Coord<f64>>| { let mut shell = vec![]; for c in coords.iter() { shell.push(Point::new(c.x, c.y)); } shell }; let coordinates = match wkt.items.pop().unwrap() { wkt::Geometry::Point(wkt::typ...
code_fim
hard
{ "lang": "rust", "repo": "intdxdt/geom-2d", "path": "/src/wkt.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let coordinates = match wkt.items.pop().unwrap() { wkt::Geometry::Point(wkt::types::Point(coords)) => { geom_type = GeomType::Point; let c = coords.unwrap(); vec![vec![Point::new(c.x, c.y)]] } wkt::Geometry::LineString(wkt::types::LineString(...
code_fim
hard
{ "lang": "rust", "repo": "intdxdt/geom-2d", "path": "/src/wkt.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn tailcall(&mut self) -> Option<Box<Future<Item=B::Item, Error=B::Error>>> { match *self { Chain::First(ref mut a, _) => { a.collapse(); None } Chain::Second(ref mut b) => b.tailcall(), Cha...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/futures/src/chain.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/futures/src/chain.rs use std::mem; use util::Collapsed; use {Future, Task, Poll}; pub enum Chain<A, B, C> where A: Future, B: Send + 'static { First(Collapsed<A>, C), Second(B), Done, } impl<A, B, C> Chain<A, B, C> where...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/futures/src/chain.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ghtyrant/sinfonia-server path: /src/api.rs use std::io; use std::sync::mpsc::{Receiver, Sender}; use std::sync::{Arc, Mutex}; use actix_cors::Cors; use actix_web::middleware::Logger; use actix_web::{get, post, web, App, HttpResponse, HttpServer}; use crate::audio_engine::messages::{Command, Re...
code_fim
hard
{ "lang": "rust", "repo": "ghtyrant/sinfonia-server", "path": "/src/api.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[post("/volume")] async fn volume(state: APIDataType, payload: web::Json<Volume>) -> HttpResponse { let api_data = state.lock().unwrap(); match send_message!( api_data.sender, api_data.receiver, Command::SetVolume { value: payload.value } ) { ...
code_fim
hard
{ "lang": "rust", "repo": "ghtyrant/sinfonia-server", "path": "/src/api.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let f = get_file(file!(), "1.txt"); let result = solve_puzzle_part_b(f.as_str()); if result.is_err() { return Err(result.err().unwrap()); } assert_eq!(8, result.unwrap()); Ok(()) } #[test] fn test_part_b_puzzle() -> Result<(), Erro...
code_fim
hard
{ "lang": "rust", "repo": "denysvitali/aoc-2020", "path": "/days/dec8/src/test/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: denysvitali/aoc-2020 path: /days/dec8/src/test/mod.rs #[cfg(test)] mod tests { use crate::{solve_puzzle, solve_puzzle_part_b}; use std::io::Error; use utils::get_file; #[test] fn test_example_instructions() -> Result<(), Error>{ let f = get_file(file!(), "1.txt"); ...
code_fim
medium
{ "lang": "rust", "repo": "denysvitali/aoc-2020", "path": "/days/dec8/src/test/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let f = get_file(file!(), "2.txt"); let result = solve_puzzle_part_b(f.as_str()); if result.is_err() { return Err(result.err().unwrap()); } assert_eq!(515, result.unwrap()); Ok(()) } }<|fim_prefix|>// repo: denysvitali/aoc-2020 path: /days...
code_fim
hard
{ "lang": "rust", "repo": "denysvitali/aoc-2020", "path": "/days/dec8/src/test/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn simple() { #[derive(Deserialize, Debug, PartialEq)] struct S { s: String, i: i32, v: Vec<f64>, } let v: Value = miniserde::json::from_str(r#"{"s":"This is a test", "i":24, "v": [10, 1.2, -50]}"#) .unwrap(); let s: S = from_value(&v...
code_fim
hard
{ "lang": "rust", "repo": "etwyniel/miniserde-from-value", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: etwyniel/miniserde-from-value path: /src/lib.rs #[macro_use] mod careful; use miniserde::{ de::{Map, Seq, Visitor}, json::{Number, Value}, Deserialize, Error, Result, }; use std::collections::btree_map; use std::slice; enum Event<'a> { Visitor(&'a Value, &'a mut dyn Visitor), ...
code_fim
hard
{ "lang": "rust", "repo": "etwyniel/miniserde-from-value", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(Deserialize, Debug, PartialEq)] struct S { s: String, i: i32, v: Vec<f64>, } let v: Value = miniserde::json::from_str(r#"{"s":"This is a test", "i":24, "v": [10, 1.2, -50]}"#) .unwrap(); let s: S = from_value(&v).unwrap(); assert...
code_fim
hard
{ "lang": "rust", "repo": "etwyniel/miniserde-from-value", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> debug!("Spawning worker thread"); let worker = worker::spawn(opts.token, opts.server) .chain_err(|| "Failed to create status worker")?; let mut router = Router::new(); router.post("/hook", routes::handle_event, "github_webhook"); router.get("/status", routes::handle_status, "s...
code_fim
hard
{ "lang": "rust", "repo": "MalloZup/tailor", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut engine = HandlebarsEngine::new(); engine.add(Box::new(DirectorySource::new( opts.templates, Path::new(".hbs").to_path_buf(), ))); engine .reload() .chain_err(|| "Failed to start templating engine")?; let mut chain = Chain::new(router); chai...
code_fim
hard
{ "lang": "rust", "repo": "MalloZup/tailor", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MalloZup/tailor path: /src/main.rs // Copyright 2017 CoreOS, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-...
code_fim
hard
{ "lang": "rust", "repo": "MalloZup/tailor", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: polachok/hyper-fahrenheit path: /examples/it_runs.rs use fahrenheit; use hyper::{Client, Uri}; use hyper_fahrenheit::{Connector, FahrenheitExecutor}; <|fim_suffix|> fahrenheit::run(async move { let client: Client<Connector, hyper::Body> = Client::builder() .executor(Fahre...
code_fim
medium
{ "lang": "rust", "repo": "polachok/hyper-fahrenheit", "path": "/examples/it_runs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fahrenheit::run(async move { let client: Client<Connector, hyper::Body> = Client::builder() .executor(FahrenheitExecutor) .build(Connector); let res = client .get(Uri::from_static("http://httpbin.org/ip")) .await .unwrap(); ...
code_fim
medium
{ "lang": "rust", "repo": "polachok/hyper-fahrenheit", "path": "/examples/it_runs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Robbepop/modular-bitfield path: /tests/bits-param/complex-use-case.rs use modular_bitfield::prelude::*; #[derive(BitfieldSpecifier)] #[bits = 2] pub enum Status { Red, Green, Yellow, } <|fim_suffix|> assert_eq!(<Status as Specifier>::BITS, 2); assert_eq!(<Header as Specifier...
code_fim
hard
{ "lang": "rust", "repo": "Robbepop/modular-bitfield", "path": "/tests/bits-param/complex-use-case.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(<Status as Specifier>::BITS, 2); assert_eq!(<Header as Specifier>::BITS, 4); assert_eq!(<PackedData as Specifier>::BITS, 16); }<|fim_prefix|>// repo: Robbepop/modular-bitfield path: /tests/bits-param/complex-use-case.rs use modular_bitfield::prelude::*; #[derive(BitfieldSpecifier)...
code_fim
medium
{ "lang": "rust", "repo": "Robbepop/modular-bitfield", "path": "/tests/bits-param/complex-use-case.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ecreeth/redux-rs path: /examples/counter.rs use redux_rs::{Store, Subscription}; #[derive(Default)] // This is a state. It describes an immutable object. // It is changed via a 'reducer', a function which receives an action and returns a new state modified based on the action. struct State { ...
code_fim
medium
{ "lang": "rust", "repo": "ecreeth/redux-rs", "path": "/examples/counter.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// Here comes the reducer. It gets the current state plus an action to perform and returns a new state. fn counter_reducer(state: &State, action: &Action) -> State { match action { Action::Increment => State { counter: state.counter + 1 }, Action::Decrement => State...
code_fim
medium
{ "lang": "rust", "repo": "ecreeth/redux-rs", "path": "/examples/counter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match *self { StartStreamProcessorError::AccessDenied(ref cause) => write!(f, "{}", cause), StartStreamProcessorError::InternalServerError(ref cause) => write!(f, "{}", cause), StartStreamProcessorError::InvalidParameter(ref cause) => write!(f, "{}", cause), ...
code_fim
hard
{ "lang": "rust", "repo": "wg/rusoto", "path": "/rusoto/services/rekognition/src/generated.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wg/rusoto path: /rusoto/services/rekognition/src/generated.rs } "InternalServerError" => { return RusotoError::Service(ListFacesError::InternalServerError(err.msg)) } "InvalidPaginationTokenException" => { ...
code_fim
hard
{ "lang": "rust", "repo": "wg/rusoto", "path": "/rusoto/services/rekognition/src/generated.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl DeleteFacesError { pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteFacesError> { if let Some(err) = proto::json::Error::parse(&res) { match err.typ.as_str() { "AccessDeniedException" => { return RusotoError::Service(Dele...
code_fim
hard
{ "lang": "rust", "repo": "wg/rusoto", "path": "/rusoto/services/rekognition/src/generated.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: x7c1/log4rs-cases path: /log4rs-cases/src/rotate/size.rs use std::str::FromStr; use log::{Level, LevelFilter}; use log4rs::append::rolling_file::policy::compound::roll::fixed_window::FixedWindowRoller; use log4rs::append::rolling_file::policy::compound::trigger::size::SizeTrigger; use log4rs::a...
code_fim
hard
{ "lang": "rust", "repo": "x7c1/log4rs-cases", "path": "/log4rs-cases/src/rotate/size.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl SettingBuilder<Filled, Filled> { pub fn build(self) -> Setting { Setting { appender_name: self.appender_name.unwrap_or_else(|| "default".to_string()), file_pattern: self.file_pattern.unwrap(), file_path: self.file_path.unwrap(), log_level: s...
code_fim
hard
{ "lang": "rust", "repo": "x7c1/log4rs-cases", "path": "/log4rs-cases/src/rotate/size.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> kind: &str, ) -> Option<Box<dyn Factory<BoxedOutputDecl<BoxedNodeDecl<RGBColor>>, Builder>>> { return Some(match kind { "led-strip:spi:ws2811rgb" => registry::output::< Builder, LedStripOutputDecl<controllers::spi::SPI, chips::Ws2811Rgb>, ...
code_fim
hard
{ "lang": "rust", "repo": "fooker/photonic", "path": "/photonic-ledstrip/src/registry.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fooker/photonic path: /photonic-ledstrip/src/registry.rs #![cfg(feature = "dyn")] use photonic_core::boxed::{BoxedNodeDecl, BoxedOutputDecl}; use photonic_core::element::RGBColor; use photonic_dyn::builder::OutputBuilder; use photonic_dyn::registry::{self, Factory, OutputRegistry}; use crate::...
code_fim
hard
{ "lang": "rust", "repo": "fooker/photonic", "path": "/photonic-ledstrip/src/registry.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ptomato/mozjs path: /third_party/rust/serde_with/tests/chrono.rs #![cfg(feature = "chrono")] extern crate chrono; extern crate pretty_assertions; extern crate serde; extern crate serde_derive; extern crate serde_json; extern crate serde_with; <|fim_suffix|>fn new_datetime(secs: i64, nsecs: u32...
code_fim
medium
{ "lang": "rust", "repo": "ptomato/mozjs", "path": "/third_party/rust/serde_with/tests/chrono.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // floats, shows precision errors in subsecond part assert_eq!(new_datetime(1_478_563_200, 122_999_906), res[3].date); assert_eq!(new_datetime(0, 0), res[4].date); assert_eq!(new_datetime(-86000, 998_999_999), res[5].date); // string representation of floats assert_eq!(new_datetim...
code_fim
hard
{ "lang": "rust", "repo": "ptomato/mozjs", "path": "/third_party/rust/serde_with/tests/chrono.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_that(&todos.next).is_some(); assert_that(&todos.items).has_length(2); let text: Vec<_> = todos.items.iter().map(|it| it.text.as_str()).collect(); assert_that(&text).is_equal_to(vec!["bar", "foo"]); } #[test] fn should_update_todo() { let todos_repo = create_repo(); l...
code_fim
hard
{ "lang": "rust", "repo": "dmexe/todo-demo-rs", "path": "/src/db/todos_repo.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dmexe/todo-demo-rs path: /src/db/todos_repo.rs use chrono::{NaiveDateTime, Utc}; use diesel; use futures_cpupool::{CpuFuture, CpuPool}; use diesel::prelude::*; use result::Error; use super::functions::last_insert_id; use super::schema::todos; use super::ConnectionPool; use super::Paginated; /...
code_fim
hard
{ "lang": "rust", "repo": "dmexe/todo-demo-rs", "path": "/src/db/todos_repo.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: starcoinorg/starcoin path: /vm/types/src/account_config/resources/auto_accept_token.rs // Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::token::token_code::TokenCode; use crate::{ account_config::constants::{ACCOUNT_MODULE_NAME, CORE_CODE_ADDRESS}...
code_fim
hard
{ "lang": "rust", "repo": "starcoinorg/starcoin", "path": "/vm/types/src/account_config/resources/auto_accept_token.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl MoveResource for AutoAcceptToken { const MODULE_NAME: &'static str = ACCOUNT_MODULE_NAME; const STRUCT_NAME: &'static str = "AutoAcceptToken"; }<|fim_prefix|>// repo: starcoinorg/starcoin path: /vm/types/src/account_config/resources/auto_accept_token.rs // Copyright (c) The Diem Core Contrib...
code_fim
hard
{ "lang": "rust", "repo": "starcoinorg/starcoin", "path": "/vm/types/src/account_config/resources/auto_accept_token.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let sprite_render = SpriteRender::new(spritesheet_handle, 0); world .create_entity() .with(Paddle::new(Side::Left)) .with(sprite_render.clone()) .with(left_transform) .build(); world .create_entity() .with(Paddle::new(Side::Right)) ...
code_fim
hard
{ "lang": "rust", "repo": "AQUIN0S/pong", "path": "/src/components/paddle.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AQUIN0S/pong path: /src/components/paddle.rs use crate::pong::{ PADDLE_WIDTH, PADDLE_HEIGHT, ARENA_WIDTH, ARENA_HEIGHT, }; use amethyst::ecs::{ Component, DenseVecStorage, World, WorldExt, Builder }; use amethyst::renderer::{ SpriteSheet, SpriteRender }; use amethyst::assets::Handle; use amethys...
code_fim
hard
{ "lang": "rust", "repo": "AQUIN0S/pong", "path": "/src/components/paddle.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Carrigan/rustbee path: /src/buffer.rs use core::num::Wrapping; use super::frame::Frame; #[derive(Debug)] pub enum FrameBufferState { WaitingForDelimiter, ReceivingLengthMsb, ReceivingLengthLsb, ReceivingData, ReceivingChecksum } /// A state machine that handles receiving bytes coming...
code_fim
hard
{ "lang": "rust", "repo": "Carrigan/rustbee", "path": "/src/buffer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> FrameBufferState::ReceivingChecksum => { let return_val = if received == 0xFF - self.checksum.0 { Some(Frame::new(&self.buffer[0..self.count])) } else { None }; // Reset everything self.state = FrameBufferState::WaitingForDelimiter; ...
code_fim
hard
{ "lang": "rust", "repo": "Carrigan/rustbee", "path": "/src/buffer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> FrameBufferState::ReceivingData => { self.left -= 1; if self.left == 0 { self.state = FrameBufferState::ReceivingChecksum; } self.buffer[self.count] = received; self.checksum += Wrapping(received); self.count += 1; None }, ...
code_fim
hard
{ "lang": "rust", "repo": "Carrigan/rustbee", "path": "/src/buffer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Ui entities "UiDigit" => Some(Box::new(ui_digit::UiDigit::default()) as Box<dyn entity::Entity>), "UiFlightBar" => { Some(Box::new(ui_flight_bar::UiFlightBar::default()) as Box<dyn entity::Entity>) } "UiHealthDot" => { Some(Box::new(ui_h...
code_fim
hard
{ "lang": "rust", "repo": "drupalio/Platformer", "path": "/src/entities/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drupalio/Platformer path: /src/entities/mod.rs pub mod bat; pub mod boss_fight_trigger; pub mod boss_fish; pub mod check_point; pub mod death_animation; pub mod exit_door; pub mod falling_bridge; pub mod fire_sprite; pub mod fireball; pub mod firebrand; pub mod flying_fish; pub mod hoodie; pub m...
code_fim
hard
{ "lang": "rust", "repo": "drupalio/Platformer", "path": "/src/entities/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Ui classes UiDigit, UiFlightBar, UiHealthDot, } impl EntityClass { pub fn is_enemy(&self) -> bool { matches!( self, EntityClass::Bat | EntityClass::FlyingFish | EntityClass::FireSprite | EntityClass::Ho...
code_fim
hard
{ "lang": "rust", "repo": "drupalio/Platformer", "path": "/src/entities/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DarkKitsune/Fennec-Engine path: /src/vm/graphicsengine/tileregion.rs /// Represents a region of tiles in a tile map #[derive(Co<|fim_suffix|> top: u32, pub left: u32, pub width: u32, pub height: u32, pub center_x: u32, pub center_y: u32, }<|fim_middle|>py, Clone, Debug, Defau...
code_fim
easy
{ "lang": "rust", "repo": "DarkKitsune/Fennec-Engine", "path": "/src/vm/graphicsengine/tileregion.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> top: u32, pub left: u32, pub width: u32, pub height: u32, pub center_x: u32, pub center_y: u32, }<|fim_prefix|>// repo: DarkKitsune/Fennec-Engine path: /src/vm/graphicsengine/tileregion.rs /// Represents a region of tiles in a tile map #[derive(Co<|fim_middle|>py, Clone, Debug, Defau...
code_fim
easy
{ "lang": "rust", "repo": "DarkKitsune/Fennec-Engine", "path": "/src/vm/graphicsengine/tileregion.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: megumish/iza path: /src/ssh_connection/remote_file.rs use crate::ssh_connection::*; pub struct RemoteFile { user: User, host: Host, local_path: LocalPath, remote_path: RemotePath, } impl RemoteFile { pub fn restore(user: User, host: Host, local_path: LocalPath, remote_path:...
code_fim
medium
{ "lang": "rust", "repo": "megumish/iza", "path": "/src/ssh_connection/remote_file.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn remote_path_of_remote_file(&self) -> RemotePath { self.remote_path.clone() } }<|fim_prefix|>// repo: megumish/iza path: /src/ssh_connection/remote_file.rs use crate::ssh_connection::*; pub struct RemoteFile { user: User, host: Host, local_path: LocalPath, remote_pa...
code_fim
medium
{ "lang": "rust", "repo": "megumish/iza", "path": "/src/ssh_connection/remote_file.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: etaoins/arret path: /compiler/hir/var_id.rs use std::num::NonZeroU32; use std::sync::atomic::{AtomicU32, Ordering}; use crate::context::ModuleId; /// Identifier for a local variable within a module /// /// This is not globally unique; it must be combined with a `ModuleId` #[derive(Debug, Parti...
code_fim
hard
{ "lang": "rust", "repo": "etaoins/arret", "path": "/compiler/hir/var_id.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct LocalIdAlloc { local_id_counter: AtomicU32, } impl LocalIdAlloc { pub fn new() -> Self { Self { local_id_counter: AtomicU32::new(1), } } /// Allocates a `LocalId` using atomic operations on a shared instance pub fn alloc(&self) -> LocalId { ...
code_fim
hard
{ "lang": "rust", "repo": "etaoins/arret", "path": "/compiler/hir/var_id.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Allocates a `LocalId` using non-atomic operations on an exclusive instance pub fn alloc_mut(&mut self) -> LocalId { let local_id_counter = self.local_id_counter.get_mut(); let raw_id = *local_id_counter; *local_id_counter += 1; LocalId(NonZeroU32::new(raw_id)....
code_fim
hard
{ "lang": "rust", "repo": "etaoins/arret", "path": "/compiler/hir/var_id.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn replace(input: ParseStream, explicit_args: &mut HashSet<usize>) -> Result<TokenStream> { let mut tokens = TokenStream::new(); let mut content; while !input.is_empty() { if input.peek(token::Paren) { let paren_token = parenthesized!(content in input); let toke...
code_fim
hard
{ "lang": "rust", "repo": "kgv/lambda", "path": "/macro/src/lambda.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }