text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>, &schema , "' AND table_name = '" , &table , "'" ].concat(); let thisqry: &str = &query[..]; // convert string to &str let pgrst=conn.query(thisqry, &[]).unwrap(); for row in pgrst{ let rownum: i64=row.get(0); if rownum == 0{return false;} break; } return tru...
code_fim
hard
{ "lang": "rust", "repo": "sinnud/yahoofinance", "path": "/src/pg_utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>n pg_truncate_tbl(self: &Self, conn: &mut Client , schema: String, table: String ){ let query = ["truncate table " , &schema , "." , &table ].concat(); let thisqry: &str = &query[..]; // convert string to &str conn.batch_execute(thisqry).unwrap(); } pub fn pg_im...
code_fim
hard
{ "lang": "rust", "repo": "sinnud/yahoofinance", "path": "/src/pg_utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sinnud/yahoofinance path: /src/pg_utils.rs // postgres utilities extern crate postgres; use postgres::{Client, NoTls}; use std::io::Write; pub struct PgUtils{ host: String, user: String, password: String, } impl Default for PgUtils { fn default() -> Self { PgUtils { host:...
code_fim
hard
{ "lang": "rust", "repo": "sinnud/yahoofinance", "path": "/src/pg_utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[macro_export] macro_rules! uart_print { ($($args:tt)+) => ({ use core::fmt::Write; write!($crate::uart::UnsafeUart, $($args)+).unwrap() }); } #[macro_export] macro_rules! uart_println { () => ({ $crate::uart_print!("\n") }); ($fmt:expr) => ({ $crate::...
code_fim
medium
{ "lang": "rust", "repo": "kingkongtree/new-tee-os", "path": "/keystone-rt/src/uart.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kingkongtree/new-tee-os path: /keystone-rt/src/uart.rs use core::fmt::Write; use hal::arch::keystone::sbi; pub struct UnsafeUart; <|fim_suffix|>#[macro_export] macro_rules! uart_print { ($($args:tt)+) => ({ use core::fmt::Write; write!($crate::uart::UnsafeUart, $($args)+)....
code_fim
medium
{ "lang": "rust", "repo": "kingkongtree/new-tee-os", "path": "/keystone-rt/src/uart.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!( "{}", my_function() ) }<|fim_prefix|>// repo: stevenliebregt/cargo-generate-rosalind-template path: /src/main.rs use app::{my_function}; use std::{env, fs}; <|fim_middle|>fn main() { let path = env::args().nth(1).unwrap(); let contents = fs::read_to_string(path)...
code_fim
medium
{ "lang": "rust", "repo": "stevenliebregt/cargo-generate-rosalind-template", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let path = env::args().nth(1).unwrap(); let contents = fs::read_to_string(path).unwrap(); let mut lines = contents.lines(); println!( "{}", my_function() ) }<|fim_prefix|>// repo: stevenliebregt/cargo-generate-rosalind-template path: /src/main.rs use app::{my_functio...
code_fim
easy
{ "lang": "rust", "repo": "stevenliebregt/cargo-generate-rosalind-template", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stevenliebregt/cargo-generate-rosalind-template path: /src/main.rs use app::{my_function}; use std::{env, fs}; fn main() { <|fim_suffix|> let mut lines = contents.lines(); println!( "{}", my_function() ) }<|fim_middle|> let path = env::args().nth(1).unwrap(); ...
code_fim
medium
{ "lang": "rust", "repo": "stevenliebregt/cargo-generate-rosalind-template", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while (cur < n) { sum += cur; ind += 3.0; cur = fibn(ind); } println!("{}", sum); }<|fim_prefix|>// repo: egorsmth/project_xeux path: /rust/2.rs use std::io::{self}; fn fibn(n:f64) -> f64 { (gl.powf(n) - z.powf(n))/5.0_f64.sqrt() } fn main() { <|fim_middle|> let n:f64 = 40.0; co...
code_fim
medium
{ "lang": "rust", "repo": "egorsmth/project_xeux", "path": "/rust/2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: egorsmth/project_xeux path: /rust/2.rs use std::io::{self}; fn fibn(n:f64) -> f64 { <|fim_suffix|> let n:f64 = 40.0; const gl:f64 = (1.0 + 5.0_f64.sqrt())/2.0; const z:f64 = (1.0 - 5.0_f64.sqrt())/2.0; let mut ind:f64 = 3.0; let mut sum:f64 = 0.0; let mut cur:f64 = fibn(ind); wh...
code_fim
easy
{ "lang": "rust", "repo": "egorsmth/project_xeux", "path": "/rust/2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: remorses/block-mesh-rs path: /bench/src/bench.rs use block_mesh::ndshape::{ConstShape, ConstShape3u32}; use block_mesh::{ greedy_quads, visible_block_faces, GreedyQuadsBuffer, MergeVoxel, UnitQuadBuffer, Voxel, RIGHT_HANDED_Y_UP_CONFIG, }; use criterion::{criterion_group, criterion_main...
code_fim
hard
{ "lang": "rust", "repo": "remorses/block-mesh-rs", "path": "/bench/src/bench.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut group = c.benchmark_group("bench_sphere_simple"); let mut samples = [EMPTY; SampleShape::SIZE as usize]; for i in 0u32..(SampleShape::SIZE) { let p = into_domain(16, SampleShape::delinearize(i)); samples[i as usize] = sphere_voxel(p); } let mut buffer = UnitQua...
code_fim
hard
{ "lang": "rust", "repo": "remorses/block-mesh-rs", "path": "/bench/src/bench.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut group = c.benchmark_group("bench_empty_space_simple"); let samples = [EMPTY; SampleShape::SIZE as usize]; let mut buffer = UnitQuadBuffer::new(); visible_block_faces( &samples, &SampleShape {}, [0; 3], [17; 3], &RIGHT_HANDED_Y_UP_CONFIG.face...
code_fim
hard
{ "lang": "rust", "repo": "remorses/block-mesh-rs", "path": "/bench/src/bench.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Dherse/secs path: /codegen/src/store.rs use proc_macro2::TokenStream; use crate::{ component::{Component, ComponentStorage}, ecs::ECS, GenericOutput, }; pub(crate) fn make_component_store<'a>( main: &ECS<'a>, components: &[Component<'a>], generics: &GenericOutput, ) -> ...
code_fim
hard
{ "lang": "rust", "repo": "Dherse/secs", "path": "/codegen/src/store.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> impl#component_generics Default for #component_store#component_generics { fn default() -> Self { Self::new() } } impl#component_generics #component_store#component_generics { #[doc = "Initializes a new component store"] ...
code_fim
hard
{ "lang": "rust", "repo": "Dherse/secs", "path": "/codegen/src/store.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pantsbuild/pants path: /src/rust/engine/protos/src/hashing.rs // Copyright 2023 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). use std::hash::{Hash, Hasher}; use crate::gen::pants::cache::dependency_inference_request::Metadata;...
code_fim
medium
{ "lang": "rust", "repo": "pantsbuild/pants", "path": "/src/rust/engine/protos/src/hashing.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Hash for Metadata { fn hash<H: Hasher>(&self, state: &mut H) { match self { Metadata::Js(m) => m.hash(state), } } }<|fim_prefix|>// repo: pantsbuild/pants path: /src/rust/engine/protos/src/hashing.rs // Copyright 2023 Pants project contributors (see CONTRIBUTORS.md). // Licensed un...
code_fim
hard
{ "lang": "rust", "repo": "pantsbuild/pants", "path": "/src/rust/engine/protos/src/hashing.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jubitaneja/wasmtime path: /crates/c-api/src/extern.rs use crate::{ wasm_externkind_t, wasm_externtype_t, wasm_func_t, wasm_global_t, wasm_instance_t, wasm_memory_t, wasm_module_t, wasm_table_t, }; use wasmtime::Extern; #[derive(Clone)] pub struct wasm_extern_t { pub(crate) which: Ex...
code_fim
hard
{ "lang": "rust", "repo": "jubitaneja/wasmtime", "path": "/crates/c-api/src/extern.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub extern "C" fn wasm_extern_as_module(e: &wasm_extern_t) -> Option<&wasm_module_t> { wasm_module_t::try_from(e) } #[no_mangle] pub extern "C" fn wasm_extern_as_module_const(e: &wasm_extern_t) -> Option<&wasm_module_t> { wasm_extern_as_module(e) } #[no_mangle] pub extern "C" fn was...
code_fim
hard
{ "lang": "rust", "repo": "jubitaneja/wasmtime", "path": "/crates/c-api/src/extern.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|>impl From<AuthError> for ScError { fn from(error: AuthError) -> Self { Self::AuthError(error) } } impl From<ClientError> for ScError { fn from(error: ClientError) -> Self { Self::ClientError(error) } } impl From<FlvSocketError> for ScError { fn from(error: FlvSocketEr...
code_fim
medium
{ "lang": "rust", "repo": "avinassh/fluvio", "path": "/src/sc/src/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: avinassh/fluvio path: /src/sc/src/error.rs // error.rs // Server Error handling (union of errors used by server) // use std::fmt; use std::io::Error as IoError; use fluvio_types::PartitionError; use k8_client::ClientError; use fluvio_socket::FlvSocketError; use fluvio_auth::AuthError; #[deri...
code_fim
medium
{ "lang": "rust", "repo": "avinassh/fluvio", "path": "/src/sc/src/error.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl From<FlvSocketError> for ScError { fn from(error: FlvSocketError) -> Self { Self::SocketError(error) } } impl From<PartitionError> for ScError { fn from(error: PartitionError) -> Self { Self::PartitionError(error) } }<|fim_prefix|>// repo: avinassh/fluvio path: /src/...
code_fim
hard
{ "lang": "rust", "repo": "avinassh/fluvio", "path": "/src/sc/src/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn parse(value: Value) -> InputValueResult<Self> { match value { Value::Boolean(n) => Ok(n), _ => Err(InputValueError::ExpectedType(value)), } } fn is_valid(value: &Value) -> bool { match value { Value::Boolean(_) => true, ...
code_fim
hard
{ "lang": "rust", "repo": "oro13/async-graphql", "path": "/src/scalars/bool.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oro13/async-graphql path: /src/scalars/bool.rs use crate::{InputValueError, InputValueResult, Result, ScalarType, Value}; use async_graphql_derive::Scalar; #[Scalar(internal)] impl ScalarType for bool { fn type_name() -> &'static str { "Boolean" } fn description() -> Option...
code_fim
hard
{ "lang": "rust", "repo": "oro13/async-graphql", "path": "/src/scalars/bool.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn store(&mut self, path: &str, data: &[u8]) -> StorageResult<()>; }<|fim_prefix|>// repo: PsichiX/Oxygengine path: /engine/core/src/storage/mod.rs pub mod engines; #[derive(Debug, Clone)] pub enum StorageError { /// path to resource. CouldNotLoadData(String), /// path to resource. C...
code_fim
medium
{ "lang": "rust", "repo": "PsichiX/Oxygengine", "path": "/engine/core/src/storage/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PsichiX/Oxygengine path: /engine/core/src/storage/mod.rs pub mod engines; #[derive(Debug, Clone)] pub enum StorageError { /// path to resource. CouldNotLoadData(String), /// path to resource. CouldNotStoreData(String), } <|fim_suffix|> fn store(&mut self, path: &str, data: &...
code_fim
medium
{ "lang": "rust", "repo": "PsichiX/Oxygengine", "path": "/engine/core/src/storage/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jimy-byerley/tri-mesh path: /examples/dust/lib/gl/build.rs use gl_generator::{Registry, Fallbacks, Api, Profile}; use std::env; use std::fs::File; use std::path::Path; fn main() { let out_dir = env::var("OUT_DIR").unwrap(); let file_gl = File::create(&Path::new(&out_dir).join("bindings....
code_fim
hard
{ "lang": "rust", "repo": "jimy-byerley/tri-mesh", "path": "/examples/dust/lib/gl/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if env::var("CARGO_FEATURE_DEBUG").is_ok() { registry.write_bindings( DebugStructGenerator, &mut file_gl ).unwrap(); } else { registry.write_bindings( StructGenerator, &mut file_gl ).unwrap(); } }<|fim_prefix|>// r...
code_fim
hard
{ "lang": "rust", "repo": "jimy-byerley/tri-mesh", "path": "/examples/dust/lib/gl/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> c.bench_function("Troika with input of 8019 trits", |b| { b.iter(|| basic_troika()) }); } criterion_group!(benches, ftroika_benchmark, troika_benchmark); criterion_main!(benches);<|fim_prefix|>// repo: ben-75/troika_rust path: /benches/troika_benchmark.rs /* * Copyright (C) 2019 Yu-Wei ...
code_fim
hard
{ "lang": "rust", "repo": "ben-75/troika_rust", "path": "/benches/troika_benchmark.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ben-75/troika_rust path: /benches/troika_benchmark.rs /* * Copyright (C) 2019 Yu-Wei Wu * All Rights Reserved. * This is free software; you can redistribute it and/or modify it under the * terms of the MIT license. A copy of the license can be found in the file * "LICENSE" at the root of th...
code_fim
hard
{ "lang": "rust", "repo": "ben-75/troika_rust", "path": "/benches/troika_benchmark.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (name, child) = from; let rel_field = match name { "ToOneOpt" => RelationField::ToOneOpt { child }, "ToOneReq" => RelationField::ToOneReq { child }, "ToMany" => RelationField::ToMany { child }, _ => { return Err(TestError:...
code_fim
hard
{ "lang": "rust", "repo": "prisma/prisma-engines", "path": "/query-engine/connector-test-kit-rs/query-tests-setup/src/schema_gen/relation_field.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl TryFrom<(&str, bool)> for RelationField { type Error = TestError; fn try_from(from: (&str, bool)) -> Result<Self, Self::Error> { let (name, child) = from; let rel_field = match name { "ToOneOpt" => RelationField::ToOneOpt { child }, "ToOneReq" => Relat...
code_fim
hard
{ "lang": "rust", "repo": "prisma/prisma-engines", "path": "/query-engine/connector-test-kit-rs/query-tests-setup/src/schema_gen/relation_field.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug)] pub struct ApplicationCommandInteraction { pub id: Snowflake, pub application_id: Snowflake, pub r#type: InteractionType, pub data: ApplicationCommandInteractionData, pub guild_id: Option<Snowflake>, pub channel_id: Snowflake, pub member...
code_fim
hard
{ "lang": "rust", "repo": "BEDSpEedTEST/tickets.rs", "path": "/model/src/interaction/interaction.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BEDSpEedTEST/tickets.rs path: /model/src/interaction/interaction.rs use crate::channel::message::Message; use crate::guild::Member; use crate::interaction::{ApplicationCommandInteractionData, ComponentType}; use crate::user::User; use crate::Snowflake; use serde::de::Error; use serde::{Deseriali...
code_fim
hard
{ "lang": "rust", "repo": "BEDSpEedTEST/tickets.rs", "path": "/model/src/interaction/interaction.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(match value { 1 => Self::Ping, 2 => Self::ApplicationCommand, 3 => Self::MessageComponent, _ => return Err(format!("invalid interaction type \"{}\"", value).into_boxed_str()), }) } } #[derive(Serialize, Deserialize, Debug)] pub struct...
code_fim
hard
{ "lang": "rust", "repo": "BEDSpEedTEST/tickets.rs", "path": "/model/src/interaction/interaction.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cqueirolo/21C1-Stormtroopers path: /web_services/src/handlers/command_filter.rs pub fn filter_cmd(cmd: String) -> String { let cmd_aux = cmd.to_lowercase(); let cmds: Vec<&str> = cmd_au<|fim_suffix|>" || cmds[0] == "exit" { format!("DISABLED COMMAND: {}", cmd) } e...
code_fim
hard
{ "lang": "rust", "repo": "cqueirolo/21C1-Stormtroopers", "path": "/web_services/src/handlers/command_filter.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>" || cmds[0] == "exit" { format!("DISABLED COMMAND: {}", cmd) } else { cmd } }<|fim_prefix|>// repo: cqueirolo/21C1-Stormtroopers path: /web_services/src/handlers/command_filter.rs pub fn filter_cmd(cmd: String) -> String { let cmd_aux = cmd.to_lowercase(); let...
code_fim
hard
{ "lang": "rust", "repo": "cqueirolo/21C1-Stormtroopers", "path": "/web_services/src/handlers/command_filter.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>[0] == "suscribe" || cmds[0] == "publish" || cmds[0] == "unsuscribe" || cmds[0] == "clear" || cmds[0] == "exit" { format!("DISABLED COMMAND: {}", cmd) } else { cmd } }<|fim_prefix|>// repo: cqueirolo/21C1-Stormtroopers path: /web_services/src/ha...
code_fim
medium
{ "lang": "rust", "repo": "cqueirolo/21C1-Stormtroopers", "path": "/web_services/src/handlers/command_filter.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn emit_ir(&self, module: LLVMModuleRef) -> Result<MemoryBuffer, CodeGenError> { let out = unsafe { LLVMPrintModuleToString(module) }; Ok(MemoryBuffer::from_ptr(out)) } pub fn emit_asm(&self, module: LLVMModuleRef) -> Result<MemoryBuffer, CodeGenError> { self.emit(...
code_fim
hard
{ "lang": "rust", "repo": "frustigor/lumen", "path": "/lumen/src/compiler/codegen/llvm/target.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: frustigor/lumen path: /lumen/src/compiler/codegen/llvm/target.rs use std::ffi::CStr; use llvm_sys::core::*; use llvm_sys::prelude::*; use llvm_sys::target::*; use llvm_sys::target_machine::*; use llvm_sys::transforms::pass_manager_builder; use super::memory_buffer::MemoryBuffer; use super::*; ...
code_fim
hard
{ "lang": "rust", "repo": "frustigor/lumen", "path": "/lumen/src/compiler/codegen/llvm/target.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cpcsdk/rust.cpclib path: /cpclib-xfer/src/lib.rs use std::fs; use std::path::Path; use curl::easy::{Easy, Form}; use curl::Error; use custom_error::custom_error; use path_absolutize::*; use {cpclib_disc as disc, cpclib_sna as sna, path_absolutize}; use crate::disc::amsdos::AmsdosFileType; use ...
code_fim
hard
{ "lang": "rust", "repo": "cpcsdk/rust.cpclib", "path": "/cpclib-xfer/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // sleep a bit to be sure the file is not deleted BEFORE sending it to CPC std::thread::sleep(std::time::Duration::from_secs(5)); temp_path.close().map_err(|e| { XferError::InternalError { reason: e.to_string() } }) } pub fn ...
code_fim
hard
{ "lang": "rust", "repo": "cpcsdk/rust.cpclib", "path": "/cpclib-xfer/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ax-lab/v1-kana path: /src/util.rs //! Internal utility functions. /// Check if the character is in the given range (inclusive). #[inline] pub fn char_in_range(c: char, start: u32, end: u32) -> bool { let c = c as u32; c >= start && c <= end } /// Return a prefix of at most `n` chara...
code_fim
hard
{ "lang": "rust", "repo": "ax-lab/v1-kana", "path": "/src/util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> "sa" => "za", "shi" => "ji", "su" => "zu", "se" => "ze", "so" => "zo", "ta" => "da", "chi" => "di", "tsu" => "du", "te" => "de", "to" => "do", "ha" => "ba", "hi" => "bi", "fu" => "bu", "he" => "be", "ho" => "bo", _ => "", } }<|fim_prefix|>// repo: ax...
code_fim
hard
{ "lang": "rust", "repo": "ax-lab/v1-kana", "path": "/src/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lvheyang/influxdb_iox path: /generated_types/src/database_rules/lifecycle.rs use std::convert::{TryFrom, TryInto}; use std::num::{NonZeroU32, NonZeroU64, NonZeroUsize}; use data_types::database_rules::{ LifecycleRules, DEFAULT_CATALOG_TRANSACTIONS_UNTIL_CHECKPOINT, DEFAULT_LATE_ARRIVE_W...
code_fim
hard
{ "lang": "rust", "repo": "lvheyang/influxdb_iox", "path": "/generated_types/src/database_rules/lifecycle.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(back.buffer_size_soft, protobuf.buffer_size_soft); assert_eq!(back.buffer_size_hard, protobuf.buffer_size_hard); assert_eq!(back.drop_non_persisted, protobuf.drop_non_persisted); assert_eq!(back.immutable, protobuf.immutable); assert_eq!(back.worker_backo...
code_fim
hard
{ "lang": "rust", "repo": "lvheyang/influxdb_iox", "path": "/generated_types/src/database_rules/lifecycle.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rantt-io/rantt path: /src/cli/config/set.rs use clap::*; pub fn build_cli<'a, 'b>() -> App<'a, 'b> { App::new("set") .version(crate_version!<|fim_suffix|>(_matches: &ArgMatches) { println!("config set"); }<|fim_middle|>()) .about("Set a config value") } pub fn run
code_fim
easy
{ "lang": "rust", "repo": "rantt-io/rantt", "path": "/src/cli/config/set.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>()) .about("Set a config value") } pub fn run(_matches: &ArgMatches) { println!("config set"); }<|fim_prefix|>// repo: rantt-io/rantt path: /src/cli/config/set.rs use clap::*; pub fn build_cli<'a, 'b>() -> App<'a, 'b<|fim_middle|>> { App::new("set") .version(crate_version!
code_fim
easy
{ "lang": "rust", "repo": "rantt-io/rantt", "path": "/src/cli/config/set.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use connection::Connection; pub use connection_options::ConnectionOptions; pub use error::Error; pub use event::*; pub use parameter::Parameter; pub use parameter::ParameterIndex; pub use parameter::Parameters; pub use parameter_type::ParameterType; pub use result::{Async, AsyncResult, Result}; pub us...
code_fim
medium
{ "lang": "rust", "repo": "alekitto/dbal", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alekitto/dbal path: /src/lib.rs #![feature(async_closure)] #![feature(backtrace)] #![feature(decl_macro)] #![feature(type_alias_impl_trait)] <|fim_suffix|>pub use connection::Connection; pub use connection_options::ConnectionOptions; pub use error::Error; pub use event::*; pub use parameter::Pa...
code_fim
medium
{ "lang": "rust", "repo": "alekitto/dbal", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>'a> IOMUX_ALTF1_OENSEL_1_W<'a> { #[doc = r"Writes raw bits to the field"] #[inline(always)] pub unsafe fn bits(self, value: u8) -> &'a mut W { self.w.bits = (self.w.bits & !0x3f) | ((value as u32) & 0x3f); self.w } } impl R { #[doc = "Bits 0:5 - 0: Select ATF2 1: Select...
code_fim
hard
{ "lang": "rust", "repo": "nickray/muscab1-pac", "path": "/src/scc/iomux_altf1_oensel_1.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn iomux_altf1_oensel_1(&self) -> IOMUX_ALTF1_OENSEL_1_R { IOMUX_ALTF1_OENSEL_1_R::new((self.bits & 0x3f) as u8) } } impl W { #[doc = "Bits 0:5 - 0: Select ATF2 1: Select ATF1"] #[inline(always)] pub fn iomux_altf1_oensel_1(&mut self) -> IOMUX_ALTF1_OENSEL_1_W { IOMUX_A...
code_fim
hard
{ "lang": "rust", "repo": "nickray/muscab1-pac", "path": "/src/scc/iomux_altf1_oensel_1.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nickray/muscab1-pac path: /src/scc/iomux_altf1_oensel_1.rs #[doc = "Reader of register IOMUX_ALTF1_OENSEL_1"] pub type R = crate::R<u32, super::IOMUX_ALTF1_OENSEL_1>; #[doc = "Writer for register IOMUX_ALTF1_OENSEL_1"] pub type W = crate::W<u32, super::IOMUX_ALTF1_OENSEL_1>; #[doc = "Register IO...
code_fim
hard
{ "lang": "rust", "repo": "nickray/muscab1-pac", "path": "/src/scc/iomux_altf1_oensel_1.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: roy-ganz/toql path: /tests/predicate.rs use toql::mock_db::MockDb; use toql::predicate_handler::PredicateHandler; use toql::prelude::{ query, Cache, ResolverError, SqlArg, SqlBuilderError, Toql, ToqlApi, ToqlError, }; use toql::row; use tracing_test::traced_test; #[derive(Debug, Default, To...
code_fim
hard
{ "lang": "rust", "repo": "roy-ganz/toql", "path": "/tests/predicate.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[tokio::test] #[traced_test("info")] async fn load3() { let cache = Cache::new(); let mut toql = MockDb::from(&cache); // Handler raises error let q = query!(Level1, "@hPred"); let err = toql.load_many(&q).await.err().unwrap(); assert_eq!( err.to_string(), ToqlEr...
code_fim
hard
{ "lang": "rust", "repo": "roy-ganz/toql", "path": "/tests/predicate.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let res = String::from("all good?"); assert!( *w == 4.5451703e-3, "test failed with '{}'", res); } #[test] fn test_inp_cms() { let _ds = std::fs::read_to_string("dat/tav-1.dat").unwrap(); let ds = TAV4.to_string(); let VHMeas {vertex: _x, helices: hl} = h_slurp(ds).unwrap(); let HM...
code_fim
hard
{ "lang": "rust", "repo": "LATBauerdick/fv-rs", "path": "/src/inp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>const TAV4: &'static str = r"PU_zpositions: 190 4.06972837448 2.44204807281 7.82136058807 -0.621172726154 -6.80061435699 -1.73116350174 -5.42739343643 -7.10662841797 -6.32562208176 -3.72315001488 1.66695046425 6.55822181702 -7.12538957596 -0.389555871487 -2.8334877491 3.09819436073 -5.65534687042 12.0682...
code_fim
hard
{ "lang": "rust", "repo": "LATBauerdick/fv-rs", "path": "/src/inp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LATBauerdick/fv-rs path: /src/inp.rs use crate::types::*; use crate::cov::*; pub fn h_slurp(ds: String) -> Option<VHMeas> { let ws = ds.split_whitespace().collect::<Vec<&str>>(); // println!("h_slurp len = {:?}", ws.len()); // sometimes there is PU information at the front -- ski...
code_fim
hard
{ "lang": "rust", "repo": "LATBauerdick/fv-rs", "path": "/src/inp.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut contents = String::new(); std::fs::File::open("../1342-0.txt") .unwrap() .read_to_string(&mut contents) .unwrap(); let _dhat = Dhat::start_heap_profiling(); for _ in 0..10 { let mut map = StringHashMap::<u32>::with_power_of_two_size(...
code_fim
medium
{ "lang": "rust", "repo": "fulmicoton/insert_only_string_hash_map", "path": "/compare_allocations/src/bin/inohash.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fulmicoton/insert_only_string_hash_map path: /compare_allocations/src/bin/inohash.rs use inohashmap::StringHashMap; use std::io::Read; use dhat::{Dhat, DhatAlloc}; #[global_allocator] static ALLOCATOR: DhatAlloc = DhatAlloc; <|fim_suffix|> let mut contents = String::new(); std::fs:...
code_fim
medium
{ "lang": "rust", "repo": "fulmicoton/insert_only_string_hash_map", "path": "/compare_allocations/src/bin/inohash.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mikephul/graph-node path: /store/postgres/src/block_store.rs use std::{ collections::HashMap, sync::{Arc, RwLock}, }; use graph::{ components::store::BlockStore as BlockStoreTrait, prelude::{error, EthereumBlockPointer, EthereumNetworkIdentifier, Logger}, }; use graph::{componen...
code_fim
hard
{ "lang": "rust", "repo": "mikephul/graph-node", "path": "/store/postgres/src/block_store.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn chain_head_pointers(&self) -> Result<HashMap<String, EthereumBlockPointer>, StoreError> { let mut map = HashMap::new(); let stores = self .stores .read() .unwrap() .values() .cloned() .collect::<Vec<_>>(); ...
code_fim
hard
{ "lang": "rust", "repo": "mikephul/graph-node", "path": "/store/postgres/src/block_store.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> take_all_items(cpu); let items = [ "hypercube", "coin", "klein bottle", "shell", "easter egg", "astrolabe", "tambourine", "dark matter" ]; for combination in 0..(1 << items.len()) { let mut cpu = cpu.clone(); f...
code_fim
hard
{ "lang": "rust", "repo": "emmericp/advent-of-code-2019", "path": "/src/bin/day25.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emmericp/advent-of-code-2019 path: /src/bin/day25.rs use std::fs; use advent_of_code::intcode::IntCodeCpu; #[allow(unused_imports)] use std::io::stdin; fn main() { let input = fs::read_to_string("./input/day25.txt").unwrap(); let cpu = IntCodeCpu::from_code(&input); part1(&mut cpu.c...
code_fim
hard
{ "lang": "rust", "repo": "emmericp/advent-of-code-2019", "path": "/src/bin/day25.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/once_cell/v1/crate/examples/bench_acquire.rs //! Benchmark the overhead that the synchronization of `OnceCell::get` causes. //! We do some other operations that write to memory to get an imprecise but somewhat realistic //! measurement. use once_cell::s...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/once_cell/v1/crate/examples/bench_acquire.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let start = std::time::Instant::now(); let threads = (0..N_THREADS).map(|i| std::thread::spawn(move || thread_main(i))).collect::<Vec<_>>(); for thread in threads { thread.join().unwrap(); } println!("{:?}", start.elapsed()); println!("{:?}", OTHER.load(...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/once_cell/v1/crate/examples/bench_acquire.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // The operations we do here don't really matter, as long as we do multiple writes, and // everything is messy enough to prevent the compiler from optimizing the loop away. let mut data = [i; 128]; let mut accum = 0usize; for _ in 0..N_ROUNDS { let _value = CELL.get_or_init(|| ...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/once_cell/v1/crate/examples/bench_acquire.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut args = std::env::args().skip(1); let reader = maxminddb::Reader::open_readfile( args.next() .ok_or("First argument must be the path to the IP database").unwrap(), ).unwrap(); return Ok(reader); } fn is_valid(&self, _: &mut maxmin...
code_fim
hard
{ "lang": "rust", "repo": "oltdaniel/auftritt", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oltdaniel/auftritt path: /src/main.rs use std::net::{SocketAddr, IpAddr}; use actix_web::{web, App, HttpResponse, HttpRequest, HttpServer, Responder}; use actix_web::http::{StatusCode}; use r2d2::{ManageConnection}; use maxminddb::geoip2; use serde::{Serialize}; type MaxmindPool = r2d2::Pool<M...
code_fim
hard
{ "lang": "rust", "repo": "oltdaniel/auftritt", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> = true; const OFFSET: u8 = 2; ((self.bits >> OFFSET) & MASK as u8) != 0 }; RXIMR { bits } } #[doc = "Bit 3 - Transmit FIFO interrupt mask:<ul><li>0: Transmit interrupt is masked (irq disabled).</li><li>1: Transmit interrupt is not masked (irq enabled).</li>...
code_fim
hard
{ "lang": "rust", "repo": "alistairbill/bluenrg1", "path": "/src/spi/imsc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alistairbill/bluenrg1 path: /src/spi/imsc.rs #[doc = r" Value read from the register"] pub struct R { bits: u8, } #[doc = r" Value to write to the register"] pub struct W { bits: u8, } impl super::IMSC { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modi...
code_fim
hard
{ "lang": "rust", "repo": "alistairbill/bluenrg1", "path": "/src/spi/imsc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> welcome::welcome_msg(); let mut game_output: screen::TerminalScreen = screen::get_terminal_size(); let default_maze: Vec<Vec<String>> = screen::build_game_screen(&mut game_output); loop { println!("Generating New Maze"); let mut new_game: Vec<Vec<String>> = default_maze.cl...
code_fim
medium
{ "lang": "rust", "repo": "plavabe12/maze_rs", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> loop { println!("Generating New Maze"); let mut new_game: Vec<Vec<String>> = default_maze.clone(); screen::build_maze(&mut new_game, &game_output); player::play_game(&mut new_game, &game_output); } }<|fim_prefix|>// repo: plavabe12/maze_rs path: /src/main.rs // Cop...
code_fim
hard
{ "lang": "rust", "repo": "plavabe12/maze_rs", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: plavabe12/maze_rs path: /src/main.rs // Copyright © 2019 Ebraheem AlAthari // [This program is licensed under the "MIT License"] // Please see the file LICENSE in the source // distribution of this software for license terms. // *** Rust Declarations *** mod player; mod screen; mod welcome; <|...
code_fim
hard
{ "lang": "rust", "repo": "plavabe12/maze_rs", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: red-avtovo/rust-redisish path: /src/main.rs extern crate uuid; use std::io; use std::net::TcpListener; use std::sync::{Arc, Mutex}; <|fim_suffix|>fn main() -> io::Result<()> { let listener = TcpListener::bind("127.0.0.1:8080")?; let atomic_data: Arc<Mutex<Vec<String>>> = Arc::new(Mutex...
code_fim
medium
{ "lang": "rust", "repo": "red-avtovo/rust-redisish", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let listener = TcpListener::bind("127.0.0.1:8080")?; let atomic_data: Arc<Mutex<Vec<String>>> = Arc::new(Mutex::new(Vec::new())); let mut pool = pool::new(3,1); // accept connections and process them serially for stream in listener.incoming() { let arc = Arc::clone(&atomic_data...
code_fim
medium
{ "lang": "rust", "repo": "red-avtovo/rust-redisish", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn scale(&self) -> PreviewSize { self.preview_size } }<|fim_prefix|>// repo: apheon-terra/image-roll path: /src/settings.rs use crate::image::PreviewSize; pub struct Settings { preview_size: PreviewSize, } <|fim_middle|>impl Settings { pub fn new(preview_size: PreviewSize) -...
code_fim
hard
{ "lang": "rust", "repo": "apheon-terra/image-roll", "path": "/src/settings.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: apheon-terra/image-roll path: /src/settings.rs use crate::image::PreviewSize; pub struct Settings { preview_size: PreviewSize, } <|fim_suffix|> pub fn scale(&self) -> PreviewSize { self.preview_size } }<|fim_middle|>impl Settings { pub fn new(preview_size: PreviewSize) -...
code_fim
hard
{ "lang": "rust", "repo": "apheon-terra/image-roll", "path": "/src/settings.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let pc = self.pc; self.pc += 2; f(self, self.read(pc + 1)?)?; Ok(Status::Normal) } fn exec3(&mut self, f: impl Fn(&mut State, Word, Word, Word) -> CpuResult<()>) -> CpuResult<Status> { let pc = self.pc; self.pc += 4; f(self, self.read(pc + 1...
code_fim
hard
{ "lang": "rust", "repo": "juho-p/advent-of-code-2019", "path": "/src/intcode.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: juho-p/advent-of-code-2019 path: /src/intcode.rs use std::fs; use std::iter; type CpuResult<T> = Result<T, String>; pub type Word = i32; #[derive(PartialEq)] pub enum Status { Normal, Output(Word), Halted, } pub struct State { mem: Vec<Word>, pc: Word, done: bool, ...
code_fim
hard
{ "lang": "rust", "repo": "juho-p/advent-of-code-2019", "path": "/src/intcode.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if f(self.mode_val(mode, 0, self.read(self.pc + 1)?)?) { self.pc = self.mode_val(mode, 1, self.read(self.pc + 2)?)?; } else { self.pc += 3; } Ok(Status::Normal) } } pub fn run_until_output(state: &mut State) -> CpuResult<Option<Word>> { loop...
code_fim
hard
{ "lang": "rust", "repo": "juho-p/advent-of-code-2019", "path": "/src/intcode.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TianTianForever/Rust-Tutorial path: /thirty-five_days_of_rust/myerror.rs use std::num::ParseIntError; use std::ops::Deref; use std::fmt; #[derive(Debug)] pub struct Animal { pub dog: Box<String>, pub cat: String, } <|fim_suffix|>pub fn mul(vec: Vec<&str>) -> Result<i32> { let value...
code_fim
hard
{ "lang": "rust", "repo": "TianTianForever/Rust-Tutorial", "path": "/thirty-five_days_of_rust/myerror.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Display for MyError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { MyError::EmptyValue => write!(f, "Empty value"), MyError::Parse(ref e) => e.fmt(f), } } } pub fn mul(vec: Vec<&str>) -> Result<i32> { le...
code_fim
hard
{ "lang": "rust", "repo": "TianTianForever/Rust-Tutorial", "path": "/thirty-five_days_of_rust/myerror.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> context.host().lock().print_err(error, &source); true } else { false } }<|fim_prefix|>// repo: seanwallawalla-forks/nushell path: /crates/nu-engine/src/print.rs use nu_source::Text; use crate::EvaluationContext; pub fn maybe_print_errors(context: &EvaluationContext, sour...
code_fim
medium
{ "lang": "rust", "repo": "seanwallawalla-forks/nushell", "path": "/crates/nu-engine/src/print.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seanwallawalla-forks/nushell path: /crates/nu-engine/src/print.rs use nu_source::Text; use crate::EvaluationContext; pub fn maybe_print_errors(context: &EvaluationContext, source: Text) -> bool { let errors = context.current_errors().clone(); let mut errors = errors.lock(); <|fim_suff...
code_fim
medium
{ "lang": "rust", "repo": "seanwallawalla-forks/nushell", "path": "/crates/nu-engine/src/print.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if errors.len() > 0 { let error = errors[0].clone(); *errors = vec![]; context.host().lock().print_err(error, &source); true } else { false } }<|fim_prefix|>// repo: seanwallawalla-forks/nushell path: /crates/nu-engine/src/print.rs use nu_source::Text;...
code_fim
medium
{ "lang": "rust", "repo": "seanwallawalla-forks/nushell", "path": "/crates/nu-engine/src/print.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FOEX-IoT/IoT-PoC path: /backend/iot_server/src/websocket/ws_session.rs use crate::websocket::messages::BCMessage; use actix::*; use actix_web_actors::ws; use crate::tradfri::TradfriServer; use crate::websocket::messages::*; use crate::websocket::ws_server::BroadcastServer; /// This is the indi...
code_fim
hard
{ "lang": "rust", "repo": "FOEX-IoT/IoT-PoC", "path": "/backend/iot_server/src/websocket/ws_session.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// WebSocket message handler impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for WSSession { fn handle(&mut self, msg: Result<ws::Message, ws::ProtocolError>, ctx: &mut Self::Context) { let msg = match msg { Err(_) => { ctx.stop(); return...
code_fim
hard
{ "lang": "rust", "repo": "FOEX-IoT/IoT-PoC", "path": "/backend/iot_server/src/websocket/ws_session.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Handle messages which are received from the server (i.e. updates) impl Handler<BCMessage> for WSSession { type Result = (); fn handle(&mut self, msg: BCMessage, ctx: &mut Self::Context) { ctx.text(msg.0); } } /// WebSocket message handler impl StreamHandler<Result<ws::Message, ws...
code_fim
hard
{ "lang": "rust", "repo": "FOEX-IoT/IoT-PoC", "path": "/backend/iot_server/src/websocket/ws_session.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: agrover/btrfsutil-rs path: /src/error/glue.rs use crate::error::LibErrorCode; use std::ffi::NulError; use std::path::PathBuf; use std::str::Utf8Error; use thiserror::Error; use uuid::Error as UuidError; /// Errors that can be raised by the glue between this Rust library and the original [libb...
code_fim
hard
{ "lang": "rust", "repo": "agrover/btrfsutil-rs", "path": "/src/error/glue.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>tr.html #[error("{0}")] NulError(NulError), /// UuidError. Wrapper around [uuid::Error]. May arise when trying to create a [Uuid] for a /// [SubvolumeInfo] from a byte array. /// /// [uuid::Error]: https://docs.rs/uuid/0.8.1/uuid/struct.Error.html /// [Uuid]: https://docs.rs/uu...
code_fim
hard
{ "lang": "rust", "repo": "agrover/btrfsutil-rs", "path": "/src/error/glue.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: museun/twitchchat path: /examples/simple_bot.rs // note this uses `smol`. you can use `tokio` or `async_std` or `async_io` if you prefer. // this is a helper module to reduce code deduplication // extensions to the Privmsg type use twitchchat::PrivmsgExt as _; use twitchchat::{ messages::{Co...
code_fim
hard
{ "lang": "rust", "repo": "museun/twitchchat", "path": "/examples/simple_bot.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> command.handle(args); } } } // stop if we're stopping Status::Quit | Status::Eof => break, // ignore the rest Status::Message(..) => continue, ...
code_fim
hard
{ "lang": "rust", "repo": "museun/twitchchat", "path": "/examples/simple_bot.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Noia/advent-of-code-2018 path: /04/part1.rs extern crate chrono; extern crate guards; use chrono::Timelike; use guards::{GuardReport, GuardState, RecordFragment}; use std::collections::HashMap; use std::fs::File; use std::io::{BufRead, BufReader, Result}; fn main() { let mut laziest_guard:...
code_fim
hard
{ "lang": "rust", "repo": "Noia/advent-of-code-2018", "path": "/04/part1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn read_input() -> Result<Vec<GuardReport>> { let file = File::open("04/input.txt")?; let file = BufReader::new(file); let mut records: Vec<RecordFragment> = Vec::new(); for line in file.lines().filter_map(|result| result.ok()) { records.push(RecordFragment::new(&line)); } ...
code_fim
hard
{ "lang": "rust", "repo": "Noia/advent-of-code-2018", "path": "/04/part1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let file = File::open("04/input.txt")?; let file = BufReader::new(file); let mut records: Vec<RecordFragment> = Vec::new(); for line in file.lines().filter_map(|result| result.ok()) { records.push(RecordFragment::new(&line)); } return Ok(guards::to_guard_reports(guards::to...
code_fim
hard
{ "lang": "rust", "repo": "Noia/advent-of-code-2018", "path": "/04/part1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jcornaz/polar-clock path: /src/arc.rs use core::time::Duration; use std::f32::consts::PI; use yew::prelude::*; use yew::services::interval::IntervalTask; use yew::services::timeout::TimeoutTask; use yew::services::{IntervalService, TimeoutService}; use crate::svg::*; use crate::vector::*; #[d...
code_fim
hard
{ "lang": "rust", "repo": "jcornaz/polar-clock", "path": "/src/arc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (text_angle, text_color, text_anchor) = if angle >= PI { (angle - (PI / 180.0), "white", "end") } else { (angle + (PI / 180.0), self.props.color, "start") }; let text_pos = Vec2::new(0.0, -inner_radius - (0.2 * self.props.width)).rot...
code_fim
hard
{ "lang": "rust", "repo": "jcornaz/polar-clock", "path": "/src/arc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let inner_start = Vec2 { x: 0.0, y: -inner_radius, }; let outer_start = Vec2 { x: 0.0, y: -outer_radius, }; let outer_end = outer_start.rotate(angle); let inner_end = inner_start.rotate(angle); let pa...
code_fim
hard
{ "lang": "rust", "repo": "jcornaz/polar-clock", "path": "/src/arc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wildarch/strontium path: /src/interrupts.rs #![allow(dead_code)] use core::intrinsics::volatile_store; use core::intrinsics::volatile_load; use core::mem; use gpio::Gpio; use uart; use rpi_timer::RpiTimer; use syscall; use rpi_const::PERIPHERAL_BASE; const INTERRUPT_CONTROLLER_BASE : usize =...
code_fim
hard
{ "lang": "rust", "repo": "wildarch/strontium", "path": "/src/interrupts.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }