text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> -> Result<(devices::Bus, Arc<Mutex<devices::Serial>>)>; /// Configures the vcpu and should be called once per vcpu from the vcpu's thread. /// /// # Arguments /// /// * `guest_mem` - The memory to be used by the guest. /// * `kernel_load_offset` - Offset in byt...
code_fim
hard
{ "lang": "rust", "repo": "Catramen/crosvm", "path": "/arch/src/lib.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> /// This creates and returns a device_manager object for this vm. /// /// # Arguments /// /// * `vm` - the vm object /// * `mem` - A copy of the GuestMemory object for this VM. fn get_device_manager(vm: &mut Vm, mem: GuestMemory) -> Result<device_mana...
code_fim
hard
{ "lang": "rust", "repo": "Catramen/crosvm", "path": "/arch/src/lib.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Catramen/crosvm path: /arch/src/lib.rs // Copyright 2018 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. extern crate sys_util; extern crate kernel_cmdline; extern crate kvm; extern crate libc;...
code_fim
hard
{ "lang": "rust", "repo": "Catramen/crosvm", "path": "/arch/src/lib.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shohei909/Lisla path: /impl/rust/lisla_lang/src/template/mod.rs pub mod error; use self::error::*; use tag::*; use tree::*; use ::error::*; use leaf::*; //#[derive(StringNewtype)] #[derive(Debug, Clone, Eq, PartialEq)] pub struct Placeholder { pub key: String, } #[derive(Debug...
code_fim
hard
{ "lang": "rust", "repo": "shohei909/Lisla", "path": "/impl/rust/lisla_lang/src/template/mod.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> ArrayTree::Leaf(current) => { // プレースホルダーを閉じる let string = match current.complete(&template.tag) { Result::Ok(ok) => ok, Result::Err(error) => { // 復帰方法プレースホルダーをそのまま...
code_fim
hard
{ "lang": "rust", "repo": "shohei909/Lisla", "path": "/impl/rust/lisla_lang/src/template/mod.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>impl TemplateProcessor { pub fn new(config: TemplateConfig) -> TemplateProcessor { TemplateProcessor { config } } pub fn array_complete( &self, template: WithTag<ArrayBranch<WithTag<ArrayTree<TemplateLeaf>>>>, errors:&mut ErrorWrite<PlaceholderComplete...
code_fim
hard
{ "lang": "rust", "repo": "shohei909/Lisla", "path": "/impl/rust/lisla_lang/src/template/mod.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> self.rerender } fn relayout(&self) -> bool { self.relayout } }<|fim_prefix|>// repo: FerionVE/guion_sdl2 path: /src/simple/valid.rs use super::*; use guion::env::ValidState; pub struct SimpleValidState { pub rerender: bool, pub relayout: bool, } //TODO move as Standar...
code_fim
medium
{ "lang": "rust", "repo": "FerionVE/guion_sdl2", "path": "/src/simple/valid.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FerionVE/guion_sdl2 path: /src/simple/valid.rs use super::*; use guion::env::ValidState; pub struct SimpleValidState { pub rerender: bool, pub relayout: bool, } //TODO move as StandardValidState to guion impl ValidState for SimpleValidState { fn valid() -> Self { <|fim_suffix|> ...
code_fim
medium
{ "lang": "rust", "repo": "FerionVE/guion_sdl2", "path": "/src/simple/valid.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> BoundingRect::from_corners(&self.from, &self.to) } fn distance2(&self, point: &V) -> V::Scalar { let nn = self.nearest_point(point); point.sub(&nn).length2() } } /// A triangle, defined by it's three points. #[derive(Clone)] #[cfg_attr(feature = "serde_serialize", der...
code_fim
hard
{ "lang": "rust", "repo": "varkor/spade", "path": "/src/primitives.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: varkor/spade path: /src/primitives.rs /! are important. If additional data needs to be stored per object, consider //! implementing `SpatialObject`. use cgmath::{Point3, Zero, One}; use traits::{SpadeFloat, SpadeNum, SpatialObject}; use point_traits::{PointN, PointNExtensions, TwoDimensional};...
code_fim
hard
{ "lang": "rust", "repo": "varkor/spade", "path": "/src/primitives.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: varkor/spade path: /src/primitives.rs /! //! Use these objects if only the geometrical properties (position and size) //! are important. If additional data needs to be stored per object, consider //! implementing `SpatialObject`. use cgmath::{Point3, Zero, One}; use traits::{SpadeFloat, SpadeN...
code_fim
hard
{ "lang": "rust", "repo": "varkor/spade", "path": "/src/primitives.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> assert!(super::validate(&mut default_strings, &mut foreign_strings).is_ok()) } #[test] fn validate_errors_in_presence_of_missing_strings() { let mut default_strings = vec![ AndroidString::localizable("s3", "d3"), AndroidString::localizable("s2", "d2"), ...
code_fim
hard
{ "lang": "rust", "repo": "jayrave/android_localization", "path": "/core/src/validate/missing_strings.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jayrave/android_localization path: /core/src/validate/missing_strings.rs use crate::android_string::AndroidString; use crate::ops::sort; use crate::util::two_pointer_traversal; pub fn validate( default_strings: &mut [AndroidString], foreign_strings: &mut [AndroidString], ) -> Result<(),...
code_fim
hard
{ "lang": "rust", "repo": "jayrave/android_localization", "path": "/core/src/validate/missing_strings.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut default_strings = vec![ AndroidString::localizable("s2", "d2"), AndroidString::localizable("s3", "d3"), ]; let mut foreign_strings = vec![ AndroidString::localizable("s2", "f2"), AndroidString::localizable("s3", "f3"), ...
code_fim
hard
{ "lang": "rust", "repo": "jayrave/android_localization", "path": "/core/src/validate/missing_strings.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drahnr/ockam path: /implementations/rust/ockam/ockam/src/entity/profile/verification.rs #[derive(Clone, Debug)] pub struct Ed25519ProfileVerificationMethod { public_key: Vec<u8>, } <|fim_suffix|>#[derive(Clone, Debug)] pub struct ProfileVerificationPolicy { verification_method: ProfileV...
code_fim
hard
{ "lang": "rust", "repo": "drahnr/ockam", "path": "/implementations/rust/ockam/ockam/src/entity/profile/verification.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone, Debug)] pub enum ProfileVerificationPurpose { // To present a ProfileChangeProof ProfileUpdate, } #[derive(Clone, Debug)] pub struct ProfileVerificationPolicy { verification_method: ProfileVerificationMethod, can_be_used_for: Vec<ProfileVerificationPurpose>, }<|fim_prefix|...
code_fim
medium
{ "lang": "rust", "repo": "drahnr/ockam", "path": "/implementations/rust/ockam/ockam/src/entity/profile/verification.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone, Debug)] pub struct ProfileVerificationPolicy { verification_method: ProfileVerificationMethod, can_be_used_for: Vec<ProfileVerificationPurpose>, }<|fim_prefix|>// repo: drahnr/ockam path: /implementations/rust/ockam/ockam/src/entity/profile/verification.rs #[derive(Clone, Debug)] ...
code_fim
hard
{ "lang": "rust", "repo": "drahnr/ockam", "path": "/implementations/rust/ockam/ockam/src/entity/profile/verification.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ErichDonGubler/ansion path: /src/escapes/formatting.rs use {crate::TerminalOutput, std::io}; #[derive(Clone, Debug)] pub enum SetGraphicsRenditionEscape { Reset, Bright, Underline, NoUnderline, Negative, Positive, ForegroundBlack, ForegroundRed, ForegroundGre...
code_fim
hard
{ "lang": "rust", "repo": "ErichDonGubler/ansion", "path": "/src/escapes/formatting.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use self::SetGraphicsRenditionEscape::*; let Style { underline, negative, } = self; TerminalOutput::fmt( &match underline { true => Underline, false => NoUnderline, }, f, )?;...
code_fim
hard
{ "lang": "rust", "repo": "ErichDonGubler/ansion", "path": "/src/escapes/formatting.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn step(&mut nes: NES) { nes.cpu.pc += 1; }<|fim_prefix|>// repo: justuswilhelm/make-a-nes path: /rust/src/nes.rs mod cpu; struct NES { cpu: cpu::CPU, memory: memory::Memory, } fn initialize_nes() -> NES { <|fim_middle|> return NES { cpu: cpu::initialize_cpu(), memory: mem...
code_fim
medium
{ "lang": "rust", "repo": "justuswilhelm/make-a-nes", "path": "/rust/src/nes.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: justuswilhelm/make-a-nes path: /rust/src/nes.rs mod cpu; struct NES { cpu: cpu::CPU, memory: memory::Memory, } <|fim_suffix|>fn step(&mut nes: NES) { nes.cpu.pc += 1; }<|fim_middle|>fn initialize_nes() -> NES { return NES { cpu: cpu::initialize_cpu(), memory: mem...
code_fim
medium
{ "lang": "rust", "repo": "justuswilhelm/make-a-nes", "path": "/rust/src/nes.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>UCHAR = 0x20 ; pub const RPN_PARAM_XOFF : UCHAR = 0x40 ; pub const RPN_PARAM_X_IN : UCHAR = 0x01 ; pub const RPN_PARAM_X_OUT : UCHAR = 0x02 ; pub const RPN_PARAM_RTR_IN : UCHAR = 0x04 ; pub const RPN_PARAM_RTR_OUT : UCHAR = 0x08 ; pub const RPN_PARAM_RTC_IN : UCHAR = 0x10 ; pub const RPN_PARAM_RTC_OUT : U...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/winapi/src/um/ws2bth.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/winapi/src/um/ws2bth.rs / / Licensed under the Apache License Version 2 . 0 / / < LICENSE - APACHE or http : / / www . apache . org / licenses / LICENSE - 2 . 0 > or the MIT license / / < LICENSE - MIT or http : / / opensource . org / licenses ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/winapi/src/um/ws2bth.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>UCHAR = BIT ! ( 6 ) ; pub const MSC_DV_BIT : UCHAR = BIT ! ( 7 ) ; pub const MSC_BREAK_BIT : UCHAR = BIT ! ( 1 ) ; macro_rules ! MSC_SET_BREAK_LENGTH { ( b : expr l : expr ) = > { ( b & 0x3 ) | ( ( l & 0xf ) < < 4 ) } ; } STRUCT ! { # [ repr ( packed ) ] struct RFCOMM_RLS_DATA { LineStatus : UCHAR } } pub...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/winapi/src/um/ws2bth.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hwchen/mondrian-schema-builder-rs path: /src/dimension.rs use elementtree::Element; use super::{Annotations, Annotation, Source}; #[derive(Debug, Clone, PartialEq)] pub struct Dimension { name: String, hierarchies: Vec<Hierarchy>, annotations: Annotations, } impl Dimension { p...
code_fim
hard
{ "lang": "rust", "repo": "hwchen/mondrian-schema-builder-rs", "path": "/src/dimension.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.annotations.build_xml(&mut hierarchy); if let Some(ref name) = self.name { hierarchy.set_attr("name", name.clone()); } if let Some(ref source) = self.source { source.build_xml(&mut hierarchy); } for level in &self.levels { ...
code_fim
hard
{ "lang": "rust", "repo": "hwchen/mondrian-schema-builder-rs", "path": "/src/dimension.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[tokio::main] pub async fn main() -> std::result::Result<(), Box<dyn std::error::Error + Send + Sync>> { tracing_subscriber::fmt::init(); consensus::run().await }<|fim_prefix|>// repo: HerrBertling/saito-rust path: /src/main.rs /*! # Saito Command Line Interface ## Help ```bash saito_rust help...
code_fim
medium
{ "lang": "rust", "repo": "HerrBertling/saito-rust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>use saito_rust::consensus; #[tokio::main] pub async fn main() -> std::result::Result<(), Box<dyn std::error::Error + Send + Sync>> { tracing_subscriber::fmt::init(); consensus::run().await }<|fim_prefix|>// repo: HerrBertling/saito-rust path: /src/main.rs /*! # Saito Command Line Interface ## H...
code_fim
hard
{ "lang": "rust", "repo": "HerrBertling/saito-rust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HerrBertling/saito-rust path: /src/main.rs /*! # Saito Command Line Interface ## Help ```bash saito_rust help ``` ## Example Usage <|fim_suffix|>#[tokio::main] pub async fn main() -> std::result::Result<(), Box<dyn std::error::Error + Send + Sync>> { tracing_subscriber::fmt::init(); ...
code_fim
hard
{ "lang": "rust", "repo": "HerrBertling/saito-rust", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Default for RuinAndRecreateMutation { fn default() -> Self { Self { recreate: Box::new(CompositeRecreate::default()), ruin: Box::new(CompositeRuin::default()) } } } impl RuinAndRecreateMutation { /// Creates a new instance of [`RuinAndRecreateMutation`]. pub fn new(recreate: ...
code_fim
hard
{ "lang": "rust", "repo": "andrewgy8/vrp", "path": "/vrp-core/src/solver/mutation/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andrewgy8/vrp path: /vrp-core/src/solver/mutation/mod.rs use crate::construction::heuristics::InsertionContext; use crate::solver::RefinementContext; mod recreate; pub use self::recreate::*; <|fim_suffix|>impl Mutation for RuinAndRecreateMutation { fn mutate(&self, refinement_ctx: &mut Ref...
code_fim
hard
{ "lang": "rust", "repo": "andrewgy8/vrp", "path": "/vrp-core/src/solver/mutation/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let z= unsafe {*raw2}; println!("y:{}",z); }<|fim_prefix|>// repo: rustbasic-arch/rust_smart_pointer path: /ptr_origin/src/main.rs fn main() { let mut x = 5; let raw = &mut x as *mut i32; <|fim_middle|> let points_at = unsafe { *raw =100; *raw}; println!("raw points at {}",...
code_fim
medium
{ "lang": "rust", "repo": "rustbasic-arch/rust_smart_pointer", "path": "/ptr_origin/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("raw points at {}", points_at); let y = 200; let raw2 = &y as *const i32; let z= unsafe {*raw2}; println!("y:{}",z); }<|fim_prefix|>// repo: rustbasic-arch/rust_smart_pointer path: /ptr_origin/src/main.rs fn main() { let mut x = 5; let raw = &mut x as *mut i32...
code_fim
easy
{ "lang": "rust", "repo": "rustbasic-arch/rust_smart_pointer", "path": "/ptr_origin/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rustbasic-arch/rust_smart_pointer path: /ptr_origin/src/main.rs fn main() { let mut x = 5; let raw = &mut x as *mut i32; <|fim_suffix|> println!("raw points at {}", points_at); let y = 200; let raw2 = &y as *const i32; let z= unsafe {*raw2}; println!("y:{}",z);...
code_fim
easy
{ "lang": "rust", "repo": "rustbasic-arch/rust_smart_pointer", "path": "/ptr_origin/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match self.ops.pop() { Some(b) => match b { Bounds::Cmp(op, expr, target) => { let inner_bound = self.cmp_bound_fn(); Box::new(move |ctx| { if op(expr.eval_with_context(ctx).unwrap(), target) { ...
code_fim
hard
{ "lang": "rust", "repo": "HarkonenBade/resistor-calc", "path": "/src/expr_builder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HarkonenBade/resistor-calc path: /src/expr_builder.rs extern crate meval; use std::{f64::EPSILON, str::FromStr}; use RSet; lazy_static!( static ref RNAMES: Vec<String> = (1..=100).map(|i| format!("R{}", i)).collect(); ); enum Bounds { Cmp(Box<Fn(f64, f64) -> bool>, meval::Expr, f64),...
code_fim
hard
{ "lang": "rust", "repo": "HarkonenBade/resistor-calc", "path": "/src/expr_builder.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Add a new bound to the builder, this must be an expression of the form `expr op target` /// where expr is a math expression using R1,...,Rn and [supported expressions](https://docs.rs/meval/#supported-expressions), /// op is one of <, >, <=, >=, ==, != or ~ and target is an [f64 value](htt...
code_fim
hard
{ "lang": "rust", "repo": "HarkonenBade/resistor-calc", "path": "/src/expr_builder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tock/tock path: /boards/components/src/ble.rs // Licensed under the Apache License, Version 2.0 or the MIT License. // SPDX-License-Identifier: Apache-2.0 OR MIT // Copyright Tock Contributors 2022. //! Component for creating a ble_advertising_driver. //! //! Usage //! ----- //! ```rust //! let...
code_fim
hard
{ "lang": "rust", "repo": "tock/tock", "path": "/boards/components/src/ble.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn finalize(self, s: Self::StaticInput) -> Self::Output { let grant_cap = create_capability!(capabilities::MemoryAllocationCapability); let ble_radio_virtual_alarm = s.0.write( capsules_core::virtualizers::virtual_alarm::VirtualMuxAlarm::new(self.mux_alarm), ); ...
code_fim
hard
{ "lang": "rust", "repo": "tock/tock", "path": "/boards/components/src/ble.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: crackdog/sqlib path: /src/escaping.rs //! escaping provides functions for the Server Query escaping. //! //! # Example //! ``` //! use sqlib::escaping::{escape, unescape}; //! //! let unescaped = "hello world/|\\".to_string(); //! let escaped = "hello\\sworld\\/\\p\\\\".to_string(); //! //! let ...
code_fim
hard
{ "lang": "rust", "repo": "crackdog/sqlib", "path": "/src/escaping.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// unescapes all chars described in the server query manual /// /// # Example /// ``` /// use sqlib::escaping::unescape; /// /// let unescaped = "hello world/|\\".to_string(); /// let escaped = "hello\\sworld\\/\\p\\\\".to_string(); /// /// let s = unescape(&escaped); /// /// assert_eq!(s, unescaped); //...
code_fim
hard
{ "lang": "rust", "repo": "crackdog/sqlib", "path": "/src/escaping.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// escapes all chars described in the server query manual /// /// # Example /// ``` /// use sqlib::escaping::escape; /// /// let unescaped = "hello world/|\\".to_string(); /// let escaped = "hello\\sworld\\/\\p\\\\".to_string(); /// /// let s = escape(&unescaped); /// /// assert_eq!(s, escaped); /// ``` ...
code_fim
hard
{ "lang": "rust", "repo": "crackdog/sqlib", "path": "/src/escaping.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn roll_strs(s: &[String]) -> Outcomes { validate_input(s).unwrap().run() } #[test] fn test_valid_roll() { assert_eq!( Roll::new("2d6").unwrap(), Roll { sides: 6, repeat: 2 } ) } #[test] #[should_panic] fn test_invalid_roll() { Roll::ne...
code_fim
hard
{ "lang": "rust", "repo": "deciduously/roll", "path": "/src/roll.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: deciduously/roll path: /src/roll.rs use actix_web::{Error, HttpRequest, HttpResponse, Responder}; use command::validate_input; use rand::{self, Rng}; use serde_json; use std::{fmt, io, str::FromStr}; #[derive(Debug, PartialEq, Serialize)] pub struct Roll { sides: u32, repeat: u32, } im...
code_fim
hard
{ "lang": "rust", "repo": "deciduously/roll", "path": "/src/roll.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> writeln!( f, "{}:\n{:?}\n{:?}", self.roll, self.rolls.iter().fold(0, |acc, x| x + acc), self.rolls ) } } #[derive(Serialize)] pub struct Outcomes { pub outcomes: Vec<Outcome>, } impl Responder for Outcomes { type Ite...
code_fim
hard
{ "lang": "rust", "repo": "deciduously/roll", "path": "/src/roll.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oabrivard/efp path: /rust/tip_calc/src/tip_calculator.rs #[derive(PartialEq, Debug)] pub struct PaymentDetails { pub tip: f64, pub total_amount: f64 } <|fim_suffix|> let result = calculate_payment_details(100.0,15.0); assert_eq!(result, PaymentDetails {tip: 15.0, total_am...
code_fim
hard
{ "lang": "rust", "repo": "oabrivard/efp", "path": "/rust/tip_calc/src/tip_calculator.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self.proc_id { RpcProcIdValue::Id(ref id) => { let val = (0xffff as u32) | ((*id as u16) as u32) << 16; dst.put_u32_le(val); } RpcProcIdValue::Name(ref _name) => { //let (left_bytes, _) = try!(write_varchar::...
code_fim
hard
{ "lang": "rust", "repo": "Niedzwiedzw/tiberius", "path": "/src/tds/codec/rpc_request.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Niedzwiedzw/tiberius path: /src/tds/codec/rpc_request.rs use super::{AllHeaderTy, Encode, ALL_HEADERS_LEN_TX}; use crate::{tds::codec::ColumnData, Result}; use bitflags::bitflags; use bytes::{BufMut, BytesMut}; use std::borrow::Cow; #[derive(Debug)] pub struct TokenRpcRequest<'a> { proc_id:...
code_fim
hard
{ "lang": "rust", "repo": "Niedzwiedzw/tiberius", "path": "/src/tds/codec/rpc_request.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chornsby/brainfuck path: /src/main.rs mod command; mod interpreter; mod program; use std::convert::TryFrom; <|fim_suffix|> let path = std::env::args().nth(1).expect("Missing filename"); let input = std::fs::read_to_string(path).expect("Missing input"); let program = Program::try_fro...
code_fim
medium
{ "lang": "rust", "repo": "chornsby/brainfuck", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let path = std::env::args().nth(1).expect("Missing filename"); let input = std::fs::read_to_string(path).expect("Missing input"); let program = Program::try_from(input.as_bytes()).expect("Malformed program"); Interpreter::new().run(&program); }<|fim_prefix|>// repo: chornsby/brainfuck pa...
code_fim
medium
{ "lang": "rust", "repo": "chornsby/brainfuck", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Expressions TUPLE_EXPR, PAREN_EXPR, CHAR_LIT_EXPR, INT_LIT_EXPR, FLOAT_LIT_EXPR, STRING_LIT_EXPR, TEMPLATE_EXPR, BLOCK_EXPR, IF_EXPR, IDENT_EXPR, BOOL_LIT_EXPR, THIS_EXPR, LAMBDA_EXPR, FOR_EXPR, WHILE_EXPR, MATCH_EXPR, BREAK_EXPR, ...
code_fim
hard
{ "lang": "rust", "repo": "dinfuehr/dora", "path": "/dora-parser/src/token.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dinfuehr/dora path: /dora-parser/src/token.rs use TokenKind::*; #[derive(Copy, Clone)] pub struct TokenSet(u128); impl TokenSet { pub const fn new(kinds: &[TokenKind]) -> TokenSet { let mut value = 0; let mut i = 0; while i < kinds.len() { value |= 1 <<...
code_fim
hard
{ "lang": "rust", "repo": "dinfuehr/dora", "path": "/dora-parser/src/token.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut map = serde_json::Map::new(); map.insert("key".to_string(), Value::String("value".to_string())); assert_eq!( Params::Array(vec![ Value::Null, Value::Bool(true), Value::from(-1), Value::from(4), ...
code_fim
hard
{ "lang": "rust", "repo": "liuchengxu/vim-clap", "path": "/crates/rpc/src/types.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: liuchengxu/vim-clap path: /crates/rpc/src/types.rs use serde::de::DeserializeOwned; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde_json::Value; #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] pub struct RpcRequest { pub ...
code_fim
hard
{ "lang": "rust", "repo": "liuchengxu/vim-clap", "path": "/crates/rpc/src/types.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eschulte/ctfp-book-club path: /exercises/markmeredith/chapter-1/src/lib.rs pub fn identity<T>(a: T) -> T { a } pub fn compose<A: 'static, B: 'static, C: 'static>( f: Box<dyn Fn(A) -> B>, g: Box<dyn Fn(B) -> C>, ) -> Box<dyn Fn(A) -> C> { Box::new(move |x| g(f(x))) } <|fim_suffi...
code_fim
hard
{ "lang": "rust", "repo": "eschulte/ctfp-book-club", "path": "/exercises/markmeredith/chapter-1/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn square(x: i32) -> i32 { x * x } for n in 0..1000 { assert_eq!( n, super::compose(Box::new(super::identity), Box::new(super::identity))(n) ); assert_eq!( square(n), sup...
code_fim
hard
{ "lang": "rust", "repo": "eschulte/ctfp-book-club", "path": "/exercises/markmeredith/chapter-1/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_identity_law() { fn square(x: i32) -> i32 { x * x } for n in 0..1000 { assert_eq!( n, super::compose(Box::new(super::identity), Box::new(super::identity))(n) ); assert_eq!( ...
code_fim
hard
{ "lang": "rust", "repo": "eschulte/ctfp-book-club", "path": "/exercises/markmeredith/chapter-1/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(linux_kernel)] pub mod epoll;<|fim_prefix|>// repo: giodamelio/little_boxes path: /vendor/rustix/src/backend/libc/event/mod.rs pub(crate) mod poll_fd; #[cfg(not(windows))] pub(crate) mod types; <|fim_middle|>#[cfg_attr(windows, path = "windows_syscalls.rs")] pub(crate) mod syscalls;
code_fim
medium
{ "lang": "rust", "repo": "giodamelio/little_boxes", "path": "/vendor/rustix/src/backend/libc/event/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: giodamelio/little_boxes path: /vendor/rustix/src/backend/libc/event/mod.rs pub(crate) mod poll_fd; #[cfg(not(windows))] pub(crate) mod types; <|fim_suffix|>#[cfg(linux_kernel)] pub mod epoll;<|fim_middle|>#[cfg_attr(windows, path = "windows_syscalls.rs")] pub(crate) mod syscalls;
code_fim
medium
{ "lang": "rust", "repo": "giodamelio/little_boxes", "path": "/vendor/rustix/src/backend/libc/event/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..n { for j in 0..n { let _ = j - i; } } }<|fim_prefix|>// repo: marshalshi/simplest-pyo3-trial path: /src/lib.rs use pyo3::prelude::*; use pyo3::wrap_pyfunction; #[pymodule] fn rust2py(_py: Python, m: &PyModule) -> PyResult<()> { <|fim_middle|> m.add_wr...
code_fim
hard
{ "lang": "rust", "repo": "marshalshi/simplest-pyo3-trial", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// loop_rust(n) /// -- /// /// O(N^2) complex sample code #[pyfunction] fn loop_rust(n: i64) { for i in 0..n { for j in 0..n { let _ = j - i; } } }<|fim_prefix|>// repo: marshalshi/simplest-pyo3-trial path: /src/lib.rs use pyo3::prelude::*; use pyo3::wrap_pyfunction; ...
code_fim
medium
{ "lang": "rust", "repo": "marshalshi/simplest-pyo3-trial", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marshalshi/simplest-pyo3-trial path: /src/lib.rs use pyo3::prelude::*; use pyo3::wrap_pyfunction; #[pymodule] fn rust2py(_py: Python, m: &PyModule) -> PyResult<()> { <|fim_suffix|>/// loop_rust(n) /// -- /// /// O(N^2) complex sample code #[pyfunction] fn loop_rust(n: i64) { for i in 0..n ...
code_fim
medium
{ "lang": "rust", "repo": "marshalshi/simplest-pyo3-trial", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> <IsCopy<T>>::VALUE } as usize] = []; } fn main() {}<|fim_prefix|>// repo: rust-lang/glacier path: /fixed/71202.rs use std::marker::PhantomData; struct DataHolder<T> { item: T, } impl<T: Copy> DataHolder<T> { const ITEM_IS_COPY: [(); 1 - { trait NotCopy { const ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/glacier", "path": "/fixed/71202.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/glacier path: /fixed/71202.rs use std::marker::PhantomData; struct DataHolder<T> { item: T, } <|fim_suffix|> impl<__Type: ?Sized> NotCopy for __Type {} struct IsCopy<__Type: ?Sized>(PhantomData<__Type>); impl<__Type> IsCopy<__Type> where ...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/glacier", "path": "/fixed/71202.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_error_handling() { //! We specify a directory as a database. This is bound to fail. let dir = TempDir::new().expect("Could not create temporary directory"); let dirpath = dir.path().to_str().unwrap(); let manager = SqliteConnectionManager::file(dirpath); assert!(manager...
code_fim
hard
{ "lang": "rust", "repo": "ivanceras/r2d2-sqlite", "path": "/tests/test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ivanceras/r2d2-sqlite path: /tests/test.rs extern crate r2d2; extern crate r2d2_sqlite; extern crate rusqlite; extern crate tempfile; use std::sync::mpsc; use std::thread; use r2d2::ManageConnection; use tempfile::TempDir; use r2d2_sqlite::SqliteConnectionManager; use rusqlite::Connection; #...
code_fim
hard
{ "lang": "rust", "repo": "ivanceras/r2d2-sqlite", "path": "/tests/test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!(result.is_ok()); } #[test] fn test_in_memory_db_persists() { let manager = SqliteConnectionManager::memory(); { // Normally, `r2d2::Pool` won't drop connection unless timed-out or broken. // So let's drop managed connection instead. let conn = manager.connect(...
code_fim
hard
{ "lang": "rust", "repo": "ivanceras/r2d2-sqlite", "path": "/tests/test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cloudflare/lol-html path: /src/parser/state_machine/syntax_dsl/arm_pattern/ch_sequence.rs macro_rules! ch_sequence_arm_pattern { // Sequences //-------------------------------------------------------------------- ( | $scope_vars:tt |> "--", $($rest_args:tt)* ) => { ch_seque...
code_fim
hard
{ "lang": "rust", "repo": "cloudflare/lol-html", "path": "/src/parser/state_machine/syntax_dsl/arm_pattern/ch_sequence.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> // Expand check for the first character //-------------------------------------------------------------------- ( @first | [$self:tt, $input:ident, $ch:ident] |> [ $exp_ch:expr, $($rest_chs:tt)* ], $actions:tt, $($case_mod:ident)* ) => { $self.enter_ch_sequence_matching(); ...
code_fim
hard
{ "lang": "rust", "repo": "cloudflare/lol-html", "path": "/src/parser/state_machine/syntax_dsl/arm_pattern/ch_sequence.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tosteiner/thoth path: /thoth-app/src/models/funder/delete_funder_mutation.rs use serde::Deserialize; use serde::Serialize; use super::Funder; const DELETE_FUNDER_MUTATION: &str = " mutation DeleteFunder( $funderId: Uuid! ) { deleteFunder( funderId: $funderId...
code_fim
medium
{ "lang": "rust", "repo": "tosteiner/thoth", "path": "/thoth-app/src/models/funder/delete_funder_mutation.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Scale the y values by 0.5 and convert back into polar form (y * 0.5).atan2(x) } #[test] fn test_rotation() { // As the map is isometric, a shot fired from (0, 0) to (10, 10) // should be travelling directly down (90' clockwise) assert_eq!( convert_rotation(direction(0.0, 0....
code_fim
hard
{ "lang": "rust", "repo": "expenses/war-against-machines", "path": "/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // As the map is isometric, a shot fired from (0, 0) to (10, 10) // should be travelling directly down (90' clockwise) assert_eq!( convert_rotation(direction(0.0, 0.0, 10.0, 10.0)).to_degrees(), 90.0 ); // A shot fired from (0, 10) to (10, 0) should go going directly l...
code_fim
hard
{ "lang": "rust", "repo": "expenses/war-against-machines", "path": "/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: expenses/war-against-machines path: /src/utils.rs // Various utility functions // Return a vec or a default if the vec is empty pub fn vec_or_default<T, C: FnOnce() -> T>(vec: Vec<T>, constructor: C) -> Vec<T> { if vec.is_empty() { vec![constructor()] } else { vec } ...
code_fim
hard
{ "lang": "rust", "repo": "expenses/war-against-machines", "path": "/src/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tocklime/aoc-rs path: /aoc/src/solutions/y2018/day05.rs aoc_harness::aoc_main!(2018 day 5, part1 [p1], part2 [p2]); fn react(a: char, b: char) -> bool { a.to_ascii_lowercase() == b.to_ascii_lowercase() && a != b } fn reduce(input: &str) -> String { let mut output : Vec<char> = Vec::new...
code_fim
hard
{ "lang": "rust", "repo": "tocklime/aoc-rs", "path": "/aoc/src/solutions/y2018/day05.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> reduce(input.trim()).len() } fn p2(input: &str) -> usize { (b'a'..=b'z').map(|c| { let new_input : String = input.trim().chars().filter(|x| x.to_ascii_lowercase() != char::from(c)).collect(); reduce(&new_input).len() }).min().unwrap() } #[test] fn d5p1_test() { assert_e...
code_fim
medium
{ "lang": "rust", "repo": "tocklime/aoc-rs", "path": "/aoc/src/solutions/y2018/day05.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MAIF/izanami path: /izanami-clients/izanami-cli/src/client.rs use reqwest; use reqwest::header::{ACCEPT, CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue}; use serde_json::{from_str, Value}; pub struct IzanamiSettings { pub client_id: String, pub client_id_header: String, pub client...
code_fim
hard
{ "lang": "rust", "repo": "MAIF/izanami", "path": "/izanami-clients/izanami-cli/src/client.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_config_tree(&self, pattern: &str) -> Value { let path = format!("{}/api/tree/configs?pattern={}", &self.settings.url.clone(), pattern); from_str(&get(&self.settings, path)).unwrap() } pub fn get_config(&self, name: &str) -> Value { let path = format!("{}/api...
code_fim
hard
{ "lang": "rust", "repo": "MAIF/izanami", "path": "/izanami-clients/izanami-cli/src/client.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>use k8_obj_metadata::Crd; use k8_obj_metadata::CrdNames; use k8_obj_metadata::GROUP; use k8_obj_metadata::V1; const TOPIC_API: Crd = Crd { group: GROUP, version: V1, names: CrdNames { kind: "Topic", plural: "topics", singular: "topic", }, };<|fim_prefix|>// repo: v...
code_fim
medium
{ "lang": "rust", "repo": "vinimin/fluvio", "path": "/src/k8-metadata/metadata-topic/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vinimin/fluvio path: /src/k8-metadata/metadata-topic/src/lib.rs mod spec; mod status; pub use self::spec::TopicSpec; pub use self::spec::Partition; pub use self::status::TopicStatus; pub use self::status::TopicStatusResolution; <|fim_suffix|>const TOPIC_API: Crd = Crd { group: GROUP, ...
code_fim
medium
{ "lang": "rust", "repo": "vinimin/fluvio", "path": "/src/k8-metadata/metadata-topic/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Symlink { /// Creates a new symlink backed by a symlink on an underlying file system. /// /// `inode` is the node number to assign to the created in-memory symlink and has no relation /// to the underlying symlink. `underlying_path` indicates the path to the symlink outside /// o...
code_fim
hard
{ "lang": "rust", "repo": "Lucretiel/sandboxfs", "path": "/src/nodes/symlink.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Lucretiel/sandboxfs path: /src/nodes/symlink.rs // Copyright 2018 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of the License at: // // http://www.apache.org/lic...
code_fim
hard
{ "lang": "rust", "repo": "Lucretiel/sandboxfs", "path": "/src/nodes/symlink.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hawkw/mycelium path: /maitake/src/task/storage.rs use super::Task; use core::future::Future; use core::ptr::NonNull; /// A trait representing a heap allocation that can own a [`Task`]. /// /// This is used to contain tasks at runtime, and abstract over the /// type erasure and type recovery ste...
code_fim
hard
{ "lang": "rust", "repo": "hawkw/mycelium", "path": "/maitake/src/task/storage.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> impl<S, F: Future> Storage<S, F> for BoxStorage { type StoredTask = Box<Task<S, F, BoxStorage>>; fn into_raw(task: Box<Task<S, F, BoxStorage>>) -> NonNull<Task<S, F, BoxStorage>> { unsafe { crate::util::non_null(Box::into_raw(task)) } } ...
code_fim
hard
{ "lang": "rust", "repo": "hawkw/mycelium", "path": "/maitake/src/task/storage.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn scatter(&self, ray: &Ray, intersection: &Intersection) -> (Option<Ray>, Vec4) { let scatter_target = intersection.point + intersection.normal + Vec3::random_in_unit_sphere(); let scattered_ray = Ray::new(intersection.point, (scatter_target - intersection.point).normalized(),...
code_fim
hard
{ "lang": "rust", "repo": "doanamo/Raytracer-2020", "path": "/src/render/materials/diffuse.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doanamo/Raytracer-2020 path: /src/render/materials/diffuse.rs use serde::{ Serialize, Deserialize }; use super::math::Vec3; use super::math::Vec4; use super::math::Ray; use super::math::Intersection; use super::Material; #[derive(Serialize, Deserialize)] pub struct Diffuse { albedo: Vec4 } ...
code_fim
medium
{ "lang": "rust", "repo": "doanamo/Raytracer-2020", "path": "/src/render/materials/diffuse.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fredrik-jansson-se/rust-advent-of-code-2016 path: /src/day24.rs use astar::*; // use permutohedron::LexicalPermutation; use permutohedron::heap_recursive; use std::fs; use std::ops::Add; use std::collections::HashMap; #[derive(Clone, Debug, PartialEq)] enum Room { Wall, Open, } pub fn ...
code_fim
hard
{ "lang": "rust", "repo": "fredrik-jansson-se/rust-advent-of-code-2016", "path": "/src/day24.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> heap_recursive(&mut w.goals, |p| { perms.push(p.to_vec()); }); for goals in perms { m = usize::min(way_len(&w, &goals, &mut lu), m); } m } fn run_2(mut w: World) -> usize { let mut m = usize::max_value(); let mut lu = HashMap::new(); let mut perms = Vec::n...
code_fim
hard
{ "lang": "rust", "repo": "fredrik-jansson-se/rust-advent-of-code-2016", "path": "/src/day24.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.distance_between(from, goal) } fn distance_between(&self, from: &Coord, to: &Coord) -> f32 { let dx = (to.x - from.x) as f32; let dy = (to.y - from.y) as f32; (dx * dx + dy * dy).sqrt() } fn neighbors(&self, n: &Coord) -> Vec<Coord> { let mut ...
code_fim
hard
{ "lang": "rust", "repo": "fredrik-jansson-se/rust-advent-of-code-2016", "path": "/src/day24.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self.info } } #[derive(Clone, Debug)] pub struct Loadout { pub left_hand: Option<ItemId>, pub right_hand: Option<ItemId>, pub head: Option<ItemId>, pub armor: Option<ItemId>, } impl Default for Loadout { fn default() -> Loadout { Loadout { head: None,...
code_fim
hard
{ "lang": "rust", "repo": "baptistemanson/rust-pathfinder", "path": "/rules/src/item.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: baptistemanson/rust-pathfinder path: /rules/src/item.rs pub mod armor; pub mod weapon; use weapon::WeaponItem; use crate::rules::Rule; use self::armor::ArmorItem; pub type ItemId = String; pub trait GameItem { fn get_info(&self) -> &ItemInfo; } pub enum AnyItem { WeaponItem(WeaponI...
code_fim
hard
{ "lang": "rust", "repo": "baptistemanson/rust-pathfinder", "path": "/rules/src/item.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gp-97/rust path: /ConditionalStatements/if_else.rs fn main() { let a: i32 = 10; let b: i32 = 12; <|fim_suffix|> // Shorthand if..else let res = if a>b {"a > b"} else if a==b {"a == b"} else {"a < b"}; println!("{}", res); }<|fim_middle|> if a > b { println!("a...
code_fim
medium
{ "lang": "rust", "repo": "gp-97/rust", "path": "/ConditionalStatements/if_else.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Shorthand if..else let res = if a>b {"a > b"} else if a==b {"a == b"} else {"a < b"}; println!("{}", res); }<|fim_prefix|>// repo: gp-97/rust path: /ConditionalStatements/if_else.rs fn main() { let a: i32 = 10; let b: i32 = 12; <|fim_middle|> if a > b { println!("a...
code_fim
medium
{ "lang": "rust", "repo": "gp-97/rust", "path": "/ConditionalStatements/if_else.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Path to the keyfile pub fn wallet_keypath(&self) -> PathBuf { let mut p = self.config.wallet_path(); p.push("wallet.xprv"); p } /// Returns a read-only reference to the wallet pub fn wallet_ref(&self) -> Result<&Wallet, Error> { self.wallet.as_ref()...
code_fim
hard
{ "lang": "rust", "repo": "stellar/slingshot", "path": "/node/src/wallet_manager.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns true if the wallet is initialized pub fn wallet_exists(&self) -> bool { self.wallet.is_some() } /// Path to the wallet file pub fn wallet_filepath(&self) -> PathBuf { let mut p = self.config.wallet_path(); p.push("wallet.bincode"); p } ...
code_fim
hard
{ "lang": "rust", "repo": "stellar/slingshot", "path": "/node/src/wallet_manager.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stellar/slingshot path: /node/src/wallet_manager.rs use super::config::Config; use super::errors::Error; use super::wallet::Wallet; use keytree::Xprv; use std::fs::{self, File}; use std::io::Write; use std::path::{Path, PathBuf}; use std::sync::Arc; use tokio::sync::RwLock; /// Reference to the...
code_fim
hard
{ "lang": "rust", "repo": "stellar/slingshot", "path": "/node/src/wallet_manager.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Offline24/LearningRust path: /common_programming_concepts/variables_and_mutability/src/lib.rs pub fn let_is_immutable() { let x = 4; println!("immutable x = {}", x); // x = 3; // produce compile error } pub fn let_with_mut_is_mutable() { let mut x = 4; println!("mutable x = ...
code_fim
hard
{ "lang": "rust", "repo": "Offline24/LearningRust", "path": "/common_programming_concepts/variables_and_mutability/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(dead_code)] fn get_constant_value() -> i32 { CONSTANT_VALUE } #[allow(unused_assignments)] #[allow(unused_variables)] fn mutable_argument(mut x: i32) { x = 0; } fn mutable_reference_argument(x: &mut i32) { *x = 0; } fn mutable_reference_argument_with_shadowing(x: &mut i32) { pr...
code_fim
hard
{ "lang": "rust", "repo": "Offline24/LearningRust", "path": "/common_programming_concepts/variables_and_mutability/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LexLuengas/yew-example-app path: /wasm-spa/tweets/src/requests.rs use serde_derive::{Serialize, Deserialize}; use util::fetch::{Auth, FetchRequest, HttpMethod}; #[derive(Serialize, Deserialize)] pub enum TwitterRequest { Search { query: String }, } <|fim_suffix|> self::Auth::NotRequ...
code_fim
hard
{ "lang": "rust", "repo": "LexLuengas/yew-example-app", "path": "/wasm-spa/tweets/src/requests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self::Auth::NotRequired } fn resolve_body_and_method(&self) -> HttpMethod { self::HttpMethod::Get } }<|fim_prefix|>// repo: LexLuengas/yew-example-app path: /wasm-spa/tweets/src/requests.rs use serde_derive::{Serialize, Deserialize}; use util::fetch::{Auth, FetchRequest, HttpM...
code_fim
hard
{ "lang": "rust", "repo": "LexLuengas/yew-example-app", "path": "/wasm-spa/tweets/src/requests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/developer/ffx/lib/writer/src/lib.rs // Copyright 2021 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { anyhow::{anyhow, Context, Result}, std::io::{stderr, ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/developer/ffx/lib/writer/src/lib.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }