text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: palmtoy/Exercise path: /Rust/thread_test/src/main.rs extern crate chrono; use chrono::offset::Local; use chrono::DateTime; use std::io::{self, BufRead}; use std::sync::mpsc; use std::thread; use std::time::Duration; use std::time::SystemTime; <|fim_suffix|> let mut line = String::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "palmtoy/Exercise", "path": "/Rust/thread_test/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: troiganto/scenarios path: /src/consumers/tokens.rs // Copyright 2017 Nico Madysa. // // Licensed under the Apache License, Version 2.0 (the "License"); you // may not use this file except in compliance with the License. You may // obtain a copy of the License at // // http://www.apache.org/licen...
code_fim
hard
{ "lang": "rust", "repo": "troiganto/scenarios", "path": "/src/consumers/tokens.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Accepts a previously handed-out token back into the stock. pub fn return_token(&mut self, _: PoolToken) { self.num_tokens += 1; } } impl Default for TokenStock { /// The default for a token stock is to contain no tokens at all. fn default() -> Self { Self::new(0) ...
code_fim
hard
{ "lang": "rust", "repo": "troiganto/scenarios", "path": "/src/consumers/tokens.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Tokens returned by [`TokenStock`]. /// /// The only purpose of these tokens is to be handed out and redeemed. /// This allows controlling how many jobs are running at any time. /// /// [`TokenStock`]: ./struct.TokenStock.html #[derive(Debug)] #[must_use] pub struct PoolToken(());<|fim_prefix|>// repo:...
code_fim
hard
{ "lang": "rust", "repo": "troiganto/scenarios", "path": "/src/consumers/tokens.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.commit(); // clean up all the done ones for cmd_id in done { self.running_commands.remove(&cmd_id).unwrap(); } } fn commit(&mut self) { self.ticks += 1; } fn take_routes(&mut self, paths: &IndexMap<DropletId, Path>, graph: &mut Gr...
code_fim
hard
{ "lang": "rust", "repo": "goaaron/puddle", "path": "/puddle-core/src/exec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: goaaron/puddle path: /puddle-core/src/exec.rs use crate::command::RunStatus; use crate::grid::{DropletId, Grid, GridView}; use crate::plan::{ graph::{CmdIndex, Graph}, Path, PlanPhase, PlannedCommand, }; use indexmap::IndexMap; pub struct Executor { pub gridview: GridView, runni...
code_fim
hard
{ "lang": "rust", "repo": "goaaron/puddle", "path": "/puddle-core/src/exec.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let test_tuples = vec![ (Vec::new(), 2, 0), (vec![1, 4], 2, 4), (vec![1, 2], 2, 3), (vec![1, 2, 6], 2, 5), ]; for (time_series, duration, expected) in test_tuples { assert_eq!(find_poisoned_duration(time_series, duration),...
code_fim
hard
{ "lang": "rust", "repo": "JamesShoaf/AlgorithmPractice", "path": "/arraysMatricesStrings/arrays/find_poisoned_duration/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JamesShoaf/AlgorithmPractice path: /arraysMatricesStrings/arrays/find_poisoned_duration/src/lib.rs /* In LOL world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking ascending time series towards Ashe and the poison...
code_fim
medium
{ "lang": "rust", "repo": "JamesShoaf/AlgorithmPractice", "path": "/arraysMatricesStrings/arrays/find_poisoned_duration/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl IntoSubdomain for UrlScanResult { fn subdomains(&self) -> Vec<String> { self.results .iter() .map(|s| s.page.domain.to_owned()) .collect() } } #[derive(Default, Clone)] pub struct UrlScan { client: Client, } impl UrlScan { pub fn new(clien...
code_fim
hard
{ "lang": "rust", "repo": "jatindhankhar/vita", "path": "/src/sources/urlscan.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jatindhankhar/vita path: /src/sources/urlscan.rs use crate::error::{Result, VitaError}; use crate::{DataSource, IntoSubdomain}; use async_trait::async_trait; use reqwest::Client; use serde::Deserialize; use std::sync::Arc; use tokio::sync::mpsc::Sender; use tracing::{info, trace, warn}; #[deriv...
code_fim
hard
{ "lang": "rust", "repo": "jatindhankhar/vita", "path": "/src/sources/urlscan.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> let mut result: Vec<Thing> = vec![]; for _ in 0..100 { result.push(Thing { id: random_string(), start_date: Utc::now(), end_date: Utc::now(), project: random_string(), name: random_string(), text: random_string(), ...
code_fim
medium
{ "lang": "rust", "repo": "adamdrake210/xlsx-in-rust-example", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> println!("Server started at localhost:8080"); warp::serve(report_route).run(([0, 0, 0, 0], 8080)).await; } async fn report_handler() -> Result<impl Reply> { let now = Instant::now(); let result = tokio::task::spawn_blocking(move || excel::create_xlsx(THINGS.to_vec())) .await ...
code_fim
hard
{ "lang": "rust", "repo": "adamdrake210/xlsx-in-rust-example", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adamdrake210/xlsx-in-rust-example path: /src/main.rs #[macro_use] extern crate lazy_static; use chrono::prelude::*; use std::time::Instant; use uuid::Uuid; use warp::{Filter, Rejection, Reply}; mod excel; type Result<T> = std::result::Result<T, Rejection>; <|fim_suffix|> let mut result: Ve...
code_fim
hard
{ "lang": "rust", "repo": "adamdrake210/xlsx-in-rust-example", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: deusletum/teensy4-rs path: /src/rt.rs //! Runtime support //! //! The useful bits are written in assembly. See `start.s` for the //! reset handler implementation. The reset handler eventually calls //! `t4_init()`, which finishes setup, and calls the `cortex-m-rt` //! `Reset()` handler. //! //! ...
code_fim
medium
{ "lang": "rust", "repo": "deusletum/teensy4-rs", "path": "/src/rt.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// System entrypoint, invoked by reset handler /// /// # Safety /// /// The function is unsafe since it directly modifies registers, and invokes /// other functions that do the same. It does not touch any memory that needs /// to first be initialized by cortex-m-rt. #[no_mangle] unsafe extern "C" fn t4_i...
code_fim
medium
{ "lang": "rust", "repo": "deusletum/teensy4-rs", "path": "/src/rt.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub type CMPersistentTrackID = i32; pub const kCMPersistentTrackID_Invalid: CMPersistentTrackID = 0;<|fim_prefix|>// repo: PneumaSolutions/rust-core-media-sys path: /src/base.rs use crate::libc::c_long; use crate::core_foundation_sys::base::{OSStatus, Boolean, CFAllocatorRef, CFTypeID, CFTypeRef}; use c...
code_fim
hard
{ "lang": "rust", "repo": "PneumaSolutions/rust-core-media-sys", "path": "/src/base.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PneumaSolutions/rust-core-media-sys path: /src/base.rs use crate::libc::c_long; use crate::core_foundation_sys::base::{OSStatus, Boolean, CFAllocatorRef, CFTypeID, CFTypeRef}; use crate::core_foundation_sys::dictionary::CFDictionaryRef; use crate::core_foundation_sys::string::CFStringRef; use c...
code_fim
hard
{ "lang": "rust", "repo": "PneumaSolutions/rust-core-media-sys", "path": "/src/base.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>cfg_if! { if #[cfg(target_pointer_width = "32")] { pub type CMBaseClassVersion = u32; pub type CMStructVersion = u32; } else if #[cfg(target_pointer_width = "64")] { pub type CMBaseClassVersion = u64; pub type CMStructVersion = u64; } else { pub type CMB...
code_fim
hard
{ "lang": "rust", "repo": "PneumaSolutions/rust-core-media-sys", "path": "/src/base.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ghostdsb/raytracer path: /src/vec3.rs use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut, AddAssign,SubAssign, MulAssign, DivAssign}; use crate::utils; #[derive(Debug, Copy, Clone, PartialEq, Default)] pub struct Vec3{ e: [f32;3], } impl Vec3{ pub fn new(e0: f32, e1: f32, e2: f32) ...
code_fim
hard
{ "lang": "rust", "repo": "ghostdsb/raytracer", "path": "/src/vec3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut vec1 = Vec3::new(1.0, 2.0, 3.0); let vec2 = vec1 * 2.0; vec1 *= 4.0; assert_eq!(vec1[0], 4.0); assert_eq!(vec1[1], 8.0); assert_eq!(vec1[2], 12.0); assert_eq!(vec2, Vec3::new(2.0, 4.0, 6.0)); } #[test] fn scalar_division_of_vecto...
code_fim
hard
{ "lang": "rust", "repo": "ghostdsb/raytracer", "path": "/src/vec3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: clchiou/garage path: /rust/g1/base/tests/owner/nonstatic-error.rs struct Struct<'a>(&'a [u8]); <|fim_suffix|>g1_base::define_owner!(Owner for Struct); fn main() { Owner::try_from(Vec::new()).unwrap(); }<|fim_middle|>impl<'a> TryFrom<&'a [u8]> for Struct<'a> { type Error = &'a [u8]; ...
code_fim
medium
{ "lang": "rust", "repo": "clchiou/garage", "path": "/rust/g1/base/tests/owner/nonstatic-error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Owner::try_from(Vec::new()).unwrap(); }<|fim_prefix|>// repo: clchiou/garage path: /rust/g1/base/tests/owner/nonstatic-error.rs struct Struct<'a>(&'a [u8]); impl<'a> TryFrom<&'a [u8]> for Struct<'a> { type Error = &'a [u8]; fn try_from(_: &'a [u8]) -> Result<Self, Self::Error> { std...
code_fim
easy
{ "lang": "rust", "repo": "clchiou/garage", "path": "/rust/g1/base/tests/owner/nonstatic-error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub mod nse_gui; pub mod utility; pub mod render_passes; pub mod images;<|fim_prefix|>// repo: ifl0w/VEO-Rust path: /src/rendering/mod.rs pub use aabb::*; pub use camera::*; pub use images::*; pub use mesh::Mesh; pub use nse_gui::octree_gui::OctreeGuiSystem; pub use octree::*; pub use render_passes::*; p...
code_fim
easy
{ "lang": "rust", "repo": "ifl0w/VEO-Rust", "path": "/src/rendering/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ifl0w/VEO-Rust path: /src/rendering/mod.rs pub use aabb::*; pub use camera::*; pub use images::*; pub use mesh::Mesh; pub use nse_gui::octree_gui::OctreeGuiSystem; pub use octree::*; pub use render_passes::*; pub use renderer::Backend; pub use renderer::RenderSystem; pub use utility::*; <|fim_s...
code_fim
easy
{ "lang": "rust", "repo": "ifl0w/VEO-Rust", "path": "/src/rendering/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod serving { pub fn take_order() { // Once seated, I guess :D // Then wait for order to be prepaired, and serve_order(); take_payment(); } fn serve_order() {} fn take_payment() {} }<|fim_prefix|>// repo: Fahien/exrust path: /the-book/managing-growing-projects-with-packages-crates-and-modul...
code_fim
medium
{ "lang": "rust", "repo": "Fahien/exrust", "path": "/the-book/managing-growing-projects-with-packages-crates-and-modules/src/front_of_house.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Fahien/exrust path: /the-book/managing-growing-projects-with-packages-crates-and-modules/src/front_of_house.rs // A module in its own file pub mod hosting { pub fn add_to_waitlist() { // Wait for some time? seat_at_table(); } <|fim_suffix|> // Super is like get parent ../ super::servi...
code_fim
easy
{ "lang": "rust", "repo": "Fahien/exrust", "path": "/the-book/managing-growing-projects-with-packages-crates-and-modules/src/front_of_house.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn serve_order() {} fn take_payment() {} }<|fim_prefix|>// repo: Fahien/exrust path: /the-book/managing-growing-projects-with-packages-crates-and-modules/src/front_of_house.rs // A module in its own file pub mod hosting { pub fn add_to_waitlist() { // Wait for some time? seat_at_table(); } fn...
code_fim
medium
{ "lang": "rust", "repo": "Fahien/exrust", "path": "/the-book/managing-growing-projects-with-packages-crates-and-modules/src/front_of_house.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn handle_other_request(mut response: Response) { let file_path = format!("{}{}", ROOT_DIR, "/405.html"); let file_content = fs::read(file_path); match file_content { Ok(content) => { response.status_code = String::from("405"); response.body = Some(content);...
code_fim
hard
{ "lang": "rust", "repo": "arunkumar-reddy/Rust-Multithreaded-Server", "path": "/src/static_file_server/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arunkumar-reddy/Rust-Multithreaded-Server path: /src/static_file_server/mod.rs use std::fs; use crate::server_core::request::Request; use crate::server_core::response::Response; use crate::server_core::response::ContentType; const ROOT_DIR: &str = "public"; pub fn handle_connection(request: Re...
code_fim
hard
{ "lang": "rust", "repo": "arunkumar-reddy/Rust-Multithreaded-Server", "path": "/src/static_file_server/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Makes this transaction abort when dropped. #[inline] pub fn set_abort(&mut self) { self.commit = false; } /// Aborts or commits the transaction depending on the finish mode. /// /// The mode can be changed with `set_commit()` and `set_abort()` methods. #[inline...
code_fim
hard
{ "lang": "rust", "repo": "dministro/ejdb.rs", "path": "/src/database/tx.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dministro/ejdb.rs path: /src/database/tx.rs use ejdb_sys; use super::Collection; use Result; impl<'db> Collection<'db> { /// Starts a transaction, returning a guard object for it. /// /// This method can be used to start transactions over an EJDB collection. Transactions /// ar...
code_fim
hard
{ "lang": "rust", "repo": "dministro/ejdb.rs", "path": "/src/database/tx.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Aborts or commits the transaction depending on the finish mode. /// /// The mode can be changed with `set_commit()` and `set_abort()` methods. #[inline] pub fn finish(mut self) -> Result<()> { self.finish_mut() } /// Attempts to commit this transaction. #[inlin...
code_fim
hard
{ "lang": "rust", "repo": "dministro/ejdb.rs", "path": "/src/database/tx.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JoNil/rlisp path: /rlisp/src/globals.rs use phf; use builtin; use cell::BuiltinFunctionSpec; use types::Type::*; pub static GLOBAL_ENVIROMENT: phf::Map<&'static str, BuiltinFunctionSpec> = phf_map! { // Math "+" => BuiltinFunctionSpec { func: builtin::add, name: "+", ...
code_fim
hard
{ "lang": "rust", "repo": "JoNil/rlisp", "path": "/rlisp/src/globals.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Char // ?? // Type // type-of // is-type // Functional // map // fold // filter // Language "eval" => BuiltinFunctionSpec { func: builtin::eval, name: "eval", argument_types: &[AnyT], }, "def" => BuiltinFunctionSpec { ...
code_fim
hard
{ "lang": "rust", "repo": "JoNil/rlisp", "path": "/rlisp/src/globals.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joshradin/graph.rs path: /src/graph/hash_graph.rs use std::hash::Hash; use std::collections::{HashMap, HashSet}; use crate::{Node, GraphRef, GraphReverse, GraphError}; use crate::graph::{Graph, GraphResult}; use crate::graph::GraphError::{IdExists, IdDoesNotExist, EdgeAlreadyExists}; use std::op...
code_fim
hard
{ "lang": "rust", "repo": "joshradin/graph.rs", "path": "/src/graph/hash_graph.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for vec1_value in vec1 { let exists = vec2_copy.iter().enumerate().find(|(pos, vec2_val)| { vec1_value == **vec2_val }).map(|(pos, _)| pos); match exists { None => {}, Some(vec2_match) => { vec...
code_fim
hard
{ "lang": "rust", "repo": "joshradin/graph.rs", "path": "/src/graph/hash_graph.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let future = (Box::new(before_execute) as Box<dyn GpuFuture>).then_signal_fence_and_flush(); if let Some(prev_frame_end) = &mut self.prev_frame_end { prev_frame_end.wait(None).unwrap(); prev_frame_end.cleanup_finished(); } self.prev_frame_end = match future { Ok(future) => Some(Arc::new(f...
code_fim
hard
{ "lang": "rust", "repo": "nice-game/nice-engine", "path": "/src/surface.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nice-game/nice-engine path: /src/surface.rs use crate::{camera::Camera, pipelines::Pipeline, Context}; use std::{ os::raw::c_ulong, sync::{Arc, Mutex}, }; use vulkano::{ device::{Device, Queue}, format::Format, swapchain::{ acquire_next_image, AcquireError, PresentMode, Surface as VkSurfa...
code_fim
hard
{ "lang": "rust", "repo": "nice-game/nice-engine", "path": "/src/surface.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: en/kcp-rs path: /tests/kcb.rs extern crate bytes; extern crate kcp; extern crate rand; extern crate time as ctime; use std::cell::RefCell; use std::collections::VecDeque; use std::io::{self, Read, Write}; use std::iter::Iterator; use std::rc::Rc; use std::thread; use std::time; use bytes::{Byt...
code_fim
hard
{ "lang": "rust", "repo": "en/kcp-rs", "path": "/tests/kcb.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut a2b = alice_to_bob.borrow_mut(); loop { match a2b.read(&mut buffer[..]) { Ok(hr) => { bob.input(&buffer[..hr]).ok(); } Err(_) => break, }; } let mut b2a = bob_to_alice.borro...
code_fim
hard
{ "lang": "rust", "repo": "en/kcp-rs", "path": "/tests/kcb.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let len: usize; if let Some(pkt) = self.delay_tunnel.front() { self.current = clock(); if self.current < pkt.ts { return Err(io::Error::new( io::ErrorKind::Other, format!("current({}) < ts({})", self.current, p...
code_fim
hard
{ "lang": "rust", "repo": "en/kcp-rs", "path": "/tests/kcb.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: judu/semver-cli path: /src/main.rs extern crate semver; #[macro_use] extern crate structopt; use structopt::StructOpt; mod filter_versions; <|fim_suffix|>fn main() { let opt = Opt::from_args(); match filter_versions::filter_and_sort(opt.versions, opt.range) { Err(err) => { ...
code_fim
hard
{ "lang": "rust", "repo": "judu/semver-cli", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let opt = Opt::from_args(); match filter_versions::filter_and_sort(opt.versions, opt.range) { Err(err) => { eprintln!("Error parsing given range: {0}", &err); std::process::exit(1); }, Ok(versions) => { for v in versions.iter(...
code_fim
hard
{ "lang": "rust", "repo": "judu/semver-cli", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Create Kafka consumer configuration. let mut consumer_config = ClientConfig::new(); consumer_config .set("produce.offset.report", "true") .set("auto.offset.reset", "earliest") .set("group.id", "example") .set("enable.auto.commit", ...
code_fim
hard
{ "lang": "rust", "repo": "danalex97/dspa", "path": "/src/operators/source.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danalex97/dspa path: /src/operators/source.rs extern crate csv; extern crate futures; extern crate rdkafka; extern crate rdkafka_sys; extern crate timely; use crate::dto::common::{Importable, Timestamped, Watermarkable}; use timely::dataflow::operators::generic::operator::source; use timely::d...
code_fim
hard
{ "lang": "rust", "repo": "danalex97/dspa", "path": "/src/operators/source.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> source(self, "Source", |mut capability, info| { //let mut message_stream = consumer.start(); let activator = self.activator_for(&info.address[..]); move |output| { activator.activate(); for message in consumer.poll(Duration::from_...
code_fim
hard
{ "lang": "rust", "repo": "danalex97/dspa", "path": "/src/operators/source.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: atsamd-rs/atsamd path: /pac/atsamd21e/src/gclk.rs #[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Control"] pub ctrl: crate::Reg<ctrl::CTRL_SPEC>, #[doc = "0x01 - Status"] pub status: crate::Reg<status::STATUS_SPEC>, #[doc = "0x02 - Generic Cl...
code_fim
hard
{ "lang": "rust", "repo": "atsamd-rs/atsamd", "path": "/pac/atsamd21e/src/gclk.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>US register accessor: an alias for `Reg<STATUS_SPEC>`"] pub type STATUS = crate::Reg<status::STATUS_SPEC>; #[doc = "Status"] pub mod status; #[doc = "CLKCTRL register accessor: an alias for `Reg<CLKCTRL_SPEC>`"] pub type CLKCTRL = crate::Reg<clkctrl::CLKCTRL_SPEC>; #[doc = "Generic Clock Control"] pub mod...
code_fim
hard
{ "lang": "rust", "repo": "atsamd-rs/atsamd", "path": "/pac/atsamd21e/src/gclk.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>r accessor: an alias for `Reg<GENCTRL_SPEC>`"] pub type GENCTRL = crate::Reg<genctrl::GENCTRL_SPEC>; #[doc = "Generic Clock Generator Control"] pub mod genctrl; #[doc = "GENDIV register accessor: an alias for `Reg<GENDIV_SPEC>`"] pub type GENDIV = crate::Reg<gendiv::GENDIV_SPEC>; #[doc = "Generic Clock Ge...
code_fim
hard
{ "lang": "rust", "repo": "atsamd-rs/atsamd", "path": "/pac/atsamd21e/src/gclk.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let deposits = AccountDeposits::<T>::get(collateral_asset_id, &borrower); if !deposits.is_collateral { return Err(Error::<T>::DepositsAreNotCollateral.into()); } let exchange_rate = Self::exchange_rate(collateral_asset_id); let borrower_deposit_amount = ...
code_fim
hard
{ "lang": "rust", "repo": "DiamondNetwork/parallel", "path": "/pallets/loans/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DiamondNetwork/parallel path: /pallets/loans/src/lib.rs ferring from payer. /// /// May only be called from `T::ReserveOrigin`. /// /// - `payer`: the payer account. /// - `asset_id`: the assets to be added. /// - `add_amount`: the amount to be add...
code_fim
hard
{ "lang": "rust", "repo": "DiamondNetwork/parallel", "path": "/pallets/loans/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(().into()) } /// Reduces reserves by transferring to receiver. /// /// May only be called from `T::ReserveOrigin`. /// /// - `receiver`: the receiver account. /// - `asset_id`: the assets to be reduced. /// - `reduce_amount`: ...
code_fim
hard
{ "lang": "rust", "repo": "DiamondNetwork/parallel", "path": "/pallets/loans/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let vk_instance = unsafe { entry .create_instance(&create_info, None) .map_err(InstanceError::from)? }; let _owned_layers = vec_cstring_from_raw(layers_ptrs); let _owned_extensions = vec_cstring_from_raw(extensions_ptrs); ...
code_fim
hard
{ "lang": "rust", "repo": "NiklasJonsson/trekanten", "path": "/src/instance/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NiklasJonsson/trekanten path: /src/instance/mod.rs use ash::extensions::ext; use ash::version::InstanceV1_0; // For destroy_instance use ash::{version::EntryV1_0, vk, Entry}; use std::ffi::{CStr, CString}; use crate::util::ffi::*; use crate::util::lifetime::LifetimeToken; pub mod error; pub us...
code_fim
hard
{ "lang": "rust", "repo": "NiklasJonsson/trekanten", "path": "/src/instance/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if use_vk_validation() { instance_extensions.push(ext::DebugUtils::name().to_owned()); } log::trace!("Choosing instance extensions:"); log_cstrings(&instance_extensions); Ok(instance_extensions) } impl Instance { pub fn new<T: AsRef<str>>(required_window_extensions: &[T]...
code_fim
hard
{ "lang": "rust", "repo": "NiklasJonsson/trekanten", "path": "/src/instance/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rauchg/AzureSDKForRust path: /src/azure/storage/blob/block_list_type.rs #[derive(Debug, Clone, Copy, PartialEq)] pub enum BlockListType { Committed, Uncommitted, All, } impl BlockListType { pub fn to_str(&self) -> &str { mat<|fim_suffix|>> "committed", BlockL...
code_fim
medium
{ "lang": "rust", "repo": "rauchg/AzureSDKForRust", "path": "/src/azure/storage/blob/block_list_type.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>> "committed", BlockListType::Uncommitted => "uncommitted", } } }<|fim_prefix|>// repo: rauchg/AzureSDKForRust path: /src/azure/storage/blob/block_list_type.rs #[derive(Debug, Clone, Copy, PartialEq)] pub enum BlockListType { Committed, Uncommitted, All, } impl BlockL...
code_fim
medium
{ "lang": "rust", "repo": "rauchg/AzureSDKForRust", "path": "/src/azure/storage/blob/block_list_type.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<OUTLET> MockButton<OUTLET> for MockButtonWidget<OUTLET> where OUTLET: OutletHolder, { fn new(outlet: OUTLET) -> PlatingResult<Self> { let result = Self { outlet, _private: crate::Private {}, }; Ok(result) } } impl<OUTLET> Widget<OUTLET> for...
code_fim
hard
{ "lang": "rust", "repo": "plating-rust/plating", "path": "/core/src/mock/button.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &self.outlet } } impl<OUTLET> Button<OUTLET> for MockButtonWidget<OUTLET> where OUTLET: OutletHolder, { fn new(outlet: OUTLET) -> PlatingResult<Self> { <Self as MockButton<OUTLET>>::new(outlet) } } impl<OUTLET1, OUTLET2> ChildOf<MockWindowWidget<OUTLET1>, ChildrenOutlet> ...
code_fim
hard
{ "lang": "rust", "repo": "plating-rust/plating", "path": "/core/src/mock/button.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: plating-rust/plating path: /core/src/mock/button.rs /* * Copyright (2021) by Marcel Lambert. * This project is dual licensed under either MIT or Apache-2.0. */ use super::MockWindowWidget; use crate::utils::children::ChildOf; use crate::utils::outlet::{ChildrenOutlet, MenuOutlet, Outlet, Out...
code_fim
medium
{ "lang": "rust", "repo": "plating-rust/plating", "path": "/core/src/mock/button.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut delete_entities: Vec<Entity> = Vec::new(); let (modifier_config_query, not_modifier_config_query, input_component_query) = queries; let modifiers = modifier_config_query.iter(world) .map(|(entity, input, action)| (*entity, *input, (*action).clo...
code_fim
hard
{ "lang": "rust", "repo": "nylonblonde/wolf-gang", "path": "/wolf_gang/src/systems/input.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Copy, Clone, Debug, PartialEq)] pub struct Modifier{} #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct Action(pub String); #[derive(Copy, Clone, Debug, PartialEq)] pub struct TypeTag(InputType); ///Repeater incremenets by delta time each frame so that individual systems can arbitrarily ...
code_fim
hard
{ "lang": "rust", "repo": "nylonblonde/wolf-gang", "path": "/wolf_gang/src/systems/input.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nylonblonde/wolf-gang path: /wolf_gang/src/systems/input.rs use gdnative::prelude::*; use gdnative::api::{ File, InputMap }; use legion::*; use ron::ser::{PrettyConfig}; use serde::{Deserialize, Serialize}; use std::collections::{ HashMap, HashSet }; const USER_CONFIG_PATH: &str = "use...
code_fim
hard
{ "lang": "rust", "repo": "nylonblonde/wolf-gang", "path": "/wolf_gang/src/systems/input.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct PrintOptPair<A: PrintOpt, B: PrintOpt>(A, B); impl<A: PrintOpt, B: PrintOpt> PrintOpt for PrintOptPair<A, B> { fn print<W: Write, C: ChromName, D: Intersection<C>>( &self, data: &D, delim: &str, mut target: W, ) -> std::io::Result<()> { self.0.pr...
code_fim
hard
{ "lang": "rust", "repo": "38/grass-demo", "path": "/grass/src/high_level_api/show.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 38/grass-demo path: /grass/src/high_level_api/show.rs use std::{ cell::RefCell, fmt::{Debug, Formatter}, fs::File, io::{BufWriter, Write}, iter::Take, marker::PhantomData, ops::{Add, Range}, path::Path, }; use num::iter::RangeFrom; use crate::{ properties::{...
code_fim
hard
{ "lang": "rust", "repo": "38/grass-demo", "path": "/grass/src/high_level_api/show.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Overlap; impl PrintOpt for Overlap { fn print<W: Write, C: ChromName, D: Intersection<C>>( &self, interval: &D, delim: &str, target: W, ) -> std::io::Result<()> { write_interval_impl(interval, delim, target) } } impl<C: PrintOpt> Add<C> for O...
code_fim
hard
{ "lang": "rust", "repo": "38/grass-demo", "path": "/grass/src/high_level_api/show.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustPython/RustPython path: /vm/src/py_io.rs use crate::{ builtins::{PyBaseExceptionRef, PyBytes, PyStr}, common::ascii, PyObject, PyObjectRef, PyResult, VirtualMachine, }; use std::{fmt, io, ops}; pub trait Write { type Error; fn write_fmt(&mut self, args: fmt::Arguments) -...
code_fim
hard
{ "lang": "rust", "repo": "RustPython/RustPython", "path": "/vm/src/py_io.rs", "mode": "psm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_suffix|> <W as io::Write>::write_fmt(&mut self.0, args) } } impl Write for String { type Error = fmt::Error; fn write_fmt(&mut self, args: fmt::Arguments) -> fmt::Result { <String as fmt::Write>::write_fmt(self, args) } } pub struct PyWriter<'vm>(pub PyObjectRef, pub &'vm VirtualM...
code_fim
hard
{ "lang": "rust", "repo": "RustPython/RustPython", "path": "/vm/src/py_io.rs", "mode": "spm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut event = Events::default(); let _r = event.create_topic("test_topic", TopicConfiguration { limit: 3 }); let subscriber_id = event.subscribe("test_topic", PollConfiguration { max_messages: 2 }).unwrap(); let subscriber_id2 = event.subscribe("te...
code_fim
hard
{ "lang": "rust", "repo": "pt2121/scion", "path": "/src/core/resources/events/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn poll_test() { let mut event = Events::default(); let _r = event.create_topic("test_topic", TopicConfiguration { limit: 100 }); let subscriber_id = event.subscribe("test_topic", PollConfiguration::default()).unwrap(); let _r = event.publish("test_topic", 4...
code_fim
hard
{ "lang": "rust", "repo": "pt2121/scion", "path": "/src/core/resources/events/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pt2121/scion path: /src/core/resources/events/mod.rs pub mod topic; use std::collections::{HashMap, VecDeque}; use serde::{de::DeserializeOwned, ser}; use serde_json::{from_str, to_string}; use crate::core::resources::events::topic::{Topic, TopicConfiguration}; pub type SubscriberId = usize;...
code_fim
hard
{ "lang": "rust", "repo": "pt2121/scion", "path": "/src/core/resources/events/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rnbguy/uosql-server path: /server/src/parse/token.rs use super::Span; use parse::ast::*; use storage::SqlType; /// A token with it's associated Span in the source code #[derive(Debug)] pub struct TokenSpan { pub tok: Token, pub span: Span, } #[derive(Debug, Clone, PartialEq)] pub enum L...
code_fim
medium
{ "lang": "rust", "repo": "rnbguy/uosql-server", "path": "/server/src/parse/token.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// A token: Everything the lexer can produce #[derive(Debug, Clone, PartialEq)] pub enum Token { Word(String), // detects literals Literal(Lit), Semi, Dot, Comma, // Bang, // QMark, // delimiter (,),'," ParenOp, ParenCl, ADel, // mathematic ops ...
code_fim
hard
{ "lang": "rust", "repo": "rnbguy/uosql-server", "path": "/server/src/parse/token.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Lit { pub fn into_DataSrc(&self) -> DataSrc { match self { &Lit::String(ref s) => DataSrc::String(s.clone()), &Lit::Int(ref i) => DataSrc::Int(i.clone()), &Lit::Float(ref f) => DataSrc::String(f.to_string()), &Lit::Bool(ref b) => DataSrc::Bo...
code_fim
medium
{ "lang": "rust", "repo": "rnbguy/uosql-server", "path": "/server/src/parse/token.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doraneko94/Rust path: /ABS/abc081a/src/main.rs fn read1<T: std::str::FromStr>() -> T { <|fim_suffix|> let s1s2s3 = read1::<String>(); let mut ans = 0; for i in 0..3 { let s: i32 = s1s2s3[i..i+1].parse().ok().unwrap(); ans += s; } println!("{}", ans); }<|fim_mid...
code_fim
medium
{ "lang": "rust", "repo": "doraneko94/Rust", "path": "/ABS/abc081a/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let s1s2s3 = read1::<String>(); let mut ans = 0; for i in 0..3 { let s: i32 = s1s2s3[i..i+1].parse().ok().unwrap(); ans += s; } println!("{}", ans); }<|fim_prefix|>// repo: doraneko94/Rust path: /ABS/abc081a/src/main.rs fn read1<T: std::str::FromStr>() -> T...
code_fim
medium
{ "lang": "rust", "repo": "doraneko94/Rust", "path": "/ABS/abc081a/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: digitalbitbox/bitbox02-firmware path: /src/rust/bitbox02-rust/src/hww/api/bitcoin/registration.rs // Copyright 2023 Shift Crypto AG // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy o...
code_fim
hard
{ "lang": "rust", "repo": "digitalbitbox/bitbox02-firmware", "path": "/src/rust/bitbox02-rust/src/hww/api/bitcoin/registration.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> use pb::btc_script_config::{multisig::ScriptType, Multisig}; #[test] fn test_process_is_script_config_registered() { fn test(sort_xpubs: SortXpubs) { mock_memory(); let keypath = &[48 + HARDENED, 0 + HARDENED, 10 + HARDENED, 2 + HARDENED]; // The x...
code_fim
hard
{ "lang": "rust", "repo": "digitalbitbox/bitbox02-firmware", "path": "/src/rust/bitbox02-rust/src/hww/api/bitcoin/registration.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut request = SignedRequest::new("POST", "personalize", &self.region, &request_uri); request.set_content_type("application/x-amz-json-1.1".to_owned()); request.set_endpoint_prefix("personalize-events".to_string()); let encoded = Some(serde_json::to_vec(&input).unwrap()...
code_fim
hard
{ "lang": "rust", "repo": "MaterializeInc/rusoto", "path": "/rusoto/services/personalize-events/src/generated.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MaterializeInc/rusoto path: /rusoto/services/personalize-events/src/generated.rs // ================================================================= // // * WARNING * // // This file is generated! // // Changes made to this file will be overwritten....
code_fim
hard
{ "lang": "rust", "repo": "MaterializeInc/rusoto", "path": "/rusoto/services/personalize-events/src/generated.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn new_with_client(client: Client, region: region::Region) -> PersonalizeEventsClient { PersonalizeEventsClient { client, region } } } #[async_trait] impl PersonalizeEvents for PersonalizeEventsClient { /// <p>Records user interaction event data.</p> #[allow(unused_mut)] a...
code_fim
hard
{ "lang": "rust", "repo": "MaterializeInc/rusoto", "path": "/rusoto/services/personalize-events/src/generated.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc153/src/bin/c.rs use proconio::input; fn main() { input! { n<|fim_suffix|>iter().skip(k).sum::<usize>(); println!("{}", ans); }<|fim_middle|>: usize, k: usize, mut h: [usize; n], }; h.sort(); h.rev...
code_fim
medium
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/abc153/src/bin/c.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> }; h.sort(); h.reverse(); let ans = h.into_iter().skip(k).sum::<usize>(); println!("{}", ans); }<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc153/src/bin/c.rs use proconio::input; fn main() { input! { n<|fim_middle|>: usize, k: usize, ...
code_fim
easy
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/abc153/src/bin/c.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Create a set of valid ancestor hashes for this fork for _ in 0..MAX_ENTRIES { my_leader_bank = Arc::new(Bank::new_from_parent( &my_leader_bank, &Pubkey::default(), my_leader_bank.slot() + 1, )); } le...
code_fim
hard
{ "lang": "rust", "repo": "jstarry/solana", "path": "/core/src/verified_vote_packets.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Send a vote from `vote_account_key`, check that it was inserted let vote_slot = 0; let vote_hash = Hash::new_unique(); let vote = Vote::new(vec![vote_slot], vote_hash); s.send(vec![VerifiedVoteMetadata { vote_account_key, vote: VoteTransac...
code_fim
hard
{ "lang": "rust", "repo": "jstarry/solana", "path": "/core/src/verified_vote_packets.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jstarry/solana path: /core/src/verified_vote_packets.rs et_account(&sysvar::slot_hashes::id()); if slot_hashes_account.is_none() { warn!( "Slot hashes sysvar doesn't exist on bank {}", my_leader_bank.slot() ); } le...
code_fim
hard
{ "lang": "rust", "repo": "jstarry/solana", "path": "/core/src/verified_vote_packets.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tempbottle/mongodb-rs path: /src/msg.rs use byteorder::{WriteBytesExt,ReadBytesExt,LittleEndian}; use bson::{Bson, Document, Array, Encoder, Decoder}; use std::io::{Write,Read}; use std::ffi::CString; static mut request_id : i32 = 0; fn new_request_id() ->i32 { unsafe { request_id+=1; r...
code_fim
hard
{ "lang": "rust", "repo": "tempbottle/mongodb-rs", "path": "/src/msg.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.header.write_to(buf); let _ = buf.write_i32::<LittleEndian>(self.flags); let _ = buf.write(self.name_space.as_bytes()); let _ = buf.write(&[0u8]); // null-terminate name let _ = buf.write_i32::<LittleEndian>(self.nskip); let _ = buf.write_i32::<LittleEndian>(self.nret); let _ = buf....
code_fim
hard
{ "lang": "rust", "repo": "tempbottle/mongodb-rs", "path": "/src/msg.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LukasKalbertodt/mahboi path: /core/src/mbc/no_mbc.rs use crate::{ cartridge::{RamSize, RomSize}, primitives::{Byte, Word}, }; use super::Mbc; /// No real MBC in the cartridge. /// /// Some games are small enough to fit in `0x8000` bytes (e.g. Tetris). Those /// games don't need to use b...
code_fim
hard
{ "lang": "rust", "repo": "LukasKalbertodt/mahboi", "path": "/core/src/mbc/no_mbc.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Self { rom: rom.into_boxed_slice(), ram: ram.into_boxed_slice(), } } } impl Mbc for NoMbc { fn load_rom_byte(&self, addr: Word) -> Byte { // Simply index our slice. In `new()`, we made sure that it's at least // `0x8000` bytes long. ...
code_fim
hard
{ "lang": "rust", "repo": "LukasKalbertodt/mahboi", "path": "/core/src/mbc/no_mbc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn store_rom_byte(&mut self, _: Word, _: Byte) { // Nothing happens, writes are completely ignored } fn load_ram_byte(&self, addr: Word) -> Byte { // If a value outside of the usable RAM is requested, we return FF. let idx = addr.get() as usize; if idx < self.r...
code_fim
hard
{ "lang": "rust", "repo": "LukasKalbertodt/mahboi", "path": "/core/src/mbc/no_mbc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn new_driver(opts: &NewDriverOpts) { if opts.static_ && opts.initrd { eprintln!("Cannot be both '--static' and '--initrd'"); panic!(); } let path = Path::new("drivers").join(&opts.category).join(&opts.name); cmd!("cargo", "new", &path, "--lib") .before_spawn(displa...
code_fim
medium
{ "lang": "rust", "repo": "charpercyr/chos", "path": "/build/src/driver.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: charpercyr/chos path: /build/src/driver.rs use std::fs::OpenOptions; use std::io::Write; use std::path::Path; use duct::cmd; use crate::opts::{DriverOpts, NewDriverOpts}; use crate::util::display_cmd_hook; const DRIVER_CARGO_TOML: &'static str = include_str!("../static/driver-Cargo.toml"); co...
code_fim
medium
{ "lang": "rust", "repo": "charpercyr/chos", "path": "/build/src/driver.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut open_opts = OpenOptions::new(); open_opts.write(true); open_opts.truncate(true); let mut cargo_toml = open_opts .open(path.join("Cargo.toml")) .expect("Could not open Cargo.toml"); cargo_toml .write_all(cargo_toml_content.as_bytes()) .expect("Co...
code_fim
hard
{ "lang": "rust", "repo": "charpercyr/chos", "path": "/build/src/driver.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: glowcoil/kira path: /kira/src/static_container/index_map.rs use std::hash::Hash; use indexmap::IndexMap; /// A thin wrapper around `IndexMap`s that prevents any memory /// allocation from occurring after the `IndexMap` is created. /// /// This is used to avoid accidental memory allocation /// ...
code_fim
hard
{ "lang": "rust", "repo": "glowcoil/kira", "path": "/kira/src/static_container/index_map.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn values_mut(&mut self) -> indexmap::map::ValuesMut<K, V> { self.index_map.values_mut() } /// Tries to add a key value pair to the map. /// /// - If the map is full, returns the key and value back through /// an `Err` /// - Otherwise, returns `Ok` with whatever item previously had /// that...
code_fim
hard
{ "lang": "rust", "repo": "glowcoil/kira", "path": "/kira/src/static_container/index_map.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: linkerd/linkerd2-proxy path: /linkerd/tracing/src/level.rs use linkerd_error::Error; use tracing::trace; use tracing_subscriber::{ filter::{self, EnvFilter, LevelFilter}, reload, Layer, Registry, }; /// Gets and sets the log level of a tracing subscriber. #[derive(Clone)] pub struct Han...
code_fim
hard
{ "lang": "rust", "repo": "linkerd/linkerd2-proxy", "path": "/linkerd/tracing/src/level.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Handle { pub(crate) fn new(handle: reload::Handle<FilteredLayer, Registry>) -> Self { Self(handle) } pub fn set_from(&self, bytes: impl AsRef<[u8]>) -> Result<(), String> { let body = std::str::from_utf8(bytes.as_ref()).map_err(|e| format!("{}", e))?; trace!(reque...
code_fim
hard
{ "lang": "rust", "repo": "linkerd/linkerd2-proxy", "path": "/linkerd/tracing/src/level.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_level(&self, level: impl AsRef<str>) -> Result<(), Error> { let level = level.as_ref(); let filter = filter_builder().parse(level)?.add_directive( format!("{}=off", super::access_log::TRACE_TARGET) .parse() .unwrap(), ); ...
code_fim
hard
{ "lang": "rust", "repo": "linkerd/linkerd2-proxy", "path": "/linkerd/tracing/src/level.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: synthVerity/Cricket path: /src/lib.rs ze, Deserialize, Debug)] pub struct History { average_queue: Vec<u64>, high_queue: Vec<u64>, low_queue: Vec<u64>, upper_bound: u64, lower_bound: u64, max_size: usize } #[allow(dead_code)] impl History { pub fn new(size: usize) -...
code_fim
hard
{ "lang": "rust", "repo": "synthVerity/Cricket", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }