text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: duskmoon314/aw-pac path: /d1-pac/src/tve/tve_burst_width.rs #[doc = "Register `tve_burst_width` reader"] pub struct R(crate::R<TVE_BURST_WIDTH_SPEC>); impl core::ops::Deref for R { type Target = crate::R<TVE_BURST_WIDTH_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { ...
code_fim
hard
{ "lang": "rust", "repo": "duskmoon314/aw-pac", "path": "/d1-pac/src/tve/tve_burst_width.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> W(writer) } } #[doc = "Field `hsync_width` reader - Specify the width of the horizontal sync pulse in encoder clock cycles. Min value is 16. Max value is (FrontPorch + ActiveLine - BackPorch). Default value is 126. The sum of HSyncSize and BackPorch is restricted to be divisible by 4.\n\nFor 7...
code_fim
hard
{ "lang": "rust", "repo": "duskmoon314/aw-pac", "path": "/d1-pac/src/tve/tve_burst_width.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wvanbreukelen/rust-research path: /src/hal_sam3x8e/clock.rs use sam3x8e; use crate::hal::clock::*; use crate::hal::pin::*; use crate::hal_sam3x8e::core::*; impl PMCConfigure<sam3x8e::PMC> for PMCControl<sam3x8e::PMC> { fn set_hw_device(&mut self, pmc: sam3x8e::PMC) { self.rf = Some...
code_fim
hard
{ "lang": "rust", "repo": "wvanbreukelen/rust-research", "path": "/src/hal_sam3x8e/clock.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let main_clock_frequency_within_16_slow_clock_cycles = { while self.get_master_clk() & MAINFRDY == 0 {} self.get_master_clk() & MAINF_MASK }; main_clock_frequency_within_16_slow_clock_cycles * SLOW_CLOCK_FREQUENCY_HZ / 16 } } impl PMCWrite<PeripheralLi...
code_fim
medium
{ "lang": "rust", "repo": "wvanbreukelen/rust-research", "path": "/src/hal_sam3x8e/clock.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn disable_peripheral(&self, p: PeripheralListing) { match &self.rf { None => {} Some(x) => x.pmc_pcdr0.write_with_zero(|w| unsafe { w.bits(p.offset) }), } } }<|fim_prefix|>// repo: wvanbreukelen/rust-research path: /src/hal_sam3x8e/clock.rs use sam3x8e; u...
code_fim
hard
{ "lang": "rust", "repo": "wvanbreukelen/rust-research", "path": "/src/hal_sam3x8e/clock.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[tracable_parser] #[packrat_parser] pub(crate) fn genvar_iteration_prefix(s: Span) -> IResult<Span, GenvarIteration> { let (s, a) = inc_or_dec_operator(s)?; let (s, b) = genvar_identifier(s)?; Ok(( s, GenvarIteration::Prefix(Box::new(GenvarIterationPrefix { nodes: (a, b) })), ...
code_fim
hard
{ "lang": "rust", "repo": "dalance/sv-parser", "path": "/sv-parser-parser/src/instantiations/generated_instantiation.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[recursive_parser] #[tracable_parser] #[packrat_parser] pub(crate) fn case_generate_item_nondefault(s: Span) -> IResult<Span, CaseGenerateItem> { let (s, a) = list(symbol(","), constant_expression)(s)?; let (s, b) = symbol(":")(s)?; let (s, c) = generate_block(s)?; Ok(( s, ...
code_fim
hard
{ "lang": "rust", "repo": "dalance/sv-parser", "path": "/sv-parser-parser/src/instantiations/generated_instantiation.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dalance/sv-parser path: /sv-parser-parser/src/instantiations/generated_instantiation.rs use crate::*; // ----------------------------------------------------------------------------- #[tracable_parser] #[packrat_parser] pub(crate) fn generate_region(s: Span) -> IResult<Span, GenerateRegion> { ...
code_fim
hard
{ "lang": "rust", "repo": "dalance/sv-parser", "path": "/sv-parser-parser/src/instantiations/generated_instantiation.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: terakun/syntactic_monoid path: /src/syntactic_monoid.rs use super::dfa::DFA; use regex::RegularExpression; use std::collections::HashMap; use std::collections::HashSet; use std::collections::VecDeque; use std::collections::BTreeSet; extern crate bit_set; use self::bit_set::BitSet; #[derive(Deb...
code_fim
hard
{ "lang": "rust", "repo": "terakun/syntactic_monoid", "path": "/src/syntactic_monoid.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(ref s) = memo.get(&m) { return s.to_string(); } let regex = if identity(&m) { let mut W = BitSet::with_capacity(256); for c in 0..256u32 { if !identity(&self.morphism((c as u8 as char).to_string())) { ...
code_fim
hard
{ "lang": "rust", "repo": "terakun/syntactic_monoid", "path": "/src/syntactic_monoid.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Align the cursor to the next 8-byte boundary. pub(crate) fn cursor_align8(cursor: &mut Cursor<&Vec<u8>>) -> io::Result<u64> { let pad = (8 - (cursor.position() % 8)) % 8; cursor_skip(cursor, pad as i64) } /// A macro to assist in early returns of `Some<Err>` in `Iterator::next()` /// implemen...
code_fim
hard
{ "lang": "rust", "repo": "udesou/ykstackmaps", "path": "/src/util.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(sec) = sec_res { let mut cursor = Cursor::new(&sec.data); cursor.seek(SeekFrom::Start(start_pos))?; Ok(cursor) } else { Err(SMParserError::Other(String::from( "Can't find stackmap section in binary", ))) } } #[derive(Clone, Debug...
code_fim
hard
{ "lang": "rust", "repo": "udesou/ykstackmaps", "path": "/src/util.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: udesou/ykstackmaps path: /src/util.rs // Copyright (c) 2018 King's College London // Created by the Software Development Team <http://soft-dev.org/> // // The Universal Permissive License (UPL), Version 1.0 // // Subject to the condition set forth below, permission is hereby granted to any // pe...
code_fim
hard
{ "lang": "rust", "repo": "udesou/ykstackmaps", "path": "/src/util.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cab/powdergame path: /crates/game/src/lib.rs mod net; mod render; mod world; use std::sync::Arc; use game_common::{ClientPacket, ServerPacket}; use tracing::debug; use wasm_bindgen::prelude::*; use winit::{ event::{Event, WindowEvent}, event_loop::{ControlFlow, EventLoop}, window::...
code_fim
hard
{ "lang": "rust", "repo": "cab/powdergame", "path": "/crates/game/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn is_valid<'a>(message: &'a str, rule_set: &RuleSet, rule_idx: usize) -> Option<&'a str> { let rules = rule_set.get(&rule_idx).unwrap(); rules.into_iter().find_map(|rule| match rule { Rule::Pointer(pointers) => pointers .into_iter() .fold(Some(message), |message, ...
code_fim
hard
{ "lang": "rust", "repo": "arjandepooter/advent-of-code-2020", "path": "/day19/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arjandepooter/advent-of-code-2020 path: /day19/src/main.rs #![feature(str_split_once)] #[allow(unused_imports)] use shared::prelude::*; const INPUT: &'static str = include_str!("./input.txt"); type RuleSet = HashMap<usize, Vec<Rule>>; type Data<'a> = (RuleSet, Vec<&'a str>); type Solution = us...
code_fim
hard
{ "lang": "rust", "repo": "arjandepooter/advent-of-code-2020", "path": "/day19/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> messages .iter() .filter(|message| is_valid(**message, &rule_set, 0) == Some("")) .count() } fn main() { let data = parse_input(INPUT); println!("Part A: {}", solve_a(&data)); println!("Part B: {}", solve_b(&data)); } #[cfg(test)] mod tests { use super::*; ...
code_fim
hard
{ "lang": "rust", "repo": "arjandepooter/advent-of-code-2020", "path": "/day19/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Pos(0.0, 0.0) } } impl Vel { fn new() -> Vel { Vel(0.0, 0.0) } } #[rustfmt::skip] #[allow(unused)] fn component_derive() { // ANCHOR: component_derive #[derive(Component, Debug)] struct Pos(f32, f32); #[derive(Component, Debug)] struct Vel(f32, f32); // ANCHOR_END: component...
code_fim
medium
{ "lang": "rust", "repo": "leudz/shipyard", "path": "/tests/book/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Vel { fn new() -> Vel { Vel(0.0, 0.0) } } #[rustfmt::skip] #[allow(unused)] fn component_derive() { // ANCHOR: component_derive #[derive(Component, Debug)] struct Pos(f32, f32); #[derive(Component, Debug)] struct Vel(f32, f32); // ANCHOR_END: component_derive }<|fim_prefix|>// repo:...
code_fim
hard
{ "lang": "rust", "repo": "leudz/shipyard", "path": "/tests/book/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leudz/shipyard path: /tests/book/mod.rs use shipyard::Component; mod add_components; mod add_entity; mod delete_components; mod delete_entity; mod get; mod hierarchy; mod iterators; #[cfg(feature = "thread_local")] mod non_send_sync; #[cfg(feature = "parallel")] mod parallelism; mod remove_comp...
code_fim
medium
{ "lang": "rust", "repo": "leudz/shipyard", "path": "/tests/book/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let a = ArrayD::<f32>::zeros(IxDyn(&[2, 3])); let a = a.map(|_| gen.sample(&mut rng)); let mut t = ArrayD::<f32>::zeros(IxDyn(a.shape())); t[[0, 0]] = 1.0; t[[1, 1]] = 1.0; println!("softmax-with-loss layer"); let mut layer: SoftmaxWithLossD<f32> = SoftmaxWithLossD::<f32>::ne...
code_fim
hard
{ "lang": "rust", "repo": "Surpris/rs-deep", "path": "/tests/integration_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Surpris/rs-deep path: /tests/integration_test.rs //! integration_test //! //! test functions extern crate rs_deep; use ndarray::prelude::*; use ndarray_rand::RandomExt; use ndarray_stats::QuantileExt; use rand::distributions::Uniform; use rand::prelude::*; use rs_deep::prelude::*; #[test] fn t...
code_fim
hard
{ "lang": "rust", "repo": "Surpris/rs-deep", "path": "/tests/integration_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut t = ArrayD::<f32>::zeros(IxDyn(a.shape())); t[[0, 0]] = 1.0; t[[1, 1]] = 1.0; println!("softmax-with-loss layer"); let mut layer: SoftmaxWithLossD<f32> = SoftmaxWithLossD::<f32>::new(a.shape(), 0); let b = layer.forward(&a, &t); println!("a: {}", a); println!("t: {...
code_fim
hard
{ "lang": "rust", "repo": "Surpris/rs-deep", "path": "/tests/integration_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (direction, amount) = line.split_at(1); ( direction.chars().next().unwrap(), amount.parse::<i32>().unwrap(), ) } pub fn run() { let input = include_bytes!("input"); let string = String::from_utf8(input.to_vec()).unwrap(); let iter: Vec<(char, i32)> = string.li...
code_fim
hard
{ "lang": "rust", "repo": "sheredom/AOC2020", "path": "/src/day12/mod.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sheredom/AOC2020 path: /src/day12/mod.rs #[exec_time] fn day12_part01(commands: &[(char, i32)]) { let mut direction = 90; let mut x = 0; let mut y = 0; for command in commands { match command.0 { 'N' => y -= command.1, 'S' => y += command.1, ...
code_fim
hard
{ "lang": "rust", "repo": "sheredom/AOC2020", "path": "/src/day12/mod.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>matter), Self::TsNullLiteralType(node) => node.to_format_element(formatter), Self::TsBooleanLiteralType(node) => node.to_format_element(formatter), Self::TsTemplateLiteralType(node) => node.to_format_element(formatter), Self::TsInferType(node) => node.to_for...
code_fim
hard
{ "lang": "rust", "repo": "Tembocs/rome", "path": "/crates/rome_js_formatter/src/ts/any/ts_type.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tembocs/rome path: /crates/rome_js_formatter/src/ts/any/ts_type.rs //! Generated file, do not edit by hand, see `xtask/codegen` use crate::{FormatElement, FormatResult, Formatter, ToFormatElement}; use rome_js_syntax::TsType; impl ToFormatElement for TsType { fn to_format_element(&self, for...
code_fim
hard
{ "lang": "rust", "repo": "Tembocs/rome", "path": "/crates/rome_js_formatter/src/ts/any/ts_type.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn reggie_testing() { let a = REGGIE.is_match("Plain and ^super^"); let b = REGGIE.is_match("Plain and ~sub~"); let c = REGGIE.is_match("Plain and ~in valid~"); let d = REGGIE.is_match("Plain and ^in valid^"); let e = REGGIE.is_match("Plain^ and unma...
code_fim
hard
{ "lang": "rust", "repo": "fizzbucket/bookbinder", "path": "/extended_pulldown/src/sub_and_superscript.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let text = r"H~2~O 25^th^ Hello^not super^. Goodbye~not_sub~."; let processed = disambiguate_sub_and_superscript(text.into()); let expected = "H<span class=\"subscript\">2</span>O 25<span class=\"superscript\">th</span> Hello^not super^. Goodbye~not_sub~."; assert_eq!(expec...
code_fim
hard
{ "lang": "rust", "repo": "fizzbucket/bookbinder", "path": "/extended_pulldown/src/sub_and_superscript.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fizzbucket/bookbinder path: /extended_pulldown/src/sub_and_superscript.rs use lazy_static::lazy_static; use pulldown_cmark::CowStr; use regex::Captures; use regex::{Regex, RegexSet}; use std::borrow::Cow; static SUPERSCRIPT: &str = r#"\^([[:alnum:]]+)\^"#; static SUBSCRIPT: &str = r#"~([[:alnum...
code_fim
hard
{ "lang": "rust", "repo": "fizzbucket/bookbinder", "path": "/extended_pulldown/src/sub_and_superscript.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vinimin/fluvio path: /src/k8-metadata/metadata-auth-token/src/status.rs //! //! # AuthToken Status //! //! Interface to the AuthToken metadata status in K8 key value store //! use serde::Deserialize; use serde::Serialize; <|fim_suffix|>#[derive(Deserialize, Serialize, Debug, PartialEq, Clone)]...
code_fim
medium
{ "lang": "rust", "repo": "vinimin/fluvio", "path": "/src/k8-metadata/metadata-auth-token/src/status.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Deserialize, Serialize, Debug, PartialEq, Clone)] pub enum TokenResolution { Ok, // operational Init, // initializing Invalid, // inactive } impl Status for AuthTokenStatus {}<|fim_prefix|>// repo: vinimin/fluvio path: /src/k8-metadata/metadata-auth-token/src/status.rs //! /...
code_fim
hard
{ "lang": "rust", "repo": "vinimin/fluvio", "path": "/src/k8-metadata/metadata-auth-token/src/status.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rogday/micro_platformer path: /src/main.rs use enigo::{Enigo, KeyboardControllable}; use std::sync::Arc; use std::time::{Duration, Instant}; use livesplit_hotkey::{Hook, Key, KeyCode}; use parking_lot::FairMutex; const CONTROLS: [KeyCode; 5] = [KeyCode::Left, KeyCode::Right, KeyCode::Up, ...
code_fim
hard
{ "lang": "rust", "repo": "rogday/micro_platformer", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use enigo::Key::*; match key { KeyCode::Left => LeftArrow, KeyCode::Right => RightArrow, KeyCode::Up => UpArrow, KeyCode::Down => DownArrow, KeyCode::Space => Space, _ => unreachable!(), } } fn replay(enigo: &mut Enigo, actions: &[Action]) { ...
code_fim
hard
{ "lang": "rust", "repo": "rogday/micro_platformer", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fenixc9/rust_learn path: /test_concurrent/src/arc.rs use std::cell::{Cell, RefCell}; use std::sync::Arc; use std::thread; use std::time::Duration; pub fn arc_cross_thread() { let arc = Arc::new(String::from("aabbcc")); <|fim_suffix|>/// 一写多读 pub fn arc_one_write_multi_read() { // let mu...
code_fim
hard
{ "lang": "rust", "repo": "fenixc9/rust_learn", "path": "/test_concurrent/src/arc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// 一写多读 pub fn arc_one_write_multi_read() { // let mut arc = Arc::new(RefCell::new(String::from("abc"))); // // for index in 0..10 { // let a = arc.clone(); // thread::spawn(move || { // for x in 0..100 { // if index == 1 { // arc.into_inne...
code_fim
hard
{ "lang": "rust", "repo": "fenixc9/rust_learn", "path": "/test_concurrent/src/arc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Cow::Borrowed(v.as_slice()) } } #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> FromIterator<T> for Cow<'a, [T]> where T: Clone, { fn from_iter<I: IntoIterator<Item = T>>(it: I) -> Cow<'a, [T]> { Cow::Owned(FromIterator::from_iter(it)) } }<|fim_prefix|>// repo: r...
code_fim
medium
{ "lang": "rust", "repo": "rust9x/rust", "path": "/library/alloc/src/vec/cow.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust9x/rust path: /library/alloc/src/vec/cow.rs use crate::borrow::Cow; use core::iter::FromIterator; use super::Vec; #[stable(feature = "cow_from_vec", since = "1.8.0")] impl<'a, T: Clone> From<&'a [T]> for Cow<'a, [T]> { fn from(s: &'a [T]) -> Cow<'a, [T]> { <|fim_suffix|> Cow::Bo...
code_fim
hard
{ "lang": "rust", "repo": "rust9x/rust", "path": "/library/alloc/src/vec/cow.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Cow::Owned(v) } } #[stable(feature = "cow_from_vec_ref", since = "1.28.0")] impl<'a, T: Clone> From<&'a Vec<T>> for Cow<'a, [T]> { fn from(v: &'a Vec<T>) -> Cow<'a, [T]> { Cow::Borrowed(v.as_slice()) } } #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> FromIterator<T...
code_fim
medium
{ "lang": "rust", "repo": "rust9x/rust", "path": "/library/alloc/src/vec/cow.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Networking & RPC settings #[derive(Debug, PartialEq, Clone)] pub struct NetworkSettings { /// Node name pub name: String, /// Name of the chain we are connected to pub chain: String, /// Is development chain pub is_dev_chain: bool, /// Networking port pub network_port: u16, /// Is JSON-RPC se...
code_fim
medium
{ "lang": "rust", "repo": "yijie37/DaQiao", "path": "/bridge/parity-ethereum/rpc/src/v1/helpers/network_settings.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yijie37/DaQiao path: /bridge/parity-ethereum/rpc/src/v1/helpers/network_settings.rs // Copyright 2015-2019 Parity Technologies (UK) Ltd. // This file is part of Parity Ethereum. // Parity Ethereum is free software: you can redistribute it and/or modify // it under the terms of the GNU General P...
code_fim
hard
{ "lang": "rust", "repo": "yijie37/DaQiao", "path": "/bridge/parity-ethereum/rpc/src/v1/helpers/network_settings.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a, B: 'a> Deref for Boo<'a, B> { type Target = B; fn deref(&self) -> &B { self.as_ref() } }<|fim_prefix|>// repo: Kevin-Zhu86/cedar path: /src/boo.rs use std::convert::AsRef; use std::ops::Deref; /// /// Borrowed or Owned /// Very similar to `std::borrow::Cow` but without requi...
code_fim
medium
{ "lang": "rust", "repo": "Kevin-Zhu86/cedar", "path": "/src/boo.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kevin-Zhu86/cedar path: /src/boo.rs use std::convert::AsRef; use std::ops::Deref; /// /// Borrowed or Owned /// Very similar to `std::borrow::Cow` but without requiring `ToOwned` (and therefore, `Clone`) /// pub enum Boo<'a, B: 'a> { Borrowed(&'a B), Owned(B), } <|fim_suffix|> m...
code_fim
medium
{ "lang": "rust", "repo": "Kevin-Zhu86/cedar", "path": "/src/boo.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match self { &Boo::Borrowed(b) => b, &Boo::Owned(ref o) => o, } } } impl<'a, B: 'a> Deref for Boo<'a, B> { type Target = B; fn deref(&self) -> &B { self.as_ref() } }<|fim_prefix|>// repo: Kevin-Zhu86/cedar path: /src/boo.rs use std::convert...
code_fim
medium
{ "lang": "rust", "repo": "Kevin-Zhu86/cedar", "path": "/src/boo.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>include!(concat!(env!("OUT_DIR"), "/properties_mappings.rs"));<|fim_prefix|>// repo: zarik5/bridgevr-dev path: /openvr-driver-sys/src/lib.rs #![allow(clippy::all, clippy::nursery, clippy::pedantic)] <|fim_middle|>include!(concat!(env!("OUT_DIR"), "/bindings.rs")); pub use root::*; pub use root::vr::*;
code_fim
medium
{ "lang": "rust", "repo": "zarik5/bridgevr-dev", "path": "/openvr-driver-sys/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zarik5/bridgevr-dev path: /openvr-driver-sys/src/lib.rs #![allow(clippy::all, clippy::nursery, clippy::pedantic)] <|fim_suffix|>include!(concat!(env!("OUT_DIR"), "/properties_mappings.rs"));<|fim_middle|>include!(concat!(env!("OUT_DIR"), "/bindings.rs")); pub use root::*; pub use root::vr::*;
code_fim
medium
{ "lang": "rust", "repo": "zarik5/bridgevr-dev", "path": "/openvr-driver-sys/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: diodesign/platform-riscv path: /src/test.rs /* diosix RV64 test harness support * * (c) Chris Williams, 2019. * * See LICENSE for usage and copying. */ use core::ptr::write_volatile; /* physical RAM location of test interface for SiFive and Qemu targets */ const TEST_INTERFACE_MMIO_ADDR: ...
code_fim
hard
{ "lang": "rust", "repo": "diodesign/platform-riscv", "path": "/src/test.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>/* write word to the test interface for SiFive, or Qemu on Virt environments */ fn write_word(word: u32) { unsafe { write_volatile(TEST_INTERFACE_MMIO_ADDR as *mut u32, word); } }<|fim_prefix|>// repo: diodesign/platform-riscv path: /src/test.rs /* diosix RV64 test harness support * * (c) Chris Wil...
code_fim
hard
{ "lang": "rust", "repo": "diodesign/platform-riscv", "path": "/src/test.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: crisptrutski/aws-sdk-rust path: /sdk/savingsplans/src/client.rs mpotency of the request.</p> pub fn client_token(mut self, input: impl Into<std::string::String>) -> Self { self.inner = self.inner.client_token(input); self } pub fn set_client_token(...
code_fim
hard
{ "lang": "rust", "repo": "crisptrutski/aws-sdk-rust", "path": "/sdk/savingsplans/src/client.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: crisptrutski/aws-sdk-rust path: /sdk/savingsplans/src/client.rs tring::String>) -> Self { self.inner = self.inner.client_token(input); self } pub fn set_client_token(mut self, input: std::option::Option<std::string::String>) -> Self { self.inne...
code_fim
hard
{ "lang": "rust", "repo": "crisptrutski/aws-sdk-rust", "path": "/sdk/savingsplans/src/client.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let stdin = std::io::stdin(); loop { let mut text = String::new(); loop { stdin.read_line(&mut text).unwrap(); if text.ends_with("\n\n") { let _ = text.pop(); break; } } print!("Lexed program: ");...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/yep", "path": "/crates/repl/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/yep path: /crates/repl/src/main.rs use ast::token::TokenKind; use lexer::Program; use parser::formatting::ToBeauty; const BLUE: &str = "\x1b[38;2;50;220;255m"; const GREEN: &str = "\x1b[38;2;80;230;100m"; const YELLOW: &str = "\x1b[38;2;255;235;0m"; const ORANGE: &str = "\x1b[38;2;255;...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/yep", "path": "/crates/repl/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> print!("Lexed program: "); let program = lexer::lex(&text); print_program(&program, &text); println!("\n"); match parser::parse(program.tokens()) { Ok(parsed) => { println!("Parsed output:"); println!("{}", parsed.to_bea...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/yep", "path": "/crates/repl/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Pacemaker { interval: u64, join_handle: Option<thread::JoinHandle<()>>, shutdown_handle: Option<ShutdownHandle>, } impl Pacemaker { pub fn new(interval: u64) -> Self { Self { interval, join_handle: None, shutdown_handle: None, ...
code_fim
hard
{ "lang": "rust", "repo": "shannynalayna/splinter", "path": "/libsplinter/src/network/connection_manager/pacemaker.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn await_shutdown(self) { let join_handle = if let Some(jh) = self.join_handle { jh } else { return; }; if let Err(err) = join_handle.join() { error!("Failed to shutdown heartbeat monitor gracefully: {:?}", err); } } ...
code_fim
hard
{ "lang": "rust", "repo": "shannynalayna/splinter", "path": "/libsplinter/src/network/connection_manager/pacemaker.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shannynalayna/splinter path: /libsplinter/src/network/connection_manager/pacemaker.rs // Copyright 2018-2020 Cargill Incorporated // // 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 ...
code_fim
hard
{ "lang": "rust", "repo": "shannynalayna/splinter", "path": "/libsplinter/src/network/connection_manager/pacemaker.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tarunjais28/RustAPI path: /src/db.rs use diesel::{ pg::PgConnection, r2d2::{self, ConnectionManager}, }; type DbPool = r2d2::Pool<ConnectionManager<PgConnection>>; <|fim_suffix|> // Setup Connection Manager let conection_manager = ConnectionManager::<PgConnection>::new(con_str); ...
code_fim
easy
{ "lang": "rust", "repo": "tarunjais28/RustAPI", "path": "/src/db.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Setup Connection Manager let conection_manager = ConnectionManager::<PgConnection>::new(con_str); // Creating DB Pool r2d2::Pool::builder() .build(conection_manager) .expect("Failed to create pool.") }<|fim_prefix|>// repo: tarunjais28/RustAPI path: /src/db.rs use diese...
code_fim
easy
{ "lang": "rust", "repo": "tarunjais28/RustAPI", "path": "/src/db.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let args: Vec<String> = env::args().collect(); let year = args[1].parse::<u32>().unwrap(); lib::display(year, lib::calendar(year)) }<|fim_prefix|>// repo: ChaosStudyGroup/rusti-cal path: /src/main.rs use std::env; mod lib; <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "ChaosStudyGroup/rusti-cal", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ChaosStudyGroup/rusti-cal path: /src/main.rs use std::env; mod lib; <|fim_suffix|> let args: Vec<String> = env::args().collect(); let year = args[1].parse::<u32>().unwrap(); lib::display(year, lib::calendar(year)) }<|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "ChaosStudyGroup/rusti-cal", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: radekvit/turn path: /turn/src/finite_automata/nda.rs // nondeterministic finite state automaton use std::collections::BTreeSet; use super::matchers::Matcher; pub struct Transitions { transitions: Vec<(Matcher, BTreeSet<usize>)>, } <|fim_suffix|> pub fn transitions(&self, state: usize, ...
code_fim
hard
{ "lang": "rust", "repo": "radekvit/turn", "path": "/turn/src/finite_automata/nda.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn transitions(&self, state: usize, c: char) -> Option<&BTreeSet<usize>> { let transitions = &self.states[state].0.transitions; for (matcher, states) in transitions.iter() { if matcher.is_matching(c) { return Some(states); } } ...
code_fim
hard
{ "lang": "rust", "repo": "radekvit/turn", "path": "/turn/src/finite_automata/nda.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jheysonsaav/cangrebot path: /src/commands/ping.rs use serenity::{ client::Context, framework::standard::{macros::command, Args,<|fim_suffix|>"Ping response"); message.channel_id.say(&ctx.http, "Pong!").await?; Ok(()) }<|fim_middle|> CommandResult}, model::channel::Message, }...
code_fim
medium
{ "lang": "rust", "repo": "jheysonsaav/cangrebot", "path": "/src/commands/ping.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>sync fn ping(ctx: &Context, message: &Message, _: Args) -> CommandResult { info!("Ping response"); message.channel_id.say(&ctx.http, "Pong!").await?; Ok(()) }<|fim_prefix|>// repo: jheysonsaav/cangrebot path: /src/commands/ping.rs use serenity::{ client::Context, framework::standard:...
code_fim
medium
{ "lang": "rust", "repo": "jheysonsaav/cangrebot", "path": "/src/commands/ping.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: diptodip/raytracer path: /src/ray.rs use std::f64::consts::PI; use crate::rand::prelude::*; use crate::linalg::dot; use crate::linalg::Vec3D; use crate::colors::rgb; use crate::colors::vec_to_rgb; use crate::colors::RGB; use crate::io::write_ppm; use crate::geometry::find_intersections; use...
code_fim
hard
{ "lang": "rust", "repo": "diptodip/raytracer", "path": "/src/ray.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn trace(ray: &Ray, world: &Vec<Intersectable>, depth: u64) -> RGB { // light enters the void if we hit the depth limit if depth <= 0 { return rgb(0.0, 0.0, 0.0); } // determine if ray intersects and choose first intersection if so let (intersections, result) = find_intersectio...
code_fim
hard
{ "lang": "rust", "repo": "diptodip/raytracer", "path": "/src/ray.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[inline] fn schlick(cos_theta: f64, index_ratio: f64) -> f64 { let mut r0 = (1.0 - index_ratio) / (1.0 + index_ratio); r0 = r0 * r0; r0 + (1.0 - r0) * (1.0 - cos_theta).powf(5.0) } fn refract(intersection: &Intersection, intersectable: &Intersectable, ray: &Ray) -> Ray { let mut material...
code_fim
hard
{ "lang": "rust", "repo": "diptodip/raytracer", "path": "/src/ray.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lnicola/fasteval path: /examples/simple-vars.rs // usage: cargo run --release --example simple-vars use std::collections::BTreeMap; fn main() -> Result<(), fasteval::Error> { <|fim_suffix|> let val = fasteval::ez_eval(r#"x + print("y:",y) + z"#, &mut map)?; // ...
code_fim
medium
{ "lang": "rust", "repo": "lnicola/fasteval", "path": "/examples/simple-vars.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let val = fasteval::ez_eval(r#"x + print("y:",y) + z"#, &mut map)?; // | // prints "y: 2" to stderr and then evaluates to 2.0 assert_eq!(val, 6.0); Ok(()) }<|fim_prefix|>// repo: lnicola/fasteval path: /examples/simp...
code_fim
medium
{ "lang": "rust", "repo": "lnicola/fasteval", "path": "/examples/simple-vars.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/traits/pointee-tail-is-generic.rs // check-pass // edition:2018 #![feature(ptr_metadata)] #![feature(type_alias_impl_trait)] type Opaque = impl std::future::Future; <|fim_suffix|>fn is_thin<T: std::ptr::Pointee<Metadata = ()>>() {} fn main() {}<|fim_middle|>fn ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/traits/pointee-tail-is-generic.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn a2<T: Iterator>() { // associated type is known to be sized is_thin::<T::Item>(); } fn is_thin<T: std::ptr::Pointee<Metadata = ()>>() {} fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/traits/pointee-tail-is-generic.rs // check-pass // edition:2018 #![feature(ptr_metadata)...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/traits/pointee-tail-is-generic.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lambdadelta34/gm_tbd path: /src/visuals/player/mod.rs mod systems; use super::utils; use crate::GameState; use bevy::prelude::*; use systems::setup::setup_player; pub struct BevyPlugin; <|fim_suffix|> app.add_system_set(SystemSet::on_enter(GameState::Game).with_system(setup_player.syst...
code_fim
medium
{ "lang": "rust", "repo": "lambdadelta34/gm_tbd", "path": "/src/visuals/player/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> app.add_system_set(SystemSet::on_enter(GameState::Game).with_system(setup_player.system())); } }<|fim_prefix|>// repo: lambdadelta34/gm_tbd path: /src/visuals/player/mod.rs mod systems; use super::utils; use crate::GameState; use bevy::prelude::*; use systems::setup::setup_player; <|fim_mid...
code_fim
medium
{ "lang": "rust", "repo": "lambdadelta34/gm_tbd", "path": "/src/visuals/player/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: im-0/zicsv path: /zicsv-tool/src/main.rs #![forbid(unsafe_code)] #![warn(unused_results)] #![cfg_attr(feature = "cargo-clippy", warn(empty_line_after_outer_attr))] #![cfg_attr(feature = "cargo-clippy", warn(filter_map))] #![cfg_attr(feature = "cargo-clippy", warn(if_not_else))] #![cfg_attr(featu...
code_fim
hard
{ "lang": "rust", "repo": "im-0/zicsv", "path": "/zicsv-tool/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn from_str(s: &str) -> Result<Self, Self::Err> { match s { "human-readable" => Ok(OutputFormat::HumanReadable), "pretty-json" => Ok(OutputFormat::PrettyJSON), "json" => Ok(OutputFormat::JSON), unknown_format => Err(format_err!("Unknown output f...
code_fim
hard
{ "lang": "rust", "repo": "im-0/zicsv", "path": "/zicsv-tool/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } } impl<'a> AuditLogReason for RemoveRoleFromMember<'a> { fn reason(mut self, reason: impl Into<String>) -> Result<Self, AuditLogReasonError> { self.reason .replace(AuditLogReasonError::validate(reason.into())?); Ok(self) } } poll_req!(RemoveRoleF...
code_fim
medium
{ "lang": "rust", "repo": "LeSeulArtichaut/twilight", "path": "/http/src/request/guild/member/remove_role_from_member.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LeSeulArtichaut/twilight path: /http/src/request/guild/member/remove_role_from_member.rs use crate::{ client::Client, error::Error, request::{self, AuditLogReason, AuditLogReasonError, Pending, Request}, routing::Route, }; use twilight_model::id::{GuildId, RoleId, UserId}; /// R...
code_fim
hard
{ "lang": "rust", "repo": "LeSeulArtichaut/twilight", "path": "/http/src/request/guild/member/remove_role_from_member.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> // find the next record to write // check is_empty() before unwrap()ing let mut idx = 0; for chunk_num in 0..self.chunks as usize { if !self.buffers[chunk_num].is_empty() && (self.buffers[idx].is_empty() || (self.sort_by_fn)( ...
code_fim
hard
{ "lang": "rust", "repo": "lilydjwg/external_sort", "path": "/src/external_sort.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn write_chunk(&self, file: &Path, chunk: &mut Vec<T>) -> Result<(), Box<dyn Error>> { let new_file = OpenOptions::new().create(true).append(true).open(file)?; let mut new_file = BufWriter::new(new_file); for s in chunk { let mut serialized = serde_json::to_string(&...
code_fim
hard
{ "lang": "rust", "repo": "lilydjwg/external_sort", "path": "/src/external_sort.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lilydjwg/external_sort path: /src/external_sort.rs use std::clone::Clone; use std::cmp::Ordering::{self, Less}; use std::collections::VecDeque; use std::error::Error; use std::fs::{File, OpenOptions}; use std::io::SeekFrom::Start; use std::io::{BufRead, BufReader, Seek, Write, BufWriter}; use st...
code_fim
hard
{ "lang": "rust", "repo": "lilydjwg/external_sort", "path": "/src/external_sort.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dmgolembiowski/sortasecret path: /keypair/src/lib.rs extern crate base16; #[cfg(test)] extern crate quickcheck; #[cfg(test)] #[macro_use(quickcheck)] extern crate quickcheck_macros; use std::fs::File; use std::io::Write; use std::path::Path; use cryptoxide::chacha20poly1305::ChaCha20Poly1305;...
code_fim
hard
{ "lang": "rust", "repo": "dmgolembiowski/sortasecret", "path": "/keypair/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn decrypt<T: AsRef<[u8]>>(&self, hex: T) -> Result<Vec<u8>, Error> { let noncetagcipher = base16::decode(&hex)?; let nonce = &noncetagcipher[0..8]; let tag = &noncetagcipher[8..24]; let cipher = &noncetagcipher[24..]; let mut output: Vec<u8> = Vec::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "dmgolembiowski/sortasecret", "path": "/keypair/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jacques-n/arrow path: /rust/src/record_batch.rs // Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // ...
code_fim
hard
{ "lang": "rust", "repo": "jacques-n/arrow", "path": "/rust/src/record_batch.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let v = vec![b'a', b'b', b'c', b'd', b'e']; let offset_data = vec![0, 1, 2, 3, 4, 5, 6]; let array_data = ArrayData::builder(DataType::Utf8) .len(5) .add_buffer(Buffer::from(v.to_byte_slice())) .add_buffer(Buffer::from(offset_data.to_byte_slice()...
code_fim
hard
{ "lang": "rust", "repo": "jacques-n/arrow", "path": "/rust/src/record_batch.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let record_batch = RecordBatch::new(Arc::new(schema), vec![Arc::new(a), Arc::new(b)]); assert_eq!(5, record_batch.num_rows()); assert_eq!(2, record_batch.num_columns()); assert_eq!(&DataType::Int32, record_batch.schema().field(0).data_type()); assert_eq!(&DataType:...
code_fim
hard
{ "lang": "rust", "repo": "jacques-n/arrow", "path": "/rust/src/record_batch.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn header(&self) -> &HeaderView { &self.header } fn empty_record(&self) -> Record { Record::new(Rc::clone(&self.header)) } } impl Drop for IndexedReader { fn drop(&mut self) { unsafe { htslib::bcf_sr_destroy(self.inner) }; } } /// This module contains the...
code_fim
hard
{ "lang": "rust", "repo": "rust-bio/rust-htslib", "path": "/src/bcf/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_writer_set_threads() { let path = &"test/test.bcf"; let tmp = tempfile::Builder::new() .prefix("rust-htslib") .tempdir() .expect("Cannot create temp dir"); let bcfpath = tmp.path().join("test.bcf"); let bcf = Reade...
code_fim
hard
{ "lang": "rust", "repo": "rust-bio/rust-htslib", "path": "/src/bcf/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-bio/rust-htslib path: /src/bcf/mod.rs by an enum that can be a pointer // into a synced reader or an owning popinter to an allocated record. unsafe { htslib::bcf_copy( record.inner, *(*(*self...
code_fim
hard
{ "lang": "rust", "repo": "rust-bio/rust-htslib", "path": "/src/bcf/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Coin::Penny => 1, Coin::Nickel => 5, Coin::Dime => 10, Coin::Quarter(state) => { println!("State quarter from {:?}", state); 25 }, } } use std::fs::File; u...
code_fim
hard
{ "lang": "rust", "repo": "synczer0/learn-rust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: synczer0/learn-rust path: /src/main.rs #[allow(unused_imports)] use std::fmt; #[allow(unused_imports)] use std::fmt::Display; #[allow(unused_imports)] use std::io; // access loops.rs file which consists of functions mod loops; #[allow(unused_imports)] use std::collections::HashMap; <|fim_suff...
code_fim
hard
{ "lang": "rust", "repo": "synczer0/learn-rust", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: geo-engine/geoengine path: /services/src/tasks/in_memory.rs <TaskUpdateStatusWithTaskId>>, } struct TaskHandle { task: SharedTask, handle: Option<JoinHandle<()>>, status: Db<TaskStatus>, unique_key: Option<(&'static str, String)>, } impl SimpleTaskManagerBackend { async fn ...
code_fim
hard
{ "lang": "rust", "repo": "geo-engine/geoengine", "path": "/services/src/tasks/in_memory.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: geo-engine/geoengine path: /services/src/tasks/in_memory.rs derive(Default, Clone)] pub struct SimpleTaskManagerBackend { tasks_by_id: Db<HashMap<TaskId, TaskHandle>>, unique_tasks: Db<HashSet<(&'static str, String)>>, // these two lists won't be cleaned-up status_by_id: Db<HashM...
code_fim
hard
{ "lang": "rust", "repo": "geo-engine/geoengine", "path": "/services/src/tasks/in_memory.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> match result { Ok(_) => set_status_to_clean_up_completed(&task_handle.status).await, Err(err) => set_status_to_clean_up_failed(&task_handle.status, err).await, }; remove_unique_key(&task_handle, &mut update_lock.unique_tasks); }); task_handle.handl...
code_fim
hard
{ "lang": "rust", "repo": "geo-engine/geoengine", "path": "/services/src/tasks/in_memory.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> for idx in (0 .. state.len()).cycle() .skip(max_idx + 1) .take(free_blocks as usize) { state[idx] += 1; } cycles += 1; if known_states.contains_key(&state) { ...
code_fim
medium
{ "lang": "rust", "repo": "nemq/AoC2017", "path": "/src/day_6.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nemq/AoC2017 path: /src/day_6.rs use std::collections::HashMap; pub fn first_puzzle() -> String { let (all_cycles, _) = cycles_count(BANKS); format!("{}", all_cycles) } pub fn second_puzzle() -> String { let (_, interval_cycles) = cycles_count(BANKS); format!("{}", i...
code_fim
hard
{ "lang": "rust", "repo": "nemq/AoC2017", "path": "/src/day_6.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: svend/advent-of-code path: /aoc-2019/src/day7.rs // https://adventofcode.com/2019/day/7 use crate::day5; use itertools::Itertools; fn run_program(phases: &[i64], program: &[i64]) -> i64 { let mut output = 0; for phase in phases { let mut program = day5::Program::new(program.to_...
code_fim
hard
{ "lang": "rust", "repo": "svend/advent-of-code", "path": "/aoc-2019/src/day7.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut output = 0; let mut programs: Vec<_> = (0..phases.len()) .map(|_| day5::Program::new(program.to_vec())) .collect(); for (i, phase) in phases.iter().enumerate() { let outputs = programs[i].run(&[*phase, output]); output = *outputs.last().unwrap(); } ...
code_fim
hard
{ "lang": "rust", "repo": "svend/advent-of-code", "path": "/aoc-2019/src/day7.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_part_1() { let tests = &[( ( "3,15,3,16,1002,16,10,16,1,16,15,15,4,15,99,0,0", "4,3,2,1,0", ), 43210, )]; for (input, expected) in tests { let (program, thruster_signal) = input;...
code_fim
hard
{ "lang": "rust", "repo": "svend/advent-of-code", "path": "/aoc-2019/src/day7.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub const SYSCNT_FRQ: u32 = defs::SYSCNT_FRQ; pub const MAX_PWR_LVL: u8 = defs::MAX_PWR_LVL; pub const MAX_RET_STATE: u8 = defs::MAX_RET_STATE; pub const MAX_OFF_STATE: u8 = defs::MAX_OFF_STATE;<|fim_prefix|>// repo: isgasho/baremetalisp path: /kernel/src/driver/defs.rs #[cfg(any(feature = "raspi3", feat...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/baremetalisp", "path": "/kernel/src/driver/defs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/baremetalisp path: /kernel/src/driver/defs.rs #[cfg(any(feature = "raspi3", feature = "raspi4"))] use super::device::raspi::defs; <|fim_suffix|>pub const SYSCNT_FRQ: u32 = defs::SYSCNT_FRQ; pub const MAX_PWR_LVL: u8 = defs::MAX_PWR_LVL; pub const MAX_RET_STATE: u8 = defs::MAX_RET_STATE;...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/baremetalisp", "path": "/kernel/src/driver/defs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }