text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>s("passivetotal.org") { //! Ok(response) => response, //! _ => panic!("Something bad happened in the JSON response"), //! }; //! ``` //! //! [1]: ./config/index.html //! [2]: ./client/struct.PTClient.html //! [3]: ./response/index.html //! [4]: https://api.passivetotal.org/api/docs/ extern crate ...
code_fim
hard
{ "lang": "rust", "repo": "passivetotal/rust_api", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VETER1309/identity.rs path: /identity_core/src/vc/types/credential_status.rs use core::convert::TryFrom; use derive_builder::Builder; use serde::{Deserialize, Serialize}; use crate::{ common::{Object, OneOrMany, Url}, error::Error, }; /// Information used to determine the current statu...
code_fim
medium
{ "lang": "rust", "repo": "VETER1309/identity.rs", "path": "/identity_core/src/vc/types/credential_status.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] #[should_panic = "`id` must be initialized"] fn test_builder_missing_id() { CredentialStatusBuilder::default() .types("my-type".to_string()) .build() .unwrap(); } #[test] #[should_panic...
code_fim
hard
{ "lang": "rust", "repo": "VETER1309/identity.rs", "path": "/identity_core/src/vc/types/credential_status.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>crate fn wf_clause_for_tuple(tcx: TyCtxt<'_>, arity: usize) -> Clauses<'_> { let type_list = generic_types::type_list(tcx, arity); let tuple_ty = tcx.mk_ty(ty::Tuple(type_list)); let sized_trait = match tcx.lang_items().sized_trait() { Some(def_id) => def_id, None => return ty...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_traits/chalk_context/program_clauses/primitive.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/librustc_traits/chalk_context/program_clauses/primitive.rs use rustc::traits::{ WellFormed, DomainGoal, GoalKind, Clause, Clauses, ProgramClause, ProgramClauseCategory, }; use rustc::ty::{self, TyCtxt}; use rustc::hir; use ru...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_traits/chalk_context/program_clauses/primitive.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let expected = normalized; assert!( (result - expected).abs() < 0.3, "Result is {0}, expected {1}", result, expected); } #[test] fn convolution_sh_nontrivial() { let mut rng = rand::thread_rng(); let func = |x:f32,y:f32,z:f32| x*x + y*z; let sh = SHFuncApproximation::from_function(func, &mu...
code_fim
hard
{ "lang": "rust", "repo": "zigaosolin/light-probes-SH", "path": "/src/spherical_harmonics.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let sh = SHFuncApproximation::from_function(func, &mut rng, 10000); // Convoluting constant function with constant is the same let result = sh.convolution(&sh); let normalized = integrate_real_space(|x,y,z| { let value = func(x,y,z); value*value }, &mut rng, 10000); let expected = normalize...
code_fim
hard
{ "lang": "rust", "repo": "zigaosolin/light-probes-SH", "path": "/src/spherical_harmonics.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zigaosolin/light-probes-SH path: /src/spherical_harmonics.rs use rand::Rng; use std::f32::consts::PI; use crate::spherical::Direction; // Spherical harmonic coefficients. You can represent any function // on sphere using these structure (to certain degree). Smooth // functions of angle are rep...
code_fim
hard
{ "lang": "rust", "repo": "zigaosolin/light-probes-SH", "path": "/src/spherical_harmonics.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bozbez/nessie path: /src/chain.rs use crate::clone_in::CloneIn; use crate::counter::Counter; use crate::unigram; use bumpalo::Bump; use hashbrown::HashMap; use std::{cell::UnsafeCell, cmp::min, hash::Hash, mem}; pub type Unigram = String; pub type Bigram = (String, String); pub type TopicMap...
code_fim
hard
{ "lang": "rust", "repo": "bozbez/nessie", "path": "/src/chain.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.chain .entry(( BUnigram::from_slice_in(words[i], pool), BUnigram::from_slice_in(words[i + 1], pool), )) .or_insert(BHashMap::with_hasher_in(self.hasher.clone(), pool)) .entry(topic_bigr...
code_fim
hard
{ "lang": "rust", "repo": "bozbez/nessie", "path": "/src/chain.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn p1(){ let input = read_file_to_string("./src/d1.txt"); println!("{}", find_floor(input.as_str())); } fn p2(){ let input = read_file_to_string("./src/d1.txt"); println!("{}",find_basement(input.as_str())); }<|fim_prefix|>// repo: MJGTwo/adventofcode path: /15/rust/src/d1.rs use crate::...
code_fim
hard
{ "lang": "rust", "repo": "MJGTwo/adventofcode", "path": "/15/rust/src/d1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{} == {}", find_floor(test0), answer0); println!("{} == {}", find_floor(test1), answer1); } fn p1(){ let input = read_file_to_string("./src/d1.txt"); println!("{}", find_floor(input.as_str())); } fn p2(){ let input = read_file_to_string("./src/d1.txt"); println!("{}",fi...
code_fim
medium
{ "lang": "rust", "repo": "MJGTwo/adventofcode", "path": "/15/rust/src/d1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MJGTwo/adventofcode path: /15/rust/src/d1.rs use crate::util::read_file_to_string; pub fn run() { ex(); p1(); p2(); } fn find_floor( seq: &str) -> usize { <|fim_suffix|> match mv { '(' => 1, ')' => -1, _ => 0 } } fn find_basement(seq: &str) -> usize ...
code_fim
medium
{ "lang": "rust", "repo": "MJGTwo/adventofcode", "path": "/15/rust/src/d1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sharksforarms/deku path: /deku-derive/src/macros/mod.rs use crate::Num; use proc_macro2::{Ident, Span, TokenStream}; use quote::{quote, ToTokens}; use syn::parse::Parser; use syn::punctuated::Punctuated; use syn::spanned::Spanned; use syn::token::Comma; pub(crate) mod deku_read; pub(crate) mod ...
code_fim
hard
{ "lang": "rust", "repo": "sharksforarms/deku", "path": "/deku-derive/src/macros/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> endian: Option<&syn::LitStr>, bits: Option<&Num>, bytes: Option<&Num>, ctx: Option<&Punctuated<syn::Expr, syn::token::Comma>>, ) -> syn::Result<TokenStream> { let crate_ = get_crate_name(); let endian = endian.map(gen_endian_from_str).transpose()?; let bits = bits.map(|n| quote...
code_fim
hard
{ "lang": "rust", "repo": "sharksforarms/deku", "path": "/deku-derive/src/macros/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thomwiggers/lpn path: /src/codes/guava/guava_24_14.rs [4105] map.insert(580, &[8201]); // 580 => [8201] map.insert(224, &[16393]); // 224 => [16393] map.insert(214, &[32777]); // 214 => [32777] map.insert(336, &[65545]); // 336 => ...
code_fim
hard
{ "lang": "rust", "repo": "thomwiggers/lpn", "path": "/src/codes/guava/guava_24_14.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>insert(614, &[163842]); // 614 => [163842] map.insert(167, &[557058]); // 167 => [557058] map.insert(425, &[2129922]); // 425 => [2129922] map.insert(852, &[4227074]); // 852 => [4227074] map.insert(684, &[8421378]); // 684 => [8421378] ...
code_fim
hard
{ "lang": "rust", "repo": "thomwiggers/lpn", "path": "/src/codes/guava/guava_24_14.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thomwiggers/lpn path: /src/codes/guava/guava_24_14.rs ); // 402 => [549] map.insert(354, &[1061]); // 354 => [1061] map.insert(549, &[2085]); // 549 => [2085] map.insert(940, &[4194341]); // 940 => [4194341] map.insert(596, &[838864...
code_fim
hard
{ "lang": "rust", "repo": "thomwiggers/lpn", "path": "/src/codes/guava/guava_24_14.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>e Bus Connected to APORT1Y is Requested"] #[inline(always)] pub fn aport1yreq(&self) -> APORT1YREQ_R { APORT1YREQ_R::new(((self.bits >> 3) & 0x01) != 0) } }<|fim_prefix|>// repo: pablo-mansanet-bluefruit/efm32gg11b path: /src/idac0/aportreq.rs #[doc = "Reader of register APORTREQ"] pub type R = c...
code_fim
medium
{ "lang": "rust", "repo": "pablo-mansanet-bluefruit/efm32gg11b", "path": "/src/idac0/aportreq.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pablo-mansanet-bluefruit/efm32gg11b path: /src/idac0/aportreq.rs #[doc = "Reader of register APORTREQ"] pub type R = crate::R<u32, super::APORTREQ>; #[doc = "Reader of field `APORT1XREQ`"] pub type APORT1XREQ_R = crate::R<bool, bool>; #[doc = "Reader of field `APORT1YREQ`"] pub type APORT1YREQ_R...
code_fim
medium
{ "lang": "rust", "repo": "pablo-mansanet-bluefruit/efm32gg11b", "path": "/src/idac0/aportreq.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jdmichaud/rust path: /exercises/pythagorean-triplet/src/lib.rs pub fn find() -> Option<u32> { let i: u32 = 0; let j: u32 = 0; let k: u32 <|fim_suffix|> if (i + j + k == 1000) && (i * i + j * j == k * k) { println!("{:?}", i+j+k); return Some(i * j * k); } ...
code_fim
medium
{ "lang": "rust", "repo": "jdmichaud/rust", "path": "/exercises/pythagorean-triplet/src/lib.rs", "mode": "psm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_suffix|> if (i + j + k == 1000) && (i * i + j * j == k * k) { println!("{:?}", i+j+k); return Some(i * j * k); } } } } None }<|fim_prefix|>// repo: jdmichaud/rust path: /exercises/pythagorean-triplet/src/lib.rs pub fn find() -> Option<u32> { let i: u32 = 0; let j: u...
code_fim
medium
{ "lang": "rust", "repo": "jdmichaud/rust", "path": "/exercises/pythagorean-triplet/src/lib.rs", "mode": "spm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JimFawcett/RustBasicDemos path: /code_structure_demo/component_a/examples/demo.rs // demo.rs - demo ComponentA extern crate component_a; // mod t_comp_a; // use t_comp_a::{TCompA}; use component_a::{*}; use display::{*}; <|fim_suffix|> let mut a = ComponentA::new(); a.set_msg("msg from a");...
code_fim
easy
{ "lang": "rust", "repo": "JimFawcett/RustBasicDemos", "path": "/code_structure_demo/component_a/examples/demo.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut a = ComponentA::new(); a.set_msg("msg from a"); a.do_work(); let mut a2 = get_instance(); a2.set_msg("msg from a2"); print!("\n {}", a2.get_msg()); putline(); }<|fim_prefix|>// repo: JimFawcett/RustBasicDemos path: /code_structure_demo/component_a/examples/demo.rs // demo.rs - demo...
code_fim
easy
{ "lang": "rust", "repo": "JimFawcett/RustBasicDemos", "path": "/code_structure_demo/component_a/examples/demo.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rotoclone/Rocket path: /contrib/lib/src/templates/fairing.rs use std::error::Error; use crate::templates::{DEFAULT_TEMPLATE_DIR, Context, Engines}; use rocket::{Rocket, Build, Orbit}; use rocket::fairing::{self, Fairing, Info, Kind}; pub(crate) use self::context::ContextManager; type Callbac...
code_fim
hard
{ "lang": "rust", "repo": "rotoclone/Rocket", "path": "/contrib/lib/src/templates/fairing.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let path = match configured_dir { Ok(dir) => dir, Err(e) if e.missing() => DEFAULT_TEMPLATE_DIR.into(), Err(e) => { rocket::config::pretty_print_error(e); return Err(rocket); } }; match Context::initia...
code_fim
hard
{ "lang": "rust", "repo": "rotoclone/Rocket", "path": "/contrib/lib/src/templates/fairing.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn compile(filepaths: &[impl AsRef<str>], fbb: &mut flatbuffers::FlatBufferBuilder) { let arena = Arena::new(); let (schema_files, declarations) = load::load(&arena, filepaths); let (symbols, schema_files) = resolve::resolve(schema_files, declarations); write::write_compilation(fbb, &s...
code_fim
hard
{ "lang": "rust", "repo": "CasperN/flatcfe", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CasperN/flatcfe path: /src/lib.rs #![feature(is_sorted)] pub use compilation_generated::flatbuffers_compiler as flatc; use load::*; use typed_arena::Arena; <|fim_suffix|>/* TODO: - Understand special annotations - id, deprecated, required, key - id needs to be inferred. - Magic type...
code_fim
medium
{ "lang": "rust", "repo": "CasperN/flatcfe", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aerospike/aerospike-client-rust path: /src/query/mod.rs // Copyright 2015-2018 Aerospike, Inc. // // Portions may be licensed to Aerospike, Inc. under one or more contributor // license agreements. // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file...
code_fim
medium
{ "lang": "rust", "repo": "aerospike/aerospike-client-rust", "path": "/src/query/mod.rs", "mode": "psm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_suffix|>pub use self::filter::Filter; pub use self::index_types::{CollectionIndexType, IndexType}; pub use self::recordset::Recordset; pub use self::statement::Statement; pub use self::udf::UDFLang; mod filter; mod index_types; mod recordset; mod statement; mod udf;<|fim_prefix|>// repo: aerospike/aerospike-clie...
code_fim
medium
{ "lang": "rust", "repo": "aerospike/aerospike-client-rust", "path": "/src/query/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_suffix|>pub fn format_duration(secs: i64) -> String { let negative = if secs < 0 { "-" } else { "" }; let secs = if secs < 0 { -secs } else { secs }; let mins = secs / SECS_IN_MIN; let secs = secs - (mins * SECS_IN_MIN); // truncate mins to 2 characters, because what song is >99 minutes? ...
code_fim
medium
{ "lang": "rust", "repo": "nfvelten/roja", "path": "/roja/src/util/format_duration.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // truncate mins to 2 characters, because what song is >99 minutes? let mut mins = mins.to_string(); mins.truncate(2); format!("{}{}:{}", negative, mins, pad_zero(secs)) }<|fim_prefix|>// repo: nfvelten/roja path: /roja/src/util/format_duration.rs const SECS_IN_MIN: i64 = 60; fn pad_zer...
code_fim
hard
{ "lang": "rust", "repo": "nfvelten/roja", "path": "/roja/src/util/format_duration.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nfvelten/roja path: /roja/src/util/format_duration.rs const SECS_IN_MIN: i64 = 60; fn pad_zero(unit: i64) -> String { if unit < 10 { format!("0{}", unit) } else { unit.to_string() } } <|fim_suffix|> // truncate mins to 2 characters, because what song is >99 minut...
code_fim
hard
{ "lang": "rust", "repo": "nfvelten/roja", "path": "/roja/src/util/format_duration.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> const DATA: &str = "16 10 15 5 1 11 7 19 6 12 4"; const DATA2: &str = "28 33 18 42 31 14 46 20 48 47 24 23 49 45 19 38 39 11 1 32 25 35 8 17 7 9 4 2 34 10 3"; #[test] fn test_part1() { let v = parse(DATA); assert_eq!(part1(&v), 35); let v = parse(DATA2); a...
code_fim
hard
{ "lang": "rust", "repo": "dcreemer/adventofcode", "path": "/2020/rust/ten/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_part1() { let v = parse(DATA); assert_eq!(part1(&v), 35); let v = parse(DATA2); assert_eq!(part1(&v), 220); } #[test] fn test_part2() { let v = parse(DATA); assert_eq!(part2(&v), 8); let v = parse(DATA2); ...
code_fim
hard
{ "lang": "rust", "repo": "dcreemer/adventofcode", "path": "/2020/rust/ten/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dcreemer/adventofcode path: /2020/rust/ten/src/main.rs // solution to // https://adventofcode.com/2020/day/10 use std::fs; fn parse(data: &str) -> Vec<i64> { data.lines().map(|l| l.parse::<i64>().unwrap()).collect() } fn part1(input: &Vec<i64>) -> i64 { let mut data = input.clone(); ...
code_fim
hard
{ "lang": "rust", "repo": "dcreemer/adventofcode", "path": "/2020/rust/ten/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>nsor4d; mod tensor5d; mod tensor6d; mod zeros;<|fim_prefix|>// repo: NajmusSaqib/rustgym path: /tfrs/src/creation/mod.rs mod clone; mod concat; mod diag; mod eye; mod<|fim_middle|> fill; mod linspace; mod ones; mod scalar; mod tensor1d; mod tensor2d; mod tensor3d; mod te
code_fim
medium
{ "lang": "rust", "repo": "NajmusSaqib/rustgym", "path": "/tfrs/src/creation/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NajmusSaqib/rustgym path: /tfrs/src/creation/mod.rs mod clone; mod concat; mod diag; mod eye; mod fill; mod linspace; mod ones; mod scalar; mod<|fim_suffix|>nsor4d; mod tensor5d; mod tensor6d; mod zeros;<|fim_middle|> tensor1d; mod tensor2d; mod tensor3d; mod te
code_fim
easy
{ "lang": "rust", "repo": "NajmusSaqib/rustgym", "path": "/tfrs/src/creation/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let rv64_code = gen_code(rv64_asm); let x64_code = gen_code(x64_asm); macos_unimplemented(quote! { #[cfg(target_arch = "riscv64")] { #rv64_code } #[cfg(target_arch = "x86_64")] { #x64_code } #[cfg(not(any(target_arch = "riscv64", target_arch = "x86_64"))...
code_fim
hard
{ "lang": "rust", "repo": "rcore-os/arceos", "path": "/crates/percpu_macros/src/arch.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let (x64_asm, x64_reg) = if ["bool", "u8"].contains(&ty_str.as_str()) { ( "mov byte ptr gs:[offset {VAR}], {0}".into(), format_ident!("reg_byte"), ) } else { let (x64_mod, x64_ptr) = match ty_str.as_str() { "u16" => ("x", "word"), ...
code_fim
hard
{ "lang": "rust", "repo": "rcore-os/arceos", "path": "/crates/percpu_macros/src/arch.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rcore-os/arceos path: /crates/percpu_macros/src/arch.rs use quote::{format_ident, quote}; use syn::{Ident, Type}; fn macos_unimplemented(item: proc_macro2::TokenStream) -> proc_macro2::TokenStream { quote! { #[cfg(not(target_os = "macos"))] { #item } #[cfg(target_os ...
code_fim
hard
{ "lang": "rust", "repo": "rcore-os/arceos", "path": "/crates/percpu_macros/src/arch.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FauxFaux/ureq path: /src/request.rs use lazy_static::lazy_static; use qstring::QString; use std::io::Read; use std::sync::Arc; #[cfg(feature = "json")] use super::SerdeValue; lazy_static! { static ref URL_BASE: Url = { Url::parse("http://localhost/").expect("Failed to parse URL_BAS...
code_fim
hard
{ "lang": "rust", "repo": "FauxFaux/ureq", "path": "/src/request.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Set a header field. /// /// ``` /// let r = ureq::get("/my_page") /// .set("X-API-Key", "foobar") /// .set("Accept", "text/plain") /// .call(); /// /// if r.ok() { /// println!("yay got {}", r.into_string().unwrap()); /// } else { /// ...
code_fim
hard
{ "lang": "rust", "repo": "FauxFaux/ureq", "path": "/src/request.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Tells if the header has been set. /// /// ``` /// let req = ureq::get("/my_page") /// .set("X-API-Key", "foobar") /// .build(); /// assert_eq!(true, req.has("x-api-Key")); /// ``` pub fn has<'a>(&self, name: &'a str) -> bool { has_header(&self.header...
code_fim
hard
{ "lang": "rust", "repo": "FauxFaux/ureq", "path": "/src/request.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut fuel: Vec<i64> = input .iter() .map(|m| m.parse::<i64>().unwrap()) .collect(); let mut total_fuel: i64 = 0; while !fuel.is_empty() { fuel = fuel.iter() .map(|m| (m / 3) - 2) .collect(); fuel.retain(|&el| el > 0); ...
code_fim
medium
{ "lang": "rust", "repo": "zeroDivisible/advent-of-code", "path": "/2019/day_01/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn it_returs_value_for_part_1() { let input = lines_from_file("input/input.txt"); assert_eq!(part_01(&input), 3342050); } #[test] fn it_returns_value_for_part_2() { let input = lines_from_file("input/input.txt"); assert_eq!(part_02(&input), 50...
code_fim
hard
{ "lang": "rust", "repo": "zeroDivisible/advent-of-code", "path": "/2019/day_01/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zeroDivisible/advent-of-code path: /2019/day_01/src/main.rs use std::{ fs::File, io::{prelude::*, BufReader}, path::Path, }; fn lines_from_file(filename: impl AsRef<Path>) -> Vec<String> { let file = File::open(filename).expect("no such file"); let buf = BufReader::new(file)...
code_fim
medium
{ "lang": "rust", "repo": "zeroDivisible/advent-of-code", "path": "/2019/day_01/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn update_token(&mut self, auth_token: AuthToken) { self.auth_token = Some(auth_token) } pub async fn send_request(&self, bytes: Vec<u8>) -> Result<Vec<u8>, ProviderClientError> { let mut socket = tokio::net::TcpStream::connect(self.provider_network_address).await?; ...
code_fim
hard
{ "lang": "rust", "repo": "narodnik/nym", "path": "/common/clients/provider-client/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> InvalidRequestError, InvalidResponseError, InvalidResponseLengthError, } impl From<io::Error> for ProviderClientError { fn from(_: Error) -> Self { use ProviderClientError::*; NetworkError } } impl From<ProviderResponseError> for ProviderClientError { fn from(err...
code_fim
hard
{ "lang": "rust", "repo": "narodnik/nym", "path": "/common/clients/provider-client/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: narodnik/nym path: /common/clients/provider-client/src/lib.rs use futures::io::Error; use log::info; use sfw_provider_requests::requests::{ProviderRequest, PullRequest, RegisterRequest}; use sfw_provider_requests::responses::{ ProviderResponse, ProviderResponseError, PullResponse, RegisterRe...
code_fim
hard
{ "lang": "rust", "repo": "narodnik/nym", "path": "/common/clients/provider-client/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match instruction { N(distance) => self.waypoint.y += distance, S(distance) => self.waypoint.y -= distance, E(distance) => self.waypoint.x += distance, W(distance) => self.waypoint.x -= distance, L(90) | R(270) => { let n...
code_fim
hard
{ "lang": "rust", "repo": "jhungerford/adventofcode-2020", "path": "/day12/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let instructions = load_instructions("sample.txt"); let mut ship = Ship::new(); for instruction in instructions { ship.run(&instruction); } assert_eq!(25, ship.distance()); } #[test] fn run() { let mut ship = Ship::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "jhungerford/adventofcode-2020", "path": "/day12/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jhungerford/adventofcode-2020 path: /day12/src/main.rs use std::fs::File; use std::io::{BufRead, BufReader}; use std::str::FromStr; use crate::Heading::{East, North, South, West}; use crate::Instruction::{E, F, L, N, R, S, W}; #[derive(Debug, Eq, PartialEq)] struct ParseErr {} #[derive(Debug,...
code_fim
hard
{ "lang": "rust", "repo": "jhungerford/adventofcode-2020", "path": "/day12/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shamatar/eip2537_go_bindings path: /build.rs use std::process::Command; use std::env; // use std::path::Path; #[cfg(feature = "adx_backend")] static BUILD_SCRIPT_NAME: &'static str = "make_adx.sh"; #[cfg(feature = "asm_backend")] static BUILD_SCRIPT_NAME: &'static str = "make_asm.sh"; #[cfg(a...
code_fim
hard
{ "lang": "rust", "repo": "shamatar/eip2537_go_bindings", "path": "/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Command::new("touch").args(&["build.rs"]).status().unwrap(); // Command::new("touch").args(&[BUILD_SCRIPT_NAME]).status().unwrap(); Command::new("touch").args(&["make_asm.sh"]).status().unwrap(); Command::new("touch").args(&["make_adx.sh"]).status().unwrap(); Command::new("touch").args...
code_fim
hard
{ "lang": "rust", "repo": "shamatar/eip2537_go_bindings", "path": "/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn end(self) -> StrictCommandBuffer { scope!("vk::EndCommandBuffer"); unsafe { self.device.end_command_buffer(self.handle).unwrap(); } StrictCommandBuffer { handle: self.handle, // commands: self.commands, } } ...
code_fim
hard
{ "lang": "rust", "repo": "farnoy/renderer", "path": "/src/renderer/device/commands.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: farnoy/renderer path: /src/renderer/device/commands.rs use std::{marker::PhantomData, ops::Deref}; use ash::vk; #[cfg(debug_assertions)] use hashbrown::HashSet; use profiling::scope; use super::{sync::Fence, Device}; pub(crate) struct StrictCommandPool { handle: vk::CommandPool, #[cfg...
code_fim
hard
{ "lang": "rust", "repo": "farnoy/renderer", "path": "/src/renderer/device/commands.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> debug_assert_eq!( self.handle, vk::CommandPool::null(), "StrictCommandPool not destroyed before Drop" ); } } impl<'p> StrictRecordingCommandBuffer<'p> { #[cfg(feature = "vk_names")] pub(crate) fn debug_marker_around<'a>(&'a self, name: &str,...
code_fim
hard
{ "lang": "rust", "repo": "farnoy/renderer", "path": "/src/renderer/device/commands.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: loriopatrick/cartoon-upsample path: /src/imbin.rs pub struct ImBin { pub data: Vec<bool>, pub width: usize, pub height: usize, pub wrow: usize, } <|fim_suffix|> pub fn clear(&mut self) { for i in 0..self.data.len() { self.data[i] = false; } } ...
code_fim
hard
{ "lang": "rust", "repo": "loriopatrick/cartoon-upsample", "path": "/src/imbin.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn clear(&mut self) { for i in 0..self.data.len() { self.data[i] = false; } } }<|fim_prefix|>// repo: loriopatrick/cartoon-upsample path: /src/imbin.rs pub struct ImBin { pub data: Vec<bool>, pub width: usize, pub height: usize, pub wrow: usize, } ...
code_fim
hard
{ "lang": "rust", "repo": "loriopatrick/cartoon-upsample", "path": "/src/imbin.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let n = dst.len(); if n <= self.len() { let (a, b) = self.split_at(n); if n == 1 { dst[0] = a[0]; } else { dst.copy_from_slice(a); } *self = b; Ok(()) } else { Err(Re...
code_fim
hard
{ "lang": "rust", "repo": "stellar/slingshot", "path": "/readerwriter/src/reader.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stellar/slingshot path: /readerwriter/src/reader.rs use std::error::Error; use std::fmt::{Display, Formatter}; /// Error kinds returns by the reader. #[derive(Debug)] pub enum ReadError { InsufficientBytes, TrailingBytes, InvalidFormat, Custom(Box<dyn Error + Send + Sync>), } i...
code_fim
hard
{ "lang": "rust", "repo": "stellar/slingshot", "path": "/readerwriter/src/reader.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn test() { let subject = Proxy { real: RealSubject {} }; assert_eq!("pre:real:after", subject.operation().as_str()) } }<|fim_prefix|>// repo: iCodeIN/patterns_rs path: /src/proxy/mod.rs //!# 代理模式 //! //!代...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/patterns_rs", "path": "/src/proxy/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/patterns_rs path: /src/proxy/mod.rs //!# 代理模式 //! //!代理模式用于延迟处理操作或者在进行实际操作前后进行其它处理。 //! //!## 代理模式的常见用法有 //! //!* 虚代理 //!* COW代理 //!* 远程代理 //!* 保护代理 //!* Cache 代理 //!* 防火墙代理 //!* 同步代理 //!* 智能指引 //! <|fim_suffix|>impl Subject for Proxy { fn operation(&self) -> String { format...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/patterns_rs", "path": "/src/proxy/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> format!("pre:{}:after", self.real.operation()) } } #[cfg(test)] mod tests { use super::*; #[test] fn test() { let subject = Proxy { real: RealSubject {} }; assert_eq!("pre:real:after", subject.operation().as_str()) } }<|fim_prefix|>// repo:...
code_fim
medium
{ "lang": "rust", "repo": "iCodeIN/patterns_rs", "path": "/src/proxy/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nahkh/fluid-dynamics path: /src/simulation.rs pub mod world { use std::collections::{HashMap, HashSet}; use std::mem; use std::fmt; #[derive(PartialEq, Eq, Hash, Clone, Copy)] pub struct Position { x: i32, y: i32, } impl Position { pub fn new...
code_fim
hard
{ "lang": "rust", "repo": "nahkh/fluid-dynamics", "path": "/src/simulation.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub struct Simulation { pub grid: Grid, scale: f64, blocked_cells: HashSet<Position>, } impl Simulation { pub fn new(width: i32, height: i32, image: Vec<u8>) -> Simulation { let grid = Grid::new(width, height); let mut blocked_cells = H...
code_fim
hard
{ "lang": "rust", "repo": "nahkh/fluid-dynamics", "path": "/src/simulation.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bolcom/unFTP path: /crates/redislog/src/lib.rs //! This crate implements a [slog](https://crates.io/crates/slog) drain that outputs JSON formatted //! logs to a Redis list //! //! Useful for structured, **centralized logging** using a RELK stack (Redis, Elasticsearch, //! Logstash and Kibana). A...
code_fim
hard
{ "lang": "rust", "repo": "bolcom/unFTP", "path": "/crates/redislog/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.emit_serde_json_number::<usize>(key, val) } fn emit_isize(&mut self, key: Key, val: isize) -> slog::Result { self.emit_serde_json_number::<isize>(key, val) } fn emit_u32(&mut self, key: Key, val: u32) -> slog::Result { self.emit_serde_json_number::<u32>(key, ...
code_fim
hard
{ "lang": "rust", "repo": "bolcom/unFTP", "path": "/crates/redislog/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn round_near_zero(x: f64) -> f64 { if near_zero(x) { return 0.0; } else { return x; } } fn sqrt_real(x: f64) -> Cmplx { if x >= 0.0 { return (x.sqrt(), 0.0); } else { return (0.0, (-x).sqrt()); } } pub type Cmplx = (f64, f64); fn cmplx_add((x, xi...
code_fim
hard
{ "lang": "rust", "repo": "Ben-Ramchandani/rust_tracer", "path": "/src/cubic.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ben-Ramchandani/rust_tracer path: /src/cubic.rs /// Solve equations of the form `ax^2 + bx + c = 0`. #[derive(PartialEq, Debug)] pub enum QuadRoots { Real(f64, f64), Single(f64), None, } #[derive(PartialEq, Debug)] pub enum CubicRoots { ThreeReal(f64, f64, f64), OneRealTwoC...
code_fim
hard
{ "lang": "rust", "repo": "Ben-Ramchandani/rust_tracer", "path": "/src/cubic.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert!(cmplx_cmp_4(solve_quartic(3.0, 6.0, -123.0, -126.0, 1080.0), ((5.0, 0.0), (3.0, 0.0), (-4.0, 0.0), (-6.0, 0.0)))); assert!(cmplx_cmp_4(solve_quartic(1.0, -5.0 / 20.0, -17.0 / 20.0, 29.0 / 20.0, -87.0 / 20.0), ((1.48758311033, 0.0), ...
code_fim
hard
{ "lang": "rust", "repo": "Ben-Ramchandani/rust_tracer", "path": "/src/cubic.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oshunter/fuchsia path: /third_party/rust_crates/vendor/enum-as-inner/tests/named.rs use enum_as_inner::EnumAsInner; #[derive(Debug, EnumAsInner)] enum ManyVariants { One { one: u32 }, Two { one: u32, two: i32 }, Three { one: bool, two: u32, three: i64 }, } #[test] fn test_one_named...
code_fim
hard
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/third_party/rust_crates/vendor/enum-as-inner/tests/named.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> assert!(many.as_one().is_none()); assert!(many.as_two().is_none()); assert!(many.as_three().is_some()); assert_eq!(many.as_three().unwrap(), (&true, &1_u32, &2_i64)); assert_eq!(many.into_three().unwrap(), (true, 1_u32, 2_i64)); }<|fim_prefix|>// repo: oshunter/fuchsia path: /third_p...
code_fim
hard
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/third_party/rust_crates/vendor/enum-as-inner/tests/named.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> assert!(many.as_one().is_none()); assert!(many.as_two().is_some()); assert!(many.as_three().is_none()); assert_eq!(many.as_two().unwrap(), (&1_u32, &2_i32)); assert_eq!(many.into_two().unwrap(), (1_u32, 2_i32)); } #[test] fn test_three_named() { let many = ManyVariants::Three { ...
code_fim
hard
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/third_party/rust_crates/vendor/enum-as-inner/tests/named.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ThePerkinrex/ArmesCPU_old_RUST path: /src/romcompiler.rs extern crate armes_cpu_lib; extern crate regex; use armes_cpu_lib::compile; use regex::Regex; mod configloader; mod memory; use std::fs; fn bin(n: usize, z: usize) -> String { let mut s = format!("{:b}", n); <|fim_suffix|> l...
code_fim
medium
{ "lang": "rust", "repo": "ThePerkinrex/ArmesCPU_old_RUST", "path": "/src/romcompiler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let c = configloader::load_cfg(); let mut rommap = fs::read_to_string("uncompiled/rom.rommap").expect("Error reading rommap"); // Replace the references to instructions with the instruction // On the wasm, this will be done by the JS let re = Regex::new(r"\$\{(\w+)\}").unwrap(); le...
code_fim
medium
{ "lang": "rust", "repo": "ThePerkinrex/ArmesCPU_old_RUST", "path": "/src/romcompiler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> g1_multiexp_data.push(g1); g2_multiexp_data.push(g2); } let params = JsonMnt6PairingCurveParameters { non_residue: (random_field_element(&modulus, rng), rng.gen_bool(0.5)), x: (BigUint::from(0u64), false), exp_w0: (BigUint::from(0u64), false), exp_w...
code_fim
hard
{ "lang": "rust", "repo": "matter-labs/eip1962", "path": "/src/test/gas_meter/monte_carlo/pseudo_curves/gen_params.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matter-labs/eip1962 path: /src/test/gas_meter/monte_carlo/pseudo_curves/gen_params.rs s = res % modulus; res } fn random_biguint<R: Rng>(bytes: usize, rng: &mut R) -> BigUint { let mut tmp = vec![0u8; bytes]; rng.try_fill_bytes(&mut tmp).unwrap(); let res = BigUint::from_bytes_...
code_fim
hard
{ "lang": "rust", "repo": "matter-labs/eip1962", "path": "/src/test/gas_meter/monte_carlo/pseudo_curves/gen_params.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matter-labs/eip1962 path: /src/test/gas_meter/monte_carlo/pseudo_curves/gen_params.rs _twist_2: random_field_element(&modulus, rng), g1_x: random_field_element(&modulus, rng), g1_y: random_field_element(&modulus, rng), g2_x_0: random_field_element(&modulus, rng), ...
code_fim
hard
{ "lang": "rust", "repo": "matter-labs/eip1962", "path": "/src/test/gas_meter/monte_carlo/pseudo_curves/gen_params.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Genysys/substrate path: /frame/identity/src/weights.rs e. // Copyright (C) 2022 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may...
code_fim
hard
{ "lang": "rust", "repo": "Genysys/substrate", "path": "/frame/identity/src/weights.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> (28_195_000 as Weight) // Standard Error: 3_000 .saturating_add((137_000 as Weight).saturating_mul(r as Weight)) // Standard Error: 0 .saturating_add((328_000 as Weight).saturating_mul(x as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight:...
code_fim
hard
{ "lang": "rust", "repo": "Genysys/substrate", "path": "/frame/identity/src/weights.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Genysys/substrate path: /frame/identity/src/weights.rs S IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. //! Autogenerated weights for pallet_identity ...
code_fim
hard
{ "lang": "rust", "repo": "Genysys/substrate", "path": "/frame/identity/src/weights.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut buf = Cursor::new(vec![49, 50, 51]); assert_eq!(buf.read_str_eos("ascii").unwrap(), "123"); assert_eq!(buf.pos().unwrap(), 3); } #[test] fn read_strz() { let mut buf = Cursor::new(vec![ 230, 151, 165, 230, 156, 172, 232, 170, 158, 0, // utf-...
code_fim
hard
{ "lang": "rust", "repo": "Smcculle/kaitai_struct_rust_runtime", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Smcculle/kaitai_struct_rust_runtime path: /src/lib.rs extern crate byteorder; extern crate encoding; extern crate flate2; mod kaitai_stream; mod kaitai_struct; pub use kaitai_stream::KaitaiStream; pub use kaitai_struct::KaitaiStruct; #[cfg(test)] mod tests { use std::io::Cursor; use K...
code_fim
hard
{ "lang": "rust", "repo": "Smcculle/kaitai_struct_rust_runtime", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: clchiou/garage path: /rust/bittorrent/utp/src/socket.rs use std::collections::HashMap; use std::io::{Error, ErrorKind}; use std::net::SocketAddr; use std::panic; use std::sync::Arc; use bytes::{Bytes, BytesMut}; use futures::{ sink::{Sink, SinkExt}, stream::{Stream, TryStreamExt}, }; us...
code_fim
hard
{ "lang": "rust", "repo": "clchiou/garage", "path": "/rust/bittorrent/utp/src/socket.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, peer_endpoint: SocketAddr, result_send: oneshot::Sender<Result<UtpStream, Error>>, ) { // Unfortunately, the borrow checker disallows the use of `HashMap::entry` because we call // methods (which also borrow `self`) while holding the entry. if...
code_fim
hard
{ "lang": "rust", "repo": "clchiou/garage", "path": "/rust/bittorrent/utp/src/socket.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> async fn run(mut self) -> Result<(), Error> { let result = try { loop { tokio::select! { connect = self.connect_recv.recv() => { match connect { Some((peer_endpoint, result_send)) => { ...
code_fim
hard
{ "lang": "rust", "repo": "clchiou/garage", "path": "/rust/bittorrent/utp/src/socket.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while i < n { match nums.get(i) { None => break, Some(v) => { if *v == val { nums.swap(i, n - 1); n -= 1; } else { i += 1; ...
code_fim
hard
{ "lang": "rust", "repo": "ytakhs/leetcode-rs", "path": "/examples/archives/remove_element.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ytakhs/leetcode-rs path: /examples/archives/remove_element.rs struct Solution {} impl Solution { pub fn remove_element(nums: &mut Vec<i32>, val: i32) -> i32 { nums.retain(|n| *n != val); nums.len() as i32 } pub fn remove_element_2(nums: &mut Vec<i32>, val: i32) -> i...
code_fim
hard
{ "lang": "rust", "repo": "ytakhs/leetcode-rs", "path": "/examples/archives/remove_element.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pajamapants3000/coreutils path: /src/bin/free.rs //#![deny(warnings)] extern crate extra; use std::fs::File; use std::io; use extra::option::OptionalExt; const MAN_PAGE: &'static str = /* @MANSTART{free} */ r#" NAME free - display amount of free and used memory in the system <|fim_suffix...
code_fim
medium
{ "lang": "rust", "repo": "pajamapants3000/coreutils", "path": "/src/bin/free.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let stdout = io::stdout(); let mut stdout = stdout.lock(); let mut stderr = io::stderr(); let mut file = File::open("memory:").try(&mut stderr); io::copy(&mut file, &mut stdout).try(&mut stderr); }<|fim_prefix|>// repo: pajamapants3000/coreutils path: /src/bin/free.rs //#![deny(warni...
code_fim
medium
{ "lang": "rust", "repo": "pajamapants3000/coreutils", "path": "/src/bin/free.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Aurorastation/rust-g path: /tests/dm-tests.rs use std::process::{Command, Output}; #[cfg(feature = "git")] #[test] fn git() { run_dm_tests("git"); } #[cfg(feature = "toml")] #[test] fn toml() { run_dm_tests("toml"); } #[cfg(feature = "url")] #[test] fn url() { run_dm_tests("url");...
code_fim
hard
{ "lang": "rust", "repo": "Aurorastation/rust-g", "path": "/tests/dm-tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let output = Command::new("bash") .arg(&byondexec) .arg(&dream_maker) .arg(&dme) .output() .unwrap(); dump(&output); generic_check(&output); let output = Command::new("bash") .arg(&byondexec) .arg(&dream_daemon) .arg(&dmb) ...
code_fim
hard
{ "lang": "rust", "repo": "Aurorastation/rust-g", "path": "/tests/dm-tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if !is_version_supported(&self.version.0) { return Err(ClientConfigError::UnsupportedVersion(self.version.clone())); } let defined_upstreams = self.upstreams.keys().cloned().collect::<HashSet<_>>(); let used_upstreams = self .mount_points ...
code_fim
hard
{ "lang": "rust", "repo": "exogress/exogress", "path": "/src/config_core/client_config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn parse(yaml: impl AsRef<[u8]>) -> anyhow::Result<Self> { let deserialized_cfg = serde_yaml::from_slice::<Self>(yaml.as_ref())?; validate_extra_keys(&deserialized_cfg, yaml.as_ref())?; validate_schema(yaml.as_ref(), "client.json")?; Ok(deserialized_cfg) } } #[de...
code_fim
hard
{ "lang": "rust", "repo": "exogress/exogress", "path": "/src/config_core/client_config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: exogress/exogress path: /src/config_core/client_config.rs }; use serde::{Deserialize, Serialize}; use crate::{ config_core::{ cache::Cache, config::{default_rules, Config}, gcs::GcsBucketAccess, is_profile_active, is_version_supported, proxy::Proxy, ...
code_fim
hard
{ "lang": "rust", "repo": "exogress/exogress", "path": "/src/config_core/client_config.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // println!("hour is {}", hour); match hour { 6..=12 => "morning", 13..=17 => "afternoon", 18..=23 => "night", 0..=5 => "night", _ => "", } }<|fim_prefix|>// repo: legend80s/guessing_game_rust path: /src/utils.rs use ansi_term::Colour; use chrono::prelude::*; pub fn quote(str...
code_fim
hard
{ "lang": "rust", "repo": "legend80s/guessing_game_rust", "path": "/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: legend80s/guessing_game_rust path: /src/utils.rs use ansi_term::Colour; use chrono::prelude::*; pub fn quote(str: &str) -> String { return format!("🤖 {}", str); } pub fn say(str: &str) { println!("{}", quote(str)); } pub fn welcome(name: &str) { let phase = get_time_phase(); print!(...
code_fim
medium
{ "lang": "rust", "repo": "legend80s/guessing_game_rust", "path": "/src/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in numbers.iter() { for j in numbers.iter() { for k in numbers.iter() { if i + j + k == 2020 { println!("{}", i * j * k); return Ok(()); } } } } Ok(()) }<|fim_prefix|>// repo:...
code_fim
medium
{ "lang": "rust", "repo": "samwho/advent-of-code-2020", "path": "/src/1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }