text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>// interpolate position towards goal pub fn interpolate(interpolate_data: &mut InterpolateData, position: &mut V2f32, dt: f32) { if dt >= interpolate_data.time_left { interpolate_data.time_left = 0.0; *position = interpolate_data.goal; } else { let distance = interpolate_da...
code_fim
medium
{ "lang": "rust", "repo": "surgura/RustTetris", "path": "/src/interpolate.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: heinrich5991/libtw2 path: /tools/src/bin/author.rs #![cfg(not(test))] extern crate common; extern crate datafile as df; extern crate map; extern crate tools; use map::format; use std::path::Path; #[derive(Default)] struct Stats { author: u64, version: u64, credits: u64, licens...
code_fim
medium
{ "lang": "rust", "repo": "heinrich5991/libtw2", "path": "/tools/src/bin/author.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn print_stats(stats: &Stats) { println!("author: {:5}", stats.author); println!("version: {:5}", stats.version); println!("credits: {:5}", stats.credits); println!("license: {:5}", stats.license); println!("settings: {:5}", stats.settings); println!("info: {:5}", stats.in...
code_fim
hard
{ "lang": "rust", "repo": "heinrich5991/libtw2", "path": "/tools/src/bin/author.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[construct_with(u16)] pub reserved: u16be, #[construct_with(u32)] pub interface_index: u32be, #[construct_with(u16)] pub arphrd_type: u16be, #[construct_with(u8)] pub packet_type: u8, #[construct_with(u8)] pub link_layer_address_length: u8, ...
code_fim
hard
{ "lang": "rust", "repo": "libpnet/libpnet", "path": "/pnet_packet/src/sll2.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[construct_with(u32)] pub interface_index: u32be, #[construct_with(u16)] pub arphrd_type: u16be, #[construct_with(u8)] pub packet_type: u8, #[construct_with(u8)] pub link_layer_address_length: u8, #[construct_with(u8, u8, u8, u8, u8, u8, u8, u8)] ...
code_fim
medium
{ "lang": "rust", "repo": "libpnet/libpnet", "path": "/pnet_packet/src/sll2.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: libpnet/libpnet path: /pnet_packet/src/sll2.rs //! A Linux cooked-mode capture v2 (LINKTYPE_LINUX_SLL2) packet abstraction. // ref: https://www.tcpdump.org/linktypes/LINKTYPE_LINUX_SLL2.html use alloc::vec::Vec; <|fim_suffix|> #[construct_with(u16)] pub arphrd_type: u16be, #[co...
code_fim
hard
{ "lang": "rust", "repo": "libpnet/libpnet", "path": "/pnet_packet/src/sll2.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nymtech/nym path: /ephemera/src/utilities/crypto/mod.rs use std::fmt::{Debug, Display}; use std::hash::Hash; use serde::{Deserialize, Serialize}; pub use ed25519::{Keypair as Ed25519Keypair, PublicKey as Ed25519PublicKey}; pub use keypair::{EphemeraKeypair, EphemeraPublicKey, KeyPairError}; u...
code_fim
hard
{ "lang": "rust", "repo": "nymtech/nym", "path": "/ephemera/src/utilities/crypto/mod.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> write!( f, "Signature {}, PublicKey {}", self.signature.to_base58(), self.public_key.to_base58() ) } } #[cfg(test)] mod test { use crate::crypto::{EphemeraKeypair, EphemeraPublicKey}; #[test] fn test_sign_and_verify() { ...
code_fim
hard
{ "lang": "rust", "repo": "nymtech/nym", "path": "/ephemera/src/utilities/crypto/mod.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rusty-horizon/nx-rs path: /nx-std/src/test/ui/run-pass/issues/issue-25339.rs // Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LI...
code_fim
hard
{ "lang": "rust", "repo": "rusty-horizon/nx-rs", "path": "/nx-std/src/test/ui/run-pass/issues/issue-25339.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub trait Routing<I> { type Output; fn resolve(&self, input: I); } pub trait ToRouting { type Input; type Routing : ?Sized = Routing<Self::Input, Output=()>; fn to_routing(self) -> Self::Routing; } pub struct Mount<I, R: Routing<I>> { action: R, _marker: PhantomData<I> } imp...
code_fim
medium
{ "lang": "rust", "repo": "rusty-horizon/nx-rs", "path": "/nx-std/src/test/ui/run-pass/issues/issue-25339.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Mount<I, R: Routing<I>> { action: R, _marker: PhantomData<I> } impl<I, R: Routing<I>> Mount<I, R> { pub fn create<T: ToRouting<Routing=R>>(mount: &str, input: T) { input.to_routing(); } } fn main() { }<|fim_prefix|>// repo: rusty-horizon/nx-rs path: /nx-std/src/test/u...
code_fim
hard
{ "lang": "rust", "repo": "rusty-horizon/nx-rs", "path": "/nx-std/src/test/ui/run-pass/issues/issue-25339.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(roman_to_int("III".into()), 3); assert_eq!(roman_to_int("LVIII".into()), 58); assert_eq!(roman_to_int("MCMXCIV".into()), 1994); }<|fim_prefix|>// repo: zweimach/wiyata.rs path: /leetcode/roman_to_integer_test.rs #![cfg(test)] use super::roman_to_integer::roman_to_int; <|fim_middle...
code_fim
easy
{ "lang": "rust", "repo": "zweimach/wiyata.rs", "path": "/leetcode/roman_to_integer_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zweimach/wiyata.rs path: /leetcode/roman_to_integer_test.rs #![cfg(test)] use super::roman_to_integer::roman_to_int; <|fim_suffix|> assert_eq!(roman_to_int("III".into()), 3); assert_eq!(roman_to_int("LVIII".into()), 58); assert_eq!(roman_to_int("MCMXCIV".into()), 1994); }<|fim_middle...
code_fim
easy
{ "lang": "rust", "repo": "zweimach/wiyata.rs", "path": "/leetcode/roman_to_integer_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let prefab0 = Prefab { prefab_id: 0, position: Vector3::new(-10., 0., -10.), rotation: UnitQuaternion::identity(), bounding_box: AABB::from_half_extents(Point3::new(0., 0., 0.), Vector3::new(1., 1., 1.)), movement: Movement { ...
code_fim
hard
{ "lang": "rust", "repo": "Sroka/arc_level_generator", "path": "/src/generator/calculate_prefabs_spawn_bounds.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Sroka/arc_level_generator path: /src/generator/calculate_prefabs_spawn_bounds.rs use crate::generator::types::Prefab; use ncollide3d::bounding_volume::{AABB, BoundingVolume}; use nalgebra::{Point3, Vector3, Isometry3}; /// Calculated total bounding volume that encloses the given array of prefab...
code_fim
hard
{ "lang": "rust", "repo": "Sroka/arc_level_generator", "path": "/src/generator/calculate_prefabs_spawn_bounds.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let conn = &mut PgConnection::establish("..").unwrap(); // this fails because `posts` is not part of the from clause users::table .group_by(posts::id) .select(users::id) .execute(conn) .unwrap(); // order of select and group by does not matter for the erro...
code_fim
medium
{ "lang": "rust", "repo": "diesel-rs/diesel", "path": "/diesel_compile_tests/tests/fail/invalid_group_by.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: diesel-rs/diesel path: /diesel_compile_tests/tests/fail/invalid_group_by.rs extern crate diesel; use diesel::alias; use diesel::prelude::*; table! { users { id -> Integer, name -> VarChar, } } table! { posts { id -> Integer, } } allow_columns_to_appear...
code_fim
hard
{ "lang": "rust", "repo": "diesel-rs/diesel", "path": "/diesel_compile_tests/tests/fail/invalid_group_by.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Emilgardis/svd path: /svd-encoder/src/registercluster.rs use super::{Config, Element, Encode, EncodeError}; <|fim_suffix|> fn encode_with_config(&self, config: &Config) -> Result<Element, EncodeError> { match self { RegisterCluster::Register(r) => r.encode_with_config(con...
code_fim
medium
{ "lang": "rust", "repo": "Emilgardis/svd", "path": "/svd-encoder/src/registercluster.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> fn encode_with_config(&self, config: &Config) -> Result<Element, EncodeError> { match self { RegisterCluster::Register(r) => r.encode_with_config(config), RegisterCluster::Cluster(c) => c.encode_with_config(config), } } }<|fim_prefix|>// repo: Emilgardis/svd...
code_fim
medium
{ "lang": "rust", "repo": "Emilgardis/svd", "path": "/svd-encoder/src/registercluster.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: malthe/blend2d-rs path: /blend2d-sys/build.rs use cmake::Config; use std::{env, path::PathBuf}; fn main() { let target = env::var("TARGET").unwrap(); let (_arch, _vendor, sys, _abi) = { let mut target_s = target.split('-'); ( target_s.next().unwrap(), ...
code_fim
hard
{ "lang": "rust", "repo": "malthe/blend2d-rs", "path": "/blend2d-sys/build.rs", "mode": "psm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_suffix|>nerate_comments(false) .default_enum_style(bindgen::EnumVariation::ModuleConsts) .whitelist_function(whitelist_regex) .whitelist_type(whitelist_regex) .whitelist_var(whitelist_regex) .derive_debug(false) .generate() .expect("Unable to generate bindin...
code_fim
hard
{ "lang": "rust", "repo": "malthe/blend2d-rs", "path": "/blend2d-sys/build.rs", "mode": "spm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn string_of_hex(hex: & Vec<u8>) -> Vec<String> { let mut hex_vec = Vec::new(); let base16 = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']; for h in hex.iter() { ...
code_fim
hard
{ "lang": "rust", "repo": "showandtellinar/mercury", "path": "/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: showandtellinar/mercury path: /src/utils.rs pub use self::utils::*; pub mod utils { use types; /*macro_rules! printvec( ($inp:expr, $n:expr) => ( for (a,b) in $inp.iter().zip($inp ); )*/ <|fim_suffix|> } pub fn string_of_hex(hex: & Vec<u8>) ...
code_fim
hard
{ "lang": "rust", "repo": "showandtellinar/mercury", "path": "/src/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("transaction {} ({}/{})", txn.version, txn.tx_in_count, txn.tx_out_count); for tx_in in txn.tx_in.iter() { println!("-> {}", string_of_hex(&tx_in.signature_script)); } for tx_out in txn.tx_out.iter()...
code_fim
hard
{ "lang": "rust", "repo": "showandtellinar/mercury", "path": "/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ToferC/paladin path: /src/components/laser.rs use amethyst::ecs::{Component, NullStorage, DenseVecStorage}; <|fim_suffix|>impl Component for Laser { type Storage = DenseVecStorage<Self>; } impl Laser { pub fn new(timer: f32, damage: i32, side: Side) -> Laser { Laser { ...
code_fim
hard
{ "lang": "rust", "repo": "ToferC/paladin", "path": "/src/components/laser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Laser { pub fn new(timer: f32, damage: i32, side: Side) -> Laser { Laser { timer, damage, side, } } }<|fim_prefix|>// repo: ToferC/paladin path: /src/components/laser.rs use amethyst::ecs::{Component, NullStorage, DenseVecStorage}; use sup...
code_fim
hard
{ "lang": "rust", "repo": "ToferC/paladin", "path": "/src/components/laser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Component for Laser { type Storage = DenseVecStorage<Self>; } impl Laser { pub fn new(timer: f32, damage: i32, side: Side) -> Laser { Laser { timer, damage, side, } } }<|fim_prefix|>// repo: ToferC/paladin path: /src/components/laser.r...
code_fim
medium
{ "lang": "rust", "repo": "ToferC/paladin", "path": "/src/components/laser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dfrankland/mk20d7 path: /src/rfsys/mod.rs #[doc = r" Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Register file register"] pub reg: [REG; 8], } #[<|fim_suffix|>l::VolatileCell<u32>, } #[doc = "Register file register"] pub mod reg;<|fim_middle|>doc = "Register fi...
code_fim
medium
{ "lang": "rust", "repo": "dfrankland/mk20d7", "path": "/src/rfsys/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>doc = "Register file register"] pub struct REG { register: ::vcell::VolatileCell<u32>, } #[doc = "Register file register"] pub mod reg;<|fim_prefix|>// repo: dfrankland/mk20d7 path: /src/rfsys/mod.rs #[doc = r" Register block"] #[repr(C)] pub struct RegisterBlock { <|fim_middle|> #[doc = "0x00 - R...
code_fim
medium
{ "lang": "rust", "repo": "dfrankland/mk20d7", "path": "/src/rfsys/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>l::VolatileCell<u32>, } #[doc = "Register file register"] pub mod reg;<|fim_prefix|>// repo: dfrankland/mk20d7 path: /src/rfsys/mod.rs #[doc = r" Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Register file register"] pub reg: [REG; 8], } #[<|fim_middle|>doc = "Register fi...
code_fim
medium
{ "lang": "rust", "repo": "dfrankland/mk20d7", "path": "/src/rfsys/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn payload(&self) -> Value { json!({}) } }<|fim_prefix|>// repo: jsflax/stitch-rust-sdk path: /src/auth/providers/anonymous.rs use auth::provider::AuthProvider; use auth::providers::Value; pub struct AnonymousAuthProvider; <|fim_middle|>impl AuthProvider for AnonymousAuthProvider { fn auth_type...
code_fim
medium
{ "lang": "rust", "repo": "jsflax/stitch-rust-sdk", "path": "/src/auth/providers/anonymous.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jsflax/stitch-rust-sdk path: /src/auth/providers/anonymous.rs use auth::provider::AuthProvider; use auth::providers::Value; <|fim_suffix|> fn name(&self) -> &'static str { "user" } fn payload(&self) -> Value { json!({}) } }<|fim_middle|>pub struct AnonymousAuthProvider; impl AuthProvide...
code_fim
medium
{ "lang": "rust", "repo": "jsflax/stitch-rust-sdk", "path": "/src/auth/providers/anonymous.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn mul(self, rhs: u32) -> ChemicalQuantity { ChemicalQuantity::new(self.name.clone(), self.quantity * rhs) } } struct ProductionRequirements { quantity: u32, requirements: Vec<ChemicalQuantity>, } impl ProductionRequirements { fn new(quantity: u32, requirements: Vec<ChemicalQ...
code_fim
hard
{ "lang": "rust", "repo": "bmatcuk/adventofcode2019", "path": "/day14/src/bin/part1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bmatcuk/adventofcode2019 path: /day14/src/bin/part1.rs //! --- Day 14: Space Stoichiometry --- //! //! As you approach the rings of Saturn, your ship's low fuel indicator turns on. There isn't any //! fuel here, but the rings have plenty of raw material. Perhaps your ship's Inter-Stellar //! Ref...
code_fim
hard
{ "lang": "rust", "repo": "bmatcuk/adventofcode2019", "path": "/day14/src/bin/part1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // there's only one way to create each chemical, which simplifies the algo let file = File::open("input.txt")?; let reader = BufReader::new(file); let mut map = HashMap::new(); for line in reader.lines() { match line { Ok(line) => { let arrow = line....
code_fim
hard
{ "lang": "rust", "repo": "bmatcuk/adventofcode2019", "path": "/day14/src/bin/part1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut map = map.clone(); loop { let next = map.next2(); if next == map { return map.taken(); } map = next; } } #[cfg(test)] mod tests { use super::*; const INPUT: &str = "L.LL.LL.LL LLLLLLL.LL L.L.L..L.. LLLL.LL.LL...
code_fim
hard
{ "lang": "rust", "repo": "Shadlock0133/aoc2020", "path": "/src/bin/day11.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let width = input.lines().next().unwrap().chars().count(); let map = input .lines() .filter(|line| !line.trim().is_empty()) .map(|line| { let line = line .trim() .chars() .map(|ch| match ch { '....
code_fim
hard
{ "lang": "rust", "repo": "Shadlock0133/aoc2020", "path": "/src/bin/day11.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Shadlock0133/aoc2020 path: /src/bin/day11.rs use std::fmt; fn main() { let input = std::fs::read_to_string("inputs/day11.txt").unwrap(); let map = parse_input(&input); let res = check_1(&map); println!("Part 1 - Answer: {}", res); let res = check_2(&map); println!("Part ...
code_fim
hard
{ "lang": "rust", "repo": "Shadlock0133/aoc2020", "path": "/src/bin/day11.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paholg/dimensioned path: /tests/tests.rs #![cfg(test)] #![cfg(feature = "quickcheck")] #[macro_use] extern crate quickcheck; extern crate dimensioned as dim; mod quickchecking { use dim::si::*; use quickcheck::TestResult; quickcheck! { fn add(x: f64, y: f64) -> bool { ...
code_fim
medium
{ "lang": "rust", "repo": "paholg/dimensioned", "path": "/tests/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> res1 && res2 && res3 } } quickcheck! { fn div(x: f64, y: f64) -> bool { let res1 = (x * M) / y == Meter::new(x / y); let res2 = x / (y * M) == PerMeter::new(x / y); let res3 = (x * M) * (y * M) == Meter2::new(x * y); res...
code_fim
hard
{ "lang": "rust", "repo": "paholg/dimensioned", "path": "/tests/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut output = Vec::new(); for slot_idx in slot_start..slot_start + nb_slots { let date = leadership.date_at_slot(slot_idx); for (id, leader) in leaders.iter() { match leadership.is_leader_for_date(&leader, date) { Ok(LeaderOutp...
code_fim
hard
{ "lang": "rust", "repo": "aidik/jormungandr", "path": "/jormungandr/src/secure/enclave.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn create_block(&self, block: BlockBuilder, event: LeaderEvent) -> Option<Block> { let leaders = self.leaders.read().unwrap(); let leader = leaders.get(&event.id)?; let block = match event.output { LeaderOutput::None => unreachable!("Output::None are supposed to...
code_fim
hard
{ "lang": "rust", "repo": "aidik/jormungandr", "path": "/jormungandr/src/secure/enclave.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aidik/jormungandr path: /jormungandr/src/secure/enclave.rs use crate::blockcfg::{BlockBuilder, BlockDate}; use chain_impl_mockchain::block::Block; use chain_impl_mockchain::leadership::{Leader, LeaderOutput, Leadership}; use jormungandr_lib::interfaces::EnclaveLeaderId as LeaderId; use std::coll...
code_fim
hard
{ "lang": "rust", "repo": "aidik/jormungandr", "path": "/jormungandr/src/secure/enclave.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaimast/iced path: /core/src/window/user_attention.rs /// The type of user attention to request. /// /// ## Platform-specific /// /// - **X11:** Sets the WM's `XUrgencyHint`. No distinction between [`Critical`] and [`Informational`]. /// /<|fim_suffix|>** Bounces the dock icon until the applicat...
code_fim
medium
{ "lang": "rust", "repo": "kaimast/iced", "path": "/core/src/window/user_attention.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/ ## Platform-specific /// /// - **macOS:** Bounces the dock icon once. /// - **Windows:** Flashes the taskbar button until the application is in focus. Informational, }<|fim_prefix|>// repo: kaimast/iced path: /core/src/window/user_attention.rs /// The type of user attention to request. ...
code_fim
medium
{ "lang": "rust", "repo": "kaimast/iced", "path": "/core/src/window/user_attention.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let mut vec = vec![1, 2, 3]; { let ref_to_vec: &Vec<i32> = &vec; let sum = reference_sum(ref_to_vec); println!("The sum is {}.", sum); println!("We still have ownership here {:?}", vec); } { put_a_one_into_it(&mut vec); put_a_on...
code_fim
medium
{ "lang": "rust", "repo": "dairyisscary/for-your-reference-part-4", "path": "/two/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut vec = vec![1, 2, 3]; { let ref_to_vec: &Vec<i32> = &vec; let sum = reference_sum(ref_to_vec); println!("The sum is {}.", sum); println!("We still have ownership here {:?}", vec); } { put_a_one_into_it(&mut vec); put_a_one_into_it(&m...
code_fim
medium
{ "lang": "rust", "repo": "dairyisscary/for-your-reference-part-4", "path": "/two/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dairyisscary/for-your-reference-part-4 path: /two/src/main.rs fn reference_sum(borrowed_vec: &Vec<i32>) -> i32 { borrowed_vec.iter().fold(0, |sum, val| sum + val) } fn put_a_one_into_it_opps(borrowed_vec: &Vec<i32>) { borrowed_vec.push(1); } fn put_a_one_into_it(borrowed_vec: &mut Vec<...
code_fim
medium
{ "lang": "rust", "repo": "dairyisscary/for-your-reference-part-4", "path": "/two/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MuharremOkutan/scryer-prolog path: /src/main.rs #[macro_use] extern crate cfg_if; #[macro_use] extern crate downcast; #[macro_use] extern crate prolog_parser; #[macro_use] extern crate ref_thread_local; cfg_if! { if #[cfg(feature = "readline_rs_compat")] { extern crate readline_rs_c...
code_fim
hard
{ "lang": "rust", "repo": "MuharremOkutan/scryer-prolog", "path": "/src/main.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let result = compile_user_module(&mut wam, &src[0 ..]); print(&mut wam, result); }, Ok(Input::Clear) => { wam.clear(); continue; }, Err(e) => print(&mut wam, EvalSession::from(e)) }; ...
code_fim
hard
{ "lang": "rust", "repo": "MuharremOkutan/scryer-prolog", "path": "/src/main.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ezracelli/google-api-rust-client path: /crates/appengine/v1alpha/src/lib.rs serde :: Serialize, serde :: Deserialize, )] pub struct QueryParameters { #[builder( ...
code_fim
hard
{ "lang": "rust", "repo": "ezracelli/google-api-rust-client", "path": "/crates/appengine/v1alpha/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>) } } #[derive( Clone, Debug, PartialEq, derive_builder :: Builder, serde :: Serialize, serde :: Deserialize, )] #[doc = "Metadata for the given google.longrunning.Operation."] pub struct OperationMetadataV1 { #[builder(default = "{ ::std::default::Default::defa...
code_fim
hard
{ "lang": "rust", "repo": "ezracelli/google-api-rust-client", "path": "/crates/appengine/v1alpha/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mpl ListLocationsResponse { pub fn builder() -> ListLocationsResponseBuilder { ListLocationsResponseBuilder::default() } } #[derive( Clone, Debug, PartialEq, derive_builder :: Builder, serde :: Serialize, serde :: Deserialize, )] #[doc = "The response me...
code_fim
hard
{ "lang": "rust", "repo": "ezracelli/google-api-rust-client", "path": "/crates/appengine/v1alpha/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CBenoit/nushell path: /crates/nu-command/src/dataframe/lazy/fill_na.rs use crate::dataframe::values::{NuExpression, NuLazyFrame}; use nu_engine::CallExt; use nu_protocol::{ ast::Call, engine::{Command, EngineState, Stack}, Category, Example, PipelineData, ShellError, Signature, Synta...
code_fim
hard
{ "lang": "rust", "repo": "CBenoit/nushell", "path": "/crates/nu-command/src/dataframe/lazy/fill_na.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: software-opal/thread-colors path: /src/generated/brildor_ny.rs D, "3240", "Black Chrome", &[72, 62, 62], ), ThreadRef::new( BRAND, "3136", "Deep Taupe", &[117, 97, 86], ), ThreadRef::new( BRAND, "3040", ...
code_fim
hard
{ "lang": "rust", "repo": "software-opal/thread-colors", "path": "/src/generated/brildor_ny.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> BRAND, "3295", "Pro Band Blue", &[0, 108, 160], ), ThreadRef::new( BRAND, "3095", "Blue Horizon", &[0, 140, 185], ), ThreadRef::new( BRAND, "3093", "Capri", &[77, 239, 255], ), ThreadRe...
code_fim
hard
{ "lang": "rust", "repo": "software-opal/thread-colors", "path": "/src/generated/brildor_ny.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Reef", &[255, 147, 126], ), ThreadRef::new( BRAND, "3120", "Pale Mauve", &[255, 201, 255], ), ThreadRef::new( BRAND, "3121", "Orchid Pink", &[255, 171, 239], ), ThreadRef::new( BRAND, "3080", ...
code_fim
hard
{ "lang": "rust", "repo": "software-opal/thread-colors", "path": "/src/generated/brildor_ny.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // create num from splitted and parsed values num = input.split_whitespace() .map(|x| x.parse().unwrap()) .collect::<Vec<i32>>(); // clear data in input; input.clear(); stdin().read_line(&mut input); let mut target = Vec::with_capacity(1); ...
code_fim
medium
{ "lang": "rust", "repo": "Hota822/atcoder", "path": "/beginner_contest/154/a/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hota822/atcoder path: /beginner_contest/154/a/src/main.rs use std::io::stdin; fn main() { let mut input = String::new(); stdin().read_line(&mut input); let mut vec = Vec::with_capacity(2); <|fim_suffix|> // create num from splitted and parsed values num = input.split_whitesp...
code_fim
hard
{ "lang": "rust", "repo": "Hota822/atcoder", "path": "/beginner_contest/154/a/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stone-zeng/rustotf path: /src/tables/other/dsig.rs use crate::font::Font; use crate::util::{Buffer, ReadBuffer}; /// ## `DSIG` &mdash; Digital Signature Table /// /// Specification: <https://docs.microsoft.com/en-us/typography/opentype/spec/dsig>. /// /// The `DSIG` table contains the digital s...
code_fim
medium
{ "lang": "rust", "repo": "stone-zeng/rustotf", "path": "/src/tables/other/dsig.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl ReadBuffer for SignatureRecord { fn read(buffer: &mut Buffer) -> Self { Self { format: buffer.get(), length: buffer.get(), signature_block_offset: buffer.get(), ..Default::default() } } }<|fim_prefix|>// repo: stone-zeng/rustotf ...
code_fim
medium
{ "lang": "rust", "repo": "stone-zeng/rustotf", "path": "/src/tables/other/dsig.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Font { #[allow(non_snake_case)] pub fn parse_DSIG(&mut self, buffer: &mut Buffer) { let dsig_start = buffer.offset(); let version = buffer.get(); let num_signatures = buffer.get(); let flags = buffer.get(); let mut signature_records: Vec<SignatureRecord...
code_fim
medium
{ "lang": "rust", "repo": "stone-zeng/rustotf", "path": "/src/tables/other/dsig.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while er != low { mtx[er][low] = num.next().unwrap(); er -= 1; } low += 1; up -= 1; if low == up { mtx[low][up] = num.next().unwrap(); } } mtx }<|fim_prefix|>// repo: sjinno/exercism path: /spiral-matrix/src/li...
code_fim
medium
{ "lang": "rust", "repo": "sjinno/exercism", "path": "/spiral-matrix/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if low == up { mtx[low][up] = num.next().unwrap(); } } mtx }<|fim_prefix|>// repo: sjinno/exercism path: /spiral-matrix/src/lib.rs pub fn spiral_matrix(size: u32) -> Vec<Vec<u32>> { if size == 0 { return Vec::new(); } else if size == 1 { return...
code_fim
hard
{ "lang": "rust", "repo": "sjinno/exercism", "path": "/spiral-matrix/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sjinno/exercism path: /spiral-matrix/src/lib.rs pub fn spiral_matrix(size: u32) -> Vec<Vec<u32>> { if size == 0 { return Vec::new(); } else if size == 1 { return vec![vec![1]]; } let s = size as usize; let mut mtx = vec![vec![0; s]; s]; let mut num = 1.....
code_fim
hard
{ "lang": "rust", "repo": "sjinno/exercism", "path": "/spiral-matrix/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: deusletum/teensy4-rs path: /examples/bsp/src/bin/usb_writer.rs //! Demonstrates our ability to write over USB, and read //! USB serial messages from a USB host. #![no_std] #![no_main] mod usb_io; use teensy4_panic as _; use core::fmt::Write; use cortex_m_rt as rt; use teensy4_bsp as bsp; #[...
code_fim
hard
{ "lang": "rust", "repo": "deusletum/teensy4-rs", "path": "/examples/bsp/src/bin/usb_writer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> systick.delay(2000); p.ccm .pll1 .set_arm_clock(bsp::hal::ccm::PLL1::ARM_HZ, &mut p.ccm.handle, &mut p.dcdc); let mut led = bsp::configure_led(pins.p13); let mut buffer = [0; 256]; loop { let bytes_read = reader.read(&mut buffer).unwrap(); if bytes_read ...
code_fim
hard
{ "lang": "rust", "repo": "deusletum/teensy4-rs", "path": "/examples/bsp/src/bin/usb_writer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut p = bsp::Peripherals::take().unwrap(); let pins = bsp::t40::into_pins(p.iomuxc); let mut systick = bsp::SysTick::new(cortex_m::Peripherals::take().unwrap().SYST); // Split the USB stack into read / write halves let (mut reader, mut writer) = usb_io::split().unwrap(); systi...
code_fim
medium
{ "lang": "rust", "repo": "deusletum/teensy4-rs", "path": "/examples/bsp/src/bin/usb_writer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Execute if matches.opt_present("t") { args.insert(PupArg::TaskId, matches.opt_str("t").unwrap()); // Dryrun if matches.opt_present("d") { args.insert(PupArg::DryRun, "1".to_string()); match pup_main(PupTask::RunTask, args) { Ok(_...
code_fim
hard
{ "lang": "rust", "repo": "shadowmint/rust-pup", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shadowmint/rust-pup path: /src/main.rs extern crate getopts; extern crate pup_main; use std::env; use getopts::Options; use pup_main::{pup_enable_debug, pup_main, PupArg, PupTask}; use std::collections::HashMap; use std::process; use std::error::Error; fn print_usage(program: &str, opts: Optio...
code_fim
hard
{ "lang": "rust", "repo": "shadowmint/rust-pup", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut opts = Options::new(); opts.optopt("t", "task", "the id of the task to run or examine", "TASK"); opts.optflag("h", "help", "print this help menu"); opts.optflag("d", "dryrun", "dry-run the task, showing debug information"); opts.optflag("e", "execute", "execute the task"); ...
code_fim
hard
{ "lang": "rust", "repo": "shadowmint/rust-pup", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xyuan/fuchsia path: /src/connectivity/overnet/lib/core/src/link.rs // Copyright 2020 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 crate::{ future_help::Observer, labels::{Endpoint, N...
code_fim
hard
{ "lang": "rust", "repo": "xyuan/fuchsia", "path": "/src/connectivity/overnet/lib/core/src/link.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } fn forward(&self, routing_label: RoutingLabel, frame: &mut [u8]) -> Result<(), Error> { let mut state = self.state.borrow_mut(); state.packets_forwarded += 1; state.to_forward.push_back((routing_label, frame.to_vec())); state.wake_send(); O...
code_fim
hard
{ "lang": "rust", "repo": "xyuan/fuchsia", "path": "/src/connectivity/overnet/lib/core/src/link.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rome/tools path: /crates/rome_js_formatter/src/ts/any/type_member.rs //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file. use crate::prelude::*; use rome_js_syntax::AnyTsTypeMember; #[derive(Debug, Clone, Default)] pub(crate) struct Forma...
code_fim
hard
{ "lang": "rust", "repo": "rome/tools", "path": "/crates/rome_js_formatter/src/ts/any/type_member.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>> node.format().fmt(f), AnyTsTypeMember::TsSetterSignatureTypeMember(node) => node.format().fmt(f), AnyTsTypeMember::TsIndexSignatureTypeMember(node) => node.format().fmt(f), AnyTsTypeMember::JsBogusMember(node) => node.format().fmt(f), } } }<|fim_prefix|>//...
code_fim
hard
{ "lang": "rust", "repo": "rome/tools", "path": "/crates/rome_js_formatter/src/ts/any/type_member.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hisland/my-learn path: /rust-programming-2/00-common-programming-concepts/33-let-if-type-not-match-on-every-branch-got-error.rs fn main() { let x = 90; let bb = if x >= 90 { 'a' } else if x <|fim_suffix|>' }; println!("grade: {}", bb); }<|fim_middle|>>= 60 { 3...
code_fim
easy
{ "lang": "rust", "repo": "hisland/my-learn", "path": "/rust-programming-2/00-common-programming-concepts/33-let-if-type-not-match-on-every-branch-got-error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>>= 60 { 3 } else { 'c' }; println!("grade: {}", bb); }<|fim_prefix|>// repo: hisland/my-learn path: /rust-programming-2/00-common-programming-concepts/33-let-if-type-not-match-on-every-branch-got-error.rs fn main() { let x = 90; let bb = <|fim_middle|>if x >= 90 { ...
code_fim
easy
{ "lang": "rust", "repo": "hisland/my-learn", "path": "/rust-programming-2/00-common-programming-concepts/33-let-if-type-not-match-on-every-branch-got-error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn on_fail_message(message: &OscMessage) -> ScClientResult<()> { if let Some(args) = message.args.as_ref() { if let OscType::String(addr) = args.clone().remove(0) { error!("Server responses with error:\n\t{}, ", addr); } if let OscType::Strin...
code_fim
hard
{ "lang": "rust", "repo": "discordance/sc_client", "path": "/src/osc_server.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn remove_responders_for_address(&mut self, address: &str) -> ScClientResult<()> { Ok(self .responders .write() .map_err(|e| OscServerError::RemoveResponder(format!("{}", e)))? .retain(|ref responder| responder.get_address() != address.to_str...
code_fim
hard
{ "lang": "rust", "repo": "discordance/sc_client", "path": "/src/osc_server.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: discordance/sc_client path: /src/osc_server.rs use crate::ScClientResult; use failure::Fail; use log::{debug, error, warn}; use rosc::{decoder, encoder, OscBundle, OscError, OscMessage, OscPacket, OscType}; use std::net::{SocketAddr, SocketAddrV4, UdpSocket}; use std::str::FromStr; use std::sync...
code_fim
hard
{ "lang": "rust", "repo": "discordance/sc_client", "path": "/src/osc_server.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uwe-app/bracket path: /src/registry.rs //! Primary entry point for compiling and rendering templates. use serde::Serialize; #[cfg(feature = "fs")] use std::ffi::OsStr; #[cfg(feature = "fs")] use std::path::Path; use crate::{ escape::{self, EscapeFn}, helper::{HandlerRegistry, HelperReg...
code_fim
hard
{ "lang": "rust", "repo": "uwe-app/bracket", "path": "/src/registry.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Load all the files in a target directory that match the /// given extension. /// /// The generated name is the file stem; ie, the name of the file /// once the extension has been removed. /// /// Requires the `fs` feature. #[cfg(feature = "fs")] pub fn read_dir<P: A...
code_fim
hard
{ "lang": "rust", "repo": "uwe-app/bracket", "path": "/src/registry.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Mutable reference to the templates. pub fn templates_mut(&mut self) -> &mut Templates { &mut self.templates } /// Get a named template. #[deprecated(since = "0.9.29", note = "Use get() instead.")] pub fn get_template(&self, name: &str) -> Option<&Template> { se...
code_fim
hard
{ "lang": "rust", "repo": "uwe-app/bracket", "path": "/src/registry.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Utkarsh-Patel-13/Simple-Notes-API path: /src/schema.rs table! { notes (id) { id -> Nullable<Integer>, title -> Varchar, body -><|fim_suffix|> modified_on -> Nullable<Timestamp>, } }<|fim_middle|> Text, created_at -> Nullable<Timestamp>,
code_fim
easy
{ "lang": "rust", "repo": "Utkarsh-Patel-13/Simple-Notes-API", "path": "/src/schema.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Text, created_at -> Nullable<Timestamp>, modified_on -> Nullable<Timestamp>, } }<|fim_prefix|>// repo: Utkarsh-Patel-13/Simple-Notes-API path: /src/schema.rs table! { notes (id) { id -> Nullable<I<|fim_middle|>nteger>, title -> Varchar, body ->
code_fim
easy
{ "lang": "rust", "repo": "Utkarsh-Patel-13/Simple-Notes-API", "path": "/src/schema.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> modified_on -> Nullable<Timestamp>, } }<|fim_prefix|>// repo: Utkarsh-Patel-13/Simple-Notes-API path: /src/schema.rs table! { notes (id) { id -> Nullable<I<|fim_middle|>nteger>, title -> Varchar, body -> Text, created_at -> Nullable<Timestamp>,
code_fim
medium
{ "lang": "rust", "repo": "Utkarsh-Patel-13/Simple-Notes-API", "path": "/src/schema.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jhgoodwin/ssvm-nodejs-starter path: /src/lib.rs use wasm_bindgen::prelude::*; use std::convert::TryFrom; use lipsum::{lipsum as lipsum_implementation, lipsum_title as lipsum_title_implementation}; #[wasm_bindgen] pub fn say(s: &str) -> String { println!("The Rust function say() received {}", ...
code_fim
medium
{ "lang": "rust", "repo": "jhgoodwin/ssvm-nodejs-starter", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[wasm_bindgen] pub fn lipsum(i: i32) -> String { let num_words = match usize::try_from(i) { Ok(x) => x, _ => 0, }; return lipsum_implementation(num_words); } #[wasm_bindgen] pub fn lipsum_title() -> String { return lipsum_title_implementation(); }<|fim_prefix|>// repo: jhgoodwin/ssvm-nod...
code_fim
medium
{ "lang": "rust", "repo": "jhgoodwin/ssvm-nodejs-starter", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let lit = match ty { None => ast::LitFloatUnsuffixed(s), Some (ty) => ast::LitFloat(s, ty) }; MacExpr::new(cx.expr_lit(sp, lit)) } struct Ident { ident: ast::Ident, span: Span } fn parse_tts(cx: &ExtCtxt, tts: &[ast::TokenTree]) -> (P<ast::Expr>, Option<I...
code_fim
hard
{ "lang": "rust", "repo": "steveklabnik/hexfloat", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let s = match expr.node { // expression is a literal ast::ExprLit(ref lit) => match lit.node { // string literal ast::LitStr(ref s, _) => { s.clone() } _ => { cx.span_err(expr.span, "unsupported literal in ...
code_fim
hard
{ "lang": "rust", "repo": "steveklabnik/hexfloat", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: steveklabnik/hexfloat path: /src/lib.rs // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache....
code_fim
hard
{ "lang": "rust", "repo": "steveklabnik/hexfloat", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ryo97321/rust-workspace path: /yukicoder/level1/no211.rs fn getline() -> String { let mut __ret = String::new(); std::io::stdin().read_line(&mut __ret).ok(); return __ret; } fn main() { <|fim_suffix|> for i in 0..all_product_pattern.len() { if all_product_pattern[i] == k ...
code_fim
hard
{ "lang": "rust", "repo": "ryo97321/rust-workspace", "path": "/yukicoder/level1/no211.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let dice_prime_number = vec![2, 3, 5, 7, 11, 13]; let dice_number_of_composites = vec![4, 6, 8, 9, 10, 12]; let mut all_product_pattern: Vec<i32> = Vec::new(); for i in 0..dice_prime_number.len() { for j in 0..dice_number_of_composites.len() { let product = dice_prime...
code_fim
medium
{ "lang": "rust", "repo": "ryo97321/rust-workspace", "path": "/yukicoder/level1/no211.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut count = 0; for i in 0..all_product_pattern.len() { if all_product_pattern[i] == k { count += 1; } } let probability = count as f64 / 36.0; println!("{}", probability); }<|fim_prefix|>// repo: ryo97321/rust-workspace path: /yukicoder/level1/no211...
code_fim
hard
{ "lang": "rust", "repo": "ryo97321/rust-workspace", "path": "/yukicoder/level1/no211.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jgchk/rate-our-music path: /server/src/sql/release_type.rs use crate::{errors::Error, model::release_type::ReleaseType}; use sqlx::PgPool; #[derive(Debug, Clone)] pub struct ReleaseTypeDatabase<'a>(&'a PgPool); <|fim_suffix|> pub async fn get_all(&self) -> Result<Vec<ReleaseType>, Error> { ...
code_fim
medium
{ "lang": "rust", "repo": "jgchk/rate-our-music", "path": "/server/src/sql/release_type.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> ReleaseTypeDatabase<'a> { pub fn new(pool: &'a PgPool) -> Self { Self(pool) } pub async fn get_all(&self) -> Result<Vec<ReleaseType>, Error> { sqlx::query_as!(ReleaseType, "SELECT * FROM release_type") .fetch_all(self.0) .await .map...
code_fim
medium
{ "lang": "rust", "repo": "jgchk/rate-our-music", "path": "/server/src/sql/release_type.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub async fn get_all(&self) -> Result<Vec<ReleaseType>, Error> { sqlx::query_as!(ReleaseType, "SELECT * FROM release_type") .fetch_all(self.0) .await .map_err(Error::from) } }<|fim_prefix|>// repo: jgchk/rate-our-music path: /server/src/sql/release_type...
code_fim
medium
{ "lang": "rust", "repo": "jgchk/rate-our-music", "path": "/server/src/sql/release_type.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Takasakiii/KurosawaDia path: /src/database/functions/users.rs use mysql::{params, prelude::Queryable}; use serenity::{model::{prelude::User, id::UserId}, framework::standard::CommandResult}; use crate::database::{get_database_connection, models::user::DbUser}; use super::DbResult; pub ...
code_fim
hard
{ "lang": "rust", "repo": "Takasakiii/KurosawaDia", "path": "/src/database/functions/users.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn set_enable_cr(discord_id: UserId, value: bool) -> CommandResult { let mut conn = get_database_connection().await?; conn.exec_drop(r" UPDATE users SET enable_cr = :enable_cr WHERE discord_id = :discord_id ", params! { "enable_cr" => value, ...
code_fim
hard
{ "lang": "rust", "repo": "Takasakiii/KurosawaDia", "path": "/src/database/functions/users.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn get_db_user(discord_id: UserId) -> DbResult<DbUser> { let mut conn = get_database_connection().await?; let mut result: Vec<DbUser> = conn.exec_map(r" SELECT * FROM users u WHERE u.discord_id = :discord_id LIMIT 1 ", params! { "discord_id" =...
code_fim
hard
{ "lang": "rust", "repo": "Takasakiii/KurosawaDia", "path": "/src/database/functions/users.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }