text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>er; pub mod cgroup; pub mod container; pub mod created_builder; pub mod init_builder; pub mod status; pub mod utils;<|fim_prefix|>// repo: kata-containers/kata-containers path: /src/tools/runk/libcontainer/src/lib.rs // Copyright 2021-2022 Sony Group Corporation // // SPDX-<|fim_middle|>License-Identifie...
code_fim
easy
{ "lang": "rust", "repo": "kata-containers/kata-containers", "path": "/src/tools/runk/libcontainer/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn is_null(&self) -> bool { Stack::eq_item(self, &StackItem::None) } pub fn is_slice(&self) -> bool { match self { StackItem::Slice(_) => true, _ => false } } pub fn withdraw(&mut self) -> StackItem { mem::replace(self, Stac...
code_fim
hard
{ "lang": "rust", "repo": "NoamDev/rust-tvm", "path": "/src/stack/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NoamDev/rust-tvm path: /src/stack/mod.rs mitations under the License. */ use crate::{ error::TvmError, stack::{continuation::ContinuationData, integer::IntegerData}, types::{Exception, ResultMut, ResultOpt, ResultRef, ResultVec, Status} }; use std::{fmt, mem, ops::Range, slice::Iter, sy...
code_fim
hard
{ "lang": "rust", "repo": "NoamDev/rust-tvm", "path": "/src/stack/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NoamDev/rust-tvm path: /src/stack/mod.rs a, integer::IntegerData}, types::{Exception, ResultMut, ResultOpt, ResultRef, ResultVec, Status} }; use std::{fmt, mem, ops::Range, slice::Iter, sync::Arc}; use ton_types::{BuilderData, Cell, CellType, error, SliceData, Result, ExceptionCode, HashmapT...
code_fim
hard
{ "lang": "rust", "repo": "NoamDev/rust-tvm", "path": "/src/stack/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: angular-rust/clutter-rs path: /src/auto/animatable.rs use crate::Interval; use glib::{object::IsA, translate::*}; use std::fmt; glib_wrapper! { pub struct Animatable(Interface<ffi::ClutterAnimatable>); match fn { get_type => || ffi::clutter_animatable_get_type(), } } pub c...
code_fim
hard
{ "lang": "rust", "repo": "angular-rust/clutter-rs", "path": "/src/auto/animatable.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Asks a `Animatable` implementation to interpolate a /// a named property between the initial and final values of /// a `Interval`, using `progress` as the interpolation /// value, and store the result inside `value`. /// /// This function should be used for every property anima...
code_fim
hard
{ "lang": "rust", "repo": "angular-rust/clutter-rs", "path": "/src/auto/animatable.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn neutral_row_type(kind: VarRec, variants: Variants, ext: Neutral) -> TVal { Val::Neut(Neutral::Row(kind, variants, Box::new(ext))) } pub fn neutral_record(fields: Fields, ext: Neutral) -> Self { Val::Neut(Neutral::Rec(fields, Box::new(ext))) } pub fn neutral_var...
code_fim
hard
{ "lang": "rust", "repo": "clpi/voile-rs", "path": "/src/syntax/core/ast_cons.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: clpi/voile-rs path: /src/syntax/core/ast_cons.rs use voile_util::axiom::Axiom; use voile_util::level::LevelType; use voile_util::meta::MI; use voile_util::tags::*; use voile_util::uid::*; use crate::syntax::core::{CaseSplit, Closure, Fields, Neutral, TVal, Val, Variants}; /// Constructors and ...
code_fim
hard
{ "lang": "rust", "repo": "clpi/voile-rs", "path": "/src/syntax/core/ast_cons.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oli-obk/playform path: /client/lib/src/shaders/grass.rs pub fn grass() -> String { struct Wave { freq: f32, amp: f32, func: &'static str, } <|fim_suffix|> format!(r#" float total_amp = 0.0; float noise = 0.0; {} noise /= total_amp; noise = (noise + 1) / 2; ...
code_fim
hard
{ "lang": "rust", "repo": "oli-obk/playform", "path": "/client/lib/src/shaders/grass.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: himlpplm/rust-tdlib path: /src/types/get_callback_query_message.rs use crate::errors::*; use crate::types::*; use uuid::Uuid; /// Returns information about a message with the callback button that originated a callback query; for bots only #[derive(Debug, Clone, Default, Serialize, Deserialize)]...
code_fim
hard
{ "lang": "rust", "repo": "himlpplm/rust-tdlib", "path": "/src/types/get_callback_query_message.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[doc(hidden)] pub struct RTDGetCallbackQueryMessageBuilder { inner: GetCallbackQueryMessage, } impl RTDGetCallbackQueryMessageBuilder { pub fn build(&self) -> GetCallbackQueryMessage { self.inner.clone() } pub fn chat_id(&mut self, chat_id: i64) -> &mut Self { self.inner...
code_fim
hard
{ "lang": "rust", "repo": "himlpplm/rust-tdlib", "path": "/src/types/get_callback_query_message.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn callback_query_id(&self) -> i64 { self.callback_query_id } } #[doc(hidden)] pub struct RTDGetCallbackQueryMessageBuilder { inner: GetCallbackQueryMessage, } impl RTDGetCallbackQueryMessageBuilder { pub fn build(&self) -> GetCallbackQueryMessage { self.inner.clone()...
code_fim
hard
{ "lang": "rust", "repo": "himlpplm/rust-tdlib", "path": "/src/types/get_callback_query_message.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) fn uuid( value: Option<String>, ) -> Result<Option<uuid::Uuid>, uuid::parser::ParseError> { value.map(|uuid| uuid::Uuid::parse_str(&uuid)).transpose() }<|fim_prefix|>// repo: teamrebuild/Mayastor path: /mayastor/src/bdev/util/uri.rs //! Simple utility functions to help with parsing URI...
code_fim
hard
{ "lang": "rust", "repo": "teamrebuild/Mayastor", "path": "/mayastor/src/bdev/util/uri.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Parse a value that represents a boolean /// Acceptable values are: true, false, yes, no, on, off /// Also accept an (unsigned) integer, where 0 represents false /// and any other value represents true pub(crate) fn boolean( value: &str, empty: bool, ) -> Result<bool, ParseBoolError> { if v...
code_fim
hard
{ "lang": "rust", "repo": "teamrebuild/Mayastor", "path": "/mayastor/src/bdev/util/uri.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: teamrebuild/Mayastor path: /mayastor/src/bdev/util/uri.rs //! Simple utility functions to help with parsing URIs. use std::{collections::HashMap, str::ParseBoolError}; use url::Url; pub(crate) fn segments(url: &Url) -> Vec<&str> { if let Some(iter) = url.path_segments() { let mut ...
code_fim
hard
{ "lang": "rust", "repo": "teamrebuild/Mayastor", "path": "/mayastor/src/bdev/util/uri.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: makers-for-life/makair-control-ui path: /src/config/logger.rs // MakAir Control UI // // Copyright: 2020, Makers For Life // License: Public Domain License <|fim_suffix|>impl log::Log for ConfigLogger { fn enabled(&self, metadata: &Metadata) -> bool { metadata.level() <= Level::Debu...
code_fim
medium
{ "lang": "rust", "repo": "makers-for-life/makair-control-ui", "path": "/src/config/logger.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> if self.enabled(record.metadata()) { println!("({}) - {}", record.level(), record.args()); } } fn flush(&self) {} } impl ConfigLogger { pub fn init(level: LevelFilter) -> Result<(), SetLoggerError> { log::set_max_level(level); log::set_logger(&Conf...
code_fim
medium
{ "lang": "rust", "repo": "makers-for-life/makair-control-ui", "path": "/src/config/logger.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> let mut client_resp = HttpResponse::build(res.status()); // Remove `Connection` as per // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Connection#Directives for (header_name, header_value) in res.headers().iter().filter(|(h, _)| *h != "connection") { client_resp.insert...
code_fim
hard
{ "lang": "rust", "repo": "actix/examples", "path": "/http-proxy/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: actix/examples path: /http-proxy/src/main.rs use std::net::ToSocketAddrs; use actix_web::{ dev::PeerAddr, error, http::Method, middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer, }; use awc::Client; use clap::Parser; use futures_util::StreamExt as _; use tokio::sync::mps...
code_fim
hard
{ "lang": "rust", "repo": "actix/examples", "path": "/http-proxy/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MendyBerger/trying-to-get-comfortable-with-rust-and-dominator path: /src/app.rs use crate::state::State; use crate::components::table::TableComponent; use std::rc::Rc; use dominator::{Dom, html, events, with_node, clone}; use web_sys::HtmlSelectElement; #[derive(Debug)] pub struct App { } imp...
code_fim
hard
{ "lang": "rust", "repo": "MendyBerger/trying-to-get-comfortable-with-rust-and-dominator", "path": "/src/app.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> html!("button", { .child(html!("img", { .attribute("src", "assets/add-icon.png") })) .event(clone!(state => move |_event: events::Click| { ...
code_fim
hard
{ "lang": "rust", "repo": "MendyBerger/trying-to-get-comfortable-with-rust-and-dominator", "path": "/src/app.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Check if user's email is already signed up if users .filter(&email.eq(&*newuser.email)) .first::<User>(&*conn) .optional() .expect("Failed to get user from database") .is_some() { return Redirect::to(format!("/signup?e={}", FormError::EmailExi...
code_fim
hard
{ "lang": "rust", "repo": "samuelburnham/observatory-new", "path": "/src/auth/handlers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samuelburnham/observatory-new path: /src/auth/handlers.rs //! HTTP handlers for authentication use diesel::insert_into; use diesel::prelude::*; use rocket::http::{Cookie, Cookies}; use rocket::request::Form; use rocket::response::Redirect; use crate::guards::*; use crate::models::NewRelationGr...
code_fim
hard
{ "lang": "rust", "repo": "samuelburnham/observatory-new", "path": "/src/auth/handlers.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let creds = creds.into_inner(); let to = to.unwrap_or_else(|| String::from("/")); // If we find the user if let Some(user) = users .filter(&email.eq(creds.email)) .first::<User>(&*conn) .optional() .expect("Failed to get user from database") { ...
code_fim
hard
{ "lang": "rust", "repo": "samuelburnham/observatory-new", "path": "/src/auth/handlers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(ffr) } } pub struct FieldReader { reader: BytesFastFieldReader, asc: bool, signed: bool, } //the second param is signed , for datetime or i64 sort type FieldFastReader = Vec<FieldReader>; impl CustomSegmentScorer<FieldScore> for FieldFastReader { fn score(&self, doc: DocI...
code_fim
hard
{ "lang": "rust", "repo": "NLPchina/chubaodb", "path": "/src/pserver/simba/engine/tantivy/sort.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NLPchina/chubaodb path: /src/pserver/simba/engine/tantivy/sort.rs use crate::util::coding::sort_coding; use std::cmp::Ordering; use tantivy::{ collector::{CustomScorer, CustomSegmentScorer}, fastfield::BytesFastFieldReader, schema::Field, DocId, SegmentReader, }; #[derive(Clone)...
code_fim
hard
{ "lang": "rust", "repo": "NLPchina/chubaodb", "path": "/src/pserver/simba/engine/tantivy/sort.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Solarity-VR/DAO-Governance-Room path: /Goldberg Governance/src/goldberg/pentagon/sector/tile.rs pub struct Tile { pub left: i32, pub right: i32, pub pentagon: i32, pub sector: i32, pub neighbours: Vec<Location>, <|fim_suffix|>pub struct Location { pub pentagon: i32, ...
code_fim
medium
{ "lang": "rust", "repo": "Solarity-VR/DAO-Governance-Room", "path": "/Goldberg Governance/src/goldberg/pentagon/sector/tile.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Tile { pub fn new(left: i32, right: i32, pentagon: i32) -> Tile { Tile { owner: "test".to_string(), levels: 1, trees: 0, left, right, pentagon, sector: 0, neighbours: Vec::new(), } ...
code_fim
medium
{ "lang": "rust", "repo": "Solarity-VR/DAO-Governance-Room", "path": "/Goldberg Governance/src/goldberg/pentagon/sector/tile.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Location { pub pentagon: i32, pub sector: i32, pub left: i32, pub right: i32, } impl Tile { pub fn new(left: i32, right: i32, pentagon: i32) -> Tile { Tile { owner: "test".to_string(), levels: 1, trees: 0, left, ...
code_fim
medium
{ "lang": "rust", "repo": "Solarity-VR/DAO-Governance-Room", "path": "/Goldberg Governance/src/goldberg/pentagon/sector/tile.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /* void getAttention (); */ Method { name: "getAttention", abi: "C", params: &[], ret: "nsresult", }, ]), }, ];...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/bt/nsIDownloadManagerUI.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /bt/nsIDownloadManagerUI.rs // // DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIDownloadManagerUI.idl // {static D: &'static [Interface] = &[ Interface { name: "nsIDownloadManagerUI", base: Some("nsISupports"), ...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/bt/nsIDownloadManagerUI.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>iesel::QueryableByName)] #[table_name = "all_tables"] pub struct AllTables { pub table_name: String, }<|fim_prefix|>// repo: undef1nd/oapth path: /oapth/src/back_end/diesel/schemas.rs diesel::table! { all_tables (table_name) { tab<|fim_middle|>le_name -> Text, } } #[derive(Debug, PartialEq, d
code_fim
easy
{ "lang": "rust", "repo": "undef1nd/oapth", "path": "/oapth/src/back_end/diesel/schemas.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: undef1nd/oapth path: /oapth/src/back_end/diesel/schemas.rs diesel::table! { all_tables (table_name) { tab<|fim_suffix|>iesel::QueryableByName)] #[table_name = "all_tables"] pub struct AllTables { pub table_name: String, }<|fim_middle|>le_name -> Text, } } #[derive(Debug, PartialEq, d
code_fim
easy
{ "lang": "rust", "repo": "undef1nd/oapth", "path": "/oapth/src/back_end/diesel/schemas.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>] pub struct AllTables { pub table_name: String, }<|fim_prefix|>// repo: undef1nd/oapth path: /oapth/src/back_end/diesel/schemas.rs diesel::table! { all_tables (table_name) { tab<|fim_middle|>le_name -> Text, } } #[derive(Debug, PartialEq, diesel::QueryableByName)] #[table_name = "all_tables"
code_fim
medium
{ "lang": "rust", "repo": "undef1nd/oapth", "path": "/oapth/src/back_end/diesel/schemas.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> println!("Result: {}", *counter.lock().unwrap()); } pub fn thread_with_arc_share() { let mut dictionary = HashMap::new(); dictionary.insert(0, 0); dictionary.insert(1, 1); dictionary.insert(2, 4); dictionary.insert(3, 9); dictionary.insert(4, 16); dictionary.insert(5, 255)...
code_fim
hard
{ "lang": "rust", "repo": "lbt05/rust-playground", "path": "/src/concurrency/play_concurrency.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lbt05/rust-playground path: /src/concurrency/play_concurrency.rs use std::collections::hash_map::RandomState; use std::collections::HashMap; use std::sync::{Arc, mpsc, Mutex, RwLock}; use std::sync::mpsc::Sender; use std::thread; use std::time::Duration; pub fn simple_thread() { thread::spa...
code_fim
hard
{ "lang": "rust", "repo": "lbt05/rust-playground", "path": "/src/concurrency/play_concurrency.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: StephenWassell/exercism path: /rust/clock/src/lib.rs #[derive(Debug, PartialEq)] pub struct Clock { minutes: i32, } impl Clock { fn normalise(minutes: i32) -> i32 { const MINUTES_IN_DAY: i32 = 60 * 24; <|fim_suffix|> pub fn add_minutes(&self, minutes: i32) -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "StephenWassell/exercism", "path": "/rust/clock/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if minutes >= 0 { minutes } else { MINUTES_IN_DAY + minutes } } pub fn new(hours: i32, minutes: i32) -> Self { Clock { minutes: Clock::normalise(hours * 60 + minutes), } } pub fn add_minutes(&self, minutes: i32) ...
code_fim
medium
{ "lang": "rust", "repo": "StephenWassell/exercism", "path": "/rust/clock/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: woodstock-xkx/fil-params-parser path: /src/main.rs extern crate bellperson; extern crate paired; extern crate clap; extern crate anyhow; use bellperson::groth16::Parameters; use paired::bls12_381::Bls12; use std::fs::File; use std::io::BufReader; use clap::{App, Arg, ArgMatches}; use anyhow::{R...
code_fim
hard
{ "lang": "rust", "repo": "woodstock-xkx/fil-params-parser", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return Ok(()) } Err(Error::msg("path is not specified")) } fn main() { let matches = App::new("fil-params-parser") .version("0.1") .arg( Arg::with_name("path") .value_name("PATH") .takes_value(true) .short("p...
code_fim
hard
{ "lang": "rust", "repo": "woodstock-xkx/fil-params-parser", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nginnever/bellman-example path: /bellman-example/src/mul.rs #![allow(unused_imports)] #![allow(unused_variables)] extern crate bellperson; extern crate paired; extern crate rand; extern crate ff; // For randomness (during paramgen and proof generation) use self::rand::{thread_rng}; // Bring in...
code_fim
hard
{ "lang": "rust", "repo": "nginnever/bellman-example", "path": "/bellman-example/src/mul.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self, cs: &mut CS ) -> Result<(), SynthesisError> { // Allocate the first value (private) let a = cs.alloc(|| "a", || { self.a.ok_or(SynthesisError::AssignmentMissing) })?; // Allocate the second value (private) ...
code_fim
hard
{ "lang": "rust", "repo": "nginnever/bellman-example", "path": "/bellman-example/src/mul.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Larusso/unity-version-manager path: /uvm_core/src/unity/mod.rs mod component; mod current_installation; pub mod hub; mod installation; pub mod urls; mod version; mod localization; pub mod project; pub mod v2 { pub use super::version::manifest::v2::Manifest; } use core::iter::FromIterator; p...
code_fim
hard
{ "lang": "rust", "repo": "Larusso/unity-version-manager", "path": "/uvm_core/src/unity/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn list_all_installations() -> Result<Installations> { let i1 = list_installations()?; let i2 = hub::list_installations()?; let iter = i1.chain(i2); let unique = iter.unique_by(|installation| installation.version().to_owned()); Ok(Installations(Box::new(unique))) } pub fn list_ins...
code_fim
hard
{ "lang": "rust", "repo": "Larusso/unity-version-manager", "path": "/uvm_core/src/unity/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MSurfer20/test2 path: /rust/src/models/add_subscriptions_response_all_of.rs /* * Zulip REST API * * Powerful open source group chat * * The version of the OpenAPI document: 1.0.0 * * Generated by: https://openapi-generator.tech */ #[derive(Clone, Debug, PartialEq, Serialize, Deseri...
code_fim
hard
{ "lang": "rust", "repo": "MSurfer20/test2", "path": "/rust/src/models/add_subscriptions_response_all_of.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>_fatal=false`. #[serde(rename = "unauthorized", skip_serializing_if = "Option::is_none")] pub unauthorized: Option<Vec<String>>, } impl AddSubscriptionsResponseAllOf { pub fn new() -> AddSubscriptionsResponseAllOf { AddSubscriptionsResponseAllOf { result: None, ...
code_fim
hard
{ "lang": "rust", "repo": "MSurfer20/test2", "path": "/rust/src/models/add_subscriptions_response_all_of.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: simonsan/bookwerx-core-rust path: /src/routz/distribution.rs use crate::db::{ APIResponse, Distribution, DistributionJoined, DistributionShort, GetDistributionJoinedResponse, GetDistributionResponse, MyRocketSQLConn, }; use regex::Regex; use rocket::http::RawStr; use rocket_contrib::json...
code_fim
hard
{ "lang": "rust", "repo": "simonsan/bookwerx-core-rust", "path": "/src/routz/distribution.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[rocket::get("/distributions/for_tx?<apikey>&<transaction_id>")] pub fn get_distributions_for_tx( apikey: &RawStr, transaction_id: &RawStr, conn: MyRocketSQLConn, ) -> Json<GetDistributionJoinedResponse> { let mut params = Vec::new(); // parametrization // We receive these arguments ...
code_fim
hard
{ "lang": "rust", "repo": "simonsan/bookwerx-core-rust", "path": "/src/routz/distribution.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ivan770/spartan path: /spartan/node/queue.rs use tokio::sync::{Mutex, MutexGuard}; #[cfg(feature = "replication")] use crate::node::replication::storage::ReplicationStorage; use crate::node::{event::Event, persistence::PersistenceError, Manager}; pub struct Queue<DB> { /// Inner database ...
code_fim
hard
{ "lang": "rust", "repo": "ivan770/spartan", "path": "/spartan/node/queue.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!(queue.replication_storage.lock().await.is_none()); queue .prepare_replication( |_| false, || ReplicationStorage::Primary(PrimaryStorage::default()), ) .await; assert!(matches!( queue.replicati...
code_fim
hard
{ "lang": "rust", "repo": "ivan770/spartan", "path": "/spartan/node/queue.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: U007D/k210_pac path: /src/dmac/channel.rs #[doc = "SAR Address Register\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic...
code_fim
hard
{ "lang": "rust", "repo": "U007D/k210_pac", "path": "/src/dmac/channel.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>:Writable for SWHSDST {} #[doc = "Channel Software handshake Destination Register"] pub mod swhsdst; #[doc = "Channel Block Transfer Resume Request Register\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_w...
code_fim
hard
{ "lang": "rust", "repo": "U007D/k210_pac", "path": "/src/dmac/channel.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Terkwood/BUGOUT path: /micro-game-lobby/lobby-model/src/api.rs use crate::*; use core_model::*; use serde_derive::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct FindPublicGame { pub client_id: ClientId, pub session_id: SessionId, } /// game_id is e...
code_fim
hard
{ "lang": "rust", "repo": "Terkwood/BUGOUT", "path": "/micro-game-lobby/lobby-model/src/api.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] pub struct PrivateGameRejected { pub game_id: GameId, pub client_id: ClientId, pub event_id: EventId, pub session_id: SessionId, } /// This event is emitted from gateway whenever a session disconnects. /// It drives the cleanup of...
code_fim
hard
{ "lang": "rust", "repo": "Terkwood/BUGOUT", "path": "/micro-game-lobby/lobby-model/src/api.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self, predicate: P, ) -> IResult<Self, Self, E> where P: Fn(Self::Item) -> bool, { match self.split_at_position(predicate) { Err(Err::Incomplete(_)) => Ok(self.take_split(self.input_len())), res => res, } } fn split_at_p...
code_fim
hard
{ "lang": "rust", "repo": "kenaniah/ruby-parser", "path": "/ruby-parser/src/lexer/tracked_location.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kenaniah/ruby-parser path: /ruby-parser/src/lexer/tracked_location.rs use core::ops::{Deref, Range, RangeFrom, RangeFull, RangeTo}; use core::str::{CharIndices, Chars, FromStr}; use nom::error::{ErrorKind, ParseError}; use nom::{ AsBytes, Compare, CompareResult, Err, ExtendInto, FindSubstrin...
code_fim
hard
{ "lang": "rust", "repo": "kenaniah/ruby-parser", "path": "/ruby-parser/src/lexer/tracked_location.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.input.find_token(token) } } impl<'a, T: FindSubstring<&'a str>, X> FindSubstring<&'a str> for TrackedLocation<T, X> { fn find_substring(&self, substr: &'a str) -> Option<usize> { self.input.find_substring(substr) } } impl<R: FromStr, T: ParseTo<R>, X> ParseTo<R> for Trac...
code_fim
hard
{ "lang": "rust", "repo": "kenaniah/ruby-parser", "path": "/ruby-parser/src/lexer/tracked_location.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: birktj/dijkstra-controller-2019 path: /driver/src/stepper.rs use embedded_hal::digital::{InputPin, OutputPin}; use embedded_hal::timer::{CountDown, Periodic}; use stm32f1xx_hal::prelude::*; use stm32f1xx_hal::time::Hertz; use crate::mpsc; use core::cell::Cell; use cortex_m::interrupt::Mutex; p...
code_fim
hard
{ "lang": "rust", "repo": "birktj/dijkstra-controller-2019", "path": "/driver/src/stepper.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_speed(&mut self, rpm: u32) { self.timer.start((2 * self.ppr * rpm / 60).hz()); } fn single_step(&mut self) { self.pul.set_high(); nb::block!(self.timer.wait()); self.pul.set_low(); nb::block!(self.timer.wait()); // Wait for motor to r...
code_fim
hard
{ "lang": "rust", "repo": "birktj/dijkstra-controller-2019", "path": "/driver/src/stepper.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if words.len() > 0 { println!("HARD"); } else { println!("EASY"); } }<|fim_prefix|>// repo: Vicfred/codeforces-rust path: /in_search_of_an_easy_problem_1030A.rs // https://codeforces.com/problemset/problem/1030/A use std::io; fn main() { <|fim_middle|> io::stdin() ...
code_fim
hard
{ "lang": "rust", "repo": "Vicfred/codeforces-rust", "path": "/in_search_of_an_easy_problem_1030A.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Vicfred/codeforces-rust path: /in_search_of_an_easy_problem_1030A.rs // https://codeforces.com/problemset/problem/1030/A use std::io; fn main() { <|fim_suffix|> if words.len() > 0 { println!("HARD"); } else { println!("EASY"); } }<|fim_middle|> io::stdin() ...
code_fim
hard
{ "lang": "rust", "repo": "Vicfred/codeforces-rust", "path": "/in_search_of_an_easy_problem_1030A.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: franciscoaguirre/advent-of-code-2020 path: /src/days/day_04/passport/types/expiration_year.rs use super::super::digits; #[derive(Debug)] pub struct ExpirationYear(u32); <|fim_suffix|> pub fn is_valid(&self) -> bool { digits(&self.0.to_string(), 10).unwrap().len() == 4 && self.0 >= 2...
code_fim
medium
{ "lang": "rust", "repo": "franciscoaguirre/advent-of-code-2020", "path": "/src/days/day_04/passport/types/expiration_year.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mainrs/opml path: /opml_cli/tests/valid.rs use std::fs::read_to_string; use assert_cmd::Command; const SAMPLE: &str = "tests/samples/youtube.opml"; #[test] fn test_valid_rss() { <|fim_suffix|> let mut cmd = Command::cargo_bin("opml").unwrap(); let assert = cmd.args(&["--file", SAMPLE, "--j...
code_fim
hard
{ "lang": "rust", "repo": "mainrs/opml", "path": "/opml_cli/tests/valid.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert .success() .code(0) .stdout(read_to_string("tests/snapshots/json-pretty.json").unwrap()); }<|fim_prefix|>// repo: mainrs/opml path: /opml_cli/tests/valid.rs use std::fs::read_to_string; use assert_cmd::Command; const SAMPLE: &str = "tests/samples/youtube.opml"; #[test] fn test_val...
code_fim
hard
{ "lang": "rust", "repo": "mainrs/opml", "path": "/opml_cli/tests/valid.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: scott113341/advent_of_code_2018 path: /day_10/src/main.rs #![feature(dbg_macro)] mod point; extern crate regex; use crate::point::{Point, Points, BoundingBox, Coordinate}; fn main() { let points = include_str!("input.txt") .trim() .split("\n") .map(|s| Point::pars...
code_fim
hard
{ "lang": "rust", "repo": "scott113341/advent_of_code_2018", "path": "/day_10/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let lines = vec![ "position=< 9, 1> velocity=< 0, 2>", "position=< 7, 0> velocity=<-1, 0>", "position=< 3, -2> velocity=<-1, 1>", "position=< 6, 10> velocity=<-2, -1>", "position=< 2, -4> velocity=< 2, 2>", "position=<-6...
code_fim
hard
{ "lang": "rust", "repo": "scott113341/advent_of_code_2018", "path": "/day_10/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Zehua-Chen/latexbuild path: /src/latexbuild/build.rs use super::Error; use super::{Logger, Project}; use std::fs::create_dir; use std::process::Command; impl Project { /// Build a project /// /// # Arguments /// /// - `logger`: the logger pub fn build<L: Logger>(&self, l...
code_fim
hard
{ "lang": "rust", "repo": "Zehua-Chen/latexbuild", "path": "/src/latexbuild/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let command_output_str = match String::from_utf8(command_output.stdout) { Ok(s) => s, Err(_error) => return Err(Error::Encoding), }; logger.command_output(&command_output_str); return Ok(command_output.status.success()); } /// Determine if...
code_fim
hard
{ "lang": "rust", "repo": "Zehua-Chen/latexbuild", "path": "/src/latexbuild/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rodrimati1992/structural_crates path: /structural/src/utils/deref_nested.rs #![allow(non_snake_case)] /// For dereferencing tuples of pointers into tuples of mutable references. /// /// # Safety /// /// The mutable raw pointers in `Self` must be dereferenced into mutable references. /// /// The...
code_fim
hard
{ "lang": "rust", "repo": "rodrimati1992/structural_crates", "path": "/structural/src/utils/deref_nested.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>deref_nested_impl! {} deref_nested_impl! { F0 } deref_nested_impl! { F0,F1 } deref_nested_impl! { F0,F1,F2 } deref_nested_impl! { F0,F1,F2,F3 } deref_nested_impl! { F0,F1,F2,F3,F4 } deref_nested_impl! { F0,F1,F2,F3,F4,F5 } deref_nested_impl! { F0,F1,F2,F3,F4,F5,F6 } deref_nested_impl! { F0,F1,F2,F3,F4,F5,...
code_fim
hard
{ "lang": "rust", "repo": "rodrimati1992/structural_crates", "path": "/structural/src/utils/deref_nested.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let result = Handle::from_str("index id", "/12341"); assert_eq!(Err("Invalid index id: \"/12341\"".to_owned()), result); } #[test] fn get_handle_from_str_with_empty_key() { let result = Handle::from_str("index id", "mine/"); assert_eq!(Err("Invalid index id: \"mine/\"".to_owned()), result...
code_fim
hard
{ "lang": "rust", "repo": "innoave/rincon", "path": "/rincon_core/src/arango/protocol/tests.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: innoave/rincon path: /rincon_core/src/arango/protocol/tests.rs use super::*; #[test] fn get_handle_key_from_str() { let handle_key = HandleKey::from_string("index id", "12341".to_owned()).unwrap(); assert_eq!(String::from("12341"), handle_key.unwrap()); } #[test] fn get_handle_key_from...
code_fim
hard
{ "lang": "rust", "repo": "innoave/rincon", "path": "/rincon_core/src/arango/protocol/tests.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tolumide-ng/coding-challenge path: /data_structures/src/queues_stacks/moving_data_stream.rs // Given a stream of integers and a window size, calculate the moving avergae of all the integers in the sliding window use crate::queues_stacks::circular_queue::MyCircularQueue; impl MyCircularQueue { ...
code_fim
medium
{ "lang": "rust", "repo": "tolumide-ng/coding-challenge", "path": "/data_structures/src/queues_stacks/moving_data_stream.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return val; } } #[cfg(test)] mod test_circular_queue { use super::*; #[test] pub fn test_cq() { let mut queue = MyCircularQueue::new(3); assert_eq!(queue.next(1), 1.0); assert_eq!(queue.next(10), 5.5); assert_eq!(queue.next(3), (1.0 + 10.0 + 3.0) ...
code_fim
medium
{ "lang": "rust", "repo": "tolumide-ng/coding-challenge", "path": "/data_structures/src/queues_stacks/moving_data_stream.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn stage_name(&self) -> &'static str { read_str(self.stage.as_ptr()) } }<|fim_prefix|>// repo: CryZe/libtww path: /src/warping/entrance.rs use system::memory::{reference, read_str}; #[repr(C, packed)] #[derive(Clone)] pub struct Entrance { pub stage: [u8; 8], pub entrance: u1...
code_fim
medium
{ "lang": "rust", "repo": "CryZe/libtww", "path": "/src/warping/entrance.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CryZe/libtww path: /src/warping/entrance.rs use system::memory::{reference, read_str}; <|fim_suffix|>impl Entrance { pub fn last_entrance() -> &'static mut Entrance { reference(0x803BD23C) } pub fn stage_name(&self) -> &'static str { read_str(self.stage.as_ptr()) ...
code_fim
medium
{ "lang": "rust", "repo": "CryZe/libtww", "path": "/src/warping/entrance.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Entrance { pub fn last_entrance() -> &'static mut Entrance { reference(0x803BD23C) } pub fn stage_name(&self) -> &'static str { read_str(self.stage.as_ptr()) } }<|fim_prefix|>// repo: CryZe/libtww path: /src/warping/entrance.rs use system::memory::{reference, read_st...
code_fim
medium
{ "lang": "rust", "repo": "CryZe/libtww", "path": "/src/warping/entrance.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: guoyucode/rbatis path: /rbatis-core/src/postgres/protocol/authentication.rs use crate::io::Buf; use crate::postgres::database::Postgres; use byteorder::NetworkEndian; use std::str; #[derive(Debug)] pub(crate) enum Authentication { /// The authentication exchange is successfully completed. ...
code_fim
hard
{ "lang": "rust", "repo": "guoyucode/rbatis", "path": "/rbatis-core/src/postgres/protocol/authentication.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub(crate) struct AuthenticationMd5 { pub(crate) salt: [u8; 4], } impl AuthenticationMd5 { pub(crate) fn read(buf: &[u8]) -> crate::Result<Self> { let mut salt = [0_u8; 4]; salt.copy_from_slice(buf); Ok(Self { salt }) } } #[derive(Debug)] pub(crate) ...
code_fim
hard
{ "lang": "rust", "repo": "guoyucode/rbatis", "path": "/rbatis-core/src/postgres/protocol/authentication.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(Self { salt: base64::decode(&salt).map_err(|_| { protocol_err!("salt value response from postgres was not base64 encoded") })?, nonce, iter_count, data: str::from_utf8(buf) .map_err(|_| protocol_err!("Sa...
code_fim
hard
{ "lang": "rust", "repo": "guoyucode/rbatis", "path": "/rbatis-core/src/postgres/protocol/authentication.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>extern "C" { fn execve( filename: *const c_char, argv: *const *const c_char, envp: *const *const c_char, ) -> i32; fn fork() -> i32; fn wait(status: *mut i32) -> i32; fn perror(msg: *const u8); fn tcsetpgrp(fildes: i32, pgid: i32); fn getpgrp() -> i32; ...
code_fim
hard
{ "lang": "rust", "repo": "sclolus/Turbofish", "path": "/programs/modules/shell/src/shell/builtin.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// display a very lazy hello world pub fn reboot_computer(_args: &[&str]) -> u8 { unsafe { reboot(); } 1 } /// display a very lazy hello world pub fn shutdown_computer(_args: &[&str]) -> u8 { unsafe { shutdown(); } 1 } extern "C" { fn reboot() -> i32; fn ...
code_fim
hard
{ "lang": "rust", "repo": "sclolus/Turbofish", "path": "/programs/modules/shell/src/shell/builtin.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sclolus/Turbofish path: /programs/modules/shell/src/shell/builtin.rs //! Dome builtins mod fish; mod really_lazy_hello_world; use really_lazy_hello_world::really_lazy_hello_world; // simple, basic pub fn echo(args: &[&str]) -> u8 { for s in args { print!("{} ", s); } print...
code_fim
hard
{ "lang": "rust", "repo": "sclolus/Turbofish", "path": "/programs/modules/shell/src/shell/builtin.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>Encoding : : for_label ( b " iso8859 - 8 " ) Some ( ISO_8859_8 ) ) ; assert_eq ! ( Encoding : : for_label ( b " iso - ir - 58 " ) Some ( GBK ) ) ; assert_eq ! ( Encoding : : for_label ( b " iso8859 - 9 " ) Some ( WINDOWS_1254 ) ) ; assert_eq ! ( Encoding : : for_label ( b " csunicode " ) Some ( UTF_16LE )...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/encoding_rs/src/test_labels_names.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>Encoding : : for_label ( b " iso - ir - 110 " ) Some ( ISO_8859_4 ) ) ; assert_eq ! ( Encoding : : for_label ( b " gb_2312 - 80 " ) Some ( GBK ) ) ; assert_eq ! ( Encoding : : for_label ( b " iso - 8859 - 1 " ) Some ( WINDOWS_1252 ) ) ; assert_eq ! ( Encoding : : for_label ( b " iso_8859 - 1 " ) Some ( WI...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/encoding_rs/src/test_labels_names.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/encoding_rs/src/test_labels_names.rs : : for_label ( b " ascii " ) Some ( WINDOWS_1252 ) ) ; assert_eq ! ( Encoding : : for_label ( b " x - gbk " ) Some ( GBK ) ) ; assert_eq ! ( Encoding : : for_label ( b " greek " ) Some ( ISO_8859_7 ) ) ; as...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/encoding_rs/src/test_labels_names.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> #[doc(alias = "gdk_file_list_get_files")] #[doc(alias = "get_files")] pub fn files(&self) -> Vec<gio::File> { unsafe { FromGlibPtrContainer::from_glib_container(ffi::gdk_file_list_get_files(mut_override( self.to_glib_none().0, ))) } }...
code_fim
hard
{ "lang": "rust", "repo": "zecakeh/gtk4-rs", "path": "/gdk4/src/auto/file_list.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::gdk_file_list_get_type(), ptr as *mut _) as *mut ffi::GdkFileList, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::gdk_file_list_get_type(), ptr as *mut _), type_ => || ffi::gdk_file_list_get_type(), } } impl...
code_fim
medium
{ "lang": "rust", "repo": "zecakeh/gtk4-rs", "path": "/gdk4/src/auto/file_list.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zecakeh/gtk4-rs path: /gdk4/src/auto/file_list.rs // This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use glib::translate::*; glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub...
code_fim
hard
{ "lang": "rust", "repo": "zecakeh/gtk4-rs", "path": "/gdk4/src/auto/file_list.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> sleep(Duration::from_secs(1)).await; cache.async_clear().await; assert!(!cache.async_cache.exists(&cache_key_1).await); assert!(!cache.async_cache.exists(&cache_key_2).await); sleep(Duration::from_secs(1)).await; drop(cache); ...
code_fim
hard
{ "lang": "rust", "repo": "qiniu/rust-sdk", "path": "/http-client/src/regions/regions_provider/regions_cache.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qiniu/rust-sdk path: /http-client/src/regions/regions_provider/regions_cache.rs = true; Ok(vec![chaotic_up_domains_region()].into()) })? .len(), 1 ); assert!(generate_new_cache); assert!(cache.cache.exists(&c...
code_fim
hard
{ "lang": "rust", "repo": "qiniu/rust-sdk", "path": "/http-client/src/regions/regions_provider/regions_cache.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qiniu/rust-sdk path: /http-client/src/regions/regions_provider/regions_cache.rs "fakebucket".into(), "fakeaccesskey".into(), ); generate_new_cache = false; assert_eq!( cache .get(&cache_key2, || { generate...
code_fim
hard
{ "lang": "rust", "repo": "qiniu/rust-sdk", "path": "/http-client/src/regions/regions_provider/regions_cache.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let config: Value = load(); let filesystem_configs = config.get("filesystem").unwrap(); return filesystem_configs.clone(); } pub fn root_directories() -> std::vec::Vec<Value> { let filesystem_configs = filesystem(); let git_config = filesystem_configs.get("root_directories").unwrap();...
code_fim
medium
{ "lang": "rust", "repo": "diegorubin/fs-events", "path": "/src/configs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: diegorubin/fs-events path: /src/configs.rs use serde_yaml::from_reader; use serde_yaml::Value; use std::env; fn load() -> Value { let mut home_path = String::from("/root"); match env::var("HOME") { Ok(value) => home_path = value.to_owned(), Err(e) => println!("Couldn't r...
code_fim
medium
{ "lang": "rust", "repo": "diegorubin/fs-events", "path": "/src/configs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn root_directories() -> std::vec::Vec<Value> { let filesystem_configs = filesystem(); let git_config = filesystem_configs.get("root_directories").unwrap(); return git_config.as_sequence().unwrap().clone(); }<|fim_prefix|>// repo: diegorubin/fs-events path: /src/configs.rs use serde_yaml:...
code_fim
hard
{ "lang": "rust", "repo": "diegorubin/fs-events", "path": "/src/configs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } // Update the timestamp for an image. fn update_timestamp(state: &mut State, image_id: &str, verbose: bool) -> io::Result<()> { if verbose { info!( "Updating last-used timestamp for image {}\u{2026}", image_id.code_str(), ); } else { de...
code_fim
hard
{ "lang": "rust", "repo": "mdonoughe/docuum", "path": "/src/run.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Ensure the command succeeded. if !child.wait()?.success() { return Err(io::Error::new( io::ErrorKind::Other, format!("Unable to delete image {}.", image_id.code_str()), )); } Ok(()) } // Update the timestamp for an image. fn update_timestamp(sta...
code_fim
hard
{ "lang": "rust", "repo": "mdonoughe/docuum", "path": "/src/run.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mdonoughe/docuum path: /src/run.rs use crate::{ format::CodeStr, state::{self, State}, Settings, }; use byte_unit::Byte; use scopeguard::guard; use serde::{Deserialize, Serialize}; use std::{ collections::HashSet, io::{self, BufRead, BufReader}, process::{Command, Stdio},...
code_fim
hard
{ "lang": "rust", "repo": "mdonoughe/docuum", "path": "/src/run.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub struct MessageDispatcher { mail: Mail, news: News, post: Post, } impl MessageDispatcher { pub fn new() -> Self { Self { mail: Mail {}, news: News {}, post: Post {}, } } pub fn report_mail(&self) { self.mail.content();...
code_fim
medium
{ "lang": "rust", "repo": "raiote/design-pattern", "path": "/facade/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: raiote/design-pattern path: /facade/src/lib.rs pub trait Message: std::fmt::Debug { fn content(&self) { println!("This is a {:?} message.", self); } } #[derive(Debug)] pub struct News {} impl Message for News {} <|fim_suffix|>#[cfg(test)] mod tests { use crate::*; // car...
code_fim
hard
{ "lang": "rust", "repo": "raiote/design-pattern", "path": "/facade/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }