text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> fn div_euc(self, rhs: Self) -> Self; fn mod_euc(self, rhs: Self) -> Self; // NOTE depends on unstable intrinsics::powif64 // fn powi(self, n: i32) -> Self; fn powf(self, n: Self) -> Self; fn sqrt(self) -> Self; fn exp(self) -> Self; fn exp2(self) -> Self; fn ln(s...
code_fim
hard
{ "lang": "rust", "repo": "virtualritz/simdeez", "path": "/src/libm/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn sin(self) -> Self; fn cos(self) -> Self; fn tan(self) -> Self; fn asin(self) -> Self; fn acos(self) -> Self; fn atan(self) -> Self; fn atan2(self, other: Self) -> Self; #[inline] fn sin_cos(self) -> (Self, Self) where Self: Copy, { (sel...
code_fim
hard
{ "lang": "rust", "repo": "virtualritz/simdeez", "path": "/src/libm/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /rt/mozISpellI18NUtil.rs // // DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/mozISpellI18NUtil.idl // pub mod mozISpellI18NUtil_consts { pub const kCheck: i64 = 0; pub const kSuggest: i64 = 1; } #[repr(C)] pub struct mozISpellI18NUtil { ...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/rt/mozISpellI18NUtil.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /* void fromRootForm (in wstring word, [array, size_is (icount)] in wstring iwords, in uint32_t icount, [array, size_is (ocount)] out wstring owords, out uint32_t ocount); */ /* void findNextWord (in wstring word, in uint32_t length, in uint32_t offset, out int32_t begin, out int32_t end); */ ...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/rt/mozISpellI18NUtil.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let n = registers.reg(s) as i32; let d = registers.reg(t) as i32; if d == 0 { // Division by zero, results are bogus registers.set_hi(n as u32); if n >= 0 { registers.set_lo(0xffffffff) } else { regis...
code_fim
hard
{ "lang": "rust", "repo": "matthew-mcallister/playstation-emulator", "path": "/src/cpu/operations/div.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Operation for Div { fn perform(&self, registers: &mut Registers, _: &mut Interconnect, _: &mut Delay) -> Result<(), Exception> { let s = self.instruction.s(); let t = self.instruction.t(); let n = registers.reg(s) as i32; let d = registers.reg(t) as i32; ...
code_fim
hard
{ "lang": "rust", "repo": "matthew-mcallister/playstation-emulator", "path": "/src/cpu/operations/div.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matthew-mcallister/playstation-emulator path: /src/cpu/operations/div.rs use crate::cpu::delay::Delay; use crate::cpu::exception::Exception; use crate::cpu::interconnect::Interconnect; use crate::cpu::operations::Operation; use crate::cpu::registers::Registers; use crate::instruction::Instructio...
code_fim
hard
{ "lang": "rust", "repo": "matthew-mcallister/playstation-emulator", "path": "/src/cpu/operations/div.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>implement_error! { pub enum PendingProposalsError { Exists = "Can't create message because a pending proposal exists.", } } implement_error! { pub enum InvalidMessageError { Simple { MembershipTagMismatch = "A Proposal with an invalid membership tag...
code_fim
hard
{ "lang": "rust", "repo": "claucece/openmls", "path": "/src/group/managed_group/errors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: claucece/openmls path: /src/group/managed_group/errors.rs //! # MLS Managed Group errors //! //! `WelcomeError`, `ApplyCommitError`, `DecryptionError`, and //! `CreateCommitError`. use crate::codec::CodecError; use crate::config::ConfigError; use crate::error::{ErrorPayload, ErrorString}; use c...
code_fim
medium
{ "lang": "rust", "repo": "claucece/openmls", "path": "/src/group/managed_group/errors.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(pv.item_x1(0), 0.0); } #[wasm_bindgen_test] fn testcolor(){ let red = Colors::new(248, 0, 0, 0.8); assert_eq!(red.rgba(), String::from("rgba(248, 0, 0, 0.8)")); }<|fim_prefix|>// repo: newmancodes/double-pendulam-visualisation path: /tests/web.rs //! Test suite for the Web and hea...
code_fim
medium
{ "lang": "rust", "repo": "newmancodes/double-pendulam-visualisation", "path": "/tests/web.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let red = Colors::new(248, 0, 0, 0.8); assert_eq!(red.rgba(), String::from("rgba(248, 0, 0, 0.8)")); }<|fim_prefix|>// repo: newmancodes/double-pendulam-visualisation path: /tests/web.rs //! Test suite for the Web and headless browsers. #![cfg(target_arch = "wasm32")] extern crate wasm_bindgen_...
code_fim
hard
{ "lang": "rust", "repo": "newmancodes/double-pendulam-visualisation", "path": "/tests/web.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: newmancodes/double-pendulam-visualisation path: /tests/web.rs //! Test suite for the Web and headless browsers. #![cfg(target_arch = "wasm32")] extern crate wasm_bindgen_test; use wasm_bindgen_test::*; extern crate dp_vis; use dp_vis::*; // wasm_bindgen_test_configure!(run_in_browser); #[was...
code_fim
hard
{ "lang": "rust", "repo": "newmancodes/double-pendulam-visualisation", "path": "/tests/web.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sria91-rlox/luxor path: /src/scanner.rs e std::iter::Peekable; use crate::token::*; pub struct Scanner<'a> { source: Peekable<Chars<'a>>, total_len: u32, tokens: Vec<Token>, start_pos: u32, current_pos: u32, line: u32, } impl<'a> Scanner<'a> { pub fn new(source: &'a...
code_fim
hard
{ "lang": "rust", "repo": "sria91-rlox/luxor", "path": "/src/scanner.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sria91-rlox/luxor path: /src/scanner.rs use std::iter::Peekable; use crate::token::*; pub struct Scanner<'a> { source: Peekable<Chars<'a>>, total_len: u32, tokens: Vec<Token>, start_pos: u32, current_pos: u32, line: u32, } impl<'a> Scanner<'a> { pub fn new(source: &...
code_fim
hard
{ "lang": "rust", "repo": "sria91-rlox/luxor", "path": "/src/scanner.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_small_program() { let input = "var three = 3; // this is a comment var x = 8; /* and a block * multi-line comment */ var add = fun(i, j) { return i + j; } var result = add(three /* inside a statement */, x); if (3 < 8) { return true; } else { return false; ...
code_fim
hard
{ "lang": "rust", "repo": "sria91-rlox/luxor", "path": "/src/scanner.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doytsujin/parallel-disk-usage path: /src/bytes_format/parsed_value.rs use derive_more::Display; /// Return value of [`Formatter::parse_value`](super::Formatter::parse_value). #[derive(Debug, Display, Clone, Copy)] #[display(fmt = "{}{}", coefficient, unit)] pub struct ParsedValue { pub(supe...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/parallel-disk-usage", "path": "/src/bytes_format/parsed_value.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl ParsedValue { parsed_value_getter!( /// The visible part of the number. coefficient: u64 ); parsed_value_getter!( /// The unit that follows `coefficient`. unit: char ); parsed_value_getter!( /// The divisor that was used upon the original nu...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/parallel-disk-usage", "path": "/src/bytes_format/parsed_value.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let new_fields = new_fields?; Ok(quote! { pub struct #builder_name { #( #new_fields ),* } }) } fn impl_builder(fields: &Fields, builder_name: &Ident) -> Result<TokenStream> { let new_fields: Result<Vec<TokenStream>> = fields .iter() .map(|field|...
code_fim
hard
{ "lang": "rust", "repo": "hacpy/proc-macro-workshop", "path": "/builder/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hacpy/proc-macro-workshop path: /builder/src/lib.rs use proc_macro2::{Ident, Span, TokenStream}; use quote::quote; use syn::{ parse_macro_input, spanned::Spanned, Data, DeriveInput, Error, Fields, Lit, Meta, MetaList, NestedMeta, Result, Type, }; #[proc_macro_derive(Builder, attributes(...
code_fim
hard
{ "lang": "rust", "repo": "hacpy/proc-macro-workshop", "path": "/builder/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> impl #builder_name { #builder_build #builder_funcs } }; Ok(expand) } fn get_attr_value(field: &syn::Field) -> Result<Option<Ident>> { for attr in &field.attrs { if let Ok(Meta::List(MetaList { ref path, ref nested, ...
code_fim
hard
{ "lang": "rust", "repo": "hacpy/proc-macro-workshop", "path": "/builder/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yewstack/yewtify path: /src/styles.rs use strum::AsRefStr; use yew::Classes; #[derive(AsRefStr, Debug, Clone, PartialEq, Eq, Hash)] #[strum(serialize_all = "kebab-case")] pub enum Color { Red, Pink, Purple, DeepPurple, Indigo, Blue, LightBlue, Cyan, Teal, ...
code_fim
hard
{ "lang": "rust", "repo": "yewstack/yewtify", "path": "/src/styles.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(AsRefStr, Debug, Clone, PartialEq, Eq, Hash)] #[strum(serialize_all = "kebab-case")] pub enum Intensity { Lighten5, Lighten4, Lighten3, Lighten2, Lighten1, Darken1, Darken2, Darken3, Darken4, Accent1, Accent2, Accent3, Accent4, } pub struct Col...
code_fim
hard
{ "lang": "rust", "repo": "yewstack/yewtify", "path": "/src/styles.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut img_buffer = image::ImageBuffer::new(IMG_WIDTH + 1, IMG_HEIGHT + 1); let mut random_numer_generator = rand::thread_rng(); //get the polygon and it's edges, with a radius of half the image width or image height, //depending on which one's smallest let (polygon, polygon_edge...
code_fim
hard
{ "lang": "rust", "repo": "vancha/chaos_game", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vancha/chaos_game path: /src/main.rs use geo::prelude::Contains; //trait to see if one geometrical object is inside another use geo::{Coordinate, LineString, Polygon}; use rand::Rng; ///sets the width of the resulting generated image const IMG_WIDTH: u32 = 400; ///sets the height of the generat...
code_fim
hard
{ "lang": "rust", "repo": "vancha/chaos_game", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl EvalOp for Range { fn is_stateless(&self) -> bool { true } fn eval(&self, mut inputs: TVec<Arc<Tensor>>) -> TractResult<TVec<Arc<Tensor>>> { let (start, limit, delta) = args_3!(inputs); let dt = start.datum_type(); let start = start.cast_to_scalar::<u64>()...
code_fim
medium
{ "lang": "rust", "repo": "dtolnay-contrib/tract", "path": "/hir/src/ops/array/range.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dtolnay-contrib/tract path: /hir/src/ops/array/range.rs use crate::internal::*; use tract_ndarray::prelude::*; #[derive(Debug, Default, Clone, new, Hash)] pub struct Range; impl_dyn_hash!(Range); impl Op for Range { fn name(&self) -> Cow<str> { "Range".into() } op_hir!();...
code_fim
hard
{ "lang": "rust", "repo": "dtolnay-contrib/tract", "path": "/hir/src/ops/array/range.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let (start, limit, delta) = args_3!(inputs); let dt = start.datum_type(); let start = start.cast_to_scalar::<u64>()?; let limit = limit.cast_to_scalar::<u64>()?; let delta = delta.cast_to_scalar::<u64>()?; let value = Array1::from_shape_fn(((limi...
code_fim
medium
{ "lang": "rust", "repo": "dtolnay-contrib/tract", "path": "/hir/src/ops/array/range.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if s.len() > 2 { Card(Card::suit_from_char(s.chars().nth(2).unwrap()), Rank::Ten) } else { Card( Card::suit_from_char(s.chars().nth(1).unwrap()), Card::rank_from_char(s.chars().nth(0).unwrap()), ) } } fn ra...
code_fim
hard
{ "lang": "rust", "repo": "CircArgs/rust-exercism", "path": "/poker/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CircArgs/rust-exercism path: /poker/src/lib.rs use counter::Counter; use lazy_static::lazy_static; use std::char; use std::cmp::Ordering; use std::collections::{HashMap, HashSet}; #[derive(Debug, Hash, PartialEq, Eq, Copy, Clone)] enum Suit { S, C, D, H, } impl PartialOrd for S...
code_fim
hard
{ "lang": "rust", "repo": "CircArgs/rust-exercism", "path": "/poker/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>_type() && lhs.len() == rhs.len() && lhs.iter().eq(rhs.iter()) }<|fim_prefix|>// repo: ghuls/arrow2 path: /src/array/equal/dictionary.rs use crate::array::{Array, DictionaryArray, DictionaryKey}; pub<|fim_middle|>(super) fn equal<K: DictionaryKey>(lhs: &DictionaryArray<K>, rhs: &DictionaryArray<K>) -> b...
code_fim
medium
{ "lang": "rust", "repo": "ghuls/arrow2", "path": "/src/array/equal/dictionary.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ghuls/arrow2 path: /src/array/equal/dictionary.rs use crate::array::{Array, DictionaryArray, DictionaryKey}; pub<|fim_suffix|>: &DictionaryArray<K>) -> bool { lhs.data_type() == rhs.data_type() && lhs.len() == rhs.len() && lhs.iter().eq(rhs.iter()) }<|fim_middle|>(super) fn equal<K: Diction...
code_fim
medium
{ "lang": "rust", "repo": "ghuls/arrow2", "path": "/src/array/equal/dictionary.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlexeyErzyamkin/bot-runner path: /rust_src/planetary-backend/src/storage.rs use { crate::Result, tokio, tokio_postgres::{self, Client, NoTls}, }; <|fim_suffix|>pub async fn init(config: &str) -> Result<Storage> { let (client, connection) = tokio_postgres::connect(config, NoTls)....
code_fim
easy
{ "lang": "rust", "repo": "AlexeyErzyamkin/bot-runner", "path": "/rust_src/planetary-backend/src/storage.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> tokio::spawn(async move { if let Err(e) = connection.await { eprintln!("PostgreSQL connection failed: {}", e); } }); Ok(Storage { client }) }<|fim_prefix|>// repo: AlexeyErzyamkin/bot-runner path: /rust_src/planetary-backend/src/storage.rs use { crate::Result,...
code_fim
medium
{ "lang": "rust", "repo": "AlexeyErzyamkin/bot-runner", "path": "/rust_src/planetary-backend/src/storage.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn extract_shared_cache(library_path: PathBuf, input_path: CString, output_path: CString) { let progress_block = ConcreteBlock::new(|x, y| println!("extracted {}/{}", x, y)); unsafe { let library = Library::new(library_path).unwrap(); let func: Symbol< unsafe extern "C"...
code_fim
hard
{ "lang": "rust", "repo": "Andrea-MariaDB-2/dyld-shared-cache-extractor", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Andrea-MariaDB-2/dyld-shared-cache-extractor path: /src/main.rs use block::{Block, ConcreteBlock}; use clap::{AppSettings, Clap}; use libloading::{Library, Symbol}; use std::ffi::CString; use std::os::raw::c_char; use std::path::PathBuf; const VERSION: &str = env!("CARGO_PKG_VERSION"); const AU...
code_fim
hard
{ "lang": "rust", "repo": "Andrea-MariaDB-2/dyld-shared-cache-extractor", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ANEP-Research/simple-genetic-code path: /src/main.rs use std::collections::HashMap; use std::fs::File; use std::io::{self, prelude::*, BufReader, BufWriter, Write}; use contest_algorithms::scanner::UnsafeScanner; // Implementation finite deterministic automaton enum State { GetInput(usize),...
code_fim
hard
{ "lang": "rust", "repo": "ANEP-Research/simple-genetic-code", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn medial_parse(left: u8, right: u8) -> Option<u8> { if left == 21 && right == 14 { Some(9) } else if left == 21 && right == 17 { Some(10) } else if left == 21 && right == 26 { Some(11) } else if left == 23 && right == 18 { Some(14) } else if left == 23 ...
code_fim
hard
{ "lang": "rust", "repo": "ANEP-Research/simple-genetic-code", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn is_vec_of_maps(&self) -> bool { match self { serde_json::Value::Array(items) => { if items.iter().any(|item| match item { serde_json::Value::Object(inner) => { inner.iter().any(|(_, value)| !value.is_string()) ...
code_fim
hard
{ "lang": "rust", "repo": "Dzejkop/serde_converter", "path": "/src/convertible.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Dzejkop/serde_converter path: /src/convertible.rs use std::collections::{HashMap, HashSet}; use serde::Serialize; pub trait Convertible: Serialize { type T; fn as_seq(&self) -> &[Self::T]; fn is_vec_of_maps(&self) -> bool { false } fn try_into_records(&self) -> Opti...
code_fim
hard
{ "lang": "rust", "repo": "Dzejkop/serde_converter", "path": "/src/convertible.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn as_seq(&self) -> &[Self::T] { self.as_sequence().unwrap().as_slice() } } impl Convertible for Vec<Vec<String>> { type T = Vec<String>; fn as_seq(&self) -> &[Self::T] { self.as_slice() } } impl Convertible for Vec<HashMap<String, String>> { type T = Vec<String>...
code_fim
hard
{ "lang": "rust", "repo": "Dzejkop/serde_converter", "path": "/src/convertible.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alesharik/smbios-lib path: /src/structs/types/electrical_current_probe.rs use crate::{SMBiosStruct, UndefinedStruct}; use serde::{ser::SerializeStruct, Serialize, Serializer}; use core::{fmt, any}; #[cfg(feature = "no_std")] use alloc::string::String; /// # Electrical Current Probe (Type 29) //...
code_fim
hard
{ "lang": "rust", "repo": "alesharik/smbios-lib", "path": "/src/structs/types/electrical_current_probe.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match raw { 0x8000 => CurrentProbeResolution::Unknown, _ => CurrentProbeResolution::TenthsOfMilliamps(raw), } } } /// # Current Probe Accuracy #[derive(Serialize, Debug)] pub enum CurrentProbeAccuracy { /// Accuracy for the probe's reading in 1/100th of a p...
code_fim
hard
{ "lang": "rust", "repo": "alesharik/smbios-lib", "path": "/src/structs/types/electrical_current_probe.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Default for AddonManagementOptions { fn default() -> Self { Self { restart_on_failure: true, low_mem_priority: 0, failed_health_checks_before_restart: 3, } } } //TODO pub struct AddonInstanceWithStatus { instance_id: String, status:...
code_fim
hard
{ "lang": "rust", "repo": "dbyone/core", "path": "/ohx-core/src/addons/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dbyone/core path: /ohx-core/src/addons/mod.rs mod docker_cli; mod addon_registry; mod management_backend; use semver::Version; use tokio::io::AsyncBufRead; use futures_core::future::BoxFuture; use futures_core::stream::BoxStream; #[derive(Clone)] pub struct AddonInstanceReference<'a> { add...
code_fim
hard
{ "lang": "rust", "repo": "dbyone/core", "path": "/ohx-core/src/addons/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Hash, Eq, PartialEq, Debug, Serialize, Deserialize)] #[allow(non_camel_case_types)] pub enum VoucherType { DISCOUNT_VOUCHER, GIFT_VOUCHER, } #[derive(Hash, Eq, PartialEq, Debug, Serialize, Deserialize)] pub struct Publish { count: u32, entries: Option<Vec<PublishEntry>>, } #[der...
code_fim
hard
{ "lang": "rust", "repo": "voucherifyio/voucherify-rust-sdk", "path": "/src/voucher/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: voucherifyio/voucherify-rust-sdk path: /src/voucher/mod.rs pub mod create; pub mod get; pub mod update; pub mod delete; pub mod list; pub mod enable; pub mod disable; use std::collections::BTreeMap; use serde_json::Value; #[derive(Default, PartialEq, Debug, Serialize, Deserialize)] pub struct ...
code_fim
hard
{ "lang": "rust", "repo": "voucherifyio/voucherify-rust-sdk", "path": "/src/voucher/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Hash, Eq, PartialEq, Debug, Serialize, Deserialize)] pub struct Gift { amount: usize, balance: usize, } impl Gift { pub fn new(amount: usize, balance: usize) -> Gift { Gift { amount: amount, balance: balance, } } } #[derive(Hash, Eq, Parti...
code_fim
hard
{ "lang": "rust", "repo": "voucherifyio/voucherify-rust-sdk", "path": "/src/voucher/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match ZeusProject::open(PathBuf::from(path)) { Ok(p) => String::from(format!("Opened: {}", p.game_name())), Err(e) => String::from(format!("Error: {}", e)) } } fn check_result(result: winapi::HRESULT) { if result < 0 { return panic!("Error in winapi call: {:x}", result...
code_fim
hard
{ "lang": "rust", "repo": "athena-org/zeus", "path": "/zeusgui/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: athena-org/zeus path: /zeusgui/src/main.rs // Copyright 2015 The Athena Developers. // // 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...
code_fim
hard
{ "lang": "rust", "repo": "athena-org/zeus", "path": "/zeusgui/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ilammy/cartouche path: /src/cacao/text_view.rs use cocoa::{ base::{id, BOOL}, foundation::NSRect, }; use objc::{class, msg_send, sel, sel_impl}; pub trait NSTextView: Sized { unsafe fn alloc(_: Self) -> id { msg_send![class!(NSTextView), alloc] } <|fim_suffix|> unsaf...
code_fim
hard
{ "lang": "rust", "repo": "ilammy/cartouche", "path": "/src/cacao/text_view.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe fn textContainer_(self) -> id { msg_send![self, textContainer] } }<|fim_prefix|>// repo: ilammy/cartouche path: /src/cacao/text_view.rs use cocoa::{ base::{id, BOOL}, foundation::NSRect, }; use objc::{class, msg_send, sel, sel_impl}; pub trait NSTextView: Sized { unsaf...
code_fim
medium
{ "lang": "rust", "repo": "ilammy/cartouche", "path": "/src/cacao/text_view.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe fn setEditable_(self, editable: BOOL); unsafe fn textContainer_(self) -> id; } impl NSTextView for id { unsafe fn setEditable_(self, editable: BOOL) { msg_send![self, setEditable: editable] } unsafe fn textContainer_(self) -> id { msg_send![self, textContainer]...
code_fim
medium
{ "lang": "rust", "repo": "ilammy/cartouche", "path": "/src/cacao/text_view.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mrlhumphreys/salieri path: /src/backgammon/state/game_state.rs _by_player(self.current_player_number)); let point = match self.current_player_number { 2 => { players_points.max_by(|a,b| { match (a.number).partial_cmp(&b.number) { ...
code_fim
hard
{ "lang": "rust", "repo": "mrlhumphreys/salieri", "path": "/src/backgammon/state/game_state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let steps = game_state.possible_steps(); assert_eq!(steps.len(), 1); match steps.first() { Some(s) => { assert_eq!(s.from.kind, PointKind::Bar); assert_eq!(s.from.number, None); assert_eq!(s.to.kind, PointKind::Point); ...
code_fim
hard
{ "lang": "rust", "repo": "mrlhumphreys/salieri", "path": "/src/backgammon/state/game_state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let from_a = Location { kind: PointKind::Point, number: Some(1) }; let to_a = Location { kind: PointKind::Point, number: Some(2) }; let die_number_a = 1; let move_step_a = MoveStep { from: from_a, to: to_a, die_number: die_number_a, hit: false }; let from_b = Locat...
code_fim
hard
{ "lang": "rust", "repo": "mrlhumphreys/salieri", "path": "/src/backgammon/state/game_state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Planet for Earth { fn orbital_duration() -> Duration { Duration::from(31_557_600) } } impl Planet for Mars { fn orbital_duration() -> Duration { Duration::from(59354032.69008) } } impl Planet for Jupiter { fn orbital_duration() -> Duration { Duration::fro...
code_fim
hard
{ "lang": "rust", "repo": "exercism/rust", "path": "/exercises/practice/space-age/.meta/example.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: exercism/rust path: /exercises/practice/space-age/.meta/example.rs pub struct Duration { seconds: f64, } impl From<u64> for Duration { fn from(s: u64) -> Self { Duration { seconds: s as f64 } } } impl From<f64> for Duration { fn from(s: f64) -> Self { <|fim_suffix|> ...
code_fim
hard
{ "lang": "rust", "repo": "exercism/rust", "path": "/exercises/practice/space-age/.meta/example.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[doc = "Bits 0:15 - RX RCR register"] #[inline(always)] pub fn rcrc(&self) -> RCRC_R { RCRC_R::new((self.bits & 0xffff) as u16) } }<|fim_prefix|>// repo: featherfly/gd32-pac path: /gd32e23x-pac/src/gd32e230/spi1/rcrc.rs #[doc = "Reader of register RCRC"] pub type R = crate::R<u3...
code_fim
medium
{ "lang": "rust", "repo": "featherfly/gd32-pac", "path": "/gd32e23x-pac/src/gd32e230/spi1/rcrc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: featherfly/gd32-pac path: /gd32e23x-pac/src/gd32e230/spi1/rcrc.rs #[doc = "Reader of register RCRC"] pub type R = crate::R<u32, super::RCRC>; #[doc = "Reader of field `RCRC`"] pub type RCRC_R = crate::R<u16, u16>; impl R {<|fim_suffix|>crc(&self) -> RCRC_R { RCRC_R::new((self.bits & 0xff...
code_fim
medium
{ "lang": "rust", "repo": "featherfly/gd32-pac", "path": "/gd32e23x-pac/src/gd32e230/spi1/rcrc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> "Keystore file serialize error" } fn cause(&self) -> Option<&error::Error> { match *self { _ => None, } } }<|fim_prefix|>// repo: kimisan/emerald-rs path: /src/keystore/serialize/error.rs //! # Serialize keystore files (UTC / JSON) errors use std::{error,...
code_fim
hard
{ "lang": "rust", "repo": "kimisan/emerald-rs", "path": "/src/keystore/serialize/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kimisan/emerald-rs path: /src/keystore/serialize/error.rs //! # Serialize keystore files (UTC / JSON) errors use std::{error, fmt}; /// Keystore file serialize errors #[derive(Debug)] pub enum SerializeError { /// An unsupported version UnsupportedVersion(u8), } <|fim_suffix|> ...
code_fim
medium
{ "lang": "rust", "repo": "kimisan/emerald-rs", "path": "/src/keystore/serialize/error.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match *self { SerializeError::UnsupportedVersion(ver) => { write!(f, "Unsupported keystore file version: {}", ver) } } } } impl error::Error for SerializeError { fn description(&self) -> &str { "Keystore file serialize error" } ...
code_fim
medium
{ "lang": "rust", "repo": "kimisan/emerald-rs", "path": "/src/keystore/serialize/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<T> Drop for Bag<T> { fn drop(&mut self) { for index in 0..self.len { unsafe { self.garbage[index].as_mut_ptr().drop_in_place(); } } } } impl<T> Bag<T> { fn push(&mut self, item: T) { debug_assert!(self.len < GARBAGE_SLOTS_PE...
code_fim
hard
{ "lang": "rust", "repo": "spacejam/rsdb", "path": "/src/ebr.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // new garbage accumulates here first current_garbage_bag: Bag<T>, // receives garbage from terminated threads maintenance_lock: Arc<Mutex<Receiver<Bag<T>>>>, // send outstanding garbage here when this Ebr drops orphan_sender: Sender<Bag<T>>, // count of pin attempts from th...
code_fim
hard
{ "lang": "rust", "repo": "spacejam/rsdb", "path": "/src/ebr.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spacejam/rsdb path: /src/ebr.rs //! Simple, CPU cache-friendly epoch-based reclamation (EBR). //! //! ```rust //! use rsdb::ebr::Ebr; //! //! let mut ebr: Ebr<Box<u64>> = Ebr::default(); //! //! let mut guard = ebr.pin(); //! //! guard.defer_drop(Box::new(1)); //! ``` use std::{ collections...
code_fim
hard
{ "lang": "rust", "repo": "spacejam/rsdb", "path": "/src/ebr.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fhnw-rust-group/begin-rust-book-examples-dgruntz path: /11/src/assignments.rs #![allow(unused_variables)] #![allow(dead_code)] pub fn maximum(numbers: &[u32]) -> u32 { let mut max: u32 = 0; let mut i = 0; while i < numbers.len() { let elem = numbers[i]; max = if elem...
code_fim
hard
{ "lang": "rust", "repo": "fhnw-rust-group/begin-rust-book-examples-dgruntz", "path": "/11/src/assignments.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(maximum(&[1, 2, 3]), 3); assert_eq!(maximum(&[1, 8, 3]), 8); assert_eq!(maximum(&[1, 1, 1]), 1); assert_eq!(maximum(&[]), 0); let numbers = &[4, 5, 2, 8]; assert_eq!(reverse(numbers), &[8, 2, 5, 4]); assert_eq!(fibs(5), &[1, 1, 2, 3, 5]); assert_eq!(fibs(1), &[...
code_fim
hard
{ "lang": "rust", "repo": "fhnw-rust-group/begin-rust-book-examples-dgruntz", "path": "/11/src/assignments.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.dispstat.vblank_flag = true; self.dispstat.hblank_flag = false; if self.dispstat.vblank_irq_enable { interrupt::signal_irq(&self.interrupt_flags, Interrupt::LCD_VBlank); }; dma_notifier.notify(TIMING_VBLANK); se...
code_fim
hard
{ "lang": "rust", "repo": "michelhe/rustboyadvance-ng", "path": "/core/src/gpu/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: michelhe/rustboyadvance-ng path: /core/src/gpu/mod.rs use std::fmt; #[allow(unused)] pub mod consts { pub use super::VRAM_ADDR; pub const VIDEO_RAM_SIZE: usize = 128 * 1024; pub const PALETTE_RAM_SIZE: usize = 1024; pub const OAM_SIZE: usize = 1024; pub const DISPLAY_WIDTH:...
code_fim
hard
{ "lang": "rust", "repo": "michelhe/rustboyadvance-ng", "path": "/core/src/gpu/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: michelhe/rustboyadvance-ng path: /core/src/gpu/mod.rs usize = 280896; pub const TILE_SIZE: u32 = 0x20; pub(super) const VRAM_OBJ_TILES_START_TEXT: u32 = 0x1_0000; pub(super) const VRAM_OBJ_TILES_START_BITMAP: u32 = 0x1_4000; } pub use self::consts::*; #[derive(Debug, Primitive, C...
code_fim
hard
{ "lang": "rust", "repo": "michelhe/rustboyadvance-ng", "path": "/core/src/gpu/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Veetaha/db-labs path: /term3_1/lab2/src/controllers/news_ratings_controller.rs use anyhow::Context; use crate::{ models::{ services::NewsRatingService, traits::* }, views, cli }; pub struct NewsRatingController { ratings: NewsRatingService } <|fim_suffix|> ...
code_fim
medium
{ "lang": "rust", "repo": "Veetaha/db-labs", "path": "/term3_1/lab2/src/controllers/news_ratings_controller.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match &rating { Ok(rating) => views::display_new_news_rating(rating), Err(err) => views::display_err(err) } } }<|fim_prefix|>// repo: Veetaha/db-labs path: /term3_1/lab2/src/controllers/news_ratings_controller.rs use anyhow::Context; use crate::{ models::...
code_fim
hard
{ "lang": "rust", "repo": "Veetaha/db-labs", "path": "/term3_1/lab2/src/controllers/news_ratings_controller.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: noahmancino/Rust_Y86-64-simulator path: /src/instructions.rs use crate::state::*; pub fn extract_byte(byte: i8, val: i64) -> u8 { let mask = 0xff; let extracted = (val >> (8 * byte)) & mask; extracted as u8 } pub fn combine_bytes(sys_state: &State) -> i64 { let mut combined = 0...
code_fim
hard
{ "lang": "rust", "repo": "noahmancino/Rust_Y86-64-simulator", "path": "/src/instructions.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> sys_state } pub fn pushq(mut sys_state: State, src: u8) -> State { sys_state.registers[4] -= 8; // register 4 is %rsp let address = sys_state.registers[4] as usize; let mut write: u8; for x in 0..8 { write = extract_byte(7 - x, sys_state.registers[src as usize]); p...
code_fim
hard
{ "lang": "rust", "repo": "noahmancino/Rust_Y86-64-simulator", "path": "/src/instructions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlbanMinassian/iso639 path: /iso639-1/src/lib.rs ahasa Melayu, بهاس ملايو‎) Ms, /// 639-2: mlt, name: Maltese (Malti) Mt, /// 639-2: mya, name: Burmese (ဗမာစာ) My, /// 639-2: nau, name: Nauruan (Dorerin Naoero) Na, /// 639-2: nob, name: Norwegian Bokmål (Norsk bok...
code_fim
hard
{ "lang": "rust", "repo": "AlbanMinassian/iso639", "path": "/iso639-1/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Attempts to find a language for an ISO639v1 language code. /// /// # Examples /// ```rust /// use iso639_1::Iso639_1; /// use std::convert::TryFrom; /// /// fn main() { /// let lang = Iso639_1::try_from("fr").unwrap(); /// assert_eq!(lang, Iso639_1::Fr);...
code_fim
hard
{ "lang": "rust", "repo": "AlbanMinassian/iso639", "path": "/iso639-1/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlbanMinassian/iso639 path: /iso639-1/src/lib.rs (कश्मीरी, كشميري‎) Ks, /// 639-2: kur, name: Kurdish (Kurdî, كوردی‎) Ku, /// 639-2: kom, name: Komi (коми кыв) Kv, /// 639-2: cor, name: Cornish (Kernewek) Kw, /// 639-2: kir, name: Kyrgyz (Кыргызча, Кыргыз тили) ...
code_fim
hard
{ "lang": "rust", "repo": "AlbanMinassian/iso639", "path": "/iso639-1/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: michaelsproul/rust_radix_trie path: /src/iter.rs //! Iterators over key-value pairs, keys, values and child subtries. use std::iter::{FilterMap, FromIterator, Map}; use std::slice; use crate::TrieNode; use crate::{SubTrie, Trie, TrieKey}; use nibble_vec::Nibblet; // MY EYES. type Child<K, V>...
code_fim
hard
{ "lang": "rust", "repo": "michaelsproul/rust_radix_trie", "path": "/src/iter.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> v } Values { inner: iter.map(second), } } } impl<'a, K, V> Iterator for Values<'a, K, V> { type Item = &'a V; fn next(&mut self) -> Option<&'a V> { self.inner.next() } } /// Iterator over the child subtries of a trie. pub struct Ch...
code_fim
hard
{ "lang": "rust", "repo": "michaelsproul/rust_radix_trie", "path": "/src/iter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Convert the low level result of getting a key from the ledger into a /// higher level Rust representation. pub fn value_result(res: (Status, Option<Vmo>)) -> Result<Option<Vec<u8>>, ValueError> { match res { (OK, Some(vmo)) => { let buffer = read_entire_vmo(&vmo).map_err(ValueE...
code_fim
hard
{ "lang": "rust", "repo": "xi-editor/xi-editor", "path": "/rust/core-lib/src/fuchsia/ledger.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xi-editor/xi-editor path: /rust/core-lib/src/fuchsia/ledger.rs // Copyright 2017 The xi-editor Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // h...
code_fim
hard
{ "lang": "rust", "repo": "xi-editor/xi-editor", "path": "/rust/core-lib/src/fuchsia/ledger.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn output(bitstrings: &OutputT, filename: &str) { let mut file = File::create(filename).expect("Output file failed to open"); for bs in bitstrings { write!(file, "{}\n", bs).expect("Failed to write"); } } pub fn run(infile: &str, outfile: &str) { println!("==== {} ====", file!());...
code_fim
hard
{ "lang": "rust", "repo": "franklsf95/rustcuts", "path": "/src/tasks/binarize.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: franklsf95/rustcuts path: /src/tasks/binarize.rs // Task Description: // // Input: A rule file produced by classbench. // Output: A binary matrix where a row represents the bit-string of a rule. use csv::{ReaderBuilder, StringRecord}; use rayon::prelude::*; use std::fs::File; use std::io::{BufR...
code_fim
hard
{ "lang": "rust", "repo": "franklsf95/rustcuts", "path": "/src/tasks/binarize.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> input.par_iter().map(row_to_bitstring).collect() } fn output(bitstrings: &OutputT, filename: &str) { let mut file = File::create(filename).expect("Output file failed to open"); for bs in bitstrings { write!(file, "{}\n", bs).expect("Failed to write"); } } pub fn run(infile: &str,...
code_fim
hard
{ "lang": "rust", "repo": "franklsf95/rustcuts", "path": "/src/tasks/binarize.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jh3ady/yaml_file_handler path: /src/lib.rs extern crate yaml_rust; pub use yaml_rust::*; pub mod yaml_handler; use yaml_handler::FileHandler; #[test] fn it_works() { let mut handler = FileHandler::new(); handler.add_files(vec![ "parameters.yml", "routing.yml" ]); ...
code_fim
medium
{ "lang": "rust", "repo": "jh3ady/yaml_file_handler", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let config = match handler.read_all_files() { Some(data) => data, None => return, }; println!("config['parameters']['server']['hostname'] = {}", config["parameters"]["server"]["hostname"].as_str().unwrap()); }<|fim_prefix|>// repo: jh3ady/yaml_file_handler path: /src/lib.rs e...
code_fim
medium
{ "lang": "rust", "repo": "jh3ady/yaml_file_handler", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // scoreboard initialization let texture_creator = canvas.texture_creator(); let score = Rect::from_center(Point::new(400, 30), 100, 40); let path: &Path = Path::new("../droid.ttf"); let ttf_context = sdl2::ttf::init().map_err(|e| e.to_string()).unwrap(); le...
code_fim
hard
{ "lang": "rust", "repo": "kencruz/rust_pong", "path": "/src/game.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kencruz/rust_pong path: /src/game.rs use crate::ball::Ball; use crate::paddle::{Paddle, Position}; use sdl2::event::Event; use sdl2::keyboard::Keycode; use sdl2::pixels::Color; use sdl2::rect::{Point, Rect}; use std::collections::HashSet; use std::path::Path; use std::time::Duration; pub struct...
code_fim
hard
{ "lang": "rust", "repo": "kencruz/rust_pong", "path": "/src/game.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mitrid-labs/bezier path: /src/io/network/message/message/block.rs use mitrid_core::base::Result; use mitrid_core::io::{Method, Resource}; use io::network::message::message::message::*; pub struct BlockMessage; impl BlockMessage { pub fn verify_lookup(msg: &Message) -> Result<bool> { ...
code_fim
hard
{ "lang": "rust", "repo": "mitrid-labs/bezier", "path": "/src/io/network/message/message/block.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn check_create(msg: &Message) -> Result<()> { check_write_msg(msg, &Method::Create, &Resource::Block) } }<|fim_prefix|>// repo: mitrid-labs/bezier path: /src/io/network/message/message/block.rs use mitrid_core::base::Result; use mitrid_core::io::{Method, Resource}; use io::network::...
code_fim
hard
{ "lang": "rust", "repo": "mitrid-labs/bezier", "path": "/src/io/network/message/message/block.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let fid = Fid::from("1010_1010"); for (i, bit) in fid.iter().enumerate() { assert_eq!(bit, fid[i as u64]); } } } #[cfg(test)] mod iter_failure_tests { // Nothing to test }<|fim_prefix|>// repo: laysakura/fid-rs path: /src/fid/fid_iter.rs use super::{Fid, FidIt...
code_fim
hard
{ "lang": "rust", "repo": "laysakura/fid-rs", "path": "/src/fid/fid_iter.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: laysakura/fid-rs path: /src/fid/fid_iter.rs use super::{Fid, FidIter}; impl<'iter> Fid { /// Creates an iterator over FID's bit vector. /// /// # Examples /// ``` /// use fid_rs::Fid; /// /// let fid = Fid::from("1010_1010"); /// for (i, bit) in fid.iter().enumer...
code_fim
hard
{ "lang": "rust", "repo": "laysakura/fid-rs", "path": "/src/fid/fid_iter.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> async fn get_index_meta(&self, uuid: Uuid) -> Result<IndexMeta> { let (ret, receiver) = oneshot::channel(); let msg = IndexMsg::GetMeta { uuid, ret }; let _ = self.read_sender.send(msg).await; Ok(receiver.await.expect("IndexActor has been killed")?) } async fn ...
code_fim
hard
{ "lang": "rust", "repo": "shekhirin/transplant", "path": "/meilisearch-http/src/index_controller/index_actor/handle_impl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shekhirin/transplant path: /meilisearch-http/src/index_controller/index_actor/handle_impl.rs use std::path::{Path, PathBuf}; use tokio::sync::{mpsc, oneshot}; use uuid::Uuid; use crate::index::{Document, SearchQuery, SearchResult, Settings}; use crate::index_controller::{updates::Processing, U...
code_fim
hard
{ "lang": "rust", "repo": "shekhirin/transplant", "path": "/meilisearch-http/src/index_controller/index_actor/handle_impl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: june8036/muta-tutorial-dex path: /services/dex/src/lib.rs lue: order.amount, }; call_and_parse_service_response!(self, lock_asset, lock_asset_payload); self.sell_orders.insert( ctx.get_tx_hash().expect("tx hash should exist"),...
code_fim
hard
{ "lang": "rust", "repo": "june8036/muta-tutorial-dex", "path": "/services/dex/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let sub_buyer = ModifyAssetPayload { asset_id: trade.base_asset.clone(), user: current_buy.user.clone(), value: deal_amount * deal_price, }; call_and_parse_service_response!(self, sub_value, sub_buyer); let unlock_seller = ModifyAssetPa...
code_fim
hard
{ "lang": "rust", "repo": "june8036/muta-tutorial-dex", "path": "/services/dex/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let unlock_buyer = ModifyAssetPayload { asset_id: trade.base_asset.clone(), user: current_buy.user.clone(), value: deal_amount * current_buy.price, }; call_and_parse_service_response!(self, unlock_asset, unlock_buyer); let add_buyer = M...
code_fim
hard
{ "lang": "rust", "repo": "june8036/muta-tutorial-dex", "path": "/services/dex/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let args: Vec<String> = env::args().collect(); let program = &args[0]; let mut opts = Options::new(); opts.optflag("h", "help", "Show this usage message."); opts.optopt("p", "listen-port", "Port to listen on.", "PORT"); opts.optopt("l", "listen-address", "Address to listen on.", "A...
code_fim
hard
{ "lang": "rust", "repo": "bmellstrom/ocs-server-dummy", "path": "/src/main.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bmellstrom/ocs-server-dummy path: /src/main.rs extern crate getopts; extern crate byteorder; #[macro_use] extern crate bitflags; mod diameter; mod gy; use getopts::{Options, Matches}; use std::process; use std::env; use std::sync::Arc; use std::io::{Write, Read}; use std::net::{TcpListener, Tc...
code_fim
hard
{ "lang": "rust", "repo": "bmellstrom/ocs-server-dummy", "path": "/src/main.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> let mut v=vec![1,3,2,9,12,5,4,7]; bubble_sort(&mut v); println!("v :{:?}",v); }<|fim_prefix|>// repo: sanmubai/rust-practice path: /tmp/bubble_sort.rs fn bubble_sort(v:&mut Vec<i32>){ let mut n=v.len(); while n>0{ let (mut i,mut ptr_max)=(1,0); while i<n{ if...
code_fim
easy
{ "lang": "rust", "repo": "sanmubai/rust-practice", "path": "/tmp/bubble_sort.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }