text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: jakeprobst/pqc path: /src/evaluator.rs ] pub enum SyntaxError { UnknownFunction(String), InvalidFunction(String), InvalidNumberOfArguments(String, u32, usize), InvalidArgument(String, String, String), UnknownMonster(String), UnknownFloor(String), WaveAlreadyDefined(St...
code_fim
hard
{ "lang": "rust", "repo": "jakeprobst/pqc", "path": "/src/evaluator.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let section = try!(eval_generic_integer(&try!(expect_type!(args[2], PExpr::Section)))); let mut monsters = Vec::new(); let mut next = Vec::new(); let mut unlock = Vec::new(); let mut delay = u32::max_value(); for arg in args.iter().skip(3) { mat...
code_fim
hard
{ "lang": "rust", "repo": "jakeprobst/pqc", "path": "/src/evaluator.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn eval_next_wave(&mut self, args: &Vec<PExpr>) -> Result<u32, SyntaxError> { if args.len() != 1 { return Err(SyntaxError::InvalidNumberOfArguments(String::from("next-wave"), 1, args.len())); } let next = try!(expect_type!(args[0], PExpr::Identifier)); let...
code_fim
hard
{ "lang": "rust", "repo": "jakeprobst/pqc", "path": "/src/evaluator.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/wgpu-hal/src/dx11/device.rs use std : : { ffi : : c_void mem } ; use winapi : : um : : d3d11 ; use crate : : auxil : : dxgi : : result : : HResult ; impl crate : : Device < super : : Api > for super : : Device { unsafe fn exit ( self queue : su...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/wgpu-hal/src/dx11/device.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>uper : : BindGroup crate : : DeviceError > { todo ! ( ) } unsafe fn destroy_bind_group ( & self group : super : : BindGroup ) { todo ! ( ) } unsafe fn create_shader_module ( & self desc : & crate : : ShaderModuleDescriptor shader : crate : : ShaderInput ) - > Result < super : : ShaderModule crate : : Shad...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/wgpu-hal/src/dx11/device.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> & self fence : super : : Fence ) { todo ! ( ) } unsafe fn get_fence_value ( & self fence : & super : : Fence ) - > Result < crate : : FenceValue crate : : DeviceError > { todo ! ( ) } unsafe fn wait ( & self fence : & super : : Fence value : crate : : FenceValue timeout_ms : u32 ) - > Result < bool crate...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/wgpu-hal/src/dx11/device.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-windowing/winit path: /src/platform_impl/windows/window.rs n().into(); let size: (u32, u32) = monitor.size().into(); unsafe { SetWindowPos( window.0, 0, ...
code_fim
hard
{ "lang": "rust", "repo": "rust-windowing/winit", "path": "/src/platform_impl/windows/window.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { // The window must be destroyed from the same thread that created it, so we send a // custom message to be handled by our callback to do the actual work. PostMessageW(self.hwnd(), DESTROY_MSG_ID.get(), 0, 0); } } } /// A simple non-owning w...
code_fim
hard
{ "lang": "rust", "repo": "rust-windowing/winit", "path": "/src/platform_impl/windows/window.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub fn set_decorations(&self, decorations: bool) { let window = self.window.clone(); let window_state = Arc::clone(&self.window_state); self.thread_executor.execute_in_thread(move || { let _ = &window; WindowState::set_window_flags(window_...
code_fim
hard
{ "lang": "rust", "repo": "rust-windowing/winit", "path": "/src/platform_impl/windows/window.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexandrejanin/fractals path: /src/shader.rs use std::ffi::CString; use std::ptr; use gl::types::*; pub struct Program { id: u32, } impl Program { pub fn new(vertex_path: &str, fragment_path: &str) -> Self { let vertex_code: CString = CString::new(std::fs::read_to_...
code_fim
hard
{ "lang": "rust", "repo": "alexandrejanin/fractals", "path": "/src/shader.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match CString::new(name) { Err(_) => None, Ok(c_name) => match unsafe { gl::GetUniformLocation(self.id, c_name.as_ptr()) } { -1 => None, location => Some(location), }, } } pub fn set_vec2(&self, name: &str, value:...
code_fim
hard
{ "lang": "rust", "repo": "alexandrejanin/fractals", "path": "/src/shader.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let response = runner.perform("/").unwrap(); assert_eq!(response.status().as_u16(), 101); assert_matches!( response.headers().get("sec-websocket-accept"), Some(h) if h == "xxxx" ); }<|fim_prefix|>// repo: finchers-rs/finchers path: /tests/endpoints/upgrade.rs use finchers...
code_fim
hard
{ "lang": "rust", "repo": "finchers-rs/finchers", "path": "/tests/endpoints/upgrade.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: finchers-rs/finchers path: /tests/endpoints/upgrade.rs use finchers::endpoints::upgrade::Builder; use finchers::prelude::*; use finchers::test; <|fim_suffix|> let mut runner = test::runner({ endpoints::upgrade::builder().map(|builder: Builder| { builder .h...
code_fim
medium
{ "lang": "rust", "repo": "finchers-rs/finchers", "path": "/tests/endpoints/upgrade.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[aoc(day5, part1)] fn part1(passes: &[BoardingPass]) -> u16 { passes.iter().max().map(|&BoardingPass(n)| n).unwrap() } #[aoc(day5, part2)] fn part2(passes: &[BoardingPass]) -> u16 { let mut passes = passes.to_vec(); passes.sort_unstable(); let neighbors = passes .windows(2) ...
code_fim
medium
{ "lang": "rust", "repo": "jtdowney/advent-2020", "path": "/src/day5.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let neighbors = passes .windows(2) .find(|parts| { let BoardingPass(a) = parts[0]; let BoardingPass(b) = parts[1]; b - a == 2 }) .map(|passes| passes[0].0) .unwrap(); neighbors + 1 }<|fim_prefix|>// repo: jtdowney/advent-...
code_fim
hard
{ "lang": "rust", "repo": "jtdowney/advent-2020", "path": "/src/day5.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jtdowney/advent-2020 path: /src/day5.rs use std::{num::ParseIntError, str::FromStr}; #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq)] struct BoardingPass(u16); impl FromStr for BoardingPass { type Err = ParseIntError; fn from_str(s: &str) -> Result<Self, Self::Err> { let...
code_fim
medium
{ "lang": "rust", "repo": "jtdowney/advent-2020", "path": "/src/day5.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let point1 = Point1 { x: 4, y: 7 }; let point2 = Point2 { x: 6, y: 5.4 }; let point2_2 = Point2 { x: 4, y: 7 }; }<|fim_prefix|>// repo: geekynerdbiker/Rust path: /Basic/generic2.rs struct Point1<T> { x: T, y: T, } <|fim_middle|>struct Point2<T, U> { x: T, y: U, } ...
code_fim
easy
{ "lang": "rust", "repo": "geekynerdbiker/Rust", "path": "/Basic/generic2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let point1 = Point1 { x: 4, y: 7 }; let point2 = Point2 { x: 6, y: 5.4 }; let point2_2 = Point2 { x: 4, y: 7 }; }<|fim_prefix|>// repo: geekynerdbiker/Rust path: /Basic/generic2.rs struct Point1<T> { x: T, y: T, } <|fim_middle|>struct Point2<T, U> { x: T, y: U, } fn main() {...
code_fim
easy
{ "lang": "rust", "repo": "geekynerdbiker/Rust", "path": "/Basic/generic2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: geekynerdbiker/Rust path: /Basic/generic2.rs struct Point1<T> { x: T, y: T, } <|fim_suffix|> let point1 = Point1 { x: 4, y: 7 }; let point2 = Point2 { x: 6, y: 5.4 }; let point2_2 = Point2 { x: 4, y: 7 }; }<|fim_middle|>struct Point2<T, U> { x: T, y: U, } fn main() {...
code_fim
easy
{ "lang": "rust", "repo": "geekynerdbiker/Rust", "path": "/Basic/generic2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mangeption/leetcode-rust path: /src/split_array_largest_sum/solution.rs pub struct Solution {} const BIG: i32 = 1_000_000_000; impl Solution { pub fn split_array(nums: Vec<i32>, m: i32) -> i32 { Self::split_array_binary_search(nums, m) } fn split_array_binary_search(nums: V...
code_fim
hard
{ "lang": "rust", "repo": "mangeption/leetcode-rust", "path": "/src/split_array_largest_sum/solution.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// +++++++++++++++++++++++++ // 9 8 5 3 2 // 9 / 8 5 3 2 -> 18 // 9 8 / 5 3 2 -> 17 xxxxxxxxxxxxxxxxxx // 9 8 5 / 3 2 -> 22 // 9 8 5 3 / 2 -> 25 // 9 / 8 / 5 3 2 -> 10 xxxxxxxxxxxxxxxxxxxxxxxx // 9 / 8 5 / 3 2 -> 13 // 9 / 8 5 3 / 2 -> 16 // 9 8 / 5 / 3 2 -> 17 // 9 8 / 5 3 / 2 -> 17 // 9 8 5 / 3 / 2 -> ...
code_fim
hard
{ "lang": "rust", "repo": "mangeption/leetcode-rust", "path": "/src/split_array_largest_sum/solution.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(bool_to_enum::<Bool>(false), Bool::False); assert_eq!(bool_to_enum::<Bool>(true), Bool::True); assert_eq!(enum_to_bool(Bool::False), false); assert_eq!(enum_to_bool(Bool::True), true); } #[test] fn bool_roundtrip() { assert_eq!(bool_to_enum::<bool>(false), false); asse...
code_fim
hard
{ "lang": "rust", "repo": "rodrimati1992/abi_stable_crates", "path": "/abi_stable/src/sabi_types/bitarray/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rodrimati1992/abi_stable_crates path: /abi_stable/src/sabi_types/bitarray/tests.rs use super::{bool_to_enum, enum_to_bool, BitArray64, BooleanEnum}; #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[repr(u8)] pub enum Bool { /// False = 0, /// True = 1, } unsafe impl BooleanEnum f...
code_fim
hard
{ "lang": "rust", "repo": "rodrimati1992/abi_stable_crates", "path": "/abi_stable/src/sabi_types/bitarray/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danielalvsaaker/backlight-rs path: /src/main.rs use std::fs::OpenOptions; use std::io::{Error, Read, Write}; use std::str::FromStr; use structopt::StructOpt; #[derive(StructOpt)] #[structopt(name = "backlight", about = "Set backlight")] enum Options { Increase { value: u16 }, Decrease ...
code_fim
hard
{ "lang": "rust", "repo": "danielalvsaaker/backlight-rs", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } fn main() -> Result<(), Error> { match Options::from_args() { Options::Increase { value } => { set(value, "increase")?; } Options::Decrease { value } => { set(value, "decrease")?; } } Ok(()) }<|fim_prefix|>// repo: danielalv...
code_fim
hard
{ "lang": "rust", "repo": "danielalvsaaker/backlight-rs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let converted: u16 = u16::from_str(&current_value.trim()).expect("Failed to parse current brightness value"); match operation { "increase" => { let result = (converted + value).to_string(); file.write_all(&result.into_bytes())?; } "decrease"...
code_fim
medium
{ "lang": "rust", "repo": "danielalvsaaker/backlight-rs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ivan770/ares path: /src/lib/iv.rs use rand::random; use serde::{Deserialize, Serialize}; <|fim_suffix|>impl Iv { pub fn random() -> Self { Iv { iv: random() } } }<|fim_middle|>#[derive(Copy, Clone, Serialize, Deserialize)] pub struct Iv { pub iv: [u8; 16], }
code_fim
medium
{ "lang": "rust", "repo": "ivan770/ares", "path": "/src/lib/iv.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Iv { pub fn random() -> Self { Iv { iv: random() } } }<|fim_prefix|>// repo: ivan770/ares path: /src/lib/iv.rs use rand::random; use serde::{Deserialize, Serialize}; <|fim_middle|>#[derive(Copy, Clone, Serialize, Deserialize)] pub struct Iv { pub iv: [u8; 16], }
code_fim
medium
{ "lang": "rust", "repo": "ivan770/ares", "path": "/src/lib/iv.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn convert_int_to_digits() { assert!(int_to_digits(123) == vec![1, 2, 3]); assert!(int_to_digits(10) == vec![1, 0]); assert!(int_to_digits(0) == vec![]); } pub struct Memo<F, A, R> { data: HashMap<A, R>, func: F, } impl<F: Fn(A) -> R, A, R> Memo<F, A, R> where A: ::std::c...
code_fim
hard
{ "lang": "rust", "repo": "silven/rust-euler", "path": "/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: silven/rust-euler path: /src/utils.rs use std::collections::HashMap; use std::fmt::Display; use std::time::{Duration, Instant}; macro_rules! set { ( $( $x:expr ),* ) => { { let mut temp_set = HashSet::new(); $( temp_set.insert($x); ...
code_fim
hard
{ "lang": "rust", "repo": "silven/rust-euler", "path": "/src/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn int_to_digits(x: u64) -> Vec<u64> { let mut v: Vec<u64> = IterDigits { n: x }.collect(); v.reverse(); return v; } #[test] fn convert_int_to_digits() { assert!(int_to_digits(123) == vec![1, 2, 3]); assert!(int_to_digits(10) == vec![1, 0]); assert!(int_to_digits(0) == vec![])...
code_fim
hard
{ "lang": "rust", "repo": "silven/rust-euler", "path": "/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 9ary/rp2040-pac path: /src/pll_sys/prim.rs #[doc = "Reader of register PRIM"] pub type R = crate::R<u32, super::PRIM>; #[doc = "Writer for register PRIM"] pub type W = crate::W<u32, super::PRIM>; #[doc = "Register PRIM `reset()`'s with value 0x0007_7000"] impl crate::ResetValue for super::PRIM {...
code_fim
hard
{ "lang": "rust", "repo": "9ary/rp2040-pac", "path": "/src/pll_sys/prim.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> = "Bits 12:14 - divide by 1-7"] #[inline(always)] pub fn postdiv2(&self) -> POSTDIV2_R { POSTDIV2_R::new(((self.bits >> 12) & 0x07) as u8) } } impl W { #[doc = "Bits 16:18 - divide by 1-7"] #[inline(always)] pub fn postdiv1(&mut self) -> POSTDIV1_W { POSTDIV1_W { w...
code_fim
hard
{ "lang": "rust", "repo": "9ary/rp2040-pac", "path": "/src/pll_sys/prim.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: recursive-bloom/cmd-ethkey-bloom path: /src/commands/subcommand_cmd/error.rs use std::{fmt, error}; use ethereum_types::U256; use parity_crypto::publickey::{Error as EthPublicKeyCryptoError}; use rlp; use unexpected::OutOfBounds; #[derive(Debug, PartialEq, Clone)] /// Errors concerning transac...
code_fim
hard
{ "lang": "rust", "repo": "recursive-bloom/cmd-ethkey-bloom", "path": "/src/commands/subcommand_cmd/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use self::Error::*; let msg = match *self { AlreadyImported => "Already imported".into(), Old => "No longer valid".into(), TooCheapToReplace { prev, new } => ...
code_fim
hard
{ "lang": "rust", "repo": "recursive-bloom/cmd-ethkey-bloom", "path": "/src/commands/subcommand_cmd/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use self::Error::*; let msg = match *self { AlreadyImported => "Already imported".into(), Old => "No longer valid".into(), TooCheapToReplace { prev, new } => format!("Gas price too low to replace, previous tx gas: {:?}, new tx gas: {:?}",...
code_fim
hard
{ "lang": "rust", "repo": "recursive-bloom/cmd-ethkey-bloom", "path": "/src/commands/subcommand_cmd/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Machinocheese/B7 path: /build.rs extern crate bindgen; extern crate cc; use std::env; use std::path::PathBuf; <|fim_suffix|> // Compile C source cc::Build::new().file("src/b77.c").compile("b77.a"); // Generate Rust bindings let bindings = bindgen::Builder::default() .he...
code_fim
medium
{ "lang": "rust", "repo": "Machinocheese/B7", "path": "/build.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> // Compile C source cc::Build::new().file("src/b77.c").compile("b77.a"); // Generate Rust bindings let bindings = bindgen::Builder::default() .header("src/bindgen.h") .generate() .expect("Unable to generate bindings"); // Output rust bindings to a file let...
code_fim
medium
{ "lang": "rust", "repo": "Machinocheese/B7", "path": "/build.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(dead_code)] pub fn cipher_key_test_128_bit_vals(pos: usize) -> Vec<u8> { let values: Vec<Vec<u8>> = vec![ vec![0x2b, 0x7e, 0x15, 0x16], vec![0x28, 0xae, 0xd2, 0xa6], vec![0xab, 0xf7, 0x15, 0x88], vec![0x09, 0xcf, 0x4f, 0x3c], vec![0xa0, 0xfa, 0xfe, 0x17]...
code_fim
hard
{ "lang": "rust", "repo": "n0manarmy/rusty_aes", "path": "/src/test_vals/test_tables.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: n0manarmy/rusty_aes path: /src/test_vals/test_tables.rs #[allow(dead_code)] pub fn cipher_128(state: (u32, &str)) -> Vec<u8> { match state { ( 0, "input") => vec![0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff], ( 0, "...
code_fim
hard
{ "lang": "rust", "repo": "n0manarmy/rusty_aes", "path": "/src/test_vals/test_tables.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pksunkara/reign path: /reign_view/src/parse/code.rs use super::{attribute::AttributeValue, Error, Expr, For, ParseStream, Tokenize, ViewFields}; use proc_macro2::TokenStream; use std::fmt::{Debug, Error as FError, Formatter}; use syn::parse_str; pub enum Code { For(For), Expr(Expr), } ...
code_fim
medium
{ "lang": "rust", "repo": "pksunkara/reign", "path": "/reign_view/src/parse/code.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if let Ok(code) = parsed { Ok(Code::Expr(code)) } else { Err(input.error("expected expression")) } } } impl Tokenize for Code { fn tokenize(&self, tokens: &mut TokenStream, idents: &mut ViewFields, scopes: &ViewFields) { match self { ...
code_fim
hard
{ "lang": "rust", "repo": "pksunkara/reign", "path": "/reign_view/src/parse/code.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> write!(f, "{}", match *self { North => "north", South => "south", East => "east", West => "west", Up => "up", Down => "down", }) } }<|fim_prefix|>// repo: toolness/werewolves-and-wanderer-rs path: /src/direction.rs use std::fmt; use sized_enum::SizedEnum; u...
code_fim
medium
{ "lang": "rust", "repo": "toolness/werewolves-and-wanderer-rs", "path": "/src/direction.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: toolness/werewolves-and-wanderer-rs path: /src/direction.rs use std::fmt; use sized_enum::SizedEnum; use self::Direction::*; const NUM_DIRECTIONS: usize = 6; <|fim_suffix|>impl Direction { pub fn character(self) -> char { match self { North => 'n', South => 's', East ...
code_fim
medium
{ "lang": "rust", "repo": "toolness/werewolves-and-wanderer-rs", "path": "/src/direction.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> /// information about the secret data to project #[serde(skip_serializing_if = "Option::is_none")] pub secret: Option<::api::core::v1::SecretProjection>, }<|fim_prefix|>// repo: kichristensen/k8s-openapi-codegen path: /k8s-openapi/src/api/core/v1/volume_projection.rs // Generated from definit...
code_fim
hard
{ "lang": "rust", "repo": "kichristensen/k8s-openapi-codegen", "path": "/k8s-openapi/src/api/core/v1/volume_projection.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kichristensen/k8s-openapi-codegen path: /k8s-openapi/src/api/core/v1/volume_projection.rs // Generated from definition io.k8s.api.core.v1.VolumeProjection /// Projection that may be projected along with other supported volume types #[derive(Debug, Default, Deserialize, Serialize)] pub struct Vo...
code_fim
hard
{ "lang": "rust", "repo": "kichristensen/k8s-openapi-codegen", "path": "/k8s-openapi/src/api/core/v1/volume_projection.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: czak/aoc path: /2019/rust/src/bin/day01.rs use std::io::{self, BufRead}; fn fuel_requirement(mass: i32) -> i32 { (mass as f32 / 3.0).floor() as i32 - 2 } fn total_requirement(mass: i32) -> i32 { let req = fuel_requirement(mass); if req <= 0 { 0 } else { req + to...
code_fim
hard
{ "lang": "rust", "repo": "czak/aoc", "path": "/2019/rust/src/bin/day01.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Part 2 assert_eq!(2, total_requirement(14)); assert_eq!(966, total_requirement(1969)); assert_eq!(50346, total_requirement(100756)); let total: i32 = masses.iter().map(|&m| total_requirement(m)).sum(); println!("Part 2: {}", total); }<|fim_prefix|>// repo: czak/aoc path: /201...
code_fim
hard
{ "lang": "rust", "repo": "czak/aoc", "path": "/2019/rust/src/bin/day01.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>dispatch_dyn!({ my_algorithm::<S>(&mut values) }); // or with a custom generic parameter name: dispatch_dyn!(ISA, { my_algorithm::<ISA>(&mut values) }); ``` */ #[macro_export] macro_rules! dispatch_dyn { ($code:block) => { dispatch_dyn!(S, $code) }; ($s:ident, $code:block) => {{ ...
code_fim
medium
{ "lang": "rust", "repo": "raygon-renderer/thermite", "path": "/crates/thermite/src/runtime.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: raygon-renderer/thermite path: /crates/thermite/src/runtime.rs /** Detects processor architecture at runtime and generates a type definition for the current SIMD instruction-set to be passed into the given code-block. The code block given is duplicated, manually monomorphised, to give the type ...
code_fim
medium
{ "lang": "rust", "repo": "raygon-renderer/thermite", "path": "/crates/thermite/src/runtime.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>dispatch_dyn!(ISA, { my_algorithm::<ISA>(&mut values) }); ``` */ #[macro_export] macro_rules! dispatch_dyn { ($code:block) => { dispatch_dyn!(S, $code) }; ($s:ident, $code:block) => {{ use $crate::{backends, Simd, SimdInstructionSet}; match SimdInstructionSet::runtime_...
code_fim
medium
{ "lang": "rust", "repo": "raygon-renderer/thermite", "path": "/crates/thermite/src/runtime.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut counts = HashMap::new(); for line in input { let char_counts = get_char_counts(line); for &val in interest.iter() { if char_counts.iter().any(|(_, &count)| count == val) { let interest_count = counts.entry(val).or_insert(0); *inte...
code_fim
hard
{ "lang": "rust", "repo": "spwitt/aoc-2018", "path": "/day02/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spwitt/aoc-2018 path: /day02/src/main.rs use std::collections::HashMap; use std::io::{self, Read}; fn main() { let mut input = String::new(); io::stdin().read_to_string(&mut input).unwrap(); let result1 = part1(&input); println!("Part 1 result is {}", result1); let result2 =...
code_fim
hard
{ "lang": "rust", "repo": "spwitt/aoc-2018", "path": "/day02/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn sample_vec1() -> Vec<&'static str> { vec![ "abcdef", "bababc", "abbcde", "abcccd", "aabcdd", "abcdee", "ababab", ] } fn sample_vec2() -> Vec<&'static str> { vec![ "abcde", "fghij", "klmno", "pqrst", "fguij", "axcye", "wvxyz", ] } ...
code_fim
hard
{ "lang": "rust", "repo": "spwitt/aoc-2018", "path": "/day02/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BillyDM/baseview path: /src/keyboard.rs // Copyright 2020 The Druid Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licens...
code_fim
medium
{ "lang": "rust", "repo": "BillyDM/baseview", "path": "/src/keyboard.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>//! Keyboard types. use keyboard_types::{Code, Location}; #[cfg(any(target_os = "linux", target_os = "macos"))] /// Map key code to location. /// /// The logic for this is adapted from InitKeyEvent in TextInputHandler (in the Mozilla /// mac port). /// /// Note: in the original, this is based on kVK con...
code_fim
medium
{ "lang": "rust", "repo": "BillyDM/baseview", "path": "/src/keyboard.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match computers[index].run() { IntCodeResult::Output(val) => { signal = val } IntCodeResult::Halted => break, } index = (index + 1) % 5; } result = ...
code_fim
hard
{ "lang": "rust", "repo": "yzhong52/AdventOfCode", "path": "/2019/src/y2019/day7.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yzhong52/AdventOfCode path: /2019/src/y2019/day7.rs use super::super::helpers::parser::*; use std::collections::VecDeque; use crate::int_code_computers::basic_int_code_computer::{IntCodeComputer, IntCodeResult}; use crate::helpers::puzzle::Puzzle; pub struct Day7 {} impl Day7 { fn combina...
code_fim
hard
{ "lang": "rust", "repo": "yzhong52/AdventOfCode", "path": "/2019/src/y2019/day7.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> read_numbers_by_comma } fn part1(&self, input: &Vec<i32>) -> i32 { let possible_phases = Day7::combinations(vec![0, 1, 2, 3, 4]); let mut result = 0; for phases in possible_phases { let mut phase_setting = 0; for phase in phases { ...
code_fim
hard
{ "lang": "rust", "repo": "yzhong52/AdventOfCode", "path": "/2019/src/y2019/day7.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; use crate::world_step::avoid_water_filter::*; use std::iter::FromIterator; #[test] fn no_random_order_to_make() { let world_step = AvoidWaterFilter::new_from_line_map( "%%% %a% %%%", ); ...
code_fim
hard
{ "lang": "rust", "repo": "jockbert/jockbert_ants_bot", "path": "/src/strategy/random_walk.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self, world_step: &dyn WorldStep, ants: &mut HashSet<Position>, ) -> Orders { ants.iter() .flat_map(|ant| { random_direction( &world_step.available_directions(ant), ) .map(|dir| ant.order(d...
code_fim
hard
{ "lang": "rust", "repo": "jockbert/jockbert_ants_bot", "path": "/src/strategy/random_walk.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jockbert/jockbert_ants_bot path: /src/strategy/random_walk.rs use crate::strategy::Strategy; use crate::world_step::WorldStep; use ants_ai_challenge_api::Direction; use ants_ai_challenge_api::Orders; use ants_ai_challenge_api::Position; use rand::Rng; use std::collections::HashSet; <|fim_suffix...
code_fim
hard
{ "lang": "rust", "repo": "jockbert/jockbert_ants_bot", "path": "/src/strategy/random_walk.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Masterchef365/GameKernel path: /protocols/src/lib.rs use std::io::{self, ErrorKind}; use std::task::Poll; pub type ModuleId = String; pub type Port = u16; pub type Handle = u32; /// Either represents an error, or a u32 #[repr(transparent)] #[derive(Debug)] pub struct Maybe(pub i64); <|fim_suf...
code_fim
hard
{ "lang": "rust", "repo": "Masterchef365/GameKernel", "path": "/protocols/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn encode(poll: Poll<io::Result<u32>>) -> i64 { Self::from(poll).0 } } impl From<Poll<io::Result<u32>>> for Maybe { fn from(poll: Poll<io::Result<u32>>) -> Self { Maybe(match poll { Poll::Ready(Ok(n)) => n as i64, Poll::Pending => -1, Po...
code_fim
hard
{ "lang": "rust", "repo": "Masterchef365/GameKernel", "path": "/protocols/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn from_default(ents: &EntitiesRes) -> Self { Self::new(TERRAIN.iter(), ents) } } impl Default for Terrain { fn default() -> Self { Self { buckets: Array2D::new(0, 0), } } }<|fim_prefix|>// repo: Phantomical/mighty-server path: /server/src/types/collision/terrain.rs use consts::TERRAIN;...
code_fim
medium
{ "lang": "rust", "repo": "Phantomical/mighty-server", "path": "/server/src/types/collision/terrain.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self { buckets } } pub fn from_default(ents: &EntitiesRes) -> Self { Self::new(TERRAIN.iter(), ents) } } impl Default for Terrain { fn default() -> Self { Self { buckets: Array2D::new(0, 0), } } }<|fim_prefix|>// repo: Phantomical/mighty-server path: /server/src/types/collision/terrain....
code_fim
hard
{ "lang": "rust", "repo": "Phantomical/mighty-server", "path": "/server/src/types/collision/terrain.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Phantomical/mighty-server path: /server/src/types/collision/terrain.rs use consts::TERRAIN; use specs::world::*; use types::*; use types::collision::*; // Buckets are configurable here pub const BUCKETS_Y: usize = 64; pub const BUCKETS_X: usize = BUCKETS_Y * 2; pub const BUCKET_WIDTH: f32 = (3...
code_fim
hard
{ "lang": "rust", "repo": "Phantomical/mighty-server", "path": "/server/src/types/collision/terrain.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) fn geometry_as_shape( geometry: &Geometry<TU>, transform: &ControlTransform, ) -> Option<GeoShape> { match geometry { Geometry::Point(point) => { let point = Point2::new(point.0.x, point.0.y); let transformed: Point2<f64> = transform * point; ...
code_fim
hard
{ "lang": "rust", "repo": "PicoJr/geotui", "path": "/src/geo_canvas.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PicoJr/geotui path: /src/geo_canvas.rs use crate::control::{ControlTransform, TU}; use crate::geo_points::GeoPoints; use geo_types::{Geometry, Polygon}; use nalgebra::Point2; use tui::style::Color; use tui::widgets::canvas::{Line, Painter, Shape}; pub enum GeoShape { GeoPoints(GeoPoints), ...
code_fim
hard
{ "lang": "rust", "repo": "PicoJr/geotui", "path": "/src/geo_canvas.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> nums.len() as i32 } }<|fim_prefix|>// repo: MSDimos/leetcode-rust2018 path: /Q26-remove-duplicates-from-sorted-array/src/lib.rs pub struct Solution; <|fim_middle|>impl Solution { pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 { nums.dedup_by(|a, b| a == b);
code_fim
medium
{ "lang": "rust", "repo": "MSDimos/leetcode-rust2018", "path": "/Q26-remove-duplicates-from-sorted-array/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MSDimos/leetcode-rust2018 path: /Q26-remove-duplicates-from-sorted-array/src/lib.rs pub struct Solution; <|fim_suffix|> nums.len() as i32 } }<|fim_middle|>impl Solution { pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 { nums.dedup_by(|a, b| a == b);
code_fim
medium
{ "lang": "rust", "repo": "MSDimos/leetcode-rust2018", "path": "/Q26-remove-duplicates-from-sorted-array/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: japaric/no-std-async-experiments path: /generator-app/src/main.rs #![deny(unsafe_code)] #![feature(generators)] #![feature(never_type)] #![no_main] #![no_std] // panicking behavior extern crate panic_semihosting; <|fim_suffix|> let mut t1 = || { loop { hprintln!("T1").un...
code_fim
hard
{ "lang": "rust", "repo": "japaric/no-std-async-experiments", "path": "/generator-app/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> static mut COUNT: u8 = 0; *COUNT += 1; // Send signal A every second A::set(); if *COUNT % 2 == 0 { // Send signal B every 2 seconds B::set(); } } #[derive(Signal)] struct A; #[derive(Signal)] struct B;<|fim_prefix|>// repo: japaric/no-std-async-experiments pat...
code_fim
medium
{ "lang": "rust", "repo": "japaric/no-std-async-experiments", "path": "/generator-app/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn it_returns_x_for_loc_minus_one_minus_one_square_size_sixteen_and_two_fifty_six () { let screen_size = ScreenSize { width: 256.0, height: 256.0 }; assert!(Camera::new(screen_size, Loc { x: -1, y: -1 }, 16).as_mat()[3][0] == -112.0); } #[test] fn it_re...
code_fim
hard
{ "lang": "rust", "repo": "dobrite/dood-rs", "path": "/src/render/camera.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn it_returns_game_coords_for_window_loc_zero_zero_top_left() { let screen_size = ScreenSize { width: 256.0, height: 256.0 }; assert!(Camera::new(screen_size, Loc { x: 0, y: 0 }, 16) .to_game_loc(WindowLoc { x: 1.0f64, y: 1.0f64 }) == Loc { x: 0, y: 0 }); } ...
code_fim
hard
{ "lang": "rust", "repo": "dobrite/dood-rs", "path": "/src/render/camera.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dobrite/dood-rs path: /src/render/camera.rs use dir::Dir; use loc::Loc; use size::Size; use screen_size::ScreenSize; use window_loc::WindowLoc; #[derive(Debug)] pub struct Camera { screen_size: ScreenSize, loc: Loc, dim: Size, } impl Camera { pub fn new(screen_size: ScreenSize...
code_fim
hard
{ "lang": "rust", "repo": "dobrite/dood-rs", "path": "/src/render/camera.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn with_mut<V, F: FnOnce(&mut T) -> V>(&self, data: &mut AppData, f: F) -> V { match data.view_data.as_any_mut().downcast_mut::<T>() { Some(data) => f(data), None => panic!( "attempted to downcast {:?} to {}", &data.view_data, ...
code_fim
hard
{ "lang": "rust", "repo": "mmitteregger/druid-example", "path": "/src/data/app.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match data.view_data.as_any_mut().downcast_mut::<T>() { Some(data) => f(data), None => panic!( "attempted to downcast {:?} to {}", &data.view_data, std::any::type_name::<T>() ), } } }<|fim_prefix|>// re...
code_fim
hard
{ "lang": "rust", "repo": "mmitteregger/druid-example", "path": "/src/data/app.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mmitteregger/druid-example path: /src/data/app.rs use std::fmt::Debug; use druid::{Data, Lens}; use crate::data::{View1Data, View2Data, ViewData}; #[derive(Debug, Clone)] pub struct AppData { view: AppView, view_data: Box<dyn ViewData>, // ... plus some settings and other stuff } ...
code_fim
hard
{ "lang": "rust", "repo": "mmitteregger/druid-example", "path": "/src/data/app.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: clauswilke/sinab path: /src/sinab/src/style/rules.rs use crate::style::declaration_block::DeclarationBlock; use crate::style::errors::RuleParseErrorKind; use crate::style::selectors::{self, SelectorList}; use cssparser::{AtRuleParser, ParseError, Parser, QualifiedRuleParser, SourceLocation}; use...
code_fim
hard
{ "lang": "rust", "repo": "clauswilke/sinab", "path": "/src/sinab/src/style/rules.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, prelude: Self::Prelude, _location: SourceLocation, parser: &mut Parser<'i, 't>, ) -> Result<Self::QualifiedRule, ParseError<'i, Self::Error>> { Ok(CssRule::StyleRule { selectors: prelude, block: Arc::new(DeclarationBlock::parse...
code_fim
hard
{ "lang": "rust", "repo": "clauswilke/sinab", "path": "/src/sinab/src/style/rules.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let cnt = inputStr.chars().filter(|&o| match o { 'a' | 'e' | 'i' | 'o' | 'u' => true, _ => false } ).count(); println!("{}", cnt); }<|fim_prefix|>// repo: kobi-ca/algorithms-2-2021 path: /src/main.rs // Return the number (count) of vowels in the given string. // We will consider a, e, i, o, u as ...
code_fim
easy
{ "lang": "rust", "repo": "kobi-ca/algorithms-2-2021", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kobi-ca/algorithms-2-2021 path: /src/main.rs // Return the number (count) of vowels in the given string. // We will consider a, e, i, o, u as vowels for this Kata (but not y). // The input string will only consist of lower case letters and/or spaces. // https://www.codewars.com/kata/54ff3102c1ba...
code_fim
easy
{ "lang": "rust", "repo": "kobi-ca/algorithms-2-2021", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let inputStr = String::from("hello world"); let cnt = inputStr.chars().filter(|&o| match o { 'a' | 'e' | 'i' | 'o' | 'u' => true, _ => false } ).count(); println!("{}", cnt); }<|fim_prefix|>// repo: kobi-ca/algorithms-2-2021 path: /src/main.rs // Return the number (count) of vowels in the gi...
code_fim
easy
{ "lang": "rust", "repo": "kobi-ca/algorithms-2-2021", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xilec/RustParser path: /RustParser.Tests/Tests/LoopExpressions.rs fn main() { loop {} loop {}; loop<|fim_suffix|>("Foo");}; loop {break; continue; break}; }<|fim_middle|> {println!("Foo")} loop {println!("Foo")}; loop {println!("Foo");} loop {println!
code_fim
medium
{ "lang": "rust", "repo": "xilec/RustParser", "path": "/RustParser.Tests/Tests/LoopExpressions.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>("Foo");}; loop {break; continue; break}; }<|fim_prefix|>// repo: xilec/RustParser path: /RustParser.Tests/Tests/LoopExpressions.rs fn main() { loop {} loop {}; loop {println!("Foo")} loop {println!("Foo")}; <|fim_middle|> loop {println!("Foo");} loop {println!
code_fim
easy
{ "lang": "rust", "repo": "xilec/RustParser", "path": "/RustParser.Tests/Tests/LoopExpressions.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Engine { host: String::from(host), extensions: vec![], } } fn configure(&mut self, ext: Box<Extension>) { self.extensions.push(ext); } fn start(&self) { for ext in self.extensions.iter() { ext.init(self); let meta = ext.meta(); println!( "[...
code_fim
hard
{ "lang": "rust", "repo": "heypoom/rust-labs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: heypoom/rust-labs path: /src/main.rs use std::fmt; #[derive(Debug)] enum Event { ExtensionReady(&'static str), } #[derive(Clone)] struct ExtensionMeta { pub name: &'static str, pub display_name: &'static str, pub version: &'static str, } trait Extension { // Metadata of the extensio...
code_fim
hard
{ "lang": "rust", "repo": "heypoom/rust-labs", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Default view widget constructor /// /// This struct implements [`Driver`], using a default widget for the data type: /// /// - [`kas_widgets::Text`] for `String`, `&str`, integer and float types /// - [`kas_widgets::CheckBox`] (read-only) for the bool type TODO #[derive(Clone, Copy, Debug, Default...
code_fim
hard
{ "lang": "rust", "repo": "kas-gui/kas", "path": "/crates/kas-view/src/driver.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kas-gui/kas path: /crates/kas-view/src/driver.rs // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License in the LICENSE-APACHE file or at: // https://www.apache.org/licenses...
code_fim
hard
{ "lang": "rust", "repo": "kas-gui/kas", "path": "/crates/kas-view/src/driver.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, cx: &mut EventCx, data: &Data, key: &Data::Key, widget: &mut Self::Widget, ) { let _ = (cx, data, key, widget); } } /// Default view widget constructor /// /// This struct implements [`Driver`], using a default widget for the data type: /...
code_fim
hard
{ "lang": "rust", "repo": "kas-gui/kas", "path": "/crates/kas-view/src/driver.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ashlineldridge/hello_tokio path: /examples/sleepy_threads.rs use rand::Rng; use std::{thread, time}; const TOTAL_TASKS: u32 = 20; const MIN_SLEEP_MILLIS: u64 = 1000; const MAX_SLEEP_MILLIS: u64 = 2000; #[tokio::main] async fn main() { let mut rng = rand::thread_rng(); let mut tasks = v...
code_fim
hard
{ "lang": "rust", "repo": "ashlineldridge/hello_tokio", "path": "/examples/sleepy_threads.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> tasks.push(handle); } for handle in tasks { handle.await.unwrap(); } } async fn run_task(task_id: u32, sleep_millis: u64) { let thread_id = thread::current().id(); println!( "Task (ID: {}, {:?}) is getting sleepy...", task_id, thread_id ); thre...
code_fim
medium
{ "lang": "rust", "repo": "ashlineldridge/hello_tokio", "path": "/examples/sleepy_threads.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( runner().ok("div {\ \n a: {\ \n p1: q;\ \n b: {\ \n p2: q;\ \n }\ \n p3: q;\ \n }\ \n}\n\ \nfoo {\ \n bar: baz {\ \n ...
code_fim
hard
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/non_conformant/basic/t24_namespace_properties.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/non_conformant/basic/t24_namespace_properties.rs //! Tests auto-converted from "sass-spec/spec/non_conformant/basic/24_namespace_properties.hrx" #[allow(unused)] fn runner() -> crate::TestRunner { super::runner().with_cwd("24_namespace_properties") } <|fim...
code_fim
hard
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/non_conformant/basic/t24_namespace_properties.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MrElectrify/memscan path: /src/lib.rs use rayon::prelude::*; use std::str::FromStr; use subslice_index::subslice_index; /// A memory pattern. Wildcards are represented in raw buffers /// as null bytes. Must not be empty pub struct Pattern { buf: Vec<u8>, } impl Pattern { /// Tests if a...
code_fim
hard
{ "lang": "rust", "repo": "MrElectrify/memscan", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let buf = &[1, 2, 3]; let pattern = Pattern::from(&[2, 3, 0x00][..]); assert!(find_pattern(buf, pattern).is_empty()); } #[test] fn multi_match() { let buf = &[1, 2, 3, 4, 3, 2, 1, 2, 3]; let pattern = Pattern::from(&[1, 2, 0x00][..]); assert_eq!...
code_fim
hard
{ "lang": "rust", "repo": "MrElectrify/memscan", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>> { let (mut input_1, mut input_2) = (input[i + 1], input[i + 2]); if *params.get(0).unwrap_or(&48) == 48 { input_1 = input[input_1 as usize]; } if *params.get(1).unwrap_or(&48) == 48 { input_2 = input[input_2 as usize]; } if input_1 != 0 { i = input_2 as usize; ...
code_fim
hard
{ "lang": "rust", "repo": "aQaTL/advent_of_code_2019", "path": "/day_5/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aQaTL/advent_of_code_2019 path: /day_5/src/main.rs fn main() { let input = std::fs::read_to_string("day_5/input.txt") .unwrap() .split(",") .map(|e| e.parse::<i64>().unwrap()) .collect::<Vec<_>>(); println!("Part 1: {}", solve(input.clone(), 1)); println!("Part 2: {}", solve(input, 5...
code_fim
hard
{ "lang": "rust", "repo": "aQaTL/advent_of_code_2019", "path": "/day_5/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let sym = match sym_opt { Some(s) => s, None => return Ok(()), }; match sym { Sym::Native(n) => { if let e @ Err(_) = self.eval_native(n, input, output) { self.work.push_front(sym); return ...
code_fim
hard
{ "lang": "rust", "repo": "slerpyyy/paste-lang", "path": "/src/eval.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }