text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> ctx.match_symbol('(')?; if !ctx.token().is_symbol(')') { loop { let (_, arg_name) = ctx.match_ident()?; args.push(String::from(arg_name)); if !ctx.token().is_symbol(',') { break; } ctx.match_symbol(',')?; ...
code_fim
hard
{ "lang": "rust", "repo": "greendwin/rust_tutorials", "path": "/calc/src/compiler/parser/block.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let data = MyDataBuilder::default() .field2("path/to/file.png") .field3("Some string") .build() .unwrap(); println!("{:?}", data); }<|fim_prefix|>// repo: PacktPublishing/Rust-High-Performance path: /Chapter08/example6/src/main.rs #[macro_use] extern c...
code_fim
medium
{ "lang": "rust", "repo": "PacktPublishing/Rust-High-Performance", "path": "/Chapter08/example6/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PacktPublishing/Rust-High-Performance path: /Chapter08/example6/src/main.rs #[macro_use] extern crate derive_builder; use std::path::PathBuf; <|fim_suffix|> let data = MyDataBuilder::default() .field2("path/to/file.png") .field3("Some string") .build() .unwra...
code_fim
medium
{ "lang": "rust", "repo": "PacktPublishing/Rust-High-Performance", "path": "/Chapter08/example6/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[async_trait::async_trait] impl<T: WasiView> insecure::Host for T { async fn get_insecure_random_bytes(&mut self, len: u64) -> anyhow::Result<Vec<u8>> { Ok((&mut self.ctx_mut().insecure_random) .sample_iter(Standard) .take(len as usize) .collect()) } ...
code_fim
medium
{ "lang": "rust", "repo": "abrown/wasmtime", "path": "/crates/wasi/src/preview2/preview2/random.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abrown/wasmtime path: /crates/wasi/src/preview2/preview2/random.rs use crate::preview2::wasi::random::insecure; use crate::preview2::wasi::random::insecure_seed; use crate::preview2::wasi::random::random; use crate::preview2::WasiView; use cap_rand::{distributions::Standard, Rng}; #[async_trait...
code_fim
hard
{ "lang": "rust", "repo": "abrown/wasmtime", "path": "/crates/wasi/src/preview2/preview2/random.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|>#[async_trait::async_trait] impl<T: WasiView> insecure_seed::Host for T { async fn insecure_seed(&mut self) -> anyhow::Result<(u64, u64)> { let seed: u128 = self.ctx_mut().insecure_random_seed; Ok((seed as u64, (seed >> 64) as u64)) } }<|fim_prefix|>// repo: abrown/wasmtime path: ...
code_fim
hard
{ "lang": "rust", "repo": "abrown/wasmtime", "path": "/crates/wasi/src/preview2/preview2/random.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|>// // pub fn notify(item: impl Summary) { // // } // // pub fn notify<T: Summary>(item: T) { // // } // // 指定多个Trait // // pub fn notify<T: Summary + Display>(item: T) {} // // pub fn notify<T, U>(a: T, b: U) -> String where T: Summary + Display, U: Clone + Debug {} struct Pair<T> { x: T, y: T...
code_fim
medium
{ "lang": "rust", "repo": "sepiggy/rust-basic-datacamp", "path": "/ch10/demo1004/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sepiggy/rust-basic-datacamp path: /ch10/demo1004/src/main.rs use std::fmt::Display; // use std::fmt::Display; // pub trait Summary {} // pub struct NewsArticle {} // impl Summary for NewsArticle {} // pub struct Tweet {} <|fim_suffix|>// // pub fn notify(item: impl Summary) { // // } // /...
code_fim
medium
{ "lang": "rust", "repo": "sepiggy/rust-basic-datacamp", "path": "/ch10/demo1004/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: scorpasdzx/raheel-mustajab path: /classwork/24nov/square/src/main.rs fn main() { let number:u32 = 5; let receive = square(number); println!("square of {} is {}", number, receive.1); } <|fim_suffix|> (val, val.pow(2)) }<|fim_middle|>fn square(val:u32) ->(u32, u32){
code_fim
easy
{ "lang": "rust", "repo": "scorpasdzx/raheel-mustajab", "path": "/classwork/24nov/square/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (val, val.pow(2)) }<|fim_prefix|>// repo: scorpasdzx/raheel-mustajab path: /classwork/24nov/square/src/main.rs fn main() { let number:u32 = 5; let receive = square(number); println!("square of {} is {}", number, receive.1); } <|fim_middle|>fn square(val:u32) ->(u32, u32){
code_fim
easy
{ "lang": "rust", "repo": "scorpasdzx/raheel-mustajab", "path": "/classwork/24nov/square/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hrvolapeter/servo path: /scripts/dom/bindings/interface.rs error; use js::glue::{UncheckedUnwrapObject, RUST_SYMBOL_TO_JSID}; use js::jsapi::{Class, ClassOps, CompartmentOptions}; use js::jsapi::{GetGlobalForObjectCrossCompartment, GetWellKnownSymbol, HandleObject, HandleValue}; use js::jsapi::{...
code_fim
hard
{ "lang": "rust", "repo": "hrvolapeter/servo", "path": "/scripts/dom/bindings/interface.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Hook for instanceof on interface objects. unsafe extern "C" fn has_instance_hook( cx: *mut JSContext, obj: HandleObject, value: MutableHandleValue, rval: *mut bool, ) -> bool { match has_instance(cx, obj, value.handle()) { Ok(result) => { *rval = result; ...
code_fim
hard
{ "lang": "rust", "repo": "hrvolapeter/servo", "path": "/scripts/dom/bindings/interface.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Create the interface prototype object of a non-callback interface. pub unsafe fn create_interface_prototype_object( cx: *mut JSContext, proto: HandleObject, class: &'static JSClass, regular_methods: &[Guard<&'static [JSFunctionSpec]>], regular_properties: &[Guard<&'static [JSProper...
code_fim
hard
{ "lang": "rust", "repo": "hrvolapeter/servo", "path": "/scripts/dom/bindings/interface.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let n = match self.curr { None => 0, Some(ref mut r) => try!(r.read(buf)), }; if n > 0 || buf.len() == 0 || self.curr.is_none() { Ok(n) } else { // The current reader reached the end so we have to advance the iterator and try...
code_fim
hard
{ "lang": "rust", "repo": "frangio/concat.rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: frangio/concat.rs path: /src/lib.rs //! Provides the Concat reader adaptor, which wraps around an iterator of readers and exposes its //! items' contents sequentially. Thus, the contents read from a Concat instance will be the //! concatenation of the items' contents. use std::io::{Read, Result...
code_fim
hard
{ "lang": "rust", "repo": "frangio/concat.rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mikialex/rendiation path: /platform/graphics/vulkan/src/lib.rs #![allow(dead_code)] use std::ffi::{c_void, CStr, CString}; <|fim_suffix|>mod instance; pub use instance::*; mod device; pub use device::*;<|fim_middle|>use anyhow::Result; use ash::{extensions::ext::DebugUtils, vk, Entry, Instanc...
code_fim
medium
{ "lang": "rust", "repo": "mikialex/rendiation", "path": "/platform/graphics/vulkan/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod device; pub use device::*;<|fim_prefix|>// repo: mikialex/rendiation path: /platform/graphics/vulkan/src/lib.rs #![allow(dead_code)] use std::ffi::{c_void, CStr, CString}; use anyhow::Result; use ash::{extensions::ext::DebugUtils, vk, Entry, Instance as AshInstance}; use raw_window_handle::HasRawDi...
code_fim
easy
{ "lang": "rust", "repo": "mikialex/rendiation", "path": "/platform/graphics/vulkan/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iggy-rs/iggy path: /streaming/src/topics/storage.rs use crate::partitions::partition::Partition; use crate::persister::Persister; use crate::storage::{Storage, TopicStorage}; use crate::topics::consumer_group::ConsumerGroup; use crate::topics::topic::Topic; use crate::utils::file; use async_trai...
code_fim
hard
{ "lang": "rust", "repo": "iggy-rs/iggy", "path": "/streaming/src/topics/storage.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } } #[async_trait] impl Storage<Topic> for FileTopicStorage { async fn load(&self, topic: &mut Topic) -> Result<(), Error> { info!( "Loading topic with ID: {} for stream with ID: {} from disk...", topic.topic_id, topic.stream_id ); if...
code_fim
hard
{ "lang": "rust", "repo": "iggy-rs/iggy", "path": "/streaming/src/topics/storage.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: utilForever/BOJ path: /Rust/8885 - Pirate Chest.rs use io::Write; use std::{cmp, io, mem, str}; pub struct UnsafeScanner<R> { reader: R, buf_str: Vec<u8>, buf_iter: str::SplitAsciiWhitespace<'static>, } impl<R: io::BufRead> UnsafeScanner<R> { pub fn new(reader: R) -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "utilForever/BOJ", "path": "/Rust/8885 - Pirate Chest.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if a > b { mem::swap(&mut a, &mut b); } for i in 0..m { for j in 0..n { pond[i][j] = scan.token::<i64>(); } } let area_chest = (m * n) as i64; let mut ans = 0; for i in 0..m { let mut depth = vec![1_000_000_007_i64; n]; let...
code_fim
hard
{ "lang": "rust", "repo": "utilForever/BOJ", "path": "/Rust/8885 - Pirate Chest.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for k in 0..n { depth[k] = cmp::min(depth[k], pond[j][k]); } for k in 0..n { if stack.is_empty() || depth[*stack.last().unwrap() as usize] < depth[k] { left[k] = k; stack.push(k); }...
code_fim
hard
{ "lang": "rust", "repo": "utilForever/BOJ", "path": "/Rust/8885 - Pirate Chest.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: biluohc/utils path: /r4j/src/logflex.rs use flexi_logger::{Logger, Cleanup, FlexiLoggerError}; use log::Record; use chrono; use std::{self, io}; use std::sync::atomic::{AtomicUsize, Ordering}; use self::colors::{Color, ColoredLevelConfig}; static mut COLORS: Option<ColoredLevelConfig> = None...
code_fim
hard
{ "lang": "rust", "repo": "biluohc/utils", "path": "/r4j/src/logflex.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> vec![ "mio", "tokio_reactor", "tokio_core", "tokio", "tokio_threadpool", "hyper", "want", "tokio_io", ].into_iter().for_each(|c|filiter.push_str(&format!(", {}=info", c))); Logger::with_env_or_str(filiter) // .log_to_...
code_fim
hard
{ "lang": "rust", "repo": "biluohc/utils", "path": "/r4j/src/logflex.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: longfangsong/nostdhf path: /src/lib.rs //! This crate polyfills the missing methods on f32 and f64 in no_std environments #![no_std] #![warn( missing_docs, rust_2018_idioms, trivial_casts, trivial_numeric_casts, unused_qualifications )] #![feature(core_intrinsics)] <|fim_suf...
code_fim
easy
{ "lang": "rust", "repo": "longfangsong/nostdhf", "path": "/src/lib.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>pub use crate::f32ext::F32Ext; pub use crate::f64ext::F64Ext;<|fim_prefix|>// repo: longfangsong/nostdhf path: /src/lib.rs //! This crate polyfills the missing methods on f32 and f64 in no_std environments #![no_std] #![warn( missing_docs, rust_2018_idioms, trivial_casts, trivial_numeric_...
code_fim
easy
{ "lang": "rust", "repo": "longfangsong/nostdhf", "path": "/src/lib.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>), Self::TsAccessibilityModifier(node) => node.to_format_element(formatter), Self::JsStaticModifier(node) => node.to_format_element(formatter), Self::TsReadonlyModifier(node) => node.to_format_element(formatter), Self::TsOverrideModifier(node) => node.to_for...
code_fim
hard
{ "lang": "rust", "repo": "Tembocs/rome", "path": "/crates/rome_js_formatter/src/ts/any/property_signature_modifier.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tembocs/rome path: /crates/rome_js_formatter/src/ts/any/property_signature_modifier.rs //! Generated file, do not edit by hand, see `xtask/codegen` use crate::{FormatElement, FormatResult, Formatter, ToFormatElement}; use rome_js_syntax::TsAnyPropertySignatureModifier; impl ToFormatElement for ...
code_fim
hard
{ "lang": "rust", "repo": "Tembocs/rome", "path": "/crates/rome_js_formatter/src/ts/any/property_signature_modifier.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Bingwen-Hu/hackaway path: /books/algorithms/rust/bubbleSort.rs /** * 10, 34, 2, 45, 6, 8, 7, 4, 1, 3 * 1, 10, 34, 2, 45, 6, 8, 7, 4, 3 * 1, 2, 10, 34, 3, 45, 6, 8, 7, 4 * ....... */ <|fim_suffix|> let mut temp: i32; for i in 1..a.len() { for j in (i..a.l...
code_fim
medium
{ "lang": "rust", "repo": "Bingwen-Hu/hackaway", "path": "/books/algorithms/rust/bubbleSort.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let mut temp: i32; for i in 1..a.len() { for j in (i..a.len()).rev() { if a[j] < a[j-1] { temp = a[j-1]; a[j-1] = a[j]; a[j] = temp; } } } println!("{:10} {:?}", "Sorted:", a) }<|fim_prefix|>// repo:...
code_fim
medium
{ "lang": "rust", "repo": "Bingwen-Hu/hackaway", "path": "/books/algorithms/rust/bubbleSort.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oday0311/imkey-core path: /device/src/cos_upgrade.rs use crate::app_download::AppDownloadRequest; use crate::device_manager::{get_bl_version, get_cert, get_firmware_version, get_se_id, get_sn}; use crate::error::ImkeyError; use crate::ServiceResponse; use crate::{Result, TsmService}; use common:...
code_fim
hard
{ "lang": "rust", "repo": "oday0311/imkey-core", "path": "/device/src/cos_upgrade.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut request_data = CosUpgradeRequest { seid: seid.clone(), sn: sn, device_cert: device_cert.clone(), se_cos_version: se_cos_version, is_bl_status: is_bl_status, step_key: if is_jump { "03".to_string() ...
code_fim
hard
{ "lang": "rust", "repo": "oday0311/imkey-core", "path": "/device/src/cos_upgrade.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> //If we got this far, it means we went through the entire file and couldn't find the header return None; } else if header_buffer != HEADER { return None; } Some(0) } ///Finds and returns the next entry data with the associated entry flag ///This function ass...
code_fim
hard
{ "lang": "rust", "repo": "bencecile/binary-flare", "path": "/src/formats/xp3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Some(self.cmp(other)) } } impl PartialEq for ArchiveItem { fn eq(&self, other: &ArchiveItem) -> bool { self.name == other.name } } impl Eq for ArchiveItem {} #[derive(Debug)] struct ArchiveSegment { start: u64, offset: u64, //This is offset in the new fil...
code_fim
hard
{ "lang": "rust", "repo": "bencecile/binary-flare", "path": "/src/formats/xp3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bencecile/binary-flare path: /src/formats/xp3.rs for name in 4 bytes of data // Read size from u64 LE // Throw if size is larger than 32 bits // If the first name lookup worked, set the in size to size and return true // Increment the read bytes by the u64 siz...
code_fim
hard
{ "lang": "rust", "repo": "bencecile/binary-flare", "path": "/src/formats/xp3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let s = String::from("Hi Patrice nice to meet you"); let s_split = s.split(" "); let v_split: Vec<&str> = s_split.collect(); println!("{:?}", v_split); }<|fim_prefix|>// repo: Tenjin0/rust-leetcode path: /longest_sub/src/main.rs fn longuest_sub<'a>(a: &'a str, b: &'a str) -> Option<&'a...
code_fim
easy
{ "lang": "rust", "repo": "Tenjin0/rust-leetcode", "path": "/longest_sub/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tenjin0/rust-leetcode path: /longest_sub/src/main.rs fn longuest_sub<'a>(a: &'a str, b: &'a str) -> Option<&'a str> { <|fim_suffix|>fn main() { let s = String::from("Hi Patrice nice to meet you"); let s_split = s.split(" "); let v_split: Vec<&str> = s_split.collect(); println!(...
code_fim
easy
{ "lang": "rust", "repo": "Tenjin0/rust-leetcode", "path": "/longest_sub/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: utilForever/BOJ path: /Rust/27444 - Pop Star Music Gate.rs use io::Write; use std::{io, str}; pub struct UnsafeScanner<R> { reader: R, buf_str: Vec<u8>, buf_iter: str::SplitAsciiWhitespace<'static>, } impl<R: io::BufRead> UnsafeScanner<R> { pub fn new(reader: R) -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "utilForever/BOJ", "path": "/Rust/27444 - Pop Star Music Gate.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if notes.iter().all(|&x| x != 0) { long_ended = true; } else if long_started { long_ended = true; } else { long_started = true; ...
code_fim
hard
{ "lang": "rust", "repo": "utilForever/BOJ", "path": "/Rust/27444 - Pop Star Music Gate.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while idx < notes.len() { match notes[idx] { 0 => idx += 1, 1 => { idx += 1; len_note += 1; } 2 => { let mut should_calculate = false; if idx...
code_fim
hard
{ "lang": "rust", "repo": "utilForever/BOJ", "path": "/Rust/27444 - Pop Star Music Gate.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("======== Day 6 ========"); println!("Part 1 = {}", num_any_question); println!("Part 2 = {}", num_all_questions); } #[cfg(test)] mod tests { use super::*; #[test] fn test_count_any_question() { let text = "ab\nbc\nq\n\nb\nd\nq\n"; assert_eq!(count_any_qu...
code_fim
hard
{ "lang": "rust", "repo": "jonathanlofgren/advent_of_code_2020", "path": "/src/day_6.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonathanlofgren/advent_of_code_2020 path: /src/day_6.rs use std::fs; use std::collections::HashSet; fn count_any_question(text: &str) -> Vec<usize> { text .split("\n\n") .map(|s| s.replace("\n", "").chars().collect::<HashSet<_>>().len()) .collect() } <|fim_suffix|>...
code_fim
hard
{ "lang": "rust", "repo": "jonathanlofgren/advent_of_code_2020", "path": "/src/day_6.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_count_all_questions() { let text = "ab\nbc\nbqa\n\nb\ndb\nq\n"; assert_eq!(count_all_questions(text), vec![1, 0]); } }<|fim_prefix|>// repo: jonathanlofgren/advent_of_code_2020 path: /src/day_6.rs use std::fs; use std::collections::HashSet; fn count_any_quest...
code_fim
medium
{ "lang": "rust", "repo": "jonathanlofgren/advent_of_code_2020", "path": "/src/day_6.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Krenodeno/YARRT path: /src/materials/mod.rs mod material; pub use material::Material; mod lambertian; pub use lambertian::Lambertian; mod metal; pub use metal::Metal; mod dielectric; pub use dielectric::Dielectric; mod emissive; pub use emissive::Emissive; use rand::Rng; use std::f64::consts::P...
code_fim
medium
{ "lang": "rust", "repo": "Krenodeno/YARRT", "path": "/src/materials/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// More intuitive distribution pub fn random_in_hemisphere(normal: Vec3) -> Vec3 { let in_unit_sphere = random_in_unit_sphere(); if dot(in_unit_sphere, normal) > 0.0 { in_unit_sphere } else { -in_unit_sphere } } pub fn random_in_unit_sphere() -> Vec3 { let mut rng = r...
code_fim
hard
{ "lang": "rust", "repo": "Krenodeno/YARRT", "path": "/src/materials/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ithinuel/atsam4e path: /pac/atsam4e16c/src/wdt/cr.rs #[doc = "Writer for register CR"] pub type W = crate::W<u32, super::CR>; #[doc = "Write proxy for field `WDRSTT`"] pub struct WDRSTT_W<'a> { w: &'a mut W, } impl<'a> WDRSTT_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] ...
code_fim
hard
{ "lang": "rust", "repo": "ithinuel/atsam4e", "path": "/pac/atsam4e16c/src/wdt/cr.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>& 0xff) << 24); self.w } } impl W { #[doc = "Bit 0 - Watchdog Restart"] #[inline(always)] pub fn wdrstt(&mut self) -> WDRSTT_W { WDRSTT_W { w: self } } #[doc = "Bits 24:31 - Password"] #[inline(always)] pub fn key(&mut self) -> KEY_W { KEY_W { w: sel...
code_fim
hard
{ "lang": "rust", "repo": "ithinuel/atsam4e", "path": "/pac/atsam4e16c/src/wdt/cr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut event_loop = tokio::runtime::Runtime::new().unwrap(); let task = event_loop.spawn(async { println!("{}", 1) }); // core::result::Result<(), tokio::task::error::JoinError> let r : Result<_,_> = event_loop.block_on(task); println!("{}", type_of(r)) }<|fim_prefix|>// ...
code_fim
easy
{ "lang": "rust", "repo": "growingspaghetti/my-thread-coroutine-nonblockingio-scrapbox", "path": "/rs-tokio/src/bin/main9.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: growingspaghetti/my-thread-coroutine-nonblockingio-scrapbox path: /rs-tokio/src/bin/main9.rs // https://docs.rs/tokio/0.2.11/tokio/runtime/struct.Runtime.html <|fim_suffix|> // core::result::Result<(), tokio::task::error::JoinError> let r : Result<_,_> = event_loop.block_on(task); pr...
code_fim
hard
{ "lang": "rust", "repo": "growingspaghetti/my-thread-coroutine-nonblockingio-scrapbox", "path": "/rs-tokio/src/bin/main9.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kissmikijr/caolo-backend path: /sim/simulation/src/intents/dropoff_intent.rs use crate::components::{ Bot, CarryComponent, EnergyComponent, OwnedEntity, PositionComponent, Resource, }; use crate::indices::{EntityId, UserId}; use crate::scripting_api::OperationResult; use crate::storage::view...
code_fim
hard
{ "lang": "rust", "repo": "kissmikijr/caolo-backend", "path": "/sim/simulation/src/intents/dropoff_intent.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let target = intent.structure; let nearby = positions.get(id).and_then(|botpos| { positions.get(target).map(|targetpos| { targetpos.0.room == botpos.0.room && targetpos.0.pos.hex_distance(botpos.0.pos) <= DROPOFF_RANGE }) }); match nearby { ...
code_fim
hard
{ "lang": "rust", "repo": "kissmikijr/caolo-backend", "path": "/sim/simulation/src/intents/dropoff_intent.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jeremie-martin/paste-html-vim-server path: /src/main.rs #![feature(bool_to_option)] use actix_web::{http::StatusCode, web, App, HttpResponse, HttpServer}; use itertools::FoldWhile::{Continue, Done}; use itertools::Itertools; use num::Bounded; use rand::distributions::Alphanumeric; use rand::Rng...
code_fim
hard
{ "lang": "rust", "repo": "jeremie-martin/paste-html-vim-server", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>async fn file(filename: web::Path<String>) -> HttpResponse { match fs::read_to_string(format!("{}{}", PASTE_FOLDER, filename)) { Ok(content) => HttpResponse::Ok().body(content), Err(_) => HttpResponse::NotFound().body("Paste not found"), } } async fn receive_html(html: web::Json<H...
code_fim
hard
{ "lang": "rust", "repo": "jeremie-martin/paste-html-vim-server", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seanmonstar/warp path: /tests/filter.rs #![deny(warnings)] use std::convert::Infallible; use warp::Filter; #[tokio::test] async fn flattens_tuples() { let _ = pretty_env_logger::try_init(); let str1 = warp::any().map(|| "warp"); let true1 = warp::any().map(|| true); let unit1 =...
code_fim
hard
{ "lang": "rust", "repo": "seanmonstar/warp", "path": "/tests/filter.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Recover can be infallible let f = a.recover(|_| async move { Ok::<_, Infallible>("shh") }); let _: Result<_, Infallible> = warp::test::request().filter(&f).await; } #[tokio::test] async fn unify() { let _ = pretty_env_logger::try_init(); let a = warp::path::param::<u32>(); le...
code_fim
hard
{ "lang": "rust", "repo": "seanmonstar/warp", "path": "/tests/filter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let ok = warp::any().map(warp::reply); let req = warp::test::request(); let resp = req.reply(&ok).await; assert_eq!(resp.status(), 200); } #[tokio::test] async fn or() { let _ = pretty_env_logger::try_init(); // Or can be combined with an infallible filter let a = warp::path...
code_fim
hard
{ "lang": "rust", "repo": "seanmonstar/warp", "path": "/tests/filter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // draw if draw flag is set // store key press state } }<|fim_prefix|>// repo: d2ci8xc5/chip8vm path: /src/main.rs mod color; mod cpu; mod display; mod font; mod keypad; use cpu::cpu as _cpu; use std::env; use sdl2; <|fim_middle|>fn main() { let args: Vec<String> = env::args()....
code_fim
hard
{ "lang": "rust", "repo": "d2ci8xc5/chip8vm", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: d2ci8xc5/chip8vm path: /src/main.rs mod color; mod cpu; mod display; mod font; mod keypad; use cpu::cpu as _cpu; use std::env; use sdl2; <|fim_suffix|> let args: Vec<String> = env::args().collect(); if args.iter().len() == 1 { } for arg in args.iter() { println!("{}", ar...
code_fim
medium
{ "lang": "rust", "repo": "d2ci8xc5/chip8vm", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: archer884/media-get path: /src/media.rs pub mod imgur; use crate::prelude::*; use reqwest::blocking::ClientBuilder; use std::collections::VecDeque; use std::io::{self, Read}; use url::Url; static USER_AGENT: &str = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) \ AppleWebKit/537.36 (KHTM...
code_fim
hard
{ "lang": "rust", "repo": "archer884/media-get", "path": "/src/media.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use reqwest::header::CONTENT_DISPOSITION; match self.current.pop_front() { Some(url) => match self.client.get(&url).send() { Ok(response) => { let disposition = response.headers().get(CONTENT_DISPOSITION).and_then(|h| { ...
code_fim
hard
{ "lang": "rust", "repo": "archer884/media-get", "path": "/src/media.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Read for Task { fn read(&mut self, b: &mut [u8]) -> io::Result<usize> { self.response.read(b) } } impl<T: Accessor> Iterator for TaskProvider<T> { type Item = Result<Task>; fn next(&mut self) -> Option<Self::Item> { use reqwest::header::CONTENT_DISPOSITION; ...
code_fim
hard
{ "lang": "rust", "repo": "archer884/media-get", "path": "/src/media.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns a `FakeClock` instance representing the current instant. pub fn now() -> Self { let time = Self::time(); FakeClock { time_created: time } } /// Returns the duration that passed between `self` and `earlier`. pub fn duration_since(self, earlier: Self) -> Dura...
code_fim
hard
{ "lang": "rust", "repo": "tsidea/fake_clock", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tsidea/fake_clock path: /src/lib.rs // Copyright 2018 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>, at ...
code_fim
hard
{ "lang": "rust", "repo": "tsidea/fake_clock", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Sub<Duration> for FakeClock { type Output = FakeClock; fn sub(mut self, other: Duration) -> FakeClock { self.time_created -= other.as_secs() * 1000 + u64::from(other.subsec_nanos()) / 1_000_000; self } } impl Sub<FakeClock> for FakeClock { type Output = Duration; ...
code_fim
hard
{ "lang": "rust", "repo": "tsidea/fake_clock", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fossabot/sahke path: /src/requests/payloads/answer_inline_query.rs use serde::{Deserialize, Serialize}; use crate::{ requests::{dynamic, json, Method}, types::InlineQueryResult, types::True, }; /// Use this method to send answers to an inline query. On success, True is returned.No ...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/sahke", "path": "/src/requests/payloads/answer_inline_query.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn cache_time(mut self, val: i32) -> Self { self.payload.cache_time = Some(val); self } #[allow(clippy::wrong_self_convention)] pub fn is_personal(mut self, val: bool) -> Self { self.payload.is_personal = Some(val); self } pub fn next_offset<T>...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/sahke", "path": "/src/requests/payloads/answer_inline_query.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!(!IntCmp::cmp_ne(usize::MIN, usize::MIN as i128)); assert!(IntCmp::cmp_ne(usize::MIN, -1_i128)); assert!(IntCmp::cmp_ne(usize::MIN, i128::MIN)); assert!(IntCmp::cmp_ne(usize::MAX, i128::MAX)); assert!(!IntCmp::cmp_ne(usize::MAX, usize::MAX as i128)); } ...
code_fim
hard
{ "lang": "rust", "repo": "Mikastiv/int_cmp", "path": "/tests/usize_cmp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Mikastiv/int_cmp path: /tests/usize_cmp.rs use int_cmp::IntCmp; mod usize_i8_cmp { use super::*; #[test] fn eq() { assert!(IntCmp::cmp_eq(usize::MIN, usize::MIN as i8)); assert!(!IntCmp::cmp_eq(1_usize, -1_i8)); assert!(!IntCmp::cmp_eq(usize::MIN, i8::MIN)); ...
code_fim
hard
{ "lang": "rust", "repo": "Mikastiv/int_cmp", "path": "/tests/usize_cmp.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ChezRD/blockchain-voting_2021_extracted path: /blockchain/key-generator-source/src/subcommands/generate.rs use exonum_sodiumoxide::crypto::box_; use hex; use serde::{Deserialize, Serialize}; use serde_json::{json, to_string_pretty}; use std::error::Error; use crate::{cryptor::test_cryptor, erro...
code_fim
hard
{ "lang": "rust", "repo": "ChezRD/blockchain-voting_2021_extracted", "path": "/blockchain/key-generator-source/src/subcommands/generate.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let cryptosystem_json = json!({ "publicKey": public_key_as_string, "privateKey": private_key_as_string, }); let cryptosystem_json = to_string_pretty(&cryptosystem_json).unwrap(); println!("{}", cryptosystem_json); Ok(()) }<|fim_prefix|>// repo: ChezRD/blockchain-voting_20...
code_fim
hard
{ "lang": "rust", "repo": "ChezRD/blockchain-voting_2021_extracted", "path": "/blockchain/key-generator-source/src/subcommands/generate.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tz70s/rust-prac path: /native_type_02/src/main.rs // simple practice of rust-by-example // ch2 of native types fn main() { println!("Hello, world!"); println!("The usage of matrix transformation\n"); matrix_transformation(); println!("The usage of array & slice\n"); use_ar...
code_fim
medium
{ "lang": "rust", "repo": "tz70s/rust-prac", "path": "/native_type_02/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // print from first to the fourth use_slice(&short_array[0..3]); // print from first to the tenth use_slice(&long_array[..9]); } fn use_slice(s: &[i32]) { println!("The slice is : {:?}", s); }<|fim_prefix|>// repo: tz70s/rust-prac path: /native_type_02/src/main.rs // simple practice...
code_fim
hard
{ "lang": "rust", "repo": "tz70s/rust-prac", "path": "/native_type_02/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let m_str = serde_json::to_string(&message).unwrap(); println!("{}", m_str); let mut msg: HashMap<String, String> = serde_json::from_str(&m_str).unwrap(); println!("{:?}", msg); } #[test] fn test_timeout() { } }<|fim_prefix|>// repo: dragfire/ruft path: ...
code_fim
hard
{ "lang": "rust", "repo": "dragfire/ruft", "path": "/src/message.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut message = HashMap::new(); message.insert("reply_to", "127.0.0.1:6000"); message.insert("action", "heartbeat"); let m_str = serde_json::to_string(&message).unwrap(); println!("{}", m_str); let mut msg: HashMap<String, String> = serde_json::from_str(...
code_fim
hard
{ "lang": "rust", "repo": "dragfire/ruft", "path": "/src/message.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dragfire/ruft path: /src/message.rs use serde::{Serialize, Deserialize}; use std::collections::HashMap; #[derive(Debug, Serialize, Deserialize)] pub struct Message { pub content: HashMap<String, String>, } impl Message { pub fn new() -> Self { Message { content: Has...
code_fim
hard
{ "lang": "rust", "repo": "dragfire/ruft", "path": "/src/message.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return word == word.chars().rev().collect::<String>(); }<|fim_prefix|>// repo: yogaxpto/Project-Euler path: /src/Problem_04/main.rs fn main() { let mut max: u32 = 0; for i in (1..999).rev() { for k in (1..i).rev() { let product: u32 = i * k; if is_palindrome((p...
code_fim
easy
{ "lang": "rust", "repo": "yogaxpto/Project-Euler", "path": "/src/Problem_04/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yogaxpto/Project-Euler path: /src/Problem_04/main.rs fn main() { let mut max: u32 = 0; for i in (1..999).rev() { for k in (1..i).rev() { let product: u32 = i * k; if is_palindrome((product).to_string()) && product > max { max = product; ...
code_fim
easy
{ "lang": "rust", "repo": "yogaxpto/Project-Euler", "path": "/src/Problem_04/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JoshMcguigan/cargo-run-script path: /src/arg_parse.rs use std::fmt::Debug; pub struct Args { /// name of the script to be executed as specified in Cargo.toml pub script: Option<String>, } pub fn parse<T>(mut args: Vec<T>) -> Args where T: Into<String> + Debug, Optio...
code_fim
hard
{ "lang": "rust", "repo": "JoshMcguigan/cargo-run-script", "path": "/src/arg_parse.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Testing during development, with script name and no additional args // cargo run hello let incoming_args = vec!["target/debug/cargo-run-script", "hello"]; let args = parse(incoming_args); assert_eq!(Some("hello".into()), args.script); } }<|fim_prefix|>// r...
code_fim
medium
{ "lang": "rust", "repo": "JoshMcguigan/cargo-run-script", "path": "/src/arg_parse.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32f7/src/stm32f7x3/exti/swier.rs #[doc = "Register `SWIER` reader"] pub type R = crate::R<SWIER_SPEC>; #[doc = "Register `SWIER` writer"] pub type W = crate::W<SWIER_SPEC>; #[doc = "Field `SWIER0` reader - Software Interrupt on line 0"] pub type SWIER0_R = c...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32f7/src/stm32f7x3/exti/swier.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>_R::new(((self.bits >> 11) & 1) != 0) } #[doc = "Bit 12 - Software Interrupt on line 12"] #[inline(always)] pub fn swier12(&self) -> SWIER12_R { SWIER12_R::new(((self.bits >> 12) & 1) != 0) } #[doc = "Bit 13 - Software Interrupt on line 13"] #[inline(always)] pub fn...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32f7/src/stm32f7x3/exti/swier.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Display for Developer<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", &self.name) } }<|fim_prefix|>// repo: transparencies/speedrun-api path: /src/types/developer_impls.rs use std::fmt::Display; use crate::api::developers::DeveloperId; use...
code_fim
easy
{ "lang": "rust", "repo": "transparencies/speedrun-api", "path": "/src/types/developer_impls.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: transparencies/speedrun-api path: /src/types/developer_impls.rs use std::fmt::Display; use crate::api::developers::DeveloperId; <|fim_suffix|>impl Display for Developer<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", &self.name) } }<|f...
code_fim
medium
{ "lang": "rust", "repo": "transparencies/speedrun-api", "path": "/src/types/developer_impls.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn part2_1() { assert_eq!(part2(INPUT), "10100001110101001"); } pub const INPUT: &[u8] = &[1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1];<|fim_prefix|>// repo: Mark-Simulacrum/advent-of-code path: /src/bin/y2016/day16.rs fn compute(input: &[u8], disk_size: usize) -> String { let mut...
code_fim
hard
{ "lang": "rust", "repo": "Mark-Simulacrum/advent-of-code", "path": "/src/bin/y2016/day16.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Mark-Simulacrum/advent-of-code path: /src/bin/y2016/day16.rs fn compute(input: &[u8], disk_size: usize) -> String { let mut data = Vec::from(input); while data.len() < disk_size { let a = data; let mut b = a.clone(); b.reverse(); for x in &mut b { ...
code_fim
hard
{ "lang": "rust", "repo": "Mark-Simulacrum/advent-of-code", "path": "/src/bin/y2016/day16.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LEAFERx/Movable path: /symbolic_vm/src/types/values/mod.rs pub mod values_impl; pub mod account_address; pub mod primitives; pub mod types; pub use values_impl::*; pub use account_address::*; pub use primitives::*; use move_core_types::language_storage::TypeTag; use vm::errors::PartialVMResult...
code_fim
medium
{ "lang": "rust", "repo": "LEAFERx/Movable", "path": "/symbolic_vm/src/types/values/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub trait SymbolicMoveValue<'ctx> { fn as_runtime_ast(&self, ty_ctx: &TypeContext<'ctx>) -> PartialVMResult<Dynamic<'ctx>>; fn as_value_ast(&self, ty_ctx: &TypeContext<'ctx>, ty: &TypeTag) -> PartialVMResult<Dynamic<'ctx>> { Ok(ty_ctx.runtime_ast_to_value_ast(self.as_runtime_ast(ty_ctx)?, ty)) ...
code_fim
medium
{ "lang": "rust", "repo": "LEAFERx/Movable", "path": "/symbolic_vm/src/types/values/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/librustc_target/spec/i686_unknown_uefi.rs // This defines the ia32 target for UEFI systems as described in the UEFI specification. See the // uefi-base module for generic UEFI options. On ia32 systems // UEFI systems always run in protected-mode, have t...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_target/spec/i686_unknown_uefi.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Use -GNU here, because of the reason below: // Backgound and Problem: // If we use i686-unknown-windows, the LLVM IA32 MSVC generates compiler intrinsic // _alldiv, _aulldiv, _allrem, _aullrem, _allmul, which will cause undefined symbol. // A real issue is __aulldiv() is refer...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_target/spec/i686_unknown_uefi.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // UEFI mirrors the calling-conventions used on windows. In case of i686 this means small // structs will be returned as int. This shouldn't matter much, since the restrictions placed // by the UEFI specifications forbid any ABI to return structures. base.abi_return_struct_as_int = true; ...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_target/spec/i686_unknown_uefi.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut seen: HashSet<(usize, usize)> = HashSet::new(); let mut counter = 0; for x in 0..128 { for y in 0..128 { if !seen.contains(&(x,y)) && bits[x][y] { mark_region(&bits, &mut seen, (x, y)); counter += 1; } } } ...
code_fim
hard
{ "lang": "rust", "repo": "Soft/advent-of-code", "path": "/src/day14.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Soft/advent-of-code path: /src/day14.rs extern crate knot_hash; extern crate bit_vec; use std::collections::{HashSet, VecDeque}; use bit_vec::BitVec; const INPUT: &str = "jzgqcdpd"; fn neighbors((x, y): (usize, usize), bounds: usize) -> Vec<(usize, usize)> { let x = x as isize; let y ...
code_fim
hard
{ "lang": "rust", "repo": "Soft/advent-of-code", "path": "/src/day14.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>+ pub fn execvpe( + file: *const ::c_char, + argv: *const *const ::c_char, + envp: *const *const ::c_char, + ) -> ::c_int; + pub fn extattr_delete_fd( fd: ::c_int, attrnamespace: ::c_int,<|fim_prefix|>// repo: drscream/pkgsrc path: /sysutils/tealdeer/patc...
code_fim
hard
{ "lang": "rust", "repo": "drscream/pkgsrc", "path": "/sysutils/tealdeer/patches/patch-.._vendor_libc-0.2.112_src_unix_bsd_netbsdlike_netbsd_mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drscream/pkgsrc path: /sysutils/tealdeer/patches/patch-.._vendor_libc-0.2.112_src_unix_bsd_netbsdlike_netbsd_mod.rs $NetBSD: patch-.._vendor_libc-0.2.112_src_unix_bsd_netbsdlike_netbsd_mod.rs,v 1.1 2022/01/01 19:32:04 bsiegert Exp $ <|fim_suffix|>+ pub fn execvpe( + file: *const ::c_c...
code_fim
hard
{ "lang": "rust", "repo": "drscream/pkgsrc", "path": "/sysutils/tealdeer/patches/patch-.._vendor_libc-0.2.112_src_unix_bsd_netbsdlike_netbsd_mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } } }<|fim_prefix|>// repo: fosterdill/rust-gol path: /src/lib.rs pub mod engine; #[cfg(test)] mod tests { mod engine { use super::super::engine::*; <|fim_middle|> #[test] fn test_cell() {
code_fim
easy
{ "lang": "rust", "repo": "fosterdill/rust-gol", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fosterdill/rust-gol path: /src/lib.rs pub mod engine; #[cfg(test)] mod tests { mod engine { use super::super::engine::*; <|fim_suffix|> } } }<|fim_middle|> #[test] fn test_cell() {
code_fim
easy
{ "lang": "rust", "repo": "fosterdill/rust-gol", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: droundy/display-as path: /display-as/src/mathlatex.rs //! Format as LaTeX math mode use super::*; /// Format as LaTeX math mode. #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct Math; impl Format for Math { fn mime() -> mime::Mime { return "text/x-latex".pars...
code_fim
hard
{ "lang": "rust", "repo": "droundy/display-as", "path": "/display-as/src/mathlatex.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(&format_as!(Math, 3.0).into_string(), "3"); assert_eq!(&format_as!(Math, 3e5).into_string(), r"3\times10^{5}"); assert_eq!(&format_as!(Math, 1e5).into_string(), r"10^{5}"); assert_eq!(&format_as!(Math, 3e4).into_string(), "30000"); }<|fim_prefix|>// repo: droundy/display-as pat...
code_fim
hard
{ "lang": "rust", "repo": "droundy/display-as", "path": "/display-as/src/mathlatex.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: indygreg/starlark-rust path: /starlark/src/eval/tests/call.rs /* * Copyright 2018 The Starlark in Rust Authors. * Copyright (c) Facebook, Inc. and its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the Li...
code_fim
hard
{ "lang": "rust", "repo": "indygreg/starlark-rust", "path": "/starlark/src/eval/tests/call.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn funcall_extra_args_def() { fn f(x: &str) -> String { format!( " def f3(a, b, c): return a + b + c {}", x ) } assert::fail(&f("f3(1,2,3,4)"), "extra positional"); assert::fail(&f("f3(1,2)"), "Missing parameter"); assert::fail(&f("f3(...
code_fim
hard
{ "lang": "rust", "repo": "indygreg/starlark-rust", "path": "/starlark/src/eval/tests/call.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }