text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> // Wait until the alarm goes off (until the update event occurs) // SR, Status Register // UIF, Update Interrupt Flag while !tim6.sr.read().uif().bit_is_set() {} // Clear the update event flag tim6.sr.modify(|_, w| w.uif().clear_bit()); } }<|fim_prefix|...
code_fim
hard
{ "lang": "rust", "repo": "deffen3/discovery", "path": "/src/09-clocks-and-timers-tasks/src/main.rs", "mode": "spm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: deffen3/discovery path: /src/09-clocks-and-timers-tasks/src/main.rs #![no_main] #![no_std] use aux9_tasks::entry; #[entry] fn main() -> ! { let (mut leds, rcc, tim6) = aux9_tasks::init(); // Power on the TIM6 timer rcc.apb1enr.modify(|_, w| w.tim6en().set_bit()); // SR, the s...
code_fim
medium
{ "lang": "rust", "repo": "deffen3/discovery", "path": "/src/09-clocks-and-timers-tasks/src/main.rs", "mode": "psm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_suffix|> let cycle_ms = 200; let mut seq_idx = 0; let led_tasks: [i32; 8] = [1, 2, 4, 8, 16, 32, 64, 128]; loop { // Set the timer to go off in half of `cycle_ms` ticks // 1 tick = 1 ms tim6.arr.write(|w| w.arr().bits(cycle_ms / 2)); // CEN: Enable the counter ...
code_fim
hard
{ "lang": "rust", "repo": "deffen3/discovery", "path": "/src/09-clocks-and-timers-tasks/src/main.rs", "mode": "spm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bytecodealliance/wasmtime path: /cranelift/codegen/src/souper_harvest.rs es for //! superoptimization. For some of these candidates, Souper will successfully //! synthesize a right-hand side that is equivalent but has lower cost than the //! left-hand side. Then, we can combine these left- and r...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/wasmtime", "path": "/cranelift/codegen/src/souper_harvest.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bytecodealliance/wasmtime path: /cranelift/codegen/src/souper_harvest.rs ata). fn reset(&mut self) { self.ir_to_souper_val.clear(); self.dfs_stack.clear(); self.dfs_seen.clear(); } } /// Harvest a candidate LHS for `val` from the dataflow graph. fn harvest_candid...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/wasmtime", "path": "/cranelift/codegen/src/souper_harvest.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> let b = arg(allocs, 1); let c = arg(allocs, 2); ast::Instruction::Select { a, b, c }.into() } (ir::Opcode::Uextend, _) => { let a = arg(allocs, 0); ...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/wasmtime", "path": "/cranelift/codegen/src/souper_harvest.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(response_message) = self.get_message_for_local_domain(&request_key, request_message.header().id()) { debug!("local domain request"); self.metrics.counter_metric(CounterMetricType::LocalRequests).increment_value(); return response_mess...
code_fim
hard
{ "lang": "rust", "repo": "aaronriekenberg/rust-doh-proxy", "path": "/src/doh/proxy.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fonline-roleplay/rust_workspace path: /web_server/with_map_viewer/src/main.rs use std::path::{Path, PathBuf}; use web_server_core::*; fn main() -> std::io::Result<()> { env_logger::builder() .filter_level(log::LevelFilter::Warn) .filter(Some("actix_web"), log::LevelFilter::I...
code_fim
hard
{ "lang": "rust", "repo": "fonline-roleplay/rust_workspace", "path": "/web_server/with_map_viewer/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let state = web::AppState::new(config, db, fo_data.into_retriever(), items); web::run(state); //db.flush().expect("Can't flush sled database"); //join_handle.join().unwrap(); Ok(()) }<|fim_prefix|>// repo: fonline-roleplay/rust_workspace path: /web_server/with_map_viewer/src/main.rs u...
code_fim
hard
{ "lang": "rust", "repo": "fonline-roleplay/rust_workspace", "path": "/web_server/with_map_viewer/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut db_path = PathBuf::new(); db_path.push("db"); db_path.push("sled"); let db = sled::open(db_path).expect("Can't open sled database"); let state = web::AppState::new(config, db, fo_data.into_retriever(), items); web::run(state); //db.flush().expect("Can't flush sled data...
code_fim
hard
{ "lang": "rust", "repo": "fonline-roleplay/rust_workspace", "path": "/web_server/with_map_viewer/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn kxord_2() { run_test(&Instruction { mnemonic: Mnemonic::KXORD, operand1: Some(Direct(K3)), operand2: Some(Direct(K4)), operand3: Some(Direct(K1)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[196, 225, 221, 71, 217], OperandSize::Q...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/kxord.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn entropy(&self) -> f64 { let mut entropy = 0.0; let all = self.unnorm_distr.iter().sum::<usize>() as f64; for repetitions in self.unnorm_distr.iter().map(|x| *x as f64) { entropy -= repetitions * (repetitions.ln() - all.ln()); } entropy / all ...
code_fim
medium
{ "lang": "rust", "repo": "Misha007007/approx_entropy", "path": "/src/estimator/naive.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &mut self.0 } } impl From<crate::W<AESIER_SPEC>> for W { #[inline(always)] fn from(writer: crate::W<AESIER_SPEC>) -> Self { W(writer) } } #[doc = "Field `IFINTEN` reader - IFINTEN"] pub type IFINTEN_R = crate::BitReader; #[doc = "Field `IFINTEN` writer - IFINTEN"] pub type ...
code_fim
hard
{ "lang": "rust", "repo": "ht32-rs/ht32-rs-nightlies", "path": "/ht32f5xxxx/src/ht32f52142/aes/aesier.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ht32-rs/ht32-rs-nightlies path: /ht32f5xxxx/src/ht32f52142/aes/aesier.rs #[doc = "Register `AESIER` reader"] pub struct R(crate::R<AESIER_SPEC>); impl core::ops::Deref for R { type Target = crate::R<AESIER_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 ...
code_fim
hard
{ "lang": "rust", "repo": "ht32-rs/ht32-rs-nightlies", "path": "/ht32f5xxxx/src/ht32f52142/aes/aesier.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> W(writer) } } #[doc = "Field `IFINTEN` reader - IFINTEN"] pub type IFINTEN_R = crate::BitReader; #[doc = "Field `IFINTEN` writer - IFINTEN"] pub type IFINTEN_W<'a, const O: u8> = crate::BitWriter<'a, AESIER_SPEC, O>; #[doc = "Field `OFINTEN` reader - OFINTEN"] pub type OFINTEN_R = crate::BitRe...
code_fim
hard
{ "lang": "rust", "repo": "ht32-rs/ht32-rs-nightlies", "path": "/ht32f5xxxx/src/ht32f52142/aes/aesier.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let status = font_resolver .resolve(&url.to_string(), &mut update_policy, dir_request) .await?; zx::Status::ok(status)?; // Cache directory handle cache_lock.insert(path_buf.to_path_buf(), dir_proxy); ...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/src/fonts/src/font_service/asset/collection.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let path = std::env::args().nth(1).unwrap(); let text = std::fs::read_to_string(&path).unwrap(); let mut nums: Vec<_> = text.lines().map(atoi).collect(); nums.push(0); nums.sort(); nums.push(nums[nums.len() - 1] + 3); println!("{}", differences(&nums, 1) * differences(&nums, 3)...
code_fim
hard
{ "lang": "rust", "repo": "dhconnelly/advent-of-code-2020", "path": "/day10/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let path = std::env::args().nth(1).unwrap(); let text = std::fs::read_to_string(&path).unwrap(); let mut nums: Vec<_> = text.lines().map(atoi).collect(); nums.push(0); nums.sort(); nums.push(nums[nums.len() - 1] + 3); println!("{}", differences(&nums, 1) * differenc...
code_fim
hard
{ "lang": "rust", "repo": "dhconnelly/advent-of-code-2020", "path": "/day10/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dhconnelly/advent-of-code-2020 path: /day10/src/main.rs use std::collections::HashMap; fn atoi(s: &str) -> i64 { i64::from_str_radix(s, 10).unwrap() } fn differences(chain: &[i64], of: i64) -> usize { <|fim_suffix|> memo.insert(from, sum); sum } fn main() { let path = std::env:...
code_fim
hard
{ "lang": "rust", "repo": "dhconnelly/advent-of-code-2020", "path": "/day10/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jpverkamp/advent-of-code path: /2022/src/bin/25-snafuinator.rs use aoc::*; use std::{fmt::Display, path::Path}; #[derive(Clone, Debug)] struct Snafu { value: String, } impl Display for Snafu { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", ...
code_fim
hard
{ "lang": "rust", "repo": "jpverkamp/advent-of-code", "path": "/2022/src/bin/25-snafuinator.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Convert to base 5 let mut digits = Vec::new(); while v > 0 { let m = v % 5; v = v / 5; if m < 3 { digits.push(m.to_string()); } else if m == 3 { digits.push(String::from("=")); v +=...
code_fim
hard
{ "lang": "rust", "repo": "jpverkamp/advent-of-code", "path": "/2022/src/bin/25-snafuinator.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for x in max(t[0], -50)..min(50, t[1] + 1) { for y in max(t[2], -50)..min(50, t[3] + 1) { for z in max(t[4], -50)..min(50, t[5] + 1) { if l.contains("on") { pts.insert((x, y, z)); } else { ...
code_fim
hard
{ "lang": "rust", "repo": "Fadi88/AoC", "path": "/2021/day22/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> let re = Regex::new(r".*=(-?\d+)\.+(-?\d+).*=(-?\d+)\.+(-?\d+).*=(-?\d+)\.+(-?\d+)").unwrap(); let mut cubiods: Vec<Cuboid> = Vec::new(); for l in include_str!("input.txt").split("\n") { let t: Vec<_> = re .captures(l) .unwrap() .iter() ...
code_fim
hard
{ "lang": "rust", "repo": "Fadi88/AoC", "path": "/2021/day22/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>pub fn fail() { exit_qemu(0x11); } pub fn success() { exit_qemu(0x10); }<|fim_prefix|>// repo: hpolloni/xagima path: /src/testing.rs use core::panic::PanicInfo; use crate::println; pub fn runner(tests: &[&dyn Fn()]) { println!("Running {} tests", tests.len()); for test in tests { ...
code_fim
hard
{ "lang": "rust", "repo": "hpolloni/xagima", "path": "/src/testing.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spriest487/advent-of-code-2018 path: /src/day_15.rs mod point; mod astar; use { crate::{ astar::Pathfinder, point::{ Point, Neighbors, }, }, std::{ fmt, cmp::Ordering, collections::{ HashSet, ...
code_fim
hard
{ "lang": "rust", "repo": "spriest487/advent-of-code-2018", "path": "/src/day_15.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.fighters[j].hp = isize::max(0, self.fighters[j].hp - attack_power); } } fn tick(&mut self, pathfinder: &mut CavernPathfinder) -> Option<Team> { let mut targets = Vec::new(); self.fighters.sort_by(|a, b| Point::cmp_reading_order(a.pos, b.pos)); sel...
code_fim
hard
{ "lang": "rust", "repo": "spriest487/advent-of-code-2018", "path": "/src/day_15.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>struct Outcome { elf_power: isize, elves_remaining: Vec<Fighter>, winner: Team, hp_sum: isize, time: isize, } impl Outcome { fn new(cavern: &Cavern, winner: Team, time: isize) -> Self { let hp_sum = cavern.fighters.iter().map(|f| f.hp).sum::<isize>(); Self { ...
code_fim
hard
{ "lang": "rust", "repo": "spriest487/advent-of-code-2018", "path": "/src/day_15.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn poll( mut self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context, ) -> std::task::Poll<Self::Output> { std::future::Future::poll(self.sub_fut.as_mut(), cx) } } impl<'lt, T> std::fmt::Debug for MustBoxFuture<'lt, T> { fn fmt(&self, f: &mut std::fmt::Formatte...
code_fim
hard
{ "lang": "rust", "repo": "neonphog/must_future", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let max_frame = self.max_frame_size.borrow(); let max_frame: ISize = max_frame.scaled(scale).into(); let max_size = ISize::wh( std::cmp::min(max_content.width, max_frame.width), std::cmp::min(max_content.height, max_frame.height), ); positi...
code_fim
hard
{ "lang": "rust", "repo": "TerminalStudio/nativeshell", "path": "/nativeshell/src/shell/platform/win32/window_base.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TerminalStudio/nativeshell path: /nativeshell/src/shell/platform/win32/window_base.rs fCell<WindowStyle>, } const LARGE_SIZE: f64 = 64.0 * 1024.0; impl WindowBaseState { pub fn new(hwnd: HWND, delegate: Weak<dyn WindowDelegate>) -> Self { Self { hwnd, delega...
code_fim
hard
{ "lang": "rust", "repo": "TerminalStudio/nativeshell", "path": "/nativeshell/src/shell/platform/win32/window_base.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let border_width = (7.0 * self.get_scaling_factor()) as i32; if x < win_rect.left + border_width && y < win_rect.top + border_width { HTTOPLEFT } else if x > win_rect.right - border_width && y < win_rect.top + border_width { HTTOPRIGHT } else if y <...
code_fim
hard
{ "lang": "rust", "repo": "TerminalStudio/nativeshell", "path": "/nativeshell/src/shell/platform/win32/window_base.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.file.read().unwrap() } fn load(&self) { *self.modified.write().unwrap() = self.path.stat().map(|s| s.modified).unwrap_or(0); *self.file.write().unwrap() = File::open(&self.path).read_to_end().ok(); if self.unused_after.is_some() { *self.last_acces...
code_fim
hard
{ "lang": "rust", "repo": "jihokoo/rustful", "path": "/src/cache.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if self.unused_after.is_some() { *self.last_accessed.write().unwrap() = time::get_time(); } } fn free(&self) { *self.file.write().unwrap() = None; } fn expired(&self) -> bool { if self.file.read().unwrap().is_some() { self.path.stat...
code_fim
hard
{ "lang": "rust", "repo": "jihokoo/rustful", "path": "/src/cache.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // In Release Builds, initiallize the logger, so we get messages in the terminal and recorded to disk. if !cfg!(debug_assertions) { CrashReport::init()?; CombinedLogger::init( vec![ TermLogger::new(LevelFilter::Info, simplelog::Config::default(), Termina...
code_fim
hard
{ "lang": "rust", "repo": "glpeon/rpfm", "path": "/rpfm_cli/src/logger/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/semver/v1/crate/src/lib.rs ]* chapter of the Cargo reference. //! //! [Specifying Dependencies]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html #![doc(html_root_url = "https://docs.rs/semver/1.0.4")] #![cfg_attr(doc_cfg, feature(...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/semver/v1/crate/src/lib.rs", "mode": "psm", "license": "GPL-1.0-or-later", "source": "the-stack-v2" }
<|fim_suffix|>/// Optional pre-release identifier on a version string. This comes after `-` in /// a SemVer version, like `1.0.0-alpha.1` /// /// # Examples /// /// Some real world pre-release idioms drawn from crates.io: /// /// - **[mio]** <code>0.7.0-<b>alpha.1</b></code> &mdash; the most common style /// for numb...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/semver/v1/crate/src/lib.rs", "mode": "spm", "license": "GPL-1.0-or-later", "source": "the-stack-v2" }
<|fim_suffix|>/// A pair of comparison operator and partial version, such as `>=1.2`. Forms /// one piece of a VersionReq. #[derive(Clone, Eq, PartialEq, Hash, Debug)] pub struct Comparator { pub op: Op, pub major: u64, pub minor: Option<u64>, /// Patch is only allowed if minor is Some. pub patch: O...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/semver/v1/crate/src/lib.rs", "mode": "spm", "license": "GPL-1.0-or-later", "source": "the-stack-v2" }
<|fim_suffix|>w(unused_mut)] mod buf_ext; pub mod conn; mod protocol; mod protocol_binlog; mod scramble; mod util; mod value;<|fim_prefix|>// repo: maximebedard/tail_mysql path: /src/lib.rs #![allow(dead_code)] #![allow(unused_variables)] #![allo<|fim_middle|>w(unused_imports)] #![allow(unused_assignments)] #![allo
code_fim
easy
{ "lang": "rust", "repo": "maximebedard/tail_mysql", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maximebedard/tail_mysql path: /src/lib.rs #![allow(dead_code)] #![allow(unused_variables)] #![allow(unused_imports)] #![allow(unused_assignments)] #![allo<|fim_suffix|> mod protocol_binlog; mod scramble; mod util; mod value;<|fim_middle|>w(unused_mut)] mod buf_ext; pub mod conn; mod protocol;
code_fim
easy
{ "lang": "rust", "repo": "maximebedard/tail_mysql", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<D: Clone, A> tower::layer::Layer<A> for DetectProtocolLayer<D> { type Service = DetectProtocol<D, A>; fn layer(&self, accept: A) -> Self::Service { Self::Service { detect: self.detect.clone(), peek_capacity: self.peek_capacity, accept, } ...
code_fim
hard
{ "lang": "rust", "repo": "vikrem/linkerd2-proxy", "path": "/linkerd/proxy/detect/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match self.detect.detect_before_peek(target) { Ok(detected) => AcceptFuture { state: State::Accept(self.accept.accept((detected, io))), }, Err(target) => AcceptFuture { state: State::Detect { detect: self.detec...
code_fim
hard
{ "lang": "rust", "repo": "vikrem/linkerd2-proxy", "path": "/linkerd/proxy/detect/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[test] #[should_panic(expected = "null dereference")] fn figure1b_pct_with_many_tasks() { // Spawn 18 busy threads, each taking 5 steps, plus 2 main threads with 10 steps, so k=110 // n=50, k=110, d=2, so probability of finding the bug in one iteration is at least 1/(20*110) // So probability...
code_fim
hard
{ "lang": "rust", "repo": "JacobVanGeffen/shuttle", "path": "/tests/basic/pct.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[test] #[should_panic(expected = "exceeded max_steps bound")] fn yield_spin_loop_unfair() { yield_spin_loop(false); } #[test] #[should_panic(expected = "null dereference")] // Based on Fig 1(a) of the PCT paper. We model NULL pointer dereference with an Option unwrap fn figure1a_pct() { const C...
code_fim
hard
{ "lang": "rust", "repo": "JacobVanGeffen/shuttle", "path": "/tests/basic/pct.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lightsofapollo/toml-json-rs path: /src/tomljson/json_toml.rs use toml; use rustc_serialize::json::{self, Json}; use std::io::{BufReader, Read}; use std::collections::BTreeMap; pub struct JsonConverter; impl JsonConverter { pub fn new() -> JsonConverter { JsonConverter } fn ...
code_fim
hard
{ "lang": "rust", "repo": "lightsofapollo/toml-json-rs", "path": "/src/tomljson/json_toml.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn convert() { let converter = JsonConverter::new(); let path = Path::new("examples/short.json"); let mut file = File::open(&path).unwrap(); let toml = converter.convert(&mut file).expect("toml convert"); println!("{}", toml.to_string()); } }<|f...
code_fim
hard
{ "lang": "rust", "repo": "lightsofapollo/toml-json-rs", "path": "/src/tomljson/json_toml.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut builder = json::Builder::new(char_iter); let json = try!(builder.build()); Ok(self.convert_json(&json)) } } #[cfg(test)] mod tests { use super::JsonConverter; use std::fs::File; use std::path::Path; #[test] fn convert_i64() { println!("{}",...
code_fim
hard
{ "lang": "rust", "repo": "lightsofapollo/toml-json-rs", "path": "/src/tomljson/json_toml.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if keyboard_input.just_pressed(KeyCode::F) { if keyboard_input.pressed(KeyCode::LControl) { actions.focus_on_mesh = true; } else { if actions.advance_every > 0.019 { actions.advance_every -= 0.01; } else { actions.adva...
code_fim
hard
{ "lang": "rust", "repo": "rezural/mesh-ripper", "path": "/src/app/input.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> if keyboard_input.pressed(KeyCode::Right) { mesh_pool.despawn_mesh(&mut commands, &*meshes); mesh_pool.advance(); mesh_pool.spawn_mesh( &*fluid_assets, material.clone(), &mut commands, &*meshes, ...
code_fim
hard
{ "lang": "rust", "repo": "rezural/mesh-ripper", "path": "/src/app/input.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: williele/wigame path: /crates/render/src/lib.rs mod buffer; mod camera; mod material; mod renderable; pub mod renderer; mod surface; mod texture; use app::{AppStage, Plugin, Stage, StageLabel}; use util::pollster; pub use renderer::*; pub use wgpu; #[derive(Debug, Clone, Copy, PartialEq, Eq, ...
code_fim
medium
{ "lang": "rust", "repo": "williele/wigame", "path": "/crates/render/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self { RenderStage::PreRender => Box::new("Render:PreRender"), RenderStage::Render => Box::new("Render:Render"), RenderStage::PostRender => Box::new("Render:PostRender"), } } } #[derive(Debug, Default)] pub struct RenderPlugin {} impl Plugin ...
code_fim
hard
{ "lang": "rust", "repo": "williele/wigame", "path": "/crates/render/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Relation::PermissionCollections.def() } } impl Related<super::forums::Entity> for Entity { fn to() -> RelationDef { Relation::Forums.def() } } impl ActiveModelBehavior for ActiveModel {}<|fim_prefix|>// repo: jaw-sh/ruforo path: /src/orm/forum_permissions.rs //! SeaORM Entit...
code_fim
hard
{ "lang": "rust", "repo": "jaw-sh/ruforo", "path": "/src/orm/forum_permissions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Related<super::forums::Entity> for Entity { fn to() -> RelationDef { Relation::Forums.def() } } impl ActiveModelBehavior for ActiveModel {}<|fim_prefix|>// repo: jaw-sh/ruforo path: /src/orm/forum_permissions.rs //! SeaORM Entity. Generated by sea-orm-codegen 0.4.0 use sea_orm::ent...
code_fim
hard
{ "lang": "rust", "repo": "jaw-sh/ruforo", "path": "/src/orm/forum_permissions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jaw-sh/ruforo path: /src/orm/forum_permissions.rs //! SeaORM Entity. Generated by sea-orm-codegen 0.4.0 use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[sea_orm(table_name = "forum_permissions")] pub struct Model { #[sea_orm(primary_key, auto_increme...
code_fim
hard
{ "lang": "rust", "repo": "jaw-sh/ruforo", "path": "/src/orm/forum_permissions.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ricky26/advent-of-code-2020 path: /src/bags.rs use nom::{ IResult, character::complete::{space0, digit1, alpha1, space1, char}, bytes::complete::{tag}, combinator::{opt, recognize, map}, sequence::{pair, tuple}, multi::separated_list1, branch::alt, }; use std::collect...
code_fim
hard
{ "lang": "rust", "repo": "ricky26/advent-of-code-2020", "path": "/src/bags.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(parse_mapping(test_input).unwrap().1, BTreeMap::from_iter(vec![ ("dotted black".to_string(), BTreeMap::new()), ("bright white".to_string(), BTreeMap::from_iter(vec![ ("shiny gold".to_string(), 1), ])), ("light red".to_string(), BTreeMap::from_iter...
code_fim
hard
{ "lang": "rust", "repo": "ricky26/advent-of-code-2020", "path": "/src/bags.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn extract_comment_blocks_with_empty_lines(text: &str) -> Vec<Vec<String>> { do_extract_comment_blocks(text, true) } fn do_extract_comment_blocks(text: &str, allow_blocks_with_empty_lines: bool) -> Vec<Vec<String>> { let mut res = Vec::new(); let prefix = "// "; let lines = text.lines()....
code_fim
hard
{ "lang": "rust", "repo": "BurntSushi/rust-analyzer", "path": "/xtask/src/codegen.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> next.ant_y = (self.ant_y as i32 + match next.ant_dir { Direction::S => 1, Direction::N => -1, _ => 0, }) as usize; print_err!("new pos xy: {} {}", next.ant_x, next.ant_y); next.turns_left = self.turns_left - 1; next } ...
code_fim
hard
{ "lang": "rust", "repo": "XOSplicer/codingame-solutions", "path": "/puzzles/community/langtons_ant.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: XOSplicer/codingame-solutions path: /puzzles/community/langtons_ant.rs use std::io; use std::io::BufRead; macro_rules! print_err { ($($arg:tt)*) => ( { use std::io::Write; writeln!(&mut ::std::io::stderr(), $($arg)*).ok(); } ) } macro_rules! pars...
code_fim
hard
{ "lang": "rust", "repo": "XOSplicer/codingame-solutions", "path": "/puzzles/community/langtons_ant.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> HttpServer::new(move || { App::with_state(rest_state.clone()) .middleware(Logger::default()) .scope("/trade_history", |scope| { scope .resource("", |r| { r.method(Method::GET).f(restful::trade_match_root) ...
code_fim
hard
{ "lang": "rust", "repo": "kvsari/sammy", "path": "/collector/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] /// Tests invalid variable value type fn test_invalid_variable_5() { let parsed_data = common::get_file_content_parsed(PARENT_FOLDER, "invalid_variable_with_object.ura"); assert!(parsed_data .unwrap_err() .downcast_ref::<ParseError>() .is_some()); }<|fim_pre...
code_fim
hard
{ "lang": "rust", "repo": "meltinglava/gura-rs-parser", "path": "/tests/variables.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return total_fuel; } fn main() { let path = "input"; let input = File::open(path).unwrap(); let buffered = BufReader::new(input); let mut total_fuel = 0; for line in buffered.lines() { let mass: i64 = line.unwrap().parse().unwrap(); total_fuel += fuel_requiremen...
code_fim
medium
{ "lang": "rust", "repo": "fharding1/adventofcode-2019", "path": "/day1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fharding1/adventofcode-2019 path: /day1/src/main.rs use std::fs::File; use std::io::{BufRead, BufReader}; fn fuel_requirement(mass: i64) -> i64 { <|fim_suffix|> return total_fuel; } fn main() { let path = "input"; let input = File::open(path).unwrap(); let buffered = BufReader:...
code_fim
hard
{ "lang": "rust", "repo": "fharding1/adventofcode-2019", "path": "/day1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let input = File::open(path).unwrap(); let buffered = BufReader::new(input); let mut total_fuel = 0; for line in buffered.lines() { let mass: i64 = line.unwrap().parse().unwrap(); total_fuel += fuel_requirement(mass); } println!("Total Fuel: {}", total_fuel); }<|...
code_fim
hard
{ "lang": "rust", "repo": "fharding1/adventofcode-2019", "path": "/day1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, child: &mut W, ctx: &mut UpdateCtx, old_data: &AppData, data: &AppData, env: &Env, ) { child.update(ctx, old_data, data, env); } }<|fim_prefix|>// repo: kindlychung/stool path: /src/widget_controller.rs //! Controller widgets use...
code_fim
hard
{ "lang": "rust", "repo": "kindlychung/stool", "path": "/src/widget_controller.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kindlychung/stool path: /src/widget_controller.rs //! Controller widgets use druid::widget::Controller; use druid::{Env, Event, EventCtx, UpdateCtx, Widget}; use crate::AppData; <|fim_suffix|> fn update( &mut self, child: &mut W, ctx: &mut UpdateCtx, old_dat...
code_fim
hard
{ "lang": "rust", "repo": "kindlychung/stool", "path": "/src/widget_controller.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>: PathBuf) -> Option<NamedFile> { NamedFile::open(Path::new("public/").join(file)).ok() }<|fim_prefix|>// repo: steadylearner/Rust-Full-Stack path: /React_Rust/server/rocket/src/routes/static_files.rs use std::path::{Path, PathBuf}; use rocket::response::NamedFile; // Follow the structure of<|fim_mi...
code_fim
medium
{ "lang": "rust", "repo": "steadylearner/Rust-Full-Stack", "path": "/React_Rust/server/rocket/src/routes/static_files.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for chset in &self.charsets { c.append(&mut charset(chset)); } for _ in 0..self.length { s.push(*c.choose(&mut rand::thread_rng()).unwrap()); } Ok(s) } }<|fim_prefix|>// repo: x7Gv/qpasswd path: /src/gen.rs use anyhow::Result; use rand...
code_fim
hard
{ "lang": "rust", "repo": "x7Gv/qpasswd", "path": "/src/gen.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: x7Gv/qpasswd path: /src/gen.rs use anyhow::Result; use rand::seq::SliceRandom; use rand_core::OsRng; #[derive(Debug)] pub enum CharsetType { Lowercase, Uppercase, Symbols, Numbers, Special, } #[derive(Debug, Default)] pub struct PasswdGenBuilder { pub length: i16, p...
code_fim
hard
{ "lang": "rust", "repo": "x7Gv/qpasswd", "path": "/src/gen.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sugyan/atcoder path: /arc040/src/bin/b.rs use proconio::marker::Chars; use proconio::{fastout, input}; <|fim_suffix|> input! { n: usize, r: usize, mut s: Chars, } let mut answer = 0; if let Some(pos) = s.iter().rev().position(|&c| c == '.') { if n - r > po...
code_fim
easy
{ "lang": "rust", "repo": "sugyan/atcoder", "path": "/arc040/src/bin/b.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> input! { n: usize, r: usize, mut s: Chars, } let mut answer = 0; if let Some(pos) = s.iter().rev().position(|&c| c == '.') { if n - r > pos { answer += n - r - pos; } } while let Some(pos) = s.iter().position(|&c| c == '.') { answ...
code_fim
easy
{ "lang": "rust", "repo": "sugyan/atcoder", "path": "/arc040/src/bin/b.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<T> Conj for Complex<T> where T: Neg<Output = T>, { fn conj(self) -> Self { Complex::conj(self) } } impl<T> Add for Complex<T> where T: Add<Output = T>, { type Output = Self; fn add(self, other: Self) -> Self { (self.vec + other.vec).into() } } impl<T> Add<...
code_fim
hard
{ "lang": "rust", "repo": "Krout0n/vecmat-rs", "path": "/src/complex/complex_.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn action_type_name(&self) -> syn::Ident { to_ident(&to_rust_typestr(&format!("{}Actions", &self.ident))) } } #[derive(Clone, Debug, PartialEq)] pub struct Method { id: String, pub ident: syn::Ident, path: String, http_method: String, pub description: Option<String>, ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/generator", "path": "/google_rest_api_generator/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/generator path: /google_rest_api_generator/src/lib.rs method .media_upload .as_ref() .and_then(|media_upload| media_upload.resumable_path.as_ref()) .is_some() }); let any_iterable_methods = api_desc.fold_methods(fal...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/generator", "path": "/google_rest_api_generator/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.fold_nested_follow_refs(schemas, true, |accum, typ| { accum && match &typ.type_desc { TypeDesc::Any => false, TypeDesc::String => true, TypeDesc::Bool => true, TypeDesc::Int32 => true, ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/generator", "path": "/google_rest_api_generator/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: d2verb/rush path: /src/main.rs use nix::sys::wait::*; use nix::unistd::*; use rush::builtin; use rush::command::*; use rustyline::error::ReadlineError; use rustyline::Editor; use std::env; use std::ffi::CString; use std::path::Path; /// Find real path of given command. /// /// # Examples /// //...
code_fim
hard
{ "lang": "rust", "repo": "d2verb/rush", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> execve(&path, &cargs[0..], &envs).expect(&format!("failed to execute {:?}", &cargs[0])); } fn execute(cmd: Command) { match cmd { Command::Exit => builtin::exit(), Command::Cd(args) => builtin::cd(&args), Command::Pwd => builtin::pwd(), Command::External(args) => m...
code_fim
hard
{ "lang": "rust", "repo": "d2verb/rush", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut factors = Vec::new(); let mut a:$name = *self; if a==0 || a==1 { //the factorization of 0 or a unit is itself factors.push(*self); }else{ let mut i:$name = 2; ...
code_fim
hard
{ "lang": "rust", "repo": "adamAndMath/maths-traits", "path": "/src/algebra/integer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Implementation of the [`Opcode::Ldp`] instruction pub fn ldp_op(inputs: OpInputs) -> EmulatorResult<()> { // Reads a value from the PSPACE, writing it into core memory // // LDP and STP are not defined in any ICWS standard. This implementation // is based on pMARS's behavior. // ...
code_fim
hard
{ "lang": "rust", "repo": "base0x10/Marzipan", "path": "/marzipan-core/src/emulators/generic_emulator/emulation_operations.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: base0x10/Marzipan path: /marzipan-core/src/emulators/generic_emulator/emulation_operations.rs = perform_arithmetic(b.b_field, a.a_field, &inputs); let second_result = perform_arithmetic(b.a_field, a.b_field, &inputs); match (first_result, s...
code_fim
hard
{ "lang": "rust", "repo": "base0x10/Marzipan", "path": "/marzipan-core/src/emulators/generic_emulator/emulation_operations.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Implementation of the [`Opcode::Spl`] instruction pub fn spl_op(inputs: OpInputs) -> EmulatorResult<()> { // SPL queues the next instruction (PC + 1) and then queues the sum of the // program counter and A-pointer. If the queue is full, only the next // instruction is queued. let next_...
code_fim
hard
{ "lang": "rust", "repo": "base0x10/Marzipan", "path": "/marzipan-core/src/emulators/generic_emulator/emulation_operations.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Clone)] pub enum ShortcutCommand { UiPayload(UiPayload), SelectPresetOrScene } pub fn get_main_keyboard_shortcuts(config: &AxessConfiguration) -> Vec<KeyboardShortcut> { let mut s = vec![ KeyboardShortcut { key: KeyboardShortcutKey::Key(Keys::Enter), ...
code_fim
hard
{ "lang": "rust", "repo": "rudib/axess", "path": "/axess_gui/src/windows/keyboard.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if config.keyboard_shortcuts_axe_edit { s.push(KeyboardShortcut { key: KeyboardShortcutKey::CtrlKey(Keys::PageUp), command_description: "Preset Up".into(), command: ShortcutCommand::UiPayload(UiPayload::DeviceState(DeviceState::DeltaPreset { delta: 1 })) ...
code_fim
hard
{ "lang": "rust", "repo": "rudib/axess", "path": "/axess_gui/src/windows/keyboard.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DrewKestell/ForayRust path: /src/game_timer.rs use winapi::um::profileapi::QueryPerformanceCounter; use winapi::shared::ntdef::LARGE_INTEGER; use std::mem::zeroed; pub struct GameTimer { seconds_per_count: f64, delta_time: f64, base_time: i64, paused_time: i64, stop_time: i6...
code_fim
hard
{ "lang": "rust", "repo": "DrewKestell/ForayRust", "path": "/src/game_timer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn reset(&mut self) { unsafe { let mut current_time: LARGE_INTEGER = zeroed(); QueryPerformanceCounter(&mut current_time); self.base_time = *current_time.QuadPart(); self.previous_time = *current_time.QuadPart(); self.stop_time =...
code_fim
hard
{ "lang": "rust", "repo": "DrewKestell/ForayRust", "path": "/src/game_timer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.paused_time += *start_time.QuadPart() - self.stop_time; self.previous_time = *start_time.QuadPart(); self.stop_time = 0; self.stopped = false; } } } pub fn total_time(&self) -> f64 { if self.stopped {...
code_fim
hard
{ "lang": "rust", "repo": "DrewKestell/ForayRust", "path": "/src/game_timer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn assert_verify_eval_fails( verifier: &KZGVerifier, point: (Scalar, Scalar), commitment: &KZGCommitment, witness: &KZGWitness, ) { assert!(!verifier.verify_eval(point, &commitment, &witness), "expected verify_eval to fail for for point {:#?}, commitment {:#...
code_fim
hard
{ "lang": "rust", "repo": "drhanlondon/kzg", "path": "/src/coeff_form.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drhanlondon/kzg path: /src/coeff_form.rs use blstrs::{pairing, G1Affine, G1Projective, G2Projective, Scalar}; use pairing::group::{ff::Field, prime::PrimeCurveAffine, Curve}; use std::fmt::Debug; #[cfg(feature = "serde_support")] use serde::{Deserialize, Serialize}; use crate::polynomial::{op_...
code_fim
hard
{ "lang": "rust", "repo": "drhanlondon/kzg", "path": "/src/coeff_form.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let s: Scalar = rng.gen::<u64>().into(); setup(s, MAX_COEFFS) } fn test_participants<'params>( params: &'params KZGParams, ) -> (KZGProver<'params>, KZGVerifier<'params>) { let prover = KZGProver::new(params); let verifier = KZGVerifier::new(params); ...
code_fim
hard
{ "lang": "rust", "repo": "drhanlondon/kzg", "path": "/src/coeff_form.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_file() { use std::env; let mut dir = env::temp_dir(); dir.push("t_rex_test"); let basepath = format!("{}", &dir.display()); fs::remove_dir_all(&basepath); let cache = Filecache { basepath: basepath }; assert_eq!(cache.dir("tileset", 1, 2, 0), format!("{}/{}",...
code_fim
hard
{ "lang": "rust", "repo": "gijs/t-rex", "path": "/src/cache/filecache.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Cache miss assert!(cache.lookup("tileset", 1, 2, 0, |_| Ok(())).is_err()); // Write into cache let res = cache.store("tileset", 1, 2, 0, |f| { f.write_all("0123456789".as_bytes()) }); assert_eq!(res.ok(), Some(())); assert!(Path::new(&pbf).exists()); // Cache h...
code_fim
hard
{ "lang": "rust", "repo": "gijs/t-rex", "path": "/src/cache/filecache.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[no_mangle] #[allow(unused_variables)] pub fn causet_partitioner_scan_column_as_int( context: Box<CausetPartitionerContext>, column_name: &[u8], column_value: &[u8], ) -> Box<CausetPartitionerContext> { context } #[no_mangle] #[allow(unused_variables)] pub fn causet_partitioner_sca...
code_fim
hard
{ "lang": "rust", "repo": "YosiSF/EinsteinDB", "path": "/soliton_panic/src/table_properties.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> { let irq = bus_dev.get_irq(0); let io_pri = bus_dev.bind_io(0).io_base(); let st_pri = bus_dev.bind_io(1).io_base() + 2; let io_sec = bus_dev.bind_io(2).io_base(); let st_sec = bus_dev.bind_io(3).io_base() + 2; let bm_io = bus_dev.bind_io(4); Ok(device_manager::DriverInstancePtr::new( c...
code_fim
hard
{ "lang": "rust", "repo": "thepowersgang/rust_os", "path": "/Kernel/Modules/storage_ata/drivers.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> fn write(&mut self, data: &WebsocketPushData); }<|fim_prefix|>// repo: marcuslimdw/pythagoras-assessment path: /src/consumer/consumer.rs use crate::producer::WebsocketPushData; <|fim_middle|>pub trait Consumer { fn connect(url: &str) -> Self where Self: Sized;
code_fim
medium
{ "lang": "rust", "repo": "marcuslimdw/pythagoras-assessment", "path": "/src/consumer/consumer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marcuslimdw/pythagoras-assessment path: /src/consumer/consumer.rs use crate::producer::WebsocketPushData; <|fim_suffix|> fn write(&mut self, data: &WebsocketPushData); }<|fim_middle|>pub trait Consumer { fn connect(url: &str) -> Self where Self: Sized;
code_fim
medium
{ "lang": "rust", "repo": "marcuslimdw/pythagoras-assessment", "path": "/src/consumer/consumer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn write(&mut self, data: &WebsocketPushData); }<|fim_prefix|>// repo: marcuslimdw/pythagoras-assessment path: /src/consumer/consumer.rs use crate::producer::WebsocketPushData; <|fim_middle|>pub trait Consumer { fn connect(url: &str) -> Self where Self: Sized;
code_fim
medium
{ "lang": "rust", "repo": "marcuslimdw/pythagoras-assessment", "path": "/src/consumer/consumer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let transformer = Transformer::AspectRatio(16.0 / 12.0, (size.width / size.height) as f32); transformer.apply(&mut self.console) .apply(&mut self.console_term) .apply(&mut self.game_over) .apply(&mut self.message_log.console); if let Some(menu) =...
code_fim
hard
{ "lang": "rust", "repo": "KristonCosta/verbose-adventure", "path": "/src/game.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KristonCosta/verbose-adventure path: /src/game.rs use crate::game_handler::{GameContext, InputEvent, InputEventData}; use glutin::{ dpi::LogicalSize, window::Window, event::VirtualKeyCode, }; use nalgebra_glm::Vec3; use console_backend::{ColorBuffer, Camera, resources::Resources, ...
code_fim
hard
{ "lang": "rust", "repo": "KristonCosta/verbose-adventure", "path": "/src/game.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: benbrunton/pusoy-dos path: /src/game/player.rs use cards::card::PlayerCard; /// A player #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Player{ hand: Vec<PlayerCard>, id: u64 } impl Player{ /// creates a new `Player` pub fn new(id: u64) -> Player{ ...
code_fim
hard
{ "lang": "rust", "repo": "benbrunton/pusoy-dos", "path": "/src/game/player.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn remove_jokers(&self, cards:&Vec<PlayerCard>)-> Vec<PlayerCard> { let mut new_hand = vec!(); let mut jokers = 0; for card in cards.iter() { match *card { PlayerCard::Wildcard(_) => jokers += 1, _ => () } } ...
code_fim
hard
{ "lang": "rust", "repo": "benbrunton/pusoy-dos", "path": "/src/game/player.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leshow/exercism path: /hackerrank/src/sum_of_even_numbers_after_queries.rs // 985. Sum of Even Numbers After Queries // Easy // We have an array A of integers, and an array queries of queries. // For the i-th query val = queries[i][0], index = queries[i][1], we add val to // A[index]. Then, the...
code_fim
hard
{ "lang": "rust", "repo": "leshow/exercism", "path": "/hackerrank/src/sum_of_even_numbers_after_queries.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }