text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>#[async_trait] impl TestModeRPC for TestModeControl { async fn get_global_state(&self) -> Result<JsonGlobalState> { let rollup_cell = { let opt = self.rpc_client.query_rollup_cell().await?; opt.ok_or_else(|| anyhow!("rollup cell not found"))? }; let glo...
code_fim
hard
{ "lang": "rust", "repo": "Kuzirashi/godwoken", "path": "/crates/block-producer/src/test_mode_control.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kuzirashi/godwoken path: /crates/block-producer/src/test_mode_control.rs use anyhow::{anyhow, Result}; use async_trait::async_trait; use ckb_types::prelude::{Builder, Entity}; use gw_common::h256_ext::H256Ext; use gw_common::merkle_utils::{calculate_ckb_merkle_root, ckb_merkle_leaf_hash}; use gw...
code_fim
hard
{ "lang": "rust", "repo": "Kuzirashi/godwoken", "path": "/crates/block-producer/src/test_mode_control.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> async fn produce_block(&self, payload: TestModePayload) -> Result<()> { log::info!("receive tests produce block payload: {:?}", payload); *self.payload.lock().await = Some(payload); Ok(()) } async fn should_produce_block(&self) -> Result<ShouldProduceBlock> { ...
code_fim
hard
{ "lang": "rust", "repo": "Kuzirashi/godwoken", "path": "/crates/block-producer/src/test_mode_control.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spraints/advent-of-code-2019 path: /src/bin/day8.rs use std::io; #[cfg(test)] mod tests { use super::*; #[test] fn test_parse_image() { let image = parse_image("123456789012", 3, 2); assert_eq!( vec![ vec![vec![1, 2, 3], vec![4, 5, 6]], ...
code_fim
hard
{ "lang": "rust", "repo": "spraints/advent-of-code-2019", "path": "/src/bin/day8.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut counts = [0; 10]; for row in layer { for cell in row { counts[*cell as usize] += 1; } } counts } fn parse_image(input: &str, width: usize, height: usize) -> Image { let mut res = vec![]; let mut input = input.chars().map(|c| c.to_digit(10).unwra...
code_fim
hard
{ "lang": "rust", "repo": "spraints/advent-of-code-2019", "path": "/src/bin/day8.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn to_raw_mut_ref(&mut self) -> &mut raw::Local { let &mut Array(ref mut local) = self; local } fn from_raw(h: raw::Local) -> Self { Array(h) } fn is_typeof<Other: Any>(other: Other) -> bool { unsafe { Nanny_IsArray(other.to_raw_ref()) } } } pub trait ArrayIn...
code_fim
hard
{ "lang": "rust", "repo": "steveorsomethin/nanny", "path": "/src/internal/value.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn from_raw(h: raw::Local) -> Self { Integer(h) } fn is_typeof<Other: Any>(other: Other) -> bool { unsafe { Nanny_IsInteger(other.to_raw_ref()) } } } pub trait IntegerInternal { fn new_internal<'a>(isolate: *mut Isolate, i: i32) -> Handle<'a, Integer>; } impl IntegerInternal for...
code_fim
hard
{ "lang": "rust", "repo": "steveorsomethin/nanny", "path": "/src/internal/value.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: steveorsomethin/nanny path: /src/internal/value.rs o_GetIsolate, Nanny_IsUndefined, Nanny_IsNull, Nanny_IsInteger, Nanny_IsNumber, Nanny_IsString, Nanny_IsBoolean, Nanny_IsObject, Nanny_IsArray, Nanny_IsFunction, Nanny_TagOf, Tag}; use internal::mem::{Handle, HandleInternal}; use internal::scope...
code_fim
hard
{ "lang": "rust", "repo": "steveorsomethin/nanny", "path": "/src/internal/value.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang-nursery/gll path: /src/generate/templates/imports.rs use gll::runtime::{Call, Continuation, Parse<|fim_suffix|>e, Range, traverse, nd::Arrow}; use std::any; use std::fmt; use std::marker::PhantomData;<|fim_middle|>NodeKind, CodeLabel, ParseNodeShape, ParseNod
code_fim
easy
{ "lang": "rust", "repo": "rust-lang-nursery/gll", "path": "/src/generate/templates/imports.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>; use std::fmt; use std::marker::PhantomData;<|fim_prefix|>// repo: rust-lang-nursery/gll path: /src/generate/templates/imports.rs use gll::runtime::{Call, Continuation, ParseNodeKind, CodeLabel, ParseNodeShape, ParseNod<|fim_middle|>e, Range, traverse, nd::Arrow}; use std::any
code_fim
easy
{ "lang": "rust", "repo": "rust-lang-nursery/gll", "path": "/src/generate/templates/imports.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn on_start(&mut self, world: &mut World) {} fn on_stop(&mut self, world: &mut World) {} } pub struct NoneScene {} impl NoneScene { pub fn new() -> Self { Self {} } } impl Scene for NoneScene { fn update(&mut self, world: &mut World, delta_time: &Duration) { println...
code_fim
hard
{ "lang": "rust", "repo": "veloscillator/acute", "path": "/old/src/scenes/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: veloscillator/acute path: /old/src/scenes/mod.rs use legion::prelude::*; use std::any::Any; use std::time::Duration; pub struct SceneHandler { scenes: Vec<Box<dyn Scene>>, } impl SceneHandler { pub fn new(init_scene: Option<Box<dyn Scene>>) -> Self { let mut scenes = Vec::new()...
code_fim
medium
{ "lang": "rust", "repo": "veloscillator/acute", "path": "/old/src/scenes/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/traits/trivial_impl.rs //! This test checks that we do need to implement //! all members, even if their where bounds only hold //! due to other impls. trait Foo<T> { fn foo() <|fim_suffix|>impl Foo<u32> for () {} //~^ ERROR: not all trait items implemented, mi...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/traits/trivial_impl.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>} impl Foo<u32> for () {} //~^ ERROR: not all trait items implemented, missing: `foo` fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/traits/trivial_impl.rs //! This test checks that we do need to implement //! all members, even if their where bounds only hold //! due to other impls. ...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/traits/trivial_impl.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Yes, it would be really easy to fix this by just changing the value bound to `word` to be a // string slice instead of a `String`, wouldn't it?? There is a way to add one character to line // 6, though, that will coerce the `String` into a string slice.<|fim_prefix|>// repo: Unaidedsteak/ru...
code_fim
medium
{ "lang": "rust", "repo": "Unaidedsteak/rustlings-solutions", "path": "/exercises/strings/strings2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Unaidedsteak/rustlings-solutions path: /exercises/strings/strings2.rs // strings2.rs // Make me compile without changing the function signature! Scroll down for hints :) fn main() { let word = String::from("green"); // Try not changing this line :) if is_a_color_word(&word) { pr...
code_fim
medium
{ "lang": "rust", "repo": "Unaidedsteak/rustlings-solutions", "path": "/exercises/strings/strings2.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match error { ::templar::output::WriteError::DirectiveError(directive) => directive, ::templar::output::WriteError::IO(io_error) => { CoinrefError { error_type: CoinrefErrorType::ImportError, message: format!("{}", io_...
code_fim
hard
{ "lang": "rust", "repo": "monomadic/coinref.io", "path": "/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: monomadic/coinref.io path: /src/error.rs #[derive(Debug)] pub struct CoinrefError { pub error_type: CoinrefErrorType, pub message: String, } #[derive(Debug)] pub enum CoinrefErrorType { ImportError, ViewError, APIError, InsertRecordError, DatabaseConnectionError, ...
code_fim
hard
{ "lang": "rust", "repo": "monomadic/coinref.io", "path": "/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn templar_error(error: TemplarError) -> String { let mut result:String = "Templar compilation error:\n".to_string(); for (idx, c) in error.context.iter().enumerate() { let line_number = error.line_number + 2 + idx - error.context.len(); let padded_line_number = format!("{:5}:...
code_fim
hard
{ "lang": "rust", "repo": "monomadic/coinref.io", "path": "/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brson/rust-sched-bench path: /pingpong.rs // This is a simple bench that creates M pairs of of tasks. These // tasks ping-pong back and forth over a pair of streams. This is a // cannonical message-passing benchmark as it heavily strains message // passing and almost nothing else. <|fim_suffix|...
code_fim
hard
{ "lang": "rust", "repo": "brson/rust-sched-bench", "path": "/pingpong.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Create pairs of tasks that pingpong back and forth. fn run_pair(n: uint) { // Create a stream A->B let (pa,ca) = stream::<()>(); // Create a stream B->A let (pb,cb) = stream::<()>(); let pa = Cell::new(pa); let ca = Cell::new(ca); let pb...
code_fim
hard
{ "lang": "rust", "repo": "brson/rust-sched-bench", "path": "/pingpong.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> do spawn { use std::task; do task::unkillable { let chan = cb.take(); let port = pa.take(); do n.times { port.recv(); chan.send(()); } } } } ...
code_fim
hard
{ "lang": "rust", "repo": "brson/rust-sched-bench", "path": "/pingpong.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kszym2002/pcap2socks path: /src/cache/mod.rs self.sequence = sequence; self.size = self.size.checked_sub(size).unwrap_or(0); if self.size == 0 { self.head = 0; } else { self.head = (self.head + (size % self.buffer.len...
code_fim
hard
{ "lang": "rust", "repo": "kszym2002/pcap2socks", "path": "/src/cache/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kszym2002/pcap2socks path: /src/cache/mod.rs lf.size..self.head + self.size + length_a] .copy_from_slice(&payload[..length_a]); } // From the begin of the buffer to the head let length_b = payload.len() - length_a; if length_b > 0 { se...
code_fim
hard
{ "lang": "rust", "repo": "kszym2002/pcap2socks", "path": "/src/cache/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Select ranges which can be merged in a loop let mut end = sequence + payload.len() as u64; loop { let mut pop_keys = Vec::new(); for (&key, &value) in self.edges.range(( Included(&sequence), Incl...
code_fim
hard
{ "lang": "rust", "repo": "kszym2002/pcap2socks", "path": "/src/cache/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oxidecomputer/cio path: /zoho-client/src/modules.rs ion<serde_json::Value>, #[serde(rename = "Created_Time", skip_serializing_if = "Option::is_none")] pub created_time: Option<String>, #[serde(rename = "Modified_Time", skip_serializing_if = "Option::is_none")] pub modified_time: ...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/cio", "path": "/zoho-client/src/modules.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Clone, Default, Serialize)] pub struct TasksInput { #[serde(rename = "Owner", skip_serializing_if = "Option::is_none")] pub owner: Option<serde_json::Value>, #[serde(rename = "Subject")] pub subject: String, #[serde(rename = "Due_Date", skip_serializing_if = "Option::is...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/cio", "path": "/zoho-client/src/modules.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oxidecomputer/cio path: /zoho-client/src/modules.rs contact_name: Option<serde_json::Value>, #[serde(rename = "Campaign_Source", skip_serializing_if = "Option::is_none")] pub campaign_source: Option<serde_json::Value>, #[serde(rename = "Modified_By", skip_serializing_if = "Option::is...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/cio", "path": "/zoho-client/src/modules.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: element114/arangoq path: /src/arango_connection.rs use crate::ArangoQuery; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; use std::sync::Arc; use reqwest::{Body, Client}; impl From<ArangoQuery> for Body { fn from(item: ArangoQuery) -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "element114/arangoq", "path": "/src/arango_connection.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, PartialEq, Clone, Default)] pub struct Context { pub app_prefix: String, } impl Context { /// `app_prefix` is used to store collections of the same name for different apps using the same db. /// This function returns the final collection name. #[must_use] pub fn collect...
code_fim
hard
{ "lang": "rust", "repo": "element114/arangoq", "path": "/src/arango_connection.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: syuukawa/ckb path: /util/dao/utils/src/lib.rs use ckb_core::cell::{ResolvedCell, ResolvedTransaction}; use ckb_core::script::DAO_CODE_HASH; use ckb_core::{Bytes, Capacity}; use ckb_script_data_loader::DataLoader; use dao::calculate_maximum_withdraw; use numext_fixed_hash::H256; // With DAO in c...
code_fim
hard
{ "lang": "rust", "repo": "syuukawa/ckb", "path": "/util/dao/utils/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &deposit_ext.dao_stats, &withdraw_ext.dao_stats, ) .ok() } _ => None, ...
code_fim
hard
{ "lang": "rust", "repo": "syuukawa/ckb", "path": "/util/dao/utils/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> { unsafe {self.button.unsafe_get(*index as uint)} } } impl InputState { pub fn poll(player: u32) -> InputState { // assert!(player < 16, "Tried to poll input for invalid player number"); let state: InputState = unsafe { InputState ...
code_fim
hard
{ "lang": "rust", "repo": "KMFDManic/rust-libretro", "path": "/src/rust_wrapper/input.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KMFDManic/rust-libretro path: /src/rust_wrapper/input.rs use super::retro_input_state_cb; use super::libretro::RETRO_DEVICE_ID_JOYPAD_B; use super::libretro::RETRO_DEVICE_ID_JOYPAD_Y; use super::libretro::RETRO_DEVICE_ID_JOYPAD_SELECT; use super::libretro::RETRO_DEVICE_ID_JOYPAD_START; use super...
code_fim
hard
{ "lang": "rust", "repo": "KMFDManic/rust-libretro", "path": "/src/rust_wrapper/input.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub struct InputState { // WARNING // Don't change size without also changing ControllerButton // and static asserts pub button: [ButtonState, ..16] } pub struct ButtonState { pub pressed: bool, pub down: bool, pub up: bool } impl Index<ControllerButton, ButtonState> for Inpu...
code_fim
hard
{ "lang": "rust", "repo": "KMFDManic/rust-libretro", "path": "/src/rust_wrapper/input.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> None } } fn find_high_score(ingredients: &[Ingredient], caloric_target: Option<i32>) -> i32 { let mut max_score = 0; for perm in PermutationGenerator::new(100, ingredients.len()) { if let Some(target) = caloric_target { let calories = perm.iter().enumerate().fold(...
code_fim
hard
{ "lang": "rust", "repo": "acdibble/aoc", "path": "/2015/rs/day15/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: acdibble/aoc path: /2015/rs/day15/src/main.rs use std::env; use std::fs; use std::path::Path; #[derive(Debug, Copy, Clone)] struct Ingredient { capacity: i32, durability: i32, flavor: i32, texture: i32, calories: i32, } fn parse_with_comma(string: Option<&str>) -> i32 { ...
code_fim
hard
{ "lang": "rust", "repo": "acdibble/aoc", "path": "/2015/rs/day15/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: davidwilemski/aoc19 path: /day2/src/main.rs use std::io::prelude::*; use std::io::BufReader; use intcode::Machine; fn main() -> Result<(), std::io::Error> { let stdin = std::io::stdin(); let reader = BufReader::new(stdin); let program_state = reader .split(b',') .m...
code_fim
hard
{ "lang": "rust", "repo": "davidwilemski/aoc19", "path": "/day2/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for noun in 0..99 { for verb in 0..99 { println!("noun: {}, verb: {}", noun, verb); let (_, mut machine) = Machine::new(original_state.clone()); machine.set_noun(noun); machine.set_verb(verb); machine.execute(); if machine...
code_fim
hard
{ "lang": "rust", "repo": "davidwilemski/aoc19", "path": "/day2/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/async-task/src/header.rs use core : : cell : : UnsafeCell ; use core : : fmt ; use core : : sync : : atomic : : { AtomicUsize Ordering } ; use core : : task : : Waker ; use crate : : raw : : TaskVTable ; use crate : : state : : * ; use crate : ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/async-task/src/header.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>ake ( ) } { abort_on_panic ( | | waker = Some ( w ) ) ; } } / / The new state is not being notified nor registered but there might or might not be / / an awaiter depending on whether there was a concurrent notification . let new = if waker . is_none ( ) { ( state & ! NOTIFYING & ! REGISTERING ) | AWAITER ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/async-task/src/header.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> println!("chapter 1 | Arrays and Strings"); }<|fim_prefix|>// repo: ThePFMind/cracking-the-coding-interview path: /src/bin/c01p05.rs fn is_one_edit_way(s1: &str, s2: &str) -> bool { true } #[cfg(test)] mod tests { use super::*; <|fim_middle|> #[test] fn test_to() { assert_eq!...
code_fim
medium
{ "lang": "rust", "repo": "ThePFMind/cracking-the-coding-interview", "path": "/src/bin/c01p05.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ThePFMind/cracking-the-coding-interview path: /src/bin/c01p05.rs fn is_one_edit_way(s1: &str, s2: &str) -> bool { true } <|fim_suffix|> #[test] fn test_to() { assert_eq!(is_one_edit_way("pale", "ple"), true) } } fn main() { println!("chapter 1 | Arrays and Strings"); ...
code_fim
easy
{ "lang": "rust", "repo": "ThePFMind/cracking-the-coding-interview", "path": "/src/bin/c01p05.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> $ain } } )* }; } macro_rules! comp_ref_pins { ($($pin:path => $aref:expr,)+) => { $( impl LpCompRefPin for $pin { fn aref(&self) -> EXTREFSEL_A { $aref } } ...
code_fim
hard
{ "lang": "rust", "repo": "Disasm/nrf-hal", "path": "/nrf-hal-common/src/lpcomp.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(not(feature = "51"))] comp_input_pins! { P0_02<Input<Floating>> => PSEL_A::ANALOGINPUT0, P0_03<Input<Floating>> => PSEL_A::ANALOGINPUT1, P0_04<Input<Floating>> => PSEL_A::ANALOGINPUT2, P0_05<Input<Floating>> => PSEL_A::ANALOGINPUT3, P0_28<Input<Floating>> => PSEL_A::ANALOGINPUT4,...
code_fim
hard
{ "lang": "rust", "repo": "Disasm/nrf-hal", "path": "/nrf-hal-common/src/lpcomp.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Disasm/nrf-hal path: /nrf-hal-common/src/lpcomp.rs //! HAL interface for the LPCOMP peripheral. //! //! In System ON, the LPCOMP can generate separate events on rising and falling edges of a signal, //! or sample the current state of the pin as being above or below the selected reference. //! Th...
code_fim
hard
{ "lang": "rust", "repo": "Disasm/nrf-hal", "path": "/nrf-hal-common/src/lpcomp.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match message { MessageFromRenderer::Init => { if self.config.debug() { self.renderer.send_message(MessageToRenderer::Debug)?; } self.renderer.send_message(MessageToRenderer::Config { keymaps: self...
code_fim
hard
{ "lang": "rust", "repo": "rhysd/Shiba", "path": "/v2/src/app.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rhysd/Shiba path: /v2/src/app.rs {PathFilter, Watcher}; use anyhow::{Context as _, Result}; use std::collections::VecDeque; use std::env; use std::fs; use std::marker::PhantomData; use std::mem; use std::path::{Path, PathBuf, MAIN_SEPARATOR}; struct History { max_items: usize, index: us...
code_fim
hard
{ "lang": "rust", "repo": "rhysd/Shiba", "path": "/v2/src/app.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> log::debug!("Handling user event {:?}", event); match event { UserEvent::IpcMessage(msg) => return self.handle_ipc_message(msg), UserEvent::FileDrop(mut path) => { log::debug!("Previewing file dropped into window: {:?}", path); if !pa...
code_fim
hard
{ "lang": "rust", "repo": "rhysd/Shiba", "path": "/v2/src/app.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: makepad/makepad path: /widgets/src/desktop_button.rs use { crate::{ button::ButtonAction, makepad_draw::*, widget::* } }; live_design!{ import makepad_draw::shader::std::*; DrawDesktopButton = {{DrawDesktopButton}} {} DesktopButtonBase = {{Deskto...
code_fim
hard
{ "lang": "rust", "repo": "makepad/makepad", "path": "/widgets/src/desktop_button.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match event.hits(cx, self.draw_bg.area()) { Hit::FingerDown(_fe) => { dispatch_action(cx, ButtonAction::Pressed); self.animator_play(cx, id!(hover.pressed)); }, Hit::FingerHoverIn(_) => { cx.set_cursor(MouseCursor:...
code_fim
hard
{ "lang": "rust", "repo": "makepad/makepad", "path": "/widgets/src/desktop_button.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ypoluektovich/tmux-interface-rs path: /src/commands/options/show_options.rs use crate::commands::constants::*; use crate::{Error, TmuxCommand, TmuxOutput}; use std::borrow::Cow; /// Structure for showing options /// /// # Manual /// /// tmux ^3.0: /// ```text /// tmux show-options [-AgHpqsvw] [...
code_fim
hard
{ "lang": "rust", "repo": "ypoluektovich/tmux-interface-rs", "path": "/src/commands/options/show_options.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cciccia/advent-of-code-2019 path: /src/day2.rs use std::io::{BufReader, BufRead}; use std::fs::File; use std::i32; use crate::BoxResult; use std::str::{from_utf8}; use std::collections::HashMap; fn calc_output(commands: &mut HashMap<i32, i32>) -> BoxResult<i32> { let mut i = 0; loop { ...
code_fim
hard
{ "lang": "rust", "repo": "cciccia/advent-of-code-2019", "path": "/src/day2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn p2(input: BufReader<File>) -> BoxResult<String> { let mut commands = HashMap::new(); let mut i = 0; for command in input.split(b',') { let parsed = from_utf8(&command.unwrap()).unwrap().parse::<i32>().unwrap(); commands.insert(i, parsed); i = i + 1; } f...
code_fim
hard
{ "lang": "rust", "repo": "cciccia/advent-of-code-2019", "path": "/src/day2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..100 { for j in 0..100 { let mut commands_for_this_run = commands.clone(); commands_for_this_run.insert(1, i); commands_for_this_run.insert(2, j); match calc_output(&mut commands_for_this_run) { Ok(19690720) => return O...
code_fim
hard
{ "lang": "rust", "repo": "cciccia/advent-of-code-2019", "path": "/src/day2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( PokemonInfo { name: "zubat".into(), description: "".into(), is_legendary: false, habitat: "cave".into(), } .translation(), "yoda" ); } #[test] fn pokemon...
code_fim
hard
{ "lang": "rust", "repo": "conradludgate/pokefun-truelayer", "path": "/src/api.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: conradludgate/pokefun-truelayer path: /src/api.rs use crate::{pokemon, translations::translate}; use actix_web::{error::ErrorInternalServerError, get, web, HttpRequest, Result}; use reqwest_middleware::ClientWithMiddleware; use serde::{Deserialize, Serialize}; use tracing::warn; #[derive(Debug,...
code_fim
hard
{ "lang": "rust", "repo": "conradludgate/pokefun-truelayer", "path": "/src/api.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn pokemon_info_translation_rare() { assert_eq!( PokemonInfo { name: "mewtwo".into(), description: "".into(), is_legendary: true, habitat: "rare".into(), } .translation(), ...
code_fim
hard
{ "lang": "rust", "repo": "conradludgate/pokefun-truelayer", "path": "/src/api.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>::*; #[cfg(test)] pub use example_test::test_examples;<|fim_prefix|>// repo: nushell/nushell path: /crates/nu-cmd-lang/src/lib.rs mod core_commands; mod default_context; pub mod examp<|fim_middle|>le_support; mod example_test; pub use core_commands::*; pub use default_context::*; pub use example_support
code_fim
medium
{ "lang": "rust", "repo": "nushell/nushell", "path": "/crates/nu-cmd-lang/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nushell/nushell path: /crates/nu-cmd-lang/src/lib.rs mod core_commands; mod default_context; pub mod examp<|fim_suffix|>*; pub use default_context::*; pub use example_support::*; #[cfg(test)] pub use example_test::test_examples;<|fim_middle|>le_support; mod example_test; pub use core_commands::
code_fim
easy
{ "lang": "rust", "repo": "nushell/nushell", "path": "/crates/nu-cmd-lang/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(Solution::min_operations(vec![1, 1, 1]), 3); assert_eq!(Solution::min_operations(vec![1, 5, 2, 4, 1]), 14); assert_eq!(Solution::min_operations(vec![8]), 0); } }<|fim_prefix|>// repo: MDGSF/JustCoding path: /rust-leetcode/leetcode_1827/src/solution1.rs impl Solution...
code_fim
medium
{ "lang": "rust", "repo": "MDGSF/JustCoding", "path": "/rust-leetcode/leetcode_1827/src/solution1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MDGSF/JustCoding path: /rust-leetcode/leetcode_1827/src/solution1.rs impl Solution { pub fn min_operations(mut nums: Vec<i32>) -> i32 { let mut count = 0; let len = nums.len(); for i in 1..len { if nums[i - 1] >= nums[i] { count += nums[i -...
code_fim
medium
{ "lang": "rust", "repo": "MDGSF/JustCoding", "path": "/rust-leetcode/leetcode_1827/src/solution1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn reject_header(name: &str, headers: &[&Header]) -> Result<(), HttpError> { for &header in headers { if header.name.eq_ignore_ascii_case(name) { return Err(HttpError::ProcessingError(HttpStatus::InternalServerError500( String::from(format!("inva...
code_fim
hard
{ "lang": "rust", "repo": "cozydate/rust-in-production", "path": "/http/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cozydate/rust-in-production path: /http/src/lib.rs handle_tcp_stream(tcp_stream, addr, handler_clone).await; // }); // } // Err(e) => { // warn!("Failed accepting connection from socket: {:?}", e); // match e.k...
code_fim
hard
{ "lang": "rust", "repo": "cozydate/rust-in-production", "path": "/http/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn save_header_value(name: &str, value: &str, headers: &mut [&mut HeaderReceiver]) -> Result<(), HttpError> { // For-loops call .iter() and cannot mutate the returned reference: // ``` // for header in headers {...} // error[E0382]: use of moved value:...
code_fim
hard
{ "lang": "rust", "repo": "cozydate/rust-in-production", "path": "/http/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Arrays - have a fixed number of elements, not as flexible as a 'vector type' - example - months of the year // Vectors - can grow or shrink in size // let a = [1, 2, 3, 4, 5]; // let index = 10; // let element = a[index]; // highlights an error as indexing a number out of bou...
code_fim
medium
{ "lang": "rust", "repo": "Qualik/Rust_Projects", "path": "/datatypes/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // println!("The value of x is: {}, the value of y is: {}, the value of z is: {}", x, y, z); // let x: (i32, f64, u8) = (500, 6.4, 1); // let _five_hundred = x.0; // let _six_point_four = x.1; // let _one = x.2; // Arrays - have a fixed number of elements, not as flexible as a 'v...
code_fim
hard
{ "lang": "rust", "repo": "Qualik/Rust_Projects", "path": "/datatypes/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Qualik/Rust_Projects path: /datatypes/src/main.rs fn main() { // Data Types // let _guess: u32 = "42".parse().expect("Not a number!"); // Floating-point Types // let _x =2.0; // let _y: f32 = 3.0; <|fim_suffix|> // let a = [1, 2, 3, 4, 5]; // let index = 10; /...
code_fim
hard
{ "lang": "rust", "repo": "Qualik/Rust_Projects", "path": "/datatypes/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Performance Monitors Control Register pub const PMCR: PMCRAccessor = PMCRAccessor; pub struct PMCRAccessor; impl register::cpu::RegisterReadWrite<u32, PMCR::Register> for PMCRAccessor { sys_coproc_read_raw!(u32, [p15, c9, 0, c12, 0]); sys_coproc_write_raw!(u32, [p15, c9, 0, c12, 0]); } /// ...
code_fim
hard
{ "lang": "rust", "repo": "newAM/r3", "path": "/src/r3_port_arm_test_driver/src/pmu.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Performance Monitors Cycle Count Register pub const PMCCNTR: PMCCNTRAccessor = PMCCNTRAccessor; pub struct PMCCNTRAccessor; impl register::cpu::RegisterReadWrite<u32, ()> for PMCCNTRAccessor { sys_coproc_read_raw!(u32, [p15, c9, 0, c13, 0]); sys_coproc_write_raw!(u32, [p15, c9, 0, c13, 0]); }...
code_fim
hard
{ "lang": "rust", "repo": "newAM/r3", "path": "/src/r3_port_arm_test_driver/src/pmu.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: newAM/r3 path: /src/r3_port_arm_test_driver/src/pmu.rs //! Arm PMU macro_rules! sys_coproc_read_raw { ($width:ty, [$cp:ident, $crn:ident, $opc1:literal, $crm:ident, $opc2:literal]) => { #[inline] fn get(&self) -> u32 { let reg; unsafe { ...
code_fim
hard
{ "lang": "rust", "repo": "newAM/r3", "path": "/src/r3_port_arm_test_driver/src/pmu.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let num_fields = 1 $(+ 1 ignore!($field))*; if let RawTag::Tuple { arity } = reader.raw_tag().context(Source)? { if arity == num_fields { } } Err(DecodeError::BadData) } } }; }<|...
code_fim
hard
{ "lang": "rust", "repo": "eirproject/eir", "path": "/util/libeir_etf/src/decoder.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eirproject/eir path: /util/libeir_etf/src/decoder.rs use crate::{RawTag, Reader}; use std::io::Read; use snafu::{ResultExt, Snafu}; #[derive(Debug, Snafu)] pub enum DecodeError { #[snafu(display("error from source: {}", source))] Source { source: std::io::Error }, #[snafu(display(...
code_fim
hard
{ "lang": "rust", "repo": "eirproject/eir", "path": "/util/libeir_etf/src/decoder.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn debug_program(&mut self, exec: &Executable) -> i32{ self.reset_cpu_state(); self.load_program(&exec.code, &exec.data); self.cpu .regs .set(&Register::IR, PROGRAM_INIT_ADDRESS as i32); self.initialize_stackframe(); let mut breakpoin...
code_fim
hard
{ "lang": "rust", "repo": "itamar8910/c_to_vm", "path": "/src/operating_system/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn assemble_and_run_no_std(&mut self, program: &str) -> i32{ let exec = assemble_and_link(vec![program]); self.load_and_run(&exec) } pub fn debug_program(&mut self, exec: &Executable) -> i32{ self.reset_cpu_state(); self.load_program(&exec.code, &exec.data)...
code_fim
hard
{ "lang": "rust", "repo": "itamar8910/c_to_vm", "path": "/src/operating_system/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: itamar8910/c_to_vm path: /src/operating_system/mod.rs pub mod assembler; pub mod compiler; pub mod layout; use std::collections::HashMap; use std::collections::HashSet; use std::io::Read; use self::assembler::assemble; use self::assembler::assemble_and_link; use self::assembler::Executable; us...
code_fim
hard
{ "lang": "rust", "repo": "itamar8910/c_to_vm", "path": "/src/operating_system/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ta from the stream into the provided buffers returning / / / how many bytes were read . / / / / / / Data is copied to fill each buffer in order with the final buffer / / / written to possibly being only partially filled . This method behaves / / / equivalently to a single call to [ try_read ( ) ] with con...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/tokio/src/net/tcp/split.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ent to ready ( Interest : : WRITABLE ) and is usually / / / paired with try_write ( ) . / / / / / / # Cancel safety / / / / / / This method is cancel safe . Once a readiness event occurs the method / / / will continue to return immediately until the readiness event is / / / consumed by an attempt to write...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/tokio/src/net/tcp/split.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/tokio/src/net/tcp/split.rs / / ! TcpStream split support . / / ! / / ! A TcpStream can be split into a ReadHalf and a / / ! WriteHalf with the TcpStream : : split method . ReadHalf / / ! implements AsyncRead while WriteHalf implements AsyncWrit...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/tokio/src/net/tcp/split.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut drawer = renderer.drawer(); drawer.set_draw_color(sdl2::pixels::Color::RGBA(195, 217, 255, 255)); drawer.clear(); let (w, h) = match texture.query() { Ok(q) => (q.width, q.height), Err(err) => panic!(format!("Failed to query texture: {}", err)) }; drawer.co...
code_fim
hard
{ "lang": "rust", "repo": "cakecatz/rust-sdl2_ttf", "path": "/src/demo/video.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cakecatz/rust-sdl2_ttf path: /src/demo/video.rs use sdl2; use sdl2_ttf; static SCREEN_WIDTH : i32 = 800; static SCREEN_HEIGHT : i32 = 600; // fail when error macro_rules! trying( ($e:expr) => (match $e { Ok(e) => e, Err(e) => panic!("failed: {}", e) }) ); // hadle the annoying Rect i32 ma...
code_fim
hard
{ "lang": "rust", "repo": "cakecatz/rust-sdl2_ttf", "path": "/src/demo/video.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VuHoang19/snake_game path: /target/rls/debug/build/wayland-protocols-c34cf39ec060e04f/out/viewporter_client_api.rs fn ptr(&self) -> *mut wl_proxy { self.ptr } unsafe fn from_ptr_new(ptr: *mut wl_proxy) -> WpViewporter { let data: *mut UserData = Box::into_raw(Box::new(( ...
code_fim
hard
{ "lang": "rust", "repo": "VuHoang19/snake_game", "path": "/target/rls/debug/build/wayland-protocols-c34cf39ec060e04f/out/viewporter_client_api.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn supported_version() -> u32 { 1 } fn version(&self) -> u32 { unsafe { ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_proxy_get_version, self.ptr()) } } fn status(&self) -> Liveness { if let Some(ref data) = self.data { if data.0.load(Ordering::SeqCst) { ...
code_fim
hard
{ "lang": "rust", "repo": "VuHoang19/snake_game", "path": "/target/rls/debug/build/wayland-protocols-c34cf39ec060e04f/out/viewporter_client_api.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(ref data) = self.data { data.0.store(false, ::std::sync::atomic::Ordering::SeqCst); } let udata = unsafe { &mut *(ffi_dispatch!(WAYLAND_CLIENT_HANDLE, wl_proxy_get_user_data, self.ptr()) as *mut UserData) }; let _impl = udata.1.ta...
code_fim
hard
{ "lang": "rust", "repo": "VuHoang19/snake_game", "path": "/target/rls/debug/build/wayland-protocols-c34cf39ec060e04f/out/viewporter_client_api.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> bencher.iter(|| { dgemv(b'N', m, m, 1.0, &a, m, &x, 1, 1.0, &mut y, 1) }); }<|fim_prefix|>// repo: MartyIX/blas path: /benches/fortran.rs use test::Bencher; use blas::fortran::dgemv; #[bench] fn dgemv_00010(bencher: &mut Bencher) { run( 10, bencher) } #[bench] fn dgemv_00100(bencher: ...
code_fim
medium
{ "lang": "rust", "repo": "MartyIX/blas", "path": "/benches/fortran.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MartyIX/blas path: /benches/fortran.rs use test::Bencher; use blas::fortran::dgemv; #[bench] fn dgemv_00010(bencher: &mut Bencher) { run( 10, bencher) } #[bench] fn dgemv_00100(bencher: &mut Bencher) { run( 100, bencher) } #[bench] fn dgemv_01000(bencher: &mut Bencher) { run( 1000, bencher)...
code_fim
medium
{ "lang": "rust", "repo": "MartyIX/blas", "path": "/benches/fortran.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>::is_none")] pub location: Option<String>, #[serde(default, skip_serializing_if = "Option::is_none")] pub properties: Option<IoTSecuritySolutionProperties>, #[serde(rename = "systemData", default, skip_serializing_if = "Option::is_none")] pub system_data: Option<SystemData>, } #[derive...
code_fim
hard
{ "lang": "rust", "repo": "nalshihabi/azure-sdk-for-rust", "path": "/services/mgmt/security/src/package_2019_08_only/models.rs", "mode": "spm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nalshihabi/azure-sdk-for-rust path: /services/mgmt/security/src/package_2019_08_only/models.rs ialize, Deserialize)] pub struct IoTSecurityAggregatedRecommendation { #[serde(flatten)] pub resource: Resource, #[serde(flatten)] pub tags_resource: TagsResource, #[serde(default, ...
code_fim
hard
{ "lang": "rust", "repo": "nalshihabi/azure-sdk-for-rust", "path": "/services/mgmt/security/src/package_2019_08_only/models.rs", "mode": "psm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nalshihabi/azure-sdk-for-rust path: /services/mgmt/security/src/package_2019_08_only/models.rs default, skip_serializing_if = "Option::is_none")] pub reported_severity: Option<io_t_security_aggregated_recommendation_properties::ReportedSeverity>, #[serde(rename = "healthyDevices", defau...
code_fim
hard
{ "lang": "rust", "repo": "nalshihabi/azure-sdk-for-rust", "path": "/services/mgmt/security/src/package_2019_08_only/models.rs", "mode": "psm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jyomu/atcoder path: /ABC144/E.rs use std::io::BufRead; fn main() { let stdin = std::io::stdin(); let mut lines: Vec<Vec<i64>> = stdin .lock() .lines() .map(|l| { l.unwrap() .split_whitespace() .map(|w| w.parse().unwrap()...
code_fim
hard
{ "lang": "rust", "repo": "jyomu/atcoder", "path": "/ABC144/E.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>.iter() .filter(|x| (x.0 * x.1) > mp) .map(|x| x.0 - (mp / x.1)) .sum(); if sum <= k { rp = mp; } else { lp = mp; } } println!("{}", rp); } }<|fim_prefix|>// repo: jyomu/...
code_fim
hard
{ "lang": "rust", "repo": "jyomu/atcoder", "path": "/ABC144/E.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// ## What it does /// Checks for functions with "dunder" names (that is, names with two /// leading and trailing underscores) that are not documented. /// /// ## Why is this bad? /// [PEP 8] recommends that only documented "dunder" methods are used: /// /// > ..."magic" objects or attributes that live i...
code_fim
medium
{ "lang": "rust", "repo": "astral-sh/ruff", "path": "/crates/ruff/src/rules/pep8_naming/rules/dunder_function_name.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: astral-sh/ruff path: /crates/ruff/src/rules/pep8_naming/rules/dunder_function_name.rs use ruff_python_ast::Stmt; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::identifier::Identifier; use ruff_python_semantic::{Scope, Sc...
code_fim
medium
{ "lang": "rust", "repo": "astral-sh/ruff", "path": "/crates/ruff/src/rules/pep8_naming/rules/dunder_function_name.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> format!("Function name should not start and end with `__`") } } /// N807 pub(crate) fn dunder_function_name( scope: &Scope, stmt: &Stmt, name: &str, ignore_names: &[IdentifierPattern], ) -> Option<Diagnostic> { if matches!(scope.kind, ScopeKind::Class(_)) { return ...
code_fim
hard
{ "lang": "rust", "repo": "astral-sh/ruff", "path": "/crates/ruff/src/rules/pep8_naming/rules/dunder_function_name.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let s: &[Styles] = &[Underline, Italic]; test_combine!(s) } #[test] fn two3() { let s: &[Styles] = &[Bold, Italic]; test_combine!(s) } #[test] fn three1() { let s: &[Styles] = &[Bold, Underline, I...
code_fim
hard
{ "lang": "rust", "repo": "wking/cincinnati", "path": "/vendor/colored/src/style.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wking/cincinnati path: /vendor/colored/src/style.rs const CLEARV: u8 = 0b0000_0000; const BOLD: u8 = 0b0000_0001; const UNDERLINE: u8 = 0b0000_0010; const REVERSED: u8 = 0b0000_0100; const ITALIC: u8 = 0b0000_1000; const BLINK: u8 = 0b0001_0000; const HIDDEN: u8 = 0b0010_0000; const DIMMED: u8 =...
code_fim
hard
{ "lang": "rust", "repo": "wking/cincinnati", "path": "/vendor/colored/src/style.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn main() { print!("{}", MAX); let not_quite_max: u64 = 1000000; let not_quite_not_quite_max: u64 = 10; let beg1 = Instant::now(); for i in not_quite_not_quite_max..not_quite_max { if is_prime_mr_multi_core(i, 1) { print!("\n{} is prime MR mc\n", i) } }...
code_fim
hard
{ "lang": "rust", "repo": "NewlineCoding/lab_8", "path": "/src/main_ol_bkp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NewlineCoding/lab_8 path: /src/main_ol_bkp.rs extern crate rand; extern crate num_cpus; extern crate threadpool; extern crate mersenne_twister; use rand::distributions::{IndependentSample, Range}; use std::collections::HashSet; use threadpool::ThreadPool; use mersenne_twister::MersenneTwister; ...
code_fim
hard
{ "lang": "rust", "repo": "NewlineCoding/lab_8", "path": "/src/main_ol_bkp.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { print!("{}", MAX); let not_quite_max: u64 = 1000000; let not_quite_not_quite_max: u64 = 10; let beg1 = Instant::now(); for i in not_quite_not_quite_max..not_quite_max { if is_prime_mr_multi_core(i, 1) { print!("\n{} is prime MR mc\n", i) } } ...
code_fim
hard
{ "lang": "rust", "repo": "NewlineCoding/lab_8", "path": "/src/main_ol_bkp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mariomka/AdventOfCode2020 path: /day6/src/main.rs use helpers::{run, split_input}; <|fim_suffix|> run("part1", || day6::part1(&input)); run("part2", || day6::part2(&input)); }<|fim_middle|>fn main() { let input: Vec<&str> = split_input(include_str!("../input.txt"), "\n\n");
code_fim
medium
{ "lang": "rust", "repo": "mariomka/AdventOfCode2020", "path": "/day6/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }