text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> output[0].iter_mut().for_each(|s| *s = self.sig.next() as f32); } }<|fim_prefix|>// repo: remaininlight/glicol path: /rs/synth/src/signal/noise.rs use dasp_graph::{Buffer, Input, Node}; use dasp_signal::{self as signal, Signal}; use super::super::{ GlicolNodeData, mono_node, NodeData, BoxedNo...
code_fim
medium
{ "lang": "rust", "repo": "remaininlight/glicol", "path": "/rs/synth/src/signal/noise.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> mod vet_handler; pub mod misc_handler;<|fim_prefix|>// repo: Mutestock/cphsoft path: /dbd/uge05/assignment/src/logic/handlers/mod.rs pub mod caretaker_handler; pub mod cit<|fim_middle|>y_handler; pub mod pet_handler; pub mod cat_handler; pub mod dog_handler; pub
code_fim
medium
{ "lang": "rust", "repo": "Mutestock/cphsoft", "path": "/dbd/uge05/assignment/src/logic/handlers/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Mutestock/cphsoft path: /dbd/uge05/assignment/src/logic/handlers/mod.rs pub mod caretaker_handler; pub mod city_handler; pub mod pet_handler; pub mod<|fim_suffix|> mod vet_handler; pub mod misc_handler;<|fim_middle|> cat_handler; pub mod dog_handler; pub
code_fim
easy
{ "lang": "rust", "repo": "Mutestock/cphsoft", "path": "/dbd/uge05/assignment/src/logic/handlers/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let app = app_from_crate!() .arg(Arg::with_name("height") .help("Image height") .default_value("1000") .short("h") .long("height")) .arg(Arg::with_name("width") .help("Image width") .default_value("1000") ...
code_fim
hard
{ "lang": "rust", "repo": "anekos/shidaa", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: anekos/shidaa path: /src/main.rs use std::fs::OpenOptions; use std::process::exit; #[macro_use] extern crate clap; use clap::Arg; mod errors; mod generator; use crate::errors::AppResultU; fn main() { if let Err(err) = app() { eprintln!("{}", err); exit(1); } } fn...
code_fim
hard
{ "lang": "rust", "repo": "anekos/shidaa", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let background_color: &str = matches.value_of("background").unwrap(); let fern_color: &str = matches.value_of("color").unwrap(); let filepath: &str = matches.value_of("filepath").unwrap(); let frames: u32 = matches.value_of("frames").unwrap().parse()?; let height: u32 = matches.value_o...
code_fim
hard
{ "lang": "rust", "repo": "anekos/shidaa", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>assert_eq!(a.cmp(&b), F(a).cmp(&F(b))); assert_eq!(a.min(b), *F(a).min(F(b))); assert_eq!(a.max(b), *F(a).max(F(b))); } } }<|fim_prefix|>// repo: qryxip/modtype path: /tests/cmp.rs #[test] fn cmp() { #[modtype::use_modtype] type F = modtype::F<5u32>; for a...
code_fim
hard
{ "lang": "rust", "repo": "qryxip/modtype", "path": "/tests/cmp.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qryxip/modtype path: /tests/cmp.rs #[test] fn cmp() { #[modtype::use_modtype] type F = modtype::F<5u32>; for a in 0..=4 { for b in 0..=4 { assert_eq!(a == b, F(a) == F(b)); assert_eq!(a != b, F(a) != F(b)); assert_eq!(a.partial_cmp(&b), F(...
code_fim
medium
{ "lang": "rust", "repo": "qryxip/modtype", "path": "/tests/cmp.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for row in -rows..rows { let tx = tx.clone(); pool.execute(move || { for col in -columns..columns { let pixel_row = row + rows; let pixel_col = col + columns; let re = zl.re + (row as f64) / zl.zoom; let im = z...
code_fim
hard
{ "lang": "rust", "repo": "selfint/rust-mandelbrot-set", "path": "/src/mandelbrot.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn calc_rgb_parallel( zl: ZoomLocation, rows: i64, columns: i64, buffer: &mut Vec<Vec<Option<[f32; 4]>>>, ) { let pool = ThreadPool::new(num_cpus::get()); let (tx, rx) = channel(); for row in -rows..rows { let tx = tx.clone(); pool.execute(move || { ...
code_fim
hard
{ "lang": "rust", "repo": "selfint/rust-mandelbrot-set", "path": "/src/mandelbrot.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: selfint/rust-mandelbrot-set path: /src/mandelbrot.rs use angular_units::Deg; use num::complex::Complex64; use prisma::{Color, FromColor, Hsl, Rgb}; use std::sync::mpsc::channel; use threadpool::ThreadPool; pub struct Frame { pub step_fractions: Vec<Vec<f64>>, } pub struct RgbFrame { pu...
code_fim
hard
{ "lang": "rust", "repo": "selfint/rust-mandelbrot-set", "path": "/src/mandelbrot.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dastardlychimp/wikiquery path: /src/requests/category_members.rs use super::{Params, SubQuery}; /// Generates a *categorymembers* list query. /// /// Param documentation can be found at [`mediawiki:categorymembers`] /// /// # Examples /// ``` /// use wikiquery::requests::Query; /// /// let m...
code_fim
hard
{ "lang": "rust", "repo": "dastardlychimp/wikiquery", "path": "/src/requests/category_members.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn cm_continue<S: Into<String>>(&mut self, value: S) -> &mut Self { self.add_param_value("cmcontinue", value.into()) } } #[cfg(test)] mod category_members_tests { use crate::requests::Query; use crate::test::helpers::*; #[test] fn all_fields() { let mu...
code_fim
hard
{ "lang": "rust", "repo": "dastardlychimp/wikiquery", "path": "/src/requests/category_members.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn cm_limit<S: Into<String>>(&mut self, value: S) -> &mut Self { self.add_param_value("cmlimit", value.into()) } pub fn cm_sort<S: Into<String>>(&mut self, value: S) -> &mut Self { self.add_param_value("cmsort", value.into()) } pub fn cm_dir<S: Into<String...
code_fim
hard
{ "lang": "rust", "repo": "dastardlychimp/wikiquery", "path": "/src/requests/category_members.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wezm/pkb path: /src/tag.rs use std::collections::BTreeMap; use std::path::Path; use std::rc::Rc; use std::time::SystemTime; use crate::page::{Loaded, Page}; pub type Pages = Vec<Rc<Page<Loaded>>>; #[derive(Debug)] pub struct Tag { pub name: String, pages: Pages, } impl Tag { fn n...
code_fim
hard
{ "lang": "rust", "repo": "wezm/pkb", "path": "/src/tag.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn page_count(&self) -> usize { self.pages.len() } pub fn sorted_pages(&self) -> Pages { let mut sorted = self.pages.clone(); sorted.sort_by(|a, b| a.name.cmp(&b.name)); sorted } pub fn last_modified(&self) -> SystemTime { self.pages ...
code_fim
hard
{ "lang": "rust", "repo": "wezm/pkb", "path": "/src/tag.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("{}", beautiful_subarrays(vec![4, 3, 1, 2, 4])); // 2 println!("{}", beautiful_subarrays(vec![4, 3, 1, 2, 4, 4])); // 4 println!("{}", beautiful_subarrays(vec![1, 10, 4])); // 0 println!("{}", beautiful_subarrays(vec![3, 4])); // 0 println!("{}", beautiful_subarrays(vec![1]));...
code_fim
medium
{ "lang": "rust", "repo": "fredyw/leetcode", "path": "/src/main/rust/src/bin/problem2588.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fredyw/leetcode path: /src/main/rust/src/bin/problem2588.rs use std::collections::HashMap; // https://leetcode.com/problems/count-the-number-of-beautiful-subarrays/ pub fn beautiful_subarrays(nums: Vec<i32>) -> i64 { let mut answer = 0; let mut counts: HashMap<i32, i32> = HashMap::new()...
code_fim
medium
{ "lang": "rust", "repo": "fredyw/leetcode", "path": "/src/main/rust/src/bin/problem2588.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vulkano-rs/vulkano-www path: /chapter_code/src/bin/images/main.rs mod image_clear; mod mandelbrot; use chapter_code::select_example_to_run; <|fim_suffix|>fn execute_example(selection: &str) { println!("Running '{}'", selection); match selection { "image_clear" => { ...
code_fim
medium
{ "lang": "rust", "repo": "vulkano-rs/vulkano-www", "path": "/chapter_code/src/bin/images/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> select_example_to_run(&EXAMPLES.to_vec(), execute_example); }<|fim_prefix|>// repo: vulkano-rs/vulkano-www path: /chapter_code/src/bin/images/main.rs mod image_clear; mod mandelbrot; use chapter_code::select_example_to_run; const EXAMPLES: [&str; 2] = ["image_clear", "mandelbrot"]; fn execute_exam...
code_fim
hard
{ "lang": "rust", "repo": "vulkano-rs/vulkano-www", "path": "/chapter_code/src/bin/images/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lucifer1004/AtCoder path: /abc191/src/bin/d.rs use proconio::input; const TEN: [i64; 4] = [1, 10, 100, 1000]; fn parse(s: String) -> i64 { let v = s.split(".").collect::<Vec<&str>>(); if v.len() == 1 { v[0].parse::<i64>().unwrap() * 10000 } else { let sub = v[1].par...
code_fim
medium
{ "lang": "rust", "repo": "lucifer1004/AtCoder", "path": "/abc191/src/bin/d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut ans = 0i64; let x = parse(x); let y = parse(y); let r = parse(r); for i in (y - r + offset) / 10000 - offset_s..=(y + r - 1 + offset) / 10000 + 1 - offset_s { let h = y - i * 10000; let mut lo = x - r; let mut hi = x; while lo <= hi { ...
code_fim
medium
{ "lang": "rust", "repo": "lucifer1004/AtCoder", "path": "/abc191/src/bin/d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Millsky/tendie-factory path: /core/src/metrics/nlp.rs use rust_bert::{ pipelines::{ ner::{NERModel}, sentiment::{SentimentModel, SentimentPolarity}, } }; use rust_bert::pipelines::sentiment::Sentiment; use std::sync::{Mutex}; use once_cell::sync::Lazy; const BASE_CONFIDE...
code_fim
hard
{ "lang": "rust", "repo": "Millsky/tendie-factory", "path": "/core/src/metrics/nlp.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn sentiment_classifier (input: &str) -> Vec<SentimentPolarity> { let sentiment_classifier = SENTIMENT_MODEL.lock().unwrap(); let mut sentiment_scores: Vec<SentimentPolarity> = vec![]; let output: Vec<Sentiment> = sentiment_classifier.predict([input]); let scores: Vec<SentimentPolarity...
code_fim
hard
{ "lang": "rust", "repo": "Millsky/tendie-factory", "path": "/core/src/metrics/nlp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn from_str(src: &str) -> Result<Self> { let toml = toml::from_str(src).expect("Error loading config"); Ok(toml) } } impl UnveilConfig { pub fn from_disk<P: AsRef<Path>>(config_file: P) -> Result<UnveilConfig> { let mut buffer = String::new(); File::open(config...
code_fim
hard
{ "lang": "rust", "repo": "oknozor/unveil-rs", "path": "/src/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oknozor/unveil-rs path: /src/config.rs use crate::assets::{CSS_DARK_THEME, CSS_THEME}; use anyhow::{Error, Result}; use serde::{Deserialize, Serialize}; use std::{fs::File, io::Read, path::Path, str::FromStr}; #[derive(Serialize, Deserialize)] pub struct UnveilConfig { name: String, lan...
code_fim
hard
{ "lang": "rust", "repo": "oknozor/unveil-rs", "path": "/src/config.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(Config { organizations: organizations_from_dir(&oktaws_home).collect(), }) } pub fn organizations(self) -> impl Iterator<Item = Organization> { self.organizations.into_iter() } } fn organizations_from_dir(dir: &Path) -> impl Iterator<Item = Organization...
code_fim
hard
{ "lang": "rust", "repo": "WhereBeTheDan/oktaws", "path": "/src/config/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WhereBeTheDan/oktaws path: /src/config/mod.rs pub mod credentials; pub mod organization; use crate::config::organization::Organization; use std::{convert::TryInto, env::var as env_var}; use std::path::Path; use std::path::PathBuf; <|fim_suffix|> WalkDir::new(dir) .follow_links(true...
code_fim
hard
{ "lang": "rust", "repo": "WhereBeTheDan/oktaws", "path": "/src/config/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dkandalov/katas path: /rust/hello-rust/src/2-primitives.rs use std::fmt::{Display, Formatter, Result}; use std::mem; #[allow(dead_code, unused_variables, unused_mut)] fn main() { let an_integer0 = 5i8; let an_integer1 = 5i16; let an_integer2 = 5i32; let an_integer3 = 5i64; l...
code_fim
medium
{ "lang": "rust", "repo": "dkandalov/katas", "path": "/rust/hello-rust/src/2-primitives.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> // 2.3 let xs: [i32; 5] = [1, 2, 3, 4, 5]; let ys: [i32; 500] = [0; 500]; // init all elements to 0 println!("first element of the array: {}", xs[1]); println!("second element of the array: {}", xs[2]); //println!("array out of bound: {}", xs[5]); println!("array size: {}", xs....
code_fim
hard
{ "lang": "rust", "repo": "dkandalov/katas", "path": "/rust/hello-rust/src/2-primitives.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Vanfarock/th_backend path: /src/models/competition_player.rs use super::prelude::*; #[derive(Serialize, Deserialize, Debug)] pub struct CompetitionPlayer { #[serde(rename = "_id", skip_serializing_if = "Option::is_none")] id: Option<bson::oid::ObjectId>, player_id: bson::oid::ObjectId,...
code_fim
medium
{ "lang": "rust", "repo": "Vanfarock/th_backend", "path": "/src/models/competition_player.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> db.collection("competitionPlayer") } }<|fim_prefix|>// repo: Vanfarock/th_backend path: /src/models/competition_player.rs use super::prelude::*; #[derive(Serialize, Deserialize, Debug)] pub struct CompetitionPlayer { #[serde(rename = "_id", skip_serializing_if = "Option::is_none")] id: O...
code_fim
medium
{ "lang": "rust", "repo": "Vanfarock/th_backend", "path": "/src/models/competition_player.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>s::from_big_value(numer) .as_slice().iter().map(|&digit| digit as u64).sum() }<|fim_prefix|>// repo: Techcable/euler-rust path: /src/solutions/convergents_of_e.rs use utils::{ContinuedFraction, Digits, BigDigits}; pub fn solve() -> u64 { // NOTE: Project Euler counts from one here, so 99th c...
code_fim
medium
{ "lang": "rust", "repo": "Techcable/euler-rust", "path": "/src/solutions/convergents_of_e.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Techcable/euler-rust path: /src/solutions/convergents_of_e.rs use utils::{ContinuedFraction, Digits, BigDigits}; pub fn solve() -> u64 { // NO<|fim_suffix|>s::from_big_value(numer) .as_slice().iter().map(|&digit| digit as u64).sum() }<|fim_middle|>TE: Project Euler counts from one h...
code_fim
medium
{ "lang": "rust", "repo": "Techcable/euler-rust", "path": "/src/solutions/convergents_of_e.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Veetaha/numerical-methods-labs path: /lab1/src/funcs/f2.rs use std::f64::consts::PI; use super::{Func, Derivative}; <|fim_suffix|>impl Func for F2 { #[inline] fn func(&self, x: f64) -> f64 { x * (x - 2.0) + PI * ((13.0 * PI).log10() - 5.0 * x.sin()) } } impl Derivative fo...
code_fim
easy
{ "lang": "rust", "repo": "Veetaha/numerical-methods-labs", "path": "/lab1/src/funcs/f2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] fn func(&self, x: f64) -> f64 { x * (x - 2.0) + PI * ((13.0 * PI).log10() - 5.0 * x.sin()) } } impl Derivative for F2 { // fn derivative(&self, x: f64) -> f64 { // 2.0 * x - 2.0 - 5.0 * PI * x.cos() // } }<|fim_prefix|>// repo: Veetaha/numerical-methods-labs ...
code_fim
easy
{ "lang": "rust", "repo": "Veetaha/numerical-methods-labs", "path": "/lab1/src/funcs/f2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Plugin for StagePlugin { fn build(&self, app: &mut AppBuilder) { app.add_stage_before( CoreStage::Update, CustomStage::Before, SystemStage::parallel(), ) .add_stage_after( CoreStage::Update, CustomStage::...
code_fim
medium
{ "lang": "rust", "repo": "tyler-goodwin/bevy-2048", "path": "/src/stages.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tyler-goodwin/bevy-2048 path: /src/stages.rs use bevy::prelude::*; #[derive(Debug, Hash, PartialEq, Eq, Clone, StageLabel)] pub enum CustomStage { Before, After, } <|fim_suffix|> app.add_stage_before( CoreStage::Update, CustomStage::Before, ...
code_fim
medium
{ "lang": "rust", "repo": "tyler-goodwin/bevy-2048", "path": "/src/stages.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn funcs(&self) -> &[Func] { &self.funcs } pub fn inputs(&self) -> &[String] { &self.inputs } pub fn outputs(&self) -> &[String] { &self.outputs } pub fn input_then_outputs(&self) -> Vec<String> { self.inputs().iter().chain(self.outputs())...
code_fim
hard
{ "lang": "rust", "repo": "theotherphil/prism", "path": "/src/syntax/graph.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: theotherphil/prism path: /src/syntax/graph.rs use std::collections::HashSet; use crate::syntax::{Func, Schedule}; /// Doesn't yet look very graph-like... pub struct Graph { pub name: String, funcs: Vec<Func>, /// Names of the required input buffers, /// computed from funcs. ...
code_fim
hard
{ "lang": "rust", "repo": "theotherphil/prism", "path": "/src/syntax/graph.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn remove() { let mut props = properties! { "K0" => "V0" }; assert_eq!(Some("V0"), props.get("K0")); props.remove("K0"); assert_eq!(None, props.get("K0")); } #[test] fn insert() { let mut props = properties! { ...
code_fim
hard
{ "lang": "rust", "repo": "derekdreery/pipewire-rs", "path": "/pipewire/src/properties.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: derekdreery/pipewire-rs path: /pipewire/src/properties.rs use spa::dict::{ReadableDict, WritableDict}; use std::{ffi::CString, mem::ManuallyDrop}; /// A collection of key/value pairs. /// /// # Examples /// Create a `Properties` struct and access the stored values by key: /// ```rust /// use pi...
code_fim
hard
{ "lang": "rust", "repo": "derekdreery/pipewire-rs", "path": "/pipewire/src/properties.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jacderida/sn_cli path: /benches/put.rs // Copyright 2020 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT // http://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD // https://opensource.org/licenses/BSD-3-Clause>, ...
code_fim
hard
{ "lang": "rust", "repo": "jacderida/sn_cli", "path": "/benches/put.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>fn bench_cli_put(c: &mut Criterion) { c.bench_function("cli put random tiny file", |b| { b.iter_batched( || put_random_content(TINY_FILE), |_| { // use the safe command, so for bench it has to be installed cmd!(get_bin_location(), "files...
code_fim
hard
{ "lang": "rust", "repo": "jacderida/sn_cli", "path": "/benches/put.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> c.bench_function("cli put random tiny file", |b| { b.iter_batched( || put_random_content(TINY_FILE), |_| { // use the safe command, so for bench it has to be installed cmd!(get_bin_location(), "files", "put", TEST_FILE_RANDOM_CONTENT) ...
code_fim
hard
{ "lang": "rust", "repo": "jacderida/sn_cli", "path": "/benches/put.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mmitteregger/wiremock-client-rs path: /src/security.rs use http::header::{self, HeaderMap, HeaderValue}; pub trait ClientAuthenticator { fn generate_auth_headers(&self) -> HeaderMap; } pub struct NoClientAuthenticator; pub struct ClientBasicAuthenticator { headers: HeaderMap, } impl ...
code_fim
hard
{ "lang": "rust", "repo": "mmitteregger/wiremock-client-rs", "path": "/src/security.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ClientTokenAuthenticator { headers, } } } impl ClientAuthenticator for NoClientAuthenticator { fn generate_auth_headers(&self) -> HeaderMap<HeaderValue> { HeaderMap::new() } } impl ClientAuthenticator for ClientBasicAuthenticator { fn generate_auth_hea...
code_fim
hard
{ "lang": "rust", "repo": "mmitteregger/wiremock-client-rs", "path": "/src/security.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// impl From<crate::cli::DepartmentUpdate> for DepartmentUpdate { // fn from(cli_upd: crate::cli::DepartmentUpdate) -> Self { Self { // departments_id: cli_upd.departments_id, // department_name: cli_upd.department_name, // }} // }<|fim_prefix|>// repo: DeLion13/DataBases path:...
code_fim
medium
{ "lang": "rust", "repo": "DeLion13/DataBases", "path": "/lab3/src/models/entities/department.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DeLion13/DataBases path: /lab3/src/models/entities/department.rs use diesel::{Queryable, Insertable}; use crate::{models::schema::Departments}; <|fim_suffix|>// fn from(cli_upd: crate::cli::DepartmentUpdate) -> Self { Self { // departments_id: cli_upd.departments_id, // dep...
code_fim
hard
{ "lang": "rust", "repo": "DeLion13/DataBases", "path": "/lab3/src/models/entities/department.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn view(&self, _ctx: &Context<Self>) -> Html { Html::from_html_unchecked(HTML.into()) } } fn main() { yew::Renderer::<App>::new().render(); }<|fim_prefix|>// repo: doytsujin/yew path: /examples/inner_html/src/main.rs use yew::{Component, Context, Html}; const HTML: &str = include_st...
code_fim
easy
{ "lang": "rust", "repo": "doytsujin/yew", "path": "/examples/inner_html/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doytsujin/yew path: /examples/inner_html/src/main.rs use yew::{Component, Context, Html}; const HTML: &str = include_str!("document.html"); pub struct App; <|fim_suffix|> fn view(&self, _ctx: &Context<Self>) -> Html { Html::from_html_unchecked(HTML.into()) } } fn main() { ...
code_fim
medium
{ "lang": "rust", "repo": "doytsujin/yew", "path": "/examples/inner_html/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> yew::Renderer::<App>::new().render(); }<|fim_prefix|>// repo: doytsujin/yew path: /examples/inner_html/src/main.rs use yew::{Component, Context, Html}; const HTML: &str = include_str!("document.html"); pub struct App; <|fim_middle|>impl Component for App { type Message = (); type Propertie...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/yew", "path": "/examples/inner_html/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mdeg/dengbot path: /src/types.rs use ::std; use ::std::error::Error as StdError; pub type DbConnection = ::r2d2::PooledConnection<::r2d2_diesel::ConnectionManager<::diesel::PgConnection>>; pub enum Broadcast { Deng(String), NonDeng(String) } #[derive(Debug, Queryable)] pub struct Deng...
code_fim
hard
{ "lang": "rust", "repo": "mdeg/dengbot", "path": "/src/types.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Error { description: String::from(error), cause: None } } } impl From<String> for Error { fn from(error: String) -> Self { Error { description: error, cause: None } } } impl From<::slack_hook::Error> for Error { ...
code_fim
hard
{ "lang": "rust", "repo": "mdeg/dengbot", "path": "/src/types.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hosshii/rust_traq path: /src/models/bot_user.rs /* * traQ v3 * * traQ v3 API * * The version of the OpenAPI document: 3.0 * * Generated by: https://openapi-generator.tech */ <|fim_suffix|>impl BotUser { /// BOTユーザー対 pub fn new(id: String, bot_user_id: String) -> BotUser { ...
code_fim
hard
{ "lang": "rust", "repo": "Hosshii/rust_traq", "path": "/src/models/bot_user.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl BotUser { /// BOTユーザー対 pub fn new(id: String, bot_user_id: String) -> BotUser { BotUser { id, bot_user_id } } }<|fim_prefix|>// repo: Hosshii/rust_traq path: /src/models/bot_user.rs /* * traQ v3 * * traQ v3 API * * The version of the OpenAPI document: 3.0 * * Generated by:...
code_fim
hard
{ "lang": "rust", "repo": "Hosshii/rust_traq", "path": "/src/models/bot_user.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>assert_eq!(format!("{}", inst), expected); let expected = "[MFI] nop.m 0x0; frcpa.s1 f10,p6=f8,f9; nop.i 0x0;;"; let data = [0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0xa0, 0x40, 0x24, 0x8c, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00]; let mut reader = U8Reader::new(&data[..]); let inst = decoder.decode...
code_fim
hard
{ "lang": "rust", "repo": "iximeow/yaxpeax-ia64", "path": "/tests/test.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iximeow/yaxpeax-ia64 path: /tests/test.rs [MIB] mov r35=r0; nop.i 0x0; br.call.sptk.many b0=$-0x17a3f0;;"; let data = [0x11, 0x18, 0x01, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x18, 0x5c, 0xe8, 0x58]; let mut reader = U8Reader::new(&data[..]); let inst = decoder.decode...
code_fim
hard
{ "lang": "rust", "repo": "iximeow/yaxpeax-ia64", "path": "/tests/test.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|>r::new(&data[..]); let inst = decoder.decode(&mut reader).unwrap(); assert_eq!(format!("{}", inst), expected); let expected = "[MFI] nop.m 0x0; frcpa.s1 f10,p6=f8,f9; nop.i 0x0;;"; let data = [0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0xa0, 0x40, 0x24, 0x8c, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00]; ...
code_fim
hard
{ "lang": "rust", "repo": "iximeow/yaxpeax-ia64", "path": "/tests/test.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|> pub fn run(&self) { run_cli(); } }<|fim_prefix|>// repo: jjmark15/happynum_rust path: /src/lib.rs use crate::cli::run_cli; mod cli; pub mod happynum; <|fim_middle|>#[derive(Default)] pub struct App; impl App { pub fn new() -> Self { App::default() }
code_fim
medium
{ "lang": "rust", "repo": "jjmark15/happynum_rust", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jjmark15/happynum_rust path: /src/lib.rs use crate::cli::run_cli; mod cli; pub mod happynum; #[derive(Default)] pub struct App; <|fim_suffix|> pub fn run(&self) { run_cli(); } }<|fim_middle|>impl App { pub fn new() -> Self { App::default() }
code_fim
medium
{ "lang": "rust", "repo": "jjmark15/happynum_rust", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tailwind/mdbook-bookimport path: /src/lib.rs //! mdbook-bookimport is a pre-processor for [mdbook]'s that helps you avoid link rot //! when importing parts of other files into your mdbook. //! //! [mdbook]: https://github.com/rust-lang-nursery/mdBook #![deny(missing_docs, warnings)] use failur...
code_fim
hard
{ "lang": "rust", "repo": "tailwind/mdbook-bookimport", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let chapter_dir = "book/src/test-cases/tag-import"; let chapter_dir = format!("{}/{}", env!("CARGO_MANIFEST_DIR"), chapter_dir); let content_between_tags = simport.read_content_between_tags(&chapter_dir.into()); let expected_content = r#" .this-will-be-included { displa...
code_fim
hard
{ "lang": "rust", "repo": "tailwind/mdbook-bookimport", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let tag_import_chapter = make_tag_import_chapter(); let mut item = BookItem::Chapter(tag_import_chapter); process_chapter(&mut item, &"".into()).unwrap(); // Spacing an indentation is intentional let expected_content = r#"# Tag Import ```md .this-will-be-include...
code_fim
hard
{ "lang": "rust", "repo": "tailwind/mdbook-bookimport", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl slog::Serializer for FormatKeyValueList { fn emit_arguments(&mut self, key: slog::Key, val: &fmt::Arguments) -> slog::Result { if !self.buffer.is_empty() { write!(&mut self.buffer, ", {}: {}", key, val).unwrap(); } else { write!(&mut self.buffer, "{}: {}", ...
code_fim
hard
{ "lang": "rust", "repo": "yzh119/raft-rs", "path": "/src/util.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yzh119/raft-rs path: /src/util.rs //! This module contains a collection of various tools to use to manipulate //! and control messages and data associated with raft. // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. use slog::{OwnedKVList, Record, KV}; use std::fmt; use std::f...
code_fim
hard
{ "lang": "rust", "repo": "yzh119/raft-rs", "path": "/src/util.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mthstanley/stockpot path: /src/commands/server.rs use std::net::SocketAddr; <|fim_suffix|>#[derive(Parser)] pub struct RootCommand { #[clap( value_parser, default_value = "127.0.0.1:8080", env = "ADDR", value_name = "HOST_AND_PORT" )] pub addr: Socket...
code_fim
easy
{ "lang": "rust", "repo": "mthstanley/stockpot", "path": "/src/commands/server.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Parser)] pub struct RootCommand { #[clap( value_parser, default_value = "127.0.0.1:8080", env = "ADDR", value_name = "HOST_AND_PORT" )] pub addr: SocketAddr, }<|fim_prefix|>// repo: mthstanley/stockpot path: /src/commands/server.rs use std::net::Socket...
code_fim
easy
{ "lang": "rust", "repo": "mthstanley/stockpot", "path": "/src/commands/server.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>input| match user_input.parse::<u64>() { Ok(amount) => { println!("✔ Gas limit: {}", &amount); Ok(state.add_eth_gas_limit(U256::from(amount))) }, Err(_) => { println!("✘ Could not parse '{}' to an amount!", user_input); get_eth_gas_li...
code_fim
medium
{ "lang": "rust", "repo": "gskapka/etheroff", "path": "/src/interactive_cli_lib/get_eth_gas_limit.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gskapka/etheroff path: /src/interactive_cli_lib/get_eth_gas_limit.rs use ethereum_types::U256; use crate::{ interactive_cli_lib::{state::InteractiveCliState, utils::get_user_input}, lib::types::Result, }; pub fn get_eth_gas_limit_f<|fim_suffix|>input| match user_input.parse::<u64>() { ...
code_fim
medium
{ "lang": "rust", "repo": "gskapka/etheroff", "path": "/src/interactive_cli_lib/get_eth_gas_limit.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thequux/smalltalk.rs path: /src/interpreter/display.rs use crate::interpreter::{Interpreter, StEvent}; use sdl2::event::{Event, WindowEvent}; use sdl2::pixels::{Color, PixelFormatEnum}; use crate::objectmemory::{UWord, NIL_PTR}; use sdl2::rect::Rect; use sdl2::mouse::MouseButton; use sdl2::rende...
code_fim
hard
{ "lang": "rust", "repo": "thequux/smalltalk.rs", "path": "/src/interpreter/display.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // render display let frame_no = interp.startup_time.elapsed().as_millis() * 6 / 100; if interp.display_impl.last_frame < frame_no { // println!("Triggered frame"); interp.display_impl.last_frame = frame_no; if render_display(interp).is_none() { let canvas = ...
code_fim
hard
{ "lang": "rust", "repo": "thequux/smalltalk.rs", "path": "/src/interpreter/display.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match btn { MouseButton::Left => Some(130), MouseButton::Middle => Some(129), MouseButton::Right => Some(128), _ => None, } } fn key_to_st(key: sdl2::keyboard::Scancode) -> Option<char> { use sdl2::keyboard::Scancode; match key { Scancode::Backspace...
code_fim
hard
{ "lang": "rust", "repo": "thequux/smalltalk.rs", "path": "/src/interpreter/display.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Get a file to process if self.processing.is_none() && self.batch_count > 0 && self.batch_size > 0 { self.processing = self.get_file(); } // Load reader if self.reader.is_none() && self.processing.is_some() { let to_load = self.processing....
code_fim
hard
{ "lang": "rust", "repo": "StevenLeRoux/beamium", "path": "/src/sink/send.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: StevenLeRoux/beamium path: /src/sink/send.rs use std::cmp; use std::collections::VecDeque; use std::error::Error; use std::fs; use std::fs::File; use std::io; use std::io::BufReader; use std::io::prelude::*; use std::path::PathBuf; use std::sync::{Arc, Mutex}; use std::sync::atomic::{AtomicBool,...
code_fim
hard
{ "lang": "rust", "repo": "StevenLeRoux/beamium", "path": "/src/sink/send.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> { let s = buf.get_mut(idx..idx + l.len()) .ok_or(io::ErrorKind::InvalidData)?; s.copy_from_slice(l.as_ref()); } idx = idx + l.len(); buf[idx] = '\r' ...
code_fim
hard
{ "lang": "rust", "repo": "StevenLeRoux/beamium", "path": "/src/sink/send.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KaloyanYosifov/basic-http-server-rust path: /src/main.rs use http; use std::env; use regex::Regex; use std::collections::HashMap; use config::Config; use core::route::Route; use http::Method::GET; use crate::controllers::HomeController; mod controllers; fn main() { let args: Vec<String> = ...
code_fim
hard
{ "lang": "rust", "repo": "KaloyanYosifov/basic-http-server-rust", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> settings .merge(config::File::with_name("config.json").required(false)).unwrap(); if let Some(ip_address) = extract_ip_address_argument(&args) { settings.set("ip_address", ip_address).unwrap(); } if let Err(_) = settings.get_str("public_path") { settings.set("publ...
code_fim
hard
{ "lang": "rust", "repo": "KaloyanYosifov/basic-http-server-rust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: incker/stratum path: /protocols/v2/subprotocols/job-negotiation/src/allocate_mining_job.rs #[cfg(not(feature = "with_serde"))] use alloc::vec::Vec; #[cfg(not(feature = "with_serde"))] use binary_sv2::binary_codec_sv2; use binary_sv2::{Deserialize, Serialize, Str0255, B0255}; /// # AllocateMinin...
code_fim
hard
{ "lang": "rust", "repo": "incker/stratum", "path": "/protocols/v2/subprotocols/job-negotiation/src/allocate_mining_job.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ll add in /// coinbase transaction outputs. See discussion in the Template /// Distribution Protocol’s CoinbaseOutputDataSize message for more /// details. pub coinbase_output_max_additional_size: u32, /// If true, the mining_job_token can be used immediately on a mining /// connec...
code_fim
hard
{ "lang": "rust", "repo": "incker/stratum", "path": "/protocols/v2/subprotocols/job-negotiation/src/allocate_mining_job.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Aatch/spirv-utils path: /examples/dump_variables.rs extern crate spirv_utils; use std::env; use spirv_utils::{desc, instruction}; fn main() { let mut args = env::args_os(); args.next(); <|fim_suffix|> module.uses(id).filter_map(|inst| { if let instruction::Instruction::Nam...
code_fim
hard
{ "lang": "rust", "repo": "Aatch/spirv-utils", "path": "/examples/dump_variables.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn get_name<'a>(module: &'a spirv_utils::RawModule, id: desc::Id) -> Option<&'a str> { module.uses(id).filter_map(|inst| { if let instruction::Instruction::Name { ref name, .. } = *inst { Some(&name[..]) } else { None } }).next() }<|fim_prefix|>// re...
code_fim
hard
{ "lang": "rust", "repo": "Aatch/spirv-utils", "path": "/examples/dump_variables.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drogue-iot/embassy path: /embassy/src/io/util/mod.rs use core::cmp::min; use core::pin::Pin; use core::task::{Context, Poll}; use futures::ready; mod read; pub use self::read::Read; mod read_buf; pub use self::read_buf::ReadBuf; mod read_byte; pub use self::read_byte::ReadByte; mod read_exac...
code_fim
hard
{ "lang": "rust", "repo": "drogue-iot/embassy", "path": "/embassy/src/io/util/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn read_to_end<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadToEnd<'a, Self> where Self: Unpin, { ReadToEnd::new(self, buf) } } impl<R: AsyncBufRead + ?Sized> AsyncBufReadExt for R {} pub async fn read_line<R: AsyncBufRead + Unpin + ?Sized>( r: &mut R, buf: &mut [u8...
code_fim
hard
{ "lang": "rust", "repo": "drogue-iot/embassy", "path": "/embassy/src/io/util/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if normal_own_type.starts_with("!") { let ent = normal_own_type[1..].to_string(); if normal_type == &ent { return false; } } else { if normal_type != normal_own_type { return false; } } } if self.name != "" { let correct_name = match &entity.name { ...
code_fim
hard
{ "lang": "rust", "repo": "destruc7i0n/selector_sim", "path": "/src/selector.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: destruc7i0n/selector_sim path: /src/selector.rs use std::collections::HashMap; use crate::world::Entity; use crate::scoreboard::{Scoreboard, SelectorScores, extract_scores}; #[derive(Debug)] pub struct Selector { name: String, entity_type: String, tags: Vec<String>, scores: SelectorSco...
code_fim
hard
{ "lang": "rust", "repo": "destruc7i0n/selector_sim", "path": "/src/selector.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let args = &selector[3..selector.len() - 1]; let (value_based_selectors, scores) = extract_scores(&args); sel.scores = scores; let others = value_based_selectors.split(","); for selector in others { let parts = selector.split("=").collect::<Vec<_>>(); ma...
code_fim
hard
{ "lang": "rust", "repo": "destruc7i0n/selector_sim", "path": "/src/selector.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> 'outer: for i in (0..n).map(|x| x+1) { if (i % 3) != 0 { let mut x = i; while (x % 10) != 3 { if x == 0 { continue 'outer; } x /= 10; } } writef!(" {:d}", i); } ...
code_fim
medium
{ "lang": "rust", "repo": "secti6n/porus", "path": "/solutions/AOJ/ITP1/ITP1_5_D.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: secti6n/porus path: /solutions/AOJ/ITP1/ITP1_5_D.rs #![feature(proc_macro_non_items)] #![cfg_attr(not(debug_assertions), no_std)] #[macro_use] extern crate porus; prelude!(); <|fim_suffix|> let n : isize = read!(); 'outer: for i in (0..n).map(|x| x+1) { if (i % 3) != 0 { ...
code_fim
easy
{ "lang": "rust", "repo": "secti6n/porus", "path": "/solutions/AOJ/ITP1/ITP1_5_D.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Units test!(&[], Ok(()), ComputeBudget::default()); test!( &[ ComputeBudgetInstruction::request_units(1), Instruction::new_with_bincode(Pubkey::new_unique(), &0, vec![]), ], Ok(()), ComputeBudget { ...
code_fim
hard
{ "lang": "rust", "repo": "zhubby/solana", "path": "/sdk/src/compute_budget.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; use crate::{ hash::Hash, message::Message, pubkey::Pubkey, signature::Keypair, signer::Signer, transaction::Transaction, }; macro_rules! test { ( $instructions: expr, $expected_error: expr, $expected_budget: expr ) => { ...
code_fim
hard
{ "lang": "rust", "repo": "zhubby/solana", "path": "/sdk/src/compute_budget.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhubby/solana path: /sdk/src/compute_budget.rs #![cfg(feature = "full")] use { crate::{ borsh::try_from_slice_unchecked, entrypoint::HEAP_LENGTH as MIN_HEAP_FRAME_BYTES, feature_set::{requestable_heap_size, FeatureSet}, instruction::{Instruction, InstructionE...
code_fim
hard
{ "lang": "rust", "repo": "zhubby/solana", "path": "/sdk/src/compute_budget.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tock/libtock-rs path: /runner/src/elf2tab.rs use super::Cli; use std::fs::{metadata, remove_file}; use std::io::ErrorKind; use std::path::PathBuf; use std::process::Command; fn get_platform_architecture(platform: &str) -> Option<&'static str> { match platform { "raspberry_pi_pico" |...
code_fim
hard
{ "lang": "rust", "repo": "tock/libtock-rs", "path": "/runner/src/elf2tab.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut command = Command::new("elf2tab"); #[rustfmt::skip] command.args([ // TODO: libtock-rs' crates are designed for Tock 2.1's Allow interface, // so we should increment this as soon as the Tock kernel will accept a // 2.1 app. "--kernel-major".as_ref(), "2"...
code_fim
hard
{ "lang": "rust", "repo": "tock/libtock-rs", "path": "/runner/src/elf2tab.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// Reads the stack size, and returns it as a String for use on elf2tab's command // line. fn read_stack_size(cli: &Cli) -> String { let file = elf::File::open_path(&cli.elf).expect("Unable to open ELF"); for section in file.sections { // This section name comes from runtime/libtock_layout....
code_fim
hard
{ "lang": "rust", "repo": "tock/libtock-rs", "path": "/runner/src/elf2tab.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test() { for i in vec![ (2, nested![[1, 0]], true), (2, nested![[1, 0], [0, 1]], false), (5, nested![[1,0], [2,4], [3,2], [4,1]], true), (5, nested![[1,0], [2,4], [3,2], [4,1], [1, 2]], false), ] { assert_eq!(Solution::can_finish(i.0, i.1), i.2); ...
code_fim
hard
{ "lang": "rust", "repo": "HerringtonDarkholme/leetcode", "path": "/src/course_schedule.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HerringtonDarkholme/leetcode path: /src/course_schedule.rs pub struct Solution; use std::collections::HashMap; impl Solution { pub fn can_finish(num_courses: i32, pre: Vec<Vec<i32>>) -> bool { let mut graph = HashMap::new(); let num_courses = num_courses as usize; fo...
code_fim
hard
{ "lang": "rust", "repo": "HerringtonDarkholme/leetcode", "path": "/src/course_schedule.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: symphorien/cccp path: /src/cache/directio.rs use super::{CacheManager, Replacement}; use crate::utils::FileKind; use anyhow::Context; use std::fs::{File, OpenOptions}; use std::io::ErrorKind; use std::os::unix::fs::OpenOptionsExt; use std::path::Path; use nix::errno::Errno; #[derive(Default,...
code_fim
hard
{ "lang": "rust", "repo": "symphorien/cccp", "path": "/src/cache/directio.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self, options: &mut OpenOptions, custom_flags: i32, path: &Path, ) -> std::io::Result<File> { options .custom_flags(libc::O_DIRECT | custom_flags) .open(path) } fn drop_cache(&mut self, _path: &Path) -> anyhow::Result<Option<Repl...
code_fim
hard
{ "lang": "rust", "repo": "symphorien/cccp", "path": "/src/cache/directio.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>SPEC; impl crate::RegisterSpec for UR9_SPEC { type Ux = u32; } #[doc = "`read()` method returns [`ur9::R`](R) reader structure"] impl crate::Readable for UR9_SPEC {} #[doc = "`reset()` method sets UR9 to value 0"] impl crate::Resettable for UR9_SPEC { const RESET_VALUE: Self::Ux = 0; }<|fim_prefix...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h7/src/stm32h747cm4/syscfg/ur9.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }