text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: fghzxm/windows-rs path: /crates/gen/src/to_snake.rs use crate::MethodKind; /// Change a CamelCase method name to snake case and prepends an optional /// preamble depending on the kind of method. pub fn method_to_snake(camel: &str, kind: MethodKind) -> String { debug_assert!(!camel.is_empty(...
code_fim
hard
{ "lang": "rust", "repo": "fghzxm/windows-rs", "path": "/crates/gen/src/to_snake.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> snake } #[cfg(test)] mod tests { use crate::*; #[test] fn to_snake_works() { assert_eq!(to_snake("Windows"), "windows".to_owned()); assert_eq!(to_snake("ApplicationModel"), "application_model".to_owned()); assert_eq!(method_to_snake("foo", MethodKind::Normal), "...
code_fim
hard
{ "lang": "rust", "repo": "fghzxm/windows-rs", "path": "/crates/gen/src/to_snake.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aerendem/securedvote path: /src/candidate.rs use std::fmt::{ self, Debug, Formatter }; use super::*; //Candidate struct pub struct Candidate { pub name: String, pub candidate_id: u32, pub vote_count: u32 } impl Debug for Candidate { //Candidate format function to display ...
code_fim
hard
{ "lang": "rust", "repo": "aerendem/securedvote", "path": "/src/candidate.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Candidate { pub fn new (name: String, candidate_id: u32, vote_count: u32) -> Self { Candidate { name, candidate_id, vote_count } } pub fn output_candidate_vote(&mut self) { println!("adayin oy sayisi {}", &self.vote_count); ...
code_fim
hard
{ "lang": "rust", "repo": "aerendem/securedvote", "path": "/src/candidate.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //Candidate format function to display fn fmt (&self, f: &mut Formatter) -> fmt::Result { write!(f, "Adayın ismi {}, idsi {} ve sahip olduğu oy sayısı {}", &self.name, &self.candidate_id, &self.vote_count ) } } impl Candidate { pub fn ne...
code_fim
medium
{ "lang": "rust", "repo": "aerendem/securedvote", "path": "/src/candidate.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>&& c[1].is_uppercase()) }) .map(|c| c[1].to_ascii_uppercase()) .collect() }<|fim_prefix|>// repo: ltvcuong/rust-playground path: /exercism/acronym/src/lib.rs use std::iter; pub fn abbreviate(phrase: &str) -> String { iter::once(' ') .chain(phra<|fim_middle|>se.chars()...
code_fim
medium
{ "lang": "rust", "repo": "ltvcuong/rust-playground", "path": "/exercism/acronym/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ltvcuong/rust-playground path: /exercism/acronym/src/lib.rs use std::iter; pub fn abbreviate(phrase: &str) -> String { iter::once(' ') .chain(phra<|fim_suffix|> (!c[0].is_alphabetic() && c[1].is_alphabetic()) || (c[0].is_lowercase() && c[1].is_uppercase()) ...
code_fim
medium
{ "lang": "rust", "repo": "ltvcuong/rust-playground", "path": "/exercism/acronym/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Creatiwity/siren path: /src/models/update_metadata/common.rs use super::super::group_metadata::common::GroupType; use super::super::schema::update_metadata; use chrono::{DateTime, Utc}; use diesel::deserialize::{self, FromSql}; use diesel::pg::{Pg, PgValue}; use diesel::serialize::{self, IsNull,...
code_fim
hard
{ "lang": "rust", "repo": "Creatiwity/siren", "path": "/src/models/update_metadata/common.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(FromSqlRow, AsExpression, Deserialize, Serialize, Clone, Debug)] #[diesel(sql_type = Jsonb)] pub struct UpdateSummary { pub updated: bool, pub started_timestamp: DateTime<Utc>, pub finished_timestamp: Option<DateTime<Utc>>, pub steps: Vec<UpdateStepSummary>, } impl FromSql<Jsonb,...
code_fim
hard
{ "lang": "rust", "repo": "Creatiwity/siren", "path": "/src/models/update_metadata/common.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>_str ( & f ) { Value : : Number ( n . into ( ) ) } else { Value : : String ( f ) } } Yaml : : Integer ( i ) = > Value : : Number ( i . into ( ) ) Yaml : : String ( s ) = > Value : : String ( s ) Yaml : : Boolean ( b ) = > Value : : Bool ( b ) Yaml : : Array ( sequence ) = > Value : : Sequence ( sequence ....
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/serde_yaml/src/value/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/serde_yaml/src/value/mod.rs mod de ; mod from ; mod index ; mod partial_eq ; mod ser ; use crate : : ser : : SerializerToYaml ; use crate : : { Error Mapping } ; use serde : : de : : { Deserialize DeserializeOwned IntoDeser...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/serde_yaml/src/value/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hagi013/ufo-catch-man path: /src/main.rs extern crate reqwest; extern crate serde; extern crate serde_json; extern crate chrono; extern crate rusoto_core; extern crate rusoto_s3; pub mod disclosure; pub mod http; pub mod s3; use std::env; use http::{get, get_bytes}; use chrono::{Utc, Duration,...
code_fim
hard
{ "lang": "rust", "repo": "Hagi013/ufo-catch-man", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>async fn fetch_ufo_file(url: &str) -> Result<Bytes, Box<dyn std::error::Error>> { // let bytes = get_bytes("https://disclosure.edinet-fsa.go.jp/api/v1/documents/S100FJBP?type=1").await?; let bytes = get_bytes(url).await?; Ok(bytes) } fn put_ufo_file(body: Bytes, path: String) -> Result<(), Box...
code_fim
hard
{ "lang": "rust", "repo": "Hagi013/ufo-catch-man", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let start_date = Utc.ymd(splited_period_start[0].parse().unwrap(), splited_period_start[1].parse().unwrap(), splited_period_start[2].parse().unwrap()).and_hms(0, 0, 0); let days = (Utc.ymd(splited_period_end[0].parse().unwrap(), splited_period_end[1].parse().unwrap(), splited_period_end[2]...
code_fim
hard
{ "lang": "rust", "repo": "Hagi013/ufo-catch-man", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn void_unwrap_err(self) -> E; } impl<E> ResultVoidErrExt<E> for Result<Void, E> { #[inline] fn void_unwrap_err(self) -> E { match self { Ok(v) => unreachable(v), Err(e) => e } } }<|fim_prefix|>// repo: marco-c/gecko-dev-comments-remo...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/void/src/lib.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>impl<T> ResultVoidExt<T> for Result<T, Void> { #[inline] fn void_unwrap(self) -> T { match self { Ok(val) => val, Err(e) => unreachable(e) } } } pub trait ResultVoidErrExt<E>: Sized { fn void_unwrap_err(self) -> E; } impl<E> Re...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/void/src/lib.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/void/src/lib.rs #![cfg_attr(test, deny(warnings))] #![deny(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] #[cfg(not(feature = "std"))] mod coreprovider { extern crate core; pub use core::{fmt, cmp}; } #[cfg(...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/void/src/lib.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MatusT/naga path: /src/back/hlsl/writer.rs use super::Error; use crate::back::hlsl::keywords::RESERVED; use crate::proc::{NameKey, Namer}; use crate::{FastHashMap, ShaderStage}; use std::fmt::Write; const INDENT: &str = " "; pub struct Writer<W> { out: W, names: FastHashMap<NameKey,...
code_fim
hard
{ "lang": "rust", "repo": "MatusT/naga", "path": "/src/back/hlsl/writer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // TODO Support arguments self.write_block(&ep.function.body)?; } Ok(()) } fn write_block(&mut self, statements: &[crate::Statement]) -> Result<(), Error> { writeln!(self.out, "{{")?; for statement in statements { if let crate::...
code_fim
hard
{ "lang": "rust", "repo": "MatusT/naga", "path": "/src/back/hlsl/writer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>: *mut mit_des_cblock, mut schedule: *mut mit_des_key_schedule) -> libc::c_int { mit_des_make_key_sched((*k.offset(0 as libc::c_int as isize)).as_mut_ptr(), ...
code_fim
hard
{ "lang": "rust", "repo": "xentrick/gssapi-rs", "path": "/src/lib/crypto/builtin/des/d3_kysched.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xentrick/gssapi-rs path: /src/lib/crypto/builtin/des/d3_kysched.rs use ::libc; #[c2rust::header_src = "/home/nmavis/dev/gssapi-rs/code/src/lib/crypto/builtin/des/des_int.h:25"] pub mod des_int_h { /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* lib/crypto/builtin/des/des...
code_fim
hard
{ "lang": "rust", "repo": "xentrick/gssapi-rs", "path": "/src/lib/crypto/builtin/des/d3_kysched.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { state.render_player(); state.render_level(); state.render_entities(); state.render_player(); state.render_ui(); if let Some(event) = reader.next() { match event { InputEvent::Keyboard(KeyEvent::Char('q')) => break, ...
code_fim
hard
{ "lang": "rust", "repo": "iagogarrido/roguerust", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iagogarrido/roguerust path: /src/main.rs extern crate crossterm; extern crate ignore_result; extern crate rand; extern crate text_io; mod entities; mod state; mod tiling; mod world; use crossterm::cursor; use crossterm::execute; use crossterm::input::{input, InputEvent, KeyEvent}; use crosster...
code_fim
hard
{ "lang": "rust", "repo": "iagogarrido/roguerust", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // round 4 a = b.wrapping_add((c^(b|(!d))).wrapping_add(a).wrapping_add(x[0]).wrapping_add(0xf4292244).rotate_left(6)); d = a.wrapping_add((b^(a|(!c))).wrapping_add(d).wrapping_add(x[7]).wrapping_add(0x432aff97).rotate_left(10)); c = d.wrapping_add((a^(d|(!b...
code_fim
hard
{ "lang": "rust", "repo": "mengsuenyan/rcrypto", "path": "/src/md5/md5_generic.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mengsuenyan/rcrypto path: /src/md5/md5_generic.rs use crate::md5::MD5; use crate::md5::md5::MD5_BLOCK_SIZE; impl MD5 { pub(super) fn update(&mut self, data_block: Option<&[u8]>) { let data_block = match data_block {Some(x) => x, None => &self.buf}; let (mut a, mut b, mut c, ...
code_fim
hard
{ "lang": "rust", "repo": "mengsuenyan/rcrypto", "path": "/src/md5/md5_generic.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 2color/prisma-engines path: /libs/datamodel/core/src/transform/dml_to_ast/mod.rs mod datasource_serializer; mod generator_serializ<|fim_suffix|>GeneratorSerializer; pub use lower::LowerDmlToAst;<|fim_middle|>er; mod lower; pub use datasource_serializer::DatasourceSerializer; pub use generator_s...
code_fim
medium
{ "lang": "rust", "repo": "2color/prisma-engines", "path": "/libs/datamodel/core/src/transform/dml_to_ast/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>GeneratorSerializer; pub use lower::LowerDmlToAst;<|fim_prefix|>// repo: 2color/prisma-engines path: /libs/datamodel/core/src/transform/dml_to_ast/mod.rs mod datasource_serializer; mod generator_serializ<|fim_middle|>er; mod lower; pub use datasource_serializer::DatasourceSerializer; pub use generator_s...
code_fim
medium
{ "lang": "rust", "repo": "2color/prisma-engines", "path": "/libs/datamodel/core/src/transform/dml_to_ast/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/lib/async-utils/src/hanging_get/test_util.rs // Copyright 2019 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 std::{cell::RefCell, fmt::Debug, rc::Rc}; /// An obse...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/async-utils/src/hanging_get/test_util.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl<V: Debug + PartialEq> Drop for TestObserver<V> { fn drop(&mut self) { if !std::thread::panicking() { assert_eq!( *self.value.borrow(), self.expected, "Observer dropped without expected state being met" ); } ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/async-utils/src/hanging_get/test_util.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> match header.endianness { Endianness::Big => Self::read_big_endian(data), Endianness::Little => Self::read_little_endian(data), } } } pub trait BlenderWrite { fn write_big_endian<W: ::std::io::Write>(&self, target: &mut W) -> Result<(), BlenderError>; f...
code_fim
medium
{ "lang": "rust", "repo": "fschutt/blender-file-reader", "path": "/src/traits.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fschutt/blender-file-reader path: /src/traits.rs use errors::Error as BlenderError; use blender_header::{Endianness, BlenderHeader}; pub trait BlenderRead { fn read_big_endian<R: ::std::io::Read>(data: &mut R) -> Result<Self, BlenderError> where Self: Sized; <|fim_suffix|> match head...
code_fim
hard
{ "lang": "rust", "repo": "fschutt/blender-file-reader", "path": "/src/traits.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Assume there is only one relevent table assert_eq!(wasm_module.tables.len(), 1); // TODO: Do some sort of dynamic handling of table size assert!(wasm_module.tables[0].limits.initial <= 1024); assert!(wasm_module.tables[0].limits.maximum.unwrap_or(0) <= 1024); generate_table_ini...
code_fim
hard
{ "lang": "rust", "repo": "geky/aWsm", "path": "/src/codegen/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: geky/aWsm path: /src/codegen/mod.rs use std::io; use llvm::Context as LLVMCtx; use llvm::Function as LLVMFunction; use llvm::Module as LLVMModule; use wasmparser::FuncType; use crate::Opt; use crate::wasm::Export; use crate::wasm::Function; use crate::wasm::WasmModule; mod block; mod break...
code_fim
hard
{ "lang": "rust", "repo": "geky/aWsm", "path": "/src/codegen/mod.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> // We assume there is only one relevent memory assert_eq!(wasm_module.memories.len(), 1); // The runtime needs to know how big the memory is/can be add_memory_size_globals(&module_ctx, &wasm_module.memories[0].limits); // Which we then need to initialize the data generate_memory_...
code_fim
hard
{ "lang": "rust", "repo": "geky/aWsm", "path": "/src/codegen/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> pub fn height(&self) -> i32 { return (self.cells.front_ref().len() / (self.stride as usize)) as i32; } /// Modifies the cell at the given point. pub fn set_cell(&mut self, x: i32, y: i32, cell: Cell) { let index = self.index(x, y); self.cells.front_mut()[index] = c...
code_fim
hard
{ "lang": "rust", "repo": "unixzii/game-of-life", "path": "/src/engine.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: unixzii/game-of-life path: /src/engine.rs use std::cmp::PartialEq; /// A storage with two buffers for arbitary type. /// /// This is useful for generating next generation world while referring to the /// current generation world, and make this process done without allocating /// new memory. st...
code_fim
hard
{ "lang": "rust", "repo": "unixzii/game-of-life", "path": "/src/engine.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tinkerware/graphsurge path: /src/computations/mod.rs return execute_compare_differential(&cube, self, &runtime_data) } ComputationType::Timely => timely_execute(&cube, self, &runtime_data)?, } Ok(GraphSurgeResult::new(format!("{} done", runt...
code_fim
hard
{ "lang": "rust", "repo": "tinkerware/graphsurge", "path": "/src/computations/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tinkerware/graphsurge path: /src/computations/mod.rs mputationResultSet<C> = HashSet<(<C as ComputationTypes>::Result, DiffCount)>; pub type ComputationResults<C> = HashMap<GsTimestampIndex, (ComputationResultSet<C>, GSTimestamp)>; pub enum ComputationProperties { Value(PropertyValue), ...
code_fim
hard
{ "lang": "rust", "repo": "tinkerware/graphsurge", "path": "/src/computations/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn compare<T: Computation>( mut r1: ComputationResults<T>, mut r2: ComputationResults<T>, ) -> Result<GraphSurgeResult, GSError> { info!("Result Counts:"); for (timestamp_index, (values, timestamp)) in r1.iter().sorted_by_key(|&(ts_index, _)| ts_index) { info!( "{}:...
code_fim
hard
{ "lang": "rust", "repo": "tinkerware/graphsurge", "path": "/src/computations/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &format!( "/v1/companies/{}/job_applicants/{}", crate::progenitor_support::encode_path(company_id), crate::progenitor_support::encode_path(job_applicant_uuid), ), None, ); self.client .put( ...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/third-party-api-clients", "path": "/gusto/src/job_applicants_beta.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oxidecomputer/third-party-api-clients path: /gusto/src/job_applicants_beta.rs use crate::Client; use crate::ClientResult; pub struct JobApplicantsBeta { pub client: Client, } impl JobApplicantsBeta { #[doc(hidden)] pub fn new(client: Client) -> Self { JobApplicantsBeta { cl...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/third-party-api-clients", "path": "/gusto/src/job_applicants_beta.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>_FORMAT_R32G32B32A32_FLOAT, DXGI_FORMAT_R32G32B32_FLOAT, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, DXGI_MWA_NO_ALT_ENTER, DXGI_SAMPLE_DESC, DXGI_SWAP_CHAIN_DESC1, DXGI_SWAP_CHAIN_FULLSCREEN_DESC, DXGI_SWAP_EFFECT_FLIP_DISCARD...
code_fim
hard
{ "lang": "rust", "repo": "clemenswasser/d3d12rs", "path": "/bindings/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: clemenswasser/d3d12rs path: /bindings/build.rs fn main() { windows::build!( Windows::Win32::Graphics::Direct3D11::{ ID3DBlob, D3D_FEATURE_LEVEL_12_1, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST, }, Windows::Win32::Graphics::Direct3D12::{ D3D12CreateDev...
code_fim
hard
{ "lang": "rust", "repo": "clemenswasser/d3d12rs", "path": "/bindings/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// See [`RegisterTransitGatewayInput`](crate::input::RegisterTransitGatewayInput) pub mod register_transit_gateway_input { /// A builder for [`RegisterTransitGatewayInput`](crate::input::RegisterTransitGatewayInput) #[non_exhaustive] #[derive(std::default::Default, std::clone::Clone, std::cmp...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/networkmanager/src/input.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/networkmanager/src/input.rs Clone, std::cmp::PartialEq, std::fmt::Debug)] pub struct Builder { pub(crate) global_network_id: std::option::Option<std::string::String>, pub(crate) transit_gateway_arn: std::option::Option<std::string::String>, ...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/networkmanager/src/input.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hamadu/competitive-rust path: /src/atcoder/agc035/agc035_a.rs // https://atcoder.jp/contests/agc035/tasks/agc035_a // #![allow(unused_imports)] use std::io::*; use std::fmt::*; use std::str::*; use std::cmp::*; use std::collections::*; macro_rules! input { (source = $s:expr, $($r:tt)*) => {...
code_fim
hard
{ "lang": "rust", "repo": "hamadu/competitive-rust", "path": "/src/atcoder/agc035/agc035_a.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Queryable, Serialize)] pub struct Email { pub id: i32, pub mailbox_id: i32, pub fromaddr: String, pub message: String, pub timestamp: SystemTime, pub sent_via_ssl: bool, pub read: bool, }<|fim_prefix|>// repo: getslash/mailboxer path: /src/models.rs use serde::Seriali...
code_fim
medium
{ "lang": "rust", "repo": "getslash/mailboxer", "path": "/src/models.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: getslash/mailboxer path: /src/models.rs use serde::Serialize; use std::time::SystemTime; <|fim_suffix|>#[derive(Queryable, Serialize)] pub struct Email { pub id: i32, pub mailbox_id: i32, pub fromaddr: String, pub message: String, pub timestamp: SystemTime, pub sent_via_...
code_fim
medium
{ "lang": "rust", "repo": "getslash/mailboxer", "path": "/src/models.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Return the current estimation for how long we should wait for a given /// [`Action`] to complete. /// /// This function should return a 2-tuple of `(timeout, abandon)` /// durations. After `timeout` has elapsed since circuit launch, /// the circuit should no longer be used, b...
code_fim
hard
{ "lang": "rust", "repo": "erglabs/arti", "path": "/crates/tor-circmgr/src/timeouts.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: erglabs/arti path: /crates/tor-circmgr/src/timeouts.rs //! Code for estimating good values for circuit timeouts. //! //! We need good circuit timeouts for two reasons: first, they help //! user experience. If user wait too long for their circuits, or if //! they use exceptionally slow circuits,...
code_fim
hard
{ "lang": "rust", "repo": "erglabs/arti", "path": "/crates/tor-circmgr/src/timeouts.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>unsafe impl Trace for Closure { fn trace(&self, visitor: &mut Tracer) { self.code.trace(visitor); self.args.trace(visitor); self.env.trace(visitor); } } impl GcCell for Closure {}<|fim_prefix|>// repo: playXE/sierra-scheme path: /src/value/closure.rs use crate::gc::{GcCell...
code_fim
hard
{ "lang": "rust", "repo": "playXE/sierra-scheme", "path": "/src/value/closure.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: playXE/sierra-scheme path: /src/value/closure.rs use crate::gc::{GcCell, GcPointer, Trace, Tracer}; <|fim_suffix|> self.code.trace(visitor); self.args.trace(visitor); self.env.trace(visitor); } } impl GcCell for Closure {}<|fim_middle|>use super::{cons::Cons, environm...
code_fim
hard
{ "lang": "rust", "repo": "playXE/sierra-scheme", "path": "/src/value/closure.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>], "../../emtests/test_exceptions_multi.out" ); }<|fim_prefix|>// repo: forkkit/wasmer path: /lib/emscripten-tests/tests/emtests/test_exceptions_multi.rs #[test] #[ignore] fn test_test_exceptions_multi() { asse<|fim_middle|>rt_emscripten_output!( "../../emtests/test_exceptions_mul...
code_fim
medium
{ "lang": "rust", "repo": "forkkit/wasmer", "path": "/lib/emscripten-tests/tests/emtests/test_exceptions_multi.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: forkkit/wasmer path: /lib/emscripten-tests/tests/emtests/test_exceptions_multi.rs #[test] #[ignore] fn test_test_exceptions_multi() { asse<|fim_suffix|>_multi.wasm", "test_exceptions_multi", vec![], "../../emtests/test_exceptions_multi.out" ); }<|fim_middle|>rt_em...
code_fim
medium
{ "lang": "rust", "repo": "forkkit/wasmer", "path": "/lib/emscripten-tests/tests/emtests/test_exceptions_multi.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if collected_item_name == "signature::Signature" && field_being_checked == "Ed25519Signature" { // no serialization implemented for external type continue 'fields; } if collected_it...
code_fim
hard
{ "lang": "rust", "repo": "greg-szabo/struct-analyzer", "path": "/src/core/db.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Round exception // item: proposal::Proposal, field: Round -> block/round::Round if field_being_checked == "Round" && possible_object == "block/round::Round" { pusher(possible_object, &color, &mut solid, &mut dashed); ...
code_fim
hard
{ "lang": "rust", "repo": "greg-szabo/struct-analyzer", "path": "/src/core/db.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: greg-szabo/struct-analyzer path: /src/core/db.rs atch &self { DataType::Enum => "ellipse", DataType::Struct => "rectangle", DataType::Unknown => "rhombus", } .to_string() } } #[derive(PartialEq)] pub enum Color { /// Invalid struct or ...
code_fim
hard
{ "lang": "rust", "repo": "greg-szabo/struct-analyzer", "path": "/src/core/db.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BruceBrown/abstreet path: /map_model/src/pathfind/ch.rs //! Uses https://github.com/easbar/fast_paths. Slower creation during map importing, but very fast //! queries. use serde::{Deserialize, Serialize}; use abstutil::Timer; use crate::pathfind::driving::VehiclePathfinder; use crate::pathfin...
code_fim
hard
{ "lang": "rust", "repo": "BruceBrown/abstreet", "path": "/map_model/src/pathfind/ch.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> timer.start("prepare pathfinding for pedestrians using transit"); let walking_with_transit_graph = SidewalkPathfinder::new(map, true, &bus_graph, &train_graph); timer.stop("prepare pathfinding for pedestrians using transit"); ContractionHierarchyPathfinder { ...
code_fim
hard
{ "lang": "rust", "repo": "BruceBrown/abstreet", "path": "/map_model/src/pathfind/ch.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn formatters_only() { assert_pcc("§lBold", "<span style=\"font-weight: bold;\">Bold</span>"); assert_pcc("§lBold + §oItalics + §mStrikethrough", "<span style=\"font-weight: bold;\">Bold + <span style=\"font-style: italic;\">Italics + <span style=\"text-decoration: line-thr...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/Minecraft-Reports-GUI", "path": "/src/minecraft.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fossabot/Minecraft-Reports-GUI path: /src/minecraft.rs use std::collections::HashMap; /// Parses Minecraft color codes into HTML formatting. /// /// # Example /// /// ``` /// use lib::minecraft::parse_color_codes; /// assert_eq!(parse_color_codes(String::from("§2Dark green")), String::from("<s...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/Minecraft-Reports-GUI", "path": "/src/minecraft.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chronium/aatbe-lang path: /comp-be/src/fmt.rs use parser::ast::{ AtomKind, Boolean, Expression, FloatSize, FunctionType, IntSize, LValue, PrimitiveType, }; pub trait AatbeFmt { fn fmt(self) -> String; } impl AatbeFmt for PrimitiveType { fn fmt(self) -> String { (&self).fmt(...
code_fim
hard
{ "lang": "rust", "repo": "chronium/aatbe-lang", "path": "/comp-be/src/fmt.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl AatbeFmt for &AtomKind { fn fmt(self) -> String { match self { AtomKind::StringLiteral(lit) => format!("\"{}\"", lit), AtomKind::CharLiteral(lit) => format!("{}", lit), AtomKind::Integer(val, ty) => format!("{}{}", val, ty.fmt()), AtomKind::...
code_fim
hard
{ "lang": "rust", "repo": "chronium/aatbe-lang", "path": "/comp-be/src/fmt.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BurtonQin/yamux path: /src/lib.rs // Copyright 2018 Parity Technologies (UK) Ltd. // // Licensed under the Apache License, Version 2.0 or MIT license, at your option. // // A copy of the Apache License, Version 2.0 is included in the software as // LICENSE-APACHE and a copy of the MIT license is...
code_fim
hard
{ "lang": "rust", "repo": "BurtonQin/yamux", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>mod chunks; mod connection; mod error; #[allow(dead_code)] mod frame; mod notify; mod stream; pub use crate::connection::{Connection, Mode, StreamHandle}; pub use crate::error::{DecodeError, ConnectionError}; pub use crate::stream::State; pub(crate) const DEFAULT_CREDIT: u32 = 256 * 1024; // as per yamu...
code_fim
hard
{ "lang": "rust", "repo": "BurtonQin/yamux", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Default for Config { fn default() -> Self { Config { receive_window: DEFAULT_CREDIT, max_buffer_size: 1024 * 1024, max_num_streams: 8192, max_pending_frames: 2048, window_update_mode: WindowUpdateMode::OnReceive, read...
code_fim
hard
{ "lang": "rust", "repo": "BurtonQin/yamux", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Sinnlosvoll/azul path: /azul/wr_translate.rs gFlags::SHOW_OVERDRAW, new_flags.show_overdraw); debug_flags.set(DebugFlags::GPU_CACHE_DBG, new_flags.gpu_cache_dbg); r.set_debug_flags(debug_flags); } #[inline(always)] pub(crate) fn wr_translate_resource_update(resource_update: ResourceUpd...
code_fim
hard
{ "lang": "rust", "repo": "Sinnlosvoll/azul", "path": "/azul/wr_translate.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Sinnlosvoll/azul path: /azul/wr_translate.rs ancePlatformOptions { WrFontInstancePlatformOptions { unused: fio.unused, } } #[inline(always)] const fn wr_translate_font_variation(variation: FontVariation) -> WrFontVariation { WrFontVariation { tag: variation.tag, value: varia...
code_fim
hard
{ "lang": "rust", "repo": "Sinnlosvoll/azul", "path": "/azul/wr_translate.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut offset_info = *info; offset_info.clip_rect.origin.x += offset.x; offset_info.clip_rect.origin.y += offset.y; let stops: Vec<WrGradientStop> = linear_gradient.stops.iter().map(|gradient_pre| WrGradientStop { offset: gradient_pre.offset.un...
code_fim
hard
{ "lang": "rust", "repo": "Sinnlosvoll/azul", "path": "/azul/wr_translate.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_max_area_of_island() { for (grid, max_area) in TEST_CASES { let grid: Vec<Vec<i32>> = grid.iter().map(|each| each.to_vec()).collect(); assert_eq!(max_area_of_island(grid), max_area); } }<|fim_prefix|>// repo: seanpianka/leetcode-rust path: /src/bfs_dfs_backtracking...
code_fim
hard
{ "lang": "rust", "repo": "seanpianka/leetcode-rust", "path": "/src/bfs_dfs_backtracking/max_area_of_island.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seanpianka/leetcode-rust path: /src/bfs_dfs_backtracking/max_area_of_island.rs /*! https://leetcode.com/problems/max-area-of-island VecDeque双端队列内部通过ring buffer环形数组实现 在rust的1.21版本之前以下函数是错的 fn is_full(&self) -> bool { self.cap() - self.len() == 1 } 因为环状数组,tail在head的前一位索引时表示已满,所以is_full方法内需要对ca...
code_fim
hard
{ "lang": "rust", "repo": "seanpianka/leetcode-rust", "path": "/src/bfs_dfs_backtracking/max_area_of_island.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Bus { request: None.into(), busy: false.into(), dma_active: false.into(), data: 0xFFFFFFFF.into(), } } }<|fim_prefix|>// repo: yuriks/advance-emu path: /src/system.rs use std::cell::Cell; #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub...
code_fim
hard
{ "lang": "rust", "repo": "yuriks/advance-emu", "path": "/src/system.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub fn should_cpu_wait(&self) -> bool { self.busy.get() || self.dma_active.get() } #[inline] pub fn should_dma_wait(&self) -> bool { self.busy.get() } } impl Default for Bus { fn default() -> Bus { Bus { request: None.into(), ...
code_fim
hard
{ "lang": "rust", "repo": "yuriks/advance-emu", "path": "/src/system.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yuriks/advance-emu path: /src/system.rs use std::cell::Cell; #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum AccessWidth { Bit8, Bit16, Bit32, } #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum OperationType { Read { is_instruction: bool }, Write, } #[derive(Cop...
code_fim
hard
{ "lang": "rust", "repo": "yuriks/advance-emu", "path": "/src/system.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: m-labs/dslite2svd path: /crates/tm4c123x/src/udma/chmap2.rs #[doc = "Reader of register CHMAP2"] pub type R = crate::R<u32, super::CHMAP2>; #[doc = "Writer for register CHMAP2"] pub type W = crate::W<u32, super::CHMAP2>; #[doc = "Register CHMAP2 `reset()`'s with value 0"] impl crate::ResetValue ...
code_fim
hard
{ "lang": "rust", "repo": "m-labs/dslite2svd", "path": "/crates/tm4c123x/src/udma/chmap2.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|>ource Select"] #[inline(always)] pub fn ch22sel(&self) -> CH22SEL_R { CH22SEL_R::new(((self.bits >> 24) & 0x0f) as u8) } #[doc = "Bits 28:31 - uDMA Channel 23 Source Select"] #[inline(always)] pub fn ch23sel(&self) -> CH23SEL_R { CH23SEL_R::new(((self.bits >> 28) & ...
code_fim
hard
{ "lang": "rust", "repo": "m-labs/dslite2svd", "path": "/crates/tm4c123x/src/udma/chmap2.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matanshukry/qarax path: /src/services/storage.rs use super::*; use crate::models::storage::{NewStorage, Storage}; #[derive(Copy, Clone)] pub struct StorageService {} <|fim_suffix|> pub fn add(&self, new_storage: &NewStorage, conn: &DbConnection) -> Result<Uuid> { Storage::insert(new...
code_fim
medium
{ "lang": "rust", "repo": "matanshukry/qarax", "path": "/src/services/storage.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[allow(dead_code)] pub fn delete_all(&self, conn: &DbConnection) -> Result<usize, String> { match Storage::delete_all(conn) { Ok(record_count) => Ok(record_count), Err(e) => Err(e.to_string()), } } }<|fim_prefix|>// repo: matanshukry/qarax path: /src/s...
code_fim
hard
{ "lang": "rust", "repo": "matanshukry/qarax", "path": "/src/services/storage.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match character.category { CodeCharacterCategory::TogglingQuote if !characters.is_empty() && character.data == characters[0].data && characters[characters.len() - 1].data != '\\' => { TokenizerCommand::...
code_fim
hard
{ "lang": "rust", "repo": "PSudoLang/PSudo", "path": "/libpsudoc/src/tokenize/rules/quoted_string.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PSudoLang/PSudo path: /libpsudoc/src/tokenize/rules/quoted_string.rs use super::Rule; use crate::coretypes::{CodeCharacter, CodeCharacterCategory, TokenCategory}; use crate::tokenize::{RuleCategory, TokenizerCommand}; <|fim_suffix|> match character.category { CodeCharacterCat...
code_fim
hard
{ "lang": "rust", "repo": "PSudoLang/PSudo", "path": "/libpsudoc/src/tokenize/rules/quoted_string.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shangfeiSF/rust-grope path: /main/13_thread/examples/2.safe_shared_mutable.rs use std::thread; use std::sync::{Arc, Mutex}; use std::time::Duration; fn main() { { // let mut data = vec![1, 2, 3]; // for i in 0..3 { // thread::spawn(move || { data[i] += 1; }); ...
code_fim
hard
{ "lang": "rust", "repo": "shangfeiSF/rust-grope", "path": "/main/13_thread/examples/2.safe_shared_mutable.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..3 { // `clone()` makes a clone of the Arc pointer. // This creates another pointer to the same inner value, increasing the strong reference count. let data = data.clone(); thread::spawn(move || { // `lock()` acquires a mut...
code_fim
hard
{ "lang": "rust", "repo": "shangfeiSF/rust-grope", "path": "/main/13_thread/examples/2.safe_shared_mutable.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> { // data 是`安全(safe)+共享(shared)+可变(mutable)`数据 let data = Arc::new(Mutex::new(vec![1, 2, 3])); for i in 0..3 { // `clone()` makes a clone of the Arc pointer. // This creates another pointer to the same inner value, increasing the strong reference count....
code_fim
hard
{ "lang": "rust", "repo": "shangfeiSF/rust-grope", "path": "/main/13_thread/examples/2.safe_shared_mutable.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Actyx/rust-multibase path: /tests/lib.rs use multibase::Base::*; use multibase::{decode, encode, Base, Error}; #[test] fn test_bases_code() { assert_eq!(Base2.code(), '0'); } #[test] fn test_round_trip() { let slices: &[&[u8]] = &[ b"helloworld", b"we all want decentral...
code_fim
hard
{ "lang": "rust", "repo": "Actyx/rust-multibase", "path": "/tests/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( encode(Base16Lower, id), "f446563656e7472616c697a652065766572797468696e672121" ); assert_eq!( encode(Base16Lower, String::from_utf8(id.to_vec()).unwrap()), "f446563656e7472616c697a652065766572797468696e672121" ); assert_eq!( encode(...
code_fim
hard
{ "lang": "rust", "repo": "Actyx/rust-multibase", "path": "/tests/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-rosetta/rust-rosetta path: /tasks/animation/src/main.rs use iced::{ executor, widget::{button, text}, Application, Command, Element, Settings, Subscription, Theme, }; struct Animation { text: String, reverse: bool, } impl Default for Animation { fn default() -> Sel...
code_fim
hard
{ "lang": "rust", "repo": "rust-rosetta/rust-rosetta", "path": "/tasks/animation/src/main.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> fn title(&self) -> String { String::from("Animation") } fn update(&mut self, message: Message) -> Command<Message> { match message { Message::Tick => { if self.reverse { let begin = self.text.split_off(1); sel...
code_fim
hard
{ "lang": "rust", "repo": "rust-rosetta/rust-rosetta", "path": "/tasks/animation/src/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Nesquick0/Adventofcode path: /2022/02/src/main.rs #![allow(non_snake_case)] #![allow(unused_parens)] use std::io::Read; fn readToString(filename: &str) -> std::io::Result<String> { let mut file = std::fs::File::open(&filename)?; let mut text = String::new(); file.read_to_string(&mu...
code_fim
hard
{ "lang": "rust", "repo": "Nesquick0/Adventofcode", "path": "/2022/02/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn part2(text: &String) { // Part 2. let mut totalScore: i64 = 0; for line in text.lines() { let mut split = line.split(" "); let (aT, bT) = (split.next().unwrap(), split.next().unwrap()); let a: i64 = aT.chars().next().unwrap() as i64 - 'A' as i64; let b: i64 =...
code_fim
hard
{ "lang": "rust", "repo": "Nesquick0/Adventofcode", "path": "/2022/02/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> totalScore += score; } println!("Score: {}", totalScore); } fn main() { let text: String = readToString("input.txt").expect("Bad file!"); part1(&text); part2(&text); }<|fim_prefix|>// repo: Nesquick0/Adventofcode path: /2022/02/src/main.rs #![allow(non_snake_case)] #![allow(...
code_fim
hard
{ "lang": "rust", "repo": "Nesquick0/Adventofcode", "path": "/2022/02/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: a-bakos/rust-playground path: /archived-learning/the-rust-programming-language/p01/src/main.rs // the compiler will ignore the error #![allow(dead_code)] #![allow(unused_imports)] use std::mem; fn main() { println!("Hello, world!"); // println! is not a function, it's a macro let x = ...
code_fim
hard
{ "lang": "rust", "repo": "a-bakos/rust-playground", "path": "/archived-learning/the-rust-programming-language/p01/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let a = 3; let a_cubed = i32::pow(a, 3); let b = 2.5; let b_cubed = f64::powi(b, 3); // i in powi stands for integer let b_to_pi = f64::powf(b, std::f64::consts::PI); // Matching enums let color: Colors = Colors::CMYK { cyan: 0, magenta: 128, yellow: 0,...
code_fim
hard
{ "lang": "rust", "repo": "a-bakos/rust-playground", "path": "/archived-learning/the-rust-programming-language/p01/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: accidentaldevelopment/daytime path: /src/protocol.rs use strum::EnumString; #[derive(Debug, Cl<|fim_suffix|>e)] pub enum Protocol { Tcp, Udp, }<|fim_middle|>one, Copy, EnumString, PartialEq, PartialOrd, Eq, Ord)] #[strum(ascii_case_insensitiv
code_fim
medium
{ "lang": "rust", "repo": "accidentaldevelopment/daytime", "path": "/src/protocol.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>d, Eq, Ord)] #[strum(ascii_case_insensitive)] pub enum Protocol { Tcp, Udp, }<|fim_prefix|>// repo: accidentaldevelopment/daytime path: /src/protocol.rs use strum::EnumString; #[derive(Debug, Cl<|fim_middle|>one, Copy, EnumString, PartialEq, PartialOr
code_fim
easy
{ "lang": "rust", "repo": "accidentaldevelopment/daytime", "path": "/src/protocol.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Cupnfish/bevy_rapier path: /src/render/systems.rs use crate::physics::{ColliderHandleComponent, RapierPhysicsScale}; use crate::render::RapierRenderColor; use bevy::prelude::*; use rapier::dynamics::RigidBodySet; use rapier::geometry::{ColliderSet, Shape}; /// System responsible for attaching a...
code_fim
hard
{ "lang": "rust", "repo": "Cupnfish/bevy_rapier", "path": "/src/render/systems.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mesh = match collider.shape() { #[cfg(feature = "dim3")] Shape::Cuboid(_) => Mesh::from(shape::Cube { size: 1.0 }), #[cfg(feature = "dim2")] Shape::Cuboid(_) => Mesh::from(shape::Quad { ...
code_fim
hard
{ "lang": "rust", "repo": "Cupnfish/bevy_rapier", "path": "/src/render/systems.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>y.file_name(); println!( "Path is {:?}.\n Metadata is {:?}\n File_type is {:?}.\n Entry name is{:?}.\n", entry_path, entry_metadata, entry_file_type, entry_file_name ); } // Get path components let new_path = Path::new("/usr/d1/d2/d3/bar.txt"); print...
code_fim
hard
{ "lang": "rust", "repo": "burakbayramli/books", "path": "/Practical_System_Programming_for_Rust_Developers_Eshwarla/Chapter06/miscellaneous/snippet9.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn parse(path: &str) -> Map { let file = File::open(path).expect("cannot open file"); let buffer = BufReader::new(file); let tiles = buffer.lines() .map(|result| result.expect("cannot read line")) .map(|line| { line.chars().map(|c| match ...
code_fim
hard
{ "lang": "rust", "repo": "gelendir/aoc2020", "path": "/day3/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn width(&self) -> usize { //i'm trusting that all rows in the map have the same length self.0[0].len() } fn get(&self, point: &Point) -> &Tile { &self.0[point.y][point.x] } } fn count_trees(map: &Map, slope: &Point) -> usize { let mut count = 0; let mut p...
code_fim
hard
{ "lang": "rust", "repo": "gelendir/aoc2020", "path": "/day3/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gelendir/aoc2020 path: /day3/src/main.rs use std::env; use std::fs::File; use std::io::prelude::*; use std::io::BufReader; /// Can be used to represent a coordinate on the map, or a slope delta #[derive(Debug)] struct Point { x: usize, y: usize } #[derive(Debug, PartialEq)] enum Tile {...
code_fim
hard
{ "lang": "rust", "repo": "gelendir/aoc2020", "path": "/day3/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }