text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: RunOnceEx/memlib-rs path: /src/system/functions.rs use super::*; use super::util::run_async; use tarpc::context; <|fim_suffix|>pub fn move_mouse_relative(dx: i32, dy: i32) { run_async(async move { get_connection().move_mouse_relative(context::current(), dx, dy).await.unwrap() })...
code_fim
hard
{ "lang": "rust", "repo": "RunOnceEx/memlib-rs", "path": "/src/system/functions.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>(); let module = p.parse().unwrap(); println!("{:#?}", module); }<|fim_prefix|>// repo: rusty-ecma/RESSA path: /examples/simple_module.rs extern crate ressa; use ressa::*; fn main() { let js = include_str!(<|fim_middle|>"simple.mjs"); let mut p = Parser::builder() .module(true) ...
code_fim
medium
{ "lang": "rust", "repo": "rusty-ecma/RESSA", "path": "/examples/simple_module.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> .tolerant(false) .js(js) .build() .unwrap(); let module = p.parse().unwrap(); println!("{:#?}", module); }<|fim_prefix|>// repo: rusty-ecma/RESSA path: /examples/simple_module.rs extern crate ressa; use ressa::*; fn main() { let js = include_str!(<|fim_middle|>"...
code_fim
medium
{ "lang": "rust", "repo": "rusty-ecma/RESSA", "path": "/examples/simple_module.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rusty-ecma/RESSA path: /examples/simple_module.rs extern crate ressa; use ressa::*; fn main() { let js = include_str!(<|fim_suffix|>(); let module = p.parse().unwrap(); println!("{:#?}", module); }<|fim_middle|>"simple.mjs"); let mut p = Parser::builder() .module(true) ...
code_fim
medium
{ "lang": "rust", "repo": "rusty-ecma/RESSA", "path": "/examples/simple_module.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let path = current_dir()?; let file = path.join("config.log"); let mut config = OpenOptions::new() .read(true) .create(true) .write(true) .open(&file)?; let size = config.metadata()?.len(); if size > 0 { let mut engine_info = String::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "f3r10/talent-plan-kvs", "path": "/src/bin/kvs-server.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: f3r10/talent-plan-kvs path: /src/bin/kvs-server.rs extern crate slog; use kvs::KvStoreError; use std::io::prelude::*; use clap::{App, Arg}; use kvs::KvStore; use kvs::RayonThreadPool; use kvs::SharedQueueThreadPool; use kvs::SledKvsEngine; use kvs::ThreadPool; use kvs::{KvsServer, Result}; use ...
code_fim
hard
{ "lang": "rust", "repo": "f3r10/talent-plan-kvs", "path": "/src/bin/kvs-server.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn start_server(engine: String, addr: String) -> Result<()> { let path = current_dir()?; let engine_check = check_engine(engine.to_owned())?; if engine_check { match engine.as_ref() { "kvs" => { let store: KvStore = KvStore::open(path)?; let ...
code_fim
hard
{ "lang": "rust", "repo": "f3r10/talent-plan-kvs", "path": "/src/bin/kvs-server.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[inline] fn check_result(result: HRESULT) -> Result<(), IoError> { if result < 0 { Err(IoError::from_raw_os_error(result)) } else { Ok(()) } }<|fim_prefix|>// repo: mitchmindtree/cpal path: /src/wasapi/mod.rs extern crate winapi; use std::io::Error as IoError; pub use self:...
code_fim
medium
{ "lang": "rust", "repo": "mitchmindtree/cpal", "path": "/src/wasapi/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mitchmindtree/cpal path: /src/wasapi/mod.rs extern crate winapi; use std::io::Error as IoError; pub use self::device::{Device, Devices, SupportedInputFormats, SupportedOutputFormats, default_input_device, default_output_device}; pub use self::stream::{InputBuffer, OutputBuffer, EventLoop, Stre...
code_fim
medium
{ "lang": "rust", "repo": "mitchmindtree/cpal", "path": "/src/wasapi/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // ConcatSeparated(ir.rules.len(), quote! { , }); // Dup(); // MakeEnumStreamParserCommonParseImpl(); // for (n, rule) in ir.rules.iter().enumerate() { // let capitalized = capitalize(&rule.name.to_string()[..]); // let variant = rs::str_to_ident(&ca...
code_fim
hard
{ "lang": "rust", "repo": "pczarn/panini", "path": "/panini_logic/src/output/instruction.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[generate_list] pub fn translate_ir(translator: &mut IrTranslator) -> Vec<Instruction> { // MakeCommonDefinitions(); for &terminal in &translator.terminals { MakeTerminalAccessorFn { terminal, } } let map = translator.ir.maps...
code_fim
hard
{ "lang": "rust", "repo": "pczarn/panini", "path": "/panini_logic/src/output/instruction.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pczarn/panini path: /panini_logic/src/output/instruction.rs use std::collections::HashMap; use cfg::Symbol; use enum_coder::enum_coder; use input::FragmentId; use middle::symbol_maps::InputSymbol; use output::translator::IrTranslator; #[derive(Debug, Eq, PartialEq)] pub struct InstructionList...
code_fim
hard
{ "lang": "rust", "repo": "pczarn/panini", "path": "/panini_logic/src/output/instruction.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joelhy/leetcode-in-rust path: /src/n0066_plus_one.rs struct Solution {} impl Solution { pub fn plus_one(digits: Vec<i32>) -> Vec<i32> { let mut digits = digits; for i in (0..digits.len()).rev() { if digits[i] < 9 { digits[i] += 1; ...
code_fim
medium
{ "lang": "rust", "repo": "joelhy/leetcode-in-rust", "path": "/src/n0066_plus_one.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(Solution::plus_one(vec![1,2,3]), vec![1,2,4]); assert_eq!(Solution::plus_one(vec![9,9,9]), vec![1,0,0,0]); assert_eq!(Solution::plus_one(vec![1,0,9]), vec![1,1,0]); } }<|fim_prefix|>// repo: joelhy/leetcode-in-rust path: /src/n0066_plus_one.rs struct Solution {} im...
code_fim
medium
{ "lang": "rust", "repo": "joelhy/leetcode-in-rust", "path": "/src/n0066_plus_one.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // TODO: Implement TryInto trait instead when it's in stable std crate pub fn into_string(&self) -> Result<String> { let r = Handlebars::new() .template_render(MANIFESTFILE, &self.main) .map_err(SyncFailure::new)?; let mut s = r.lines().filter(|l| *l != "")....
code_fim
hard
{ "lang": "rust", "repo": "themightychris/habitat", "path": "/components/pkg-export-kubernetes/src/manifestjson.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: themightychris/habitat path: /components/pkg-export-kubernetes/src/manifestjson.rs // Copyright (c) 2017 Chef Software Inc. and/or applicable contributors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // ...
code_fim
hard
{ "lang": "rust", "repo": "themightychris/habitat", "path": "/components/pkg-export-kubernetes/src/manifestjson.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>struct Solution {} fn main() { println!("{:?}", Solution::combine(4, 2)); // [ // [2,4], // [3,4], // [2,3], // [1,2], // [1,3], // [1,4], // ] println!("{:?}", Solution::combine(1, 1)); // [[1]] }<|fim_prefix|>// repo: Gogomoe/LeetCodeSolutions pa...
code_fim
medium
{ "lang": "rust", "repo": "Gogomoe/LeetCodeSolutions", "path": "/src/0077.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Gogomoe/LeetCodeSolutions path: /src/0077.rs impl Solution { pub fn combine(n: i32, k: i32) -> Vec<Vec<i32>> { let mut list = Vec::new(); let mut result = Vec::new(); dfs(1, &mut list, n, k, &mut result); return result; } } <|fim_suffix|>struct Solution {...
code_fim
hard
{ "lang": "rust", "repo": "Gogomoe/LeetCodeSolutions", "path": "/src/0077.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Value { pub fn is_eq(&self, another: Rc<Value>) -> Result<(), ()> { let self_type_expr = self.quote(0); let another_type_expr = another.quote(0); if self_type_expr == another_type_expr { Ok(()) } else { Err(()) } } } pub mod sh...
code_fim
hard
{ "lang": "rust", "repo": "montaglue/Lambda-Rubiks-Cube", "path": "/src/interpreter/value.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn v_si(first_type: Rc<Value>, second_type: Closure) -> Rc<Value> { Rc::new(Value::Si(first_type, second_type)) } pub(crate) fn v_pair(first: Rc<Value>, second: Rc<Value>) -> Rc<Value> { Rc::new(Value::Pair(first, second)) } pub(crate) fn v_neutral(n: Rc<Ne...
code_fim
hard
{ "lang": "rust", "repo": "montaglue/Lambda-Rubiks-Cube", "path": "/src/interpreter/value.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: montaglue/Lambda-Rubiks-Cube path: /src/interpreter/value.rs use std::rc::Rc; use crate::{ interior_representation::abstract_syntax_tree::{short::*, EName, ExtendedTerm}, utils::list::List, }; use self::short::*; use super::evaluation::eval; #[derive(Debug)] pub enum Value { Univ...
code_fim
hard
{ "lang": "rust", "repo": "montaglue/Lambda-Rubiks-Cube", "path": "/src/interpreter/value.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn draw_begin(&mut self, viewport: graphics::Viewport) -> Context { self.gl.draw_begin(viewport) } pub fn draw_end(&mut self) { self.gl.draw_end(); } }<|fim_prefix|>// repo: Sharpiro/ray-casting path: /src/sharp_graphics.rs use graphics; use graphics::{math::Matrix2d,...
code_fim
hard
{ "lang": "rust", "repo": "Sharpiro/ray-casting", "path": "/src/sharp_graphics.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn clear(&mut self, color: [f32; 4]) { graphics::clear(color, &mut self.gl); } /// [x1, y1, x2, y2] pub fn draw_line(&mut self, color: [f32; 4], line: [f64; 4], transform: Matrix2d) { graphics::line(color, 1.0, line, transform, &mut self.gl); } /// Rectangle di...
code_fim
medium
{ "lang": "rust", "repo": "Sharpiro/ray-casting", "path": "/src/sharp_graphics.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Sharpiro/ray-casting path: /src/sharp_graphics.rs use graphics; use graphics::{math::Matrix2d, Context}; use opengl_graphics::{GlGraphics, GlyphCache}; pub struct SharpGraphics { gl: GlGraphics, glyphs: GlyphCache<'static>, } impl SharpGraphics { pub fn new<'a>(gl: GlGraphics, glyp...
code_fim
hard
{ "lang": "rust", "repo": "Sharpiro/ray-casting", "path": "/src/sharp_graphics.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stephanh/microbit-examples path: /oled/src/main.rs #![no_main] #![no_std] mod font24x32; use core::cell::RefCell; use core::fmt::Write; use core::ops::DerefMut; use panic_halt as _; //use panic_semihosting as _; use cortex_m::interrupt::Mutex; use cortex_m_rt::entry; use embedded_hal::adc:...
code_fim
hard
{ "lang": "rust", "repo": "stephanh/microbit-examples", "path": "/oled/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut disp: GraphicsMode<I2cInterface<i2c::I2c<TWI1>>> = Builder::new() .with_rotation(DisplayRotation::Rotate180) .connect_i2c(i2c) .into(); disp.init().unwrap(); disp.flush().unwrap(); let _ = gpio.pin17.into_floating_input(); ...
code_fim
hard
{ "lang": "rust", "repo": "stephanh/microbit-examples", "path": "/oled/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> cortex_m::interrupt::free(|cs| { if let ( Some(gpiote), Some(ref mut disp), Some(ref mut delay), Some(ref mut adc), Some(ref mut pin3), ) = ( GPIOTE.borrow(cs).borrow().as_ref(), DISPLAY.borrow(cs).borr...
code_fim
hard
{ "lang": "rust", "repo": "stephanh/microbit-examples", "path": "/oled/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) mod cmd; pub(crate) mod git; pub(crate) mod parser; pub(crate) mod ui; pub(crate) mod updater; pub(crate) mod util; pub(crate) mod ws; pub use self::cmd::execute;<|fim_prefix|>// repo: crackcomm/wtf-rlsr path: /src/lib.rs #![feature(str_strip, try_trait)] <|fim_middle|>#[macro_use] extern cr...
code_fim
medium
{ "lang": "rust", "repo": "crackcomm/wtf-rlsr", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: crackcomm/wtf-rlsr path: /src/lib.rs #![feature(str_strip, try_trait)] <|fim_suffix|>pub(crate) mod cmd; pub(crate) mod git; pub(crate) mod parser; pub(crate) mod ui; pub(crate) mod updater; pub(crate) mod util; pub(crate) mod ws; pub use self::cmd::execute;<|fim_middle|>#[macro_use] extern cr...
code_fim
medium
{ "lang": "rust", "repo": "crackcomm/wtf-rlsr", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Arnavion/k8s-openapi path: /src/v1_27/apimachinery/pkg/apis/meta/v1/patch.rs // Generated from definition io.k8s.apimachinery.pkg.apis.meta.v1.Patch /// Patch is provided to give a concrete name and type to the Kubernetes PATCH request body. #[derive(Clone, Debug, PartialEq)] pub enum Patch { ...
code_fim
hard
{ "lang": "rust", "repo": "Arnavion/k8s-openapi", "path": "/src/v1_27/apimachinery/pkg/apis/meta/v1/patch.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> SrcRegion::none() } fn single(index: usize, sym: &Token) -> Self { sym.region } fn group(syms: &[Token], _range: Range<usize>) -> Self { syms .first() .map(|s| s.region) .unwrap_or(SrcRegion::none()) .union(syms ...
code_fim
hard
{ "lang": "rust", "repo": "zesterer/leon", "path": "/src/util/src.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zesterer/leon path: /src/util/src.rs use std::{fmt, ops::Range}; use crate::lex::Token; #[derive(Copy, Clone, Hash, PartialEq, Eq)] #[cfg(test)] pub struct SrcLoc(pub usize); #[derive(Copy, Clone, Hash, PartialEq, Eq)] #[cfg(not(test))] pub struct SrcLoc(usize); impl SrcLoc { pub fn start(...
code_fim
hard
{ "lang": "rust", "repo": "zesterer/leon", "path": "/src/util/src.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GreHack/CTF-challs path: /2022/Web/FaaS/examples/src/compute_file/main.rs fn main() { let mut input_file = String::new(); let stdin = std::io::stdin(); match stdin.read_line(&mut input_file) { Ok(_) => println!("{}", compute_file(input_file.trim_end())), Err(_) => pri...
code_fim
medium
{ "lang": "rust", "repo": "GreHack/CTF-challs", "path": "/2022/Web/FaaS/examples/src/compute_file/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let kind = infer::get(&std::fs::read(path).unwrap_or(vec![])); return match kind { Some(file_type) => file_type.mime_type(), None => "cannot infer file type", } }<|fim_prefix|>// repo: GreHack/CTF-challs path: /2022/Web/FaaS/examples/src/compute_file/main.rs fn main() { ...
code_fim
medium
{ "lang": "rust", "repo": "GreHack/CTF-challs", "path": "/2022/Web/FaaS/examples/src/compute_file/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let temp_dir = common::create_temp_file_tree(3, 3, 4, 5, 6, 7)?; let results = Scandir::new(temp_dir.path(), Some(true))? .return_type(ReturnType::Ext) .collect()?; assert_eq!(192, results.0.len()); assert_eq!(0, results.1.len()); match results.0.get(0).unwrap() { ...
code_fim
medium
{ "lang": "rust", "repo": "brmmm3/scandir-rs", "path": "/scandir/tests/scandir.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brmmm3/scandir-rs path: /scandir/tests/scandir.rs use std::io::Error; use scandir::{ReturnType, Scandir, ScandirResult}; mod common; #[test] fn test_scandir() -> Result<(), Error> { <|fim_suffix|> let temp_dir = common::create_temp_file_tree(3, 3, 4, 5, 6, 7)?; let results = Scandir::n...
code_fim
hard
{ "lang": "rust", "repo": "brmmm3/scandir-rs", "path": "/scandir/tests/scandir.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zysyyz/esse path: /src/layer.rs use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::path::PathBuf; use std::sync::Arc; use tdn::{ smol::lock::RwLock, types::{ group::GroupId, message::SendType, primitive::{new_io_error, PeerAddr, Result}, ...
code_fim
hard
{ "lang": "rust", "repo": "zysyyz/esse", "path": "/src/layer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// get all onlines's groupid pub fn is_online(&self, gid: &GroupId) -> bool { self.onlines.contains_key(gid) } /// get online peer's addr. pub fn online(&self, gid: &GroupId) -> Result<PeerAddr> { self.onlines .get(gid) .map(|(online, _)| *onli...
code_fim
hard
{ "lang": "rust", "repo": "zysyyz/esse", "path": "/src/layer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Clone for SdlDrop { fn clone(&self) -> SdlDrop { let prev_count = SDL_COUNT.fetch_add(1, Ordering::Relaxed); assert!(prev_count > 0); SdlDrop { _anticonstructor: std::ptr::null_mut(), } } } impl Drop for SdlDrop { #[inline] #[doc(alias = "S...
code_fim
hard
{ "lang": "rust", "repo": "Rust-SDL2/rust-sdl2", "path": "/src/sdl2/sdl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(Debug, Clone)] pub struct $name { /// Subsystems cannot be moved or (usually) used on non-main threads. /// Luckily, Rc restricts use to the main thread. _subsystem_drop: SubsystemDrop, } impl $name { #[inline] ...
code_fim
hard
{ "lang": "rust", "repo": "Rust-SDL2/rust-sdl2", "path": "/src/sdl2/sdl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Rust-SDL2/rust-sdl2 path: /src/sdl2/sdl.rs use libc::c_char; use std::cell::Cell; use std::error; use std::ffi::{CStr, CString, NulError}; use std::fmt; use std::mem::transmute; use std::os::raw::c_void; use std::sync::atomic::{AtomicBool, AtomicU32, Ordering}; use crate::sys; #[repr(i32)] #[d...
code_fim
hard
{ "lang": "rust", "repo": "Rust-SDL2/rust-sdl2", "path": "/src/sdl2/sdl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: noobusdeer/Udemy-Rust-Course path: /src/section4/arrays.rs use std::mem; fn arrays() { let mut a:[i32;5] = [1, 2, 3, 4, 5]; println!("a has {} elements, first is {}", a.len(), a[0]); a[0] = 321; println!("a has {} elements, first is {}", a.len(), a[0]); println!(""); <|fim_...
code_fim
hard
{ "lang": "rust", "repo": "noobusdeer/Udemy-Rust-Course", "path": "/src/section4/arrays.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mtx:[[f32;3]; 2] = [ [1.0, 0.0, 0.0], [0.0, 1.0, 0.0] ]; println!("{:?}", mtx) } fn main() { arrays(); }<|fim_prefix|>// repo: noobusdeer/Udemy-Rust-Course path: /src/section4/arrays.rs use std::mem; fn arrays() { let mut a:[i32;5] = [1, 2, 3, 4, 5]; prin...
code_fim
hard
{ "lang": "rust", "repo": "noobusdeer/Udemy-Rust-Course", "path": "/src/section4/arrays.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chipmunk-project/druzhba-simulator path: /src/pipeline.rs use crate::pipeline_stage::PipelineStage; use crate::phv::Phv; use std::mem; use std::collections::HashMap; use std::fmt; /* Banzai uses write and read latches to make sure that the output values of one stage don't become the in...
code_fim
hard
{ "lang": "rust", "repo": "chipmunk-project/druzhba-simulator", "path": "/src/pipeline.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn len (&self) -> usize { self.pipeline_stages.len() } // Pumps a phv into the pipeline and runs the ALUs in the // first stage on them. Phvs later in the pipeline are // funneled to the next sequential stage. // // Also calculates and keeps track of the state variable // values f...
code_fim
hard
{ "lang": "rust", "repo": "chipmunk-project/druzhba-simulator", "path": "/src/pipeline.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.pipeline_stages[0].tick(t_packet.clone(), t_packet) } else{ let (first_initial_phv, first_result_phv) = self.pipeline_stages[0].tick(t_packet.clone(), t_packet.clone()); self.new_phvs.insert(0, first...
code_fim
hard
{ "lang": "rust", "repo": "chipmunk-project/druzhba-simulator", "path": "/src/pipeline.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pvdrz/cryptopals-old path: /src/fields/rijndael.rs pub fn mul(mut a: u8, mut b: u8) -> u8 { let mut p = 0u8; for _ in 0..8 { if b & 1 == 1 { p = p ^ a;<|fim_suffix|> b = b >> 1; } p } pub fn invert(a: u8) -> Option<u8> { let mut inv = None; if a != 0...
code_fim
medium
{ "lang": "rust", "repo": "pvdrz/cryptopals-old", "path": "/src/fields/rijndael.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>5 { if mul(a, b) == 1 { inv = Some(b); break; } } } inv }<|fim_prefix|>// repo: pvdrz/cryptopals-old path: /src/fields/rijndael.rs pub fn mul(mut a: u8, mut b: u8) -> u8 { let mut p = 0u8; for _ in 0..8 { if b & 1 == ...
code_fim
medium
{ "lang": "rust", "repo": "pvdrz/cryptopals-old", "path": "/src/fields/rijndael.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xixixao/hot-reload-rs path: /raw_sync-rs/src/lib.rs pub(crate) type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; /// Event implementations pub mod<|fim_suffix|>m Timeout { Infinite, Val(std::time::Duration), }<|fim_middle|> events; /// Lock implementations pub mod lock...
code_fim
easy
{ "lang": "rust", "repo": "xixixao/hot-reload-rs", "path": "/raw_sync-rs/src/lib.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>m Timeout { Infinite, Val(std::time::Duration), }<|fim_prefix|>// repo: xixixao/hot-reload-rs path: /raw_sync-rs/src/lib.rs pub(crate) type Result<T> = std::result::Result<T, Box<d<|fim_middle|>yn std::error::Error>>; /// Event implementations pub mod events; /// Lock implementations pub mod lock...
code_fim
medium
{ "lang": "rust", "repo": "xixixao/hot-reload-rs", "path": "/raw_sync-rs/src/lib.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>pub mod xterm; pub use xterm::Terminal; #[cfg(feature = "crossterm-support")] #[cfg_attr(all(docs, not(doctest)), doc(cfg(feature = "crossterm-support")))] pub mod crossterm_support; #[cfg(feature = "ext")] #[cfg_attr(all(docs, not(doctest)), doc(cfg(feature = "ext")))] pub mod ext;<|fim_prefix|>// repo...
code_fim
hard
{ "lang": "rust", "repo": "ichn-hu/xterm-js-sys", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mod readonly_array; pub use readonly_array::ReadOnlyArray; pub mod xterm; pub use xterm::Terminal; #[cfg(feature = "crossterm-support")] #[cfg_attr(all(docs, not(doctest)), doc(cfg(feature = "crossterm-support")))] pub mod crossterm_support; #[cfg(feature = "ext")] #[cfg_attr(all(docs, not(doctest)), d...
code_fim
hard
{ "lang": "rust", "repo": "ichn-hu/xterm-js-sys", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ichn-hu/xterm-js-sys path: /src/lib.rs #![cfg_attr(all(docs, not(doctest)), feature(doc_cfg))] #![cfg_attr(all(docs, not(doctest)), feature(external_doc))] #![cfg_attr(all(docs, not(doctest)), doc(include = "../README.md"))] //! // ^ is there so it looks like we have at some crate level docs whe...
code_fim
hard
{ "lang": "rust", "repo": "ichn-hu/xterm-js-sys", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Retsam/AdventOfCode path: /2019/day12/src/main.rs use core::num::ParseIntError; use core::str::FromStr; use std::io::{self, Read}; const PART_1: bool = false; fn gcd(x: i64, y: i64) -> i64 { let mut x = x; let mut y = y; while y != 0 { let t = y; y = x % y; ...
code_fim
hard
{ "lang": "rust", "repo": "Retsam/AdventOfCode", "path": "/2019/day12/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut buffer = String::new(); io::stdin().read_to_string(&mut buffer)?; let mut moons = buffer.lines() .map(|line| { MoonData { pos: line.parse::<Point3>().unwrap(), vel: Point3 { x: 0, y: 0, z: 0 }, } }) .collec...
code_fim
hard
{ "lang": "rust", "repo": "Retsam/AdventOfCode", "path": "/2019/day12/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RoccoDev/aoc-2020 path: /src/days/day21.rs use fxhash::FxHashMap; use regex::Regex; lazy_static::lazy_static! { static ref REGEX: Regex = Regex::new(r#"(.+) \(contains (.+)\)"#).unwrap(); } struct Food { ingredients: Vec<String>, allergens: Vec<String>, } fn calc_allergens(foods: ...
code_fim
hard
{ "lang": "rust", "repo": "RoccoDev/aoc-2020", "path": "/src/days/day21.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn part1_example() { let input = "mxmxvkd kfcds sqjhc nhms (contains dairy, fish) trh fvjkl sbzzf mxmxvkd (contains dairy) sqjhc fvjkl (contains soy) sqjhc mxmxvkd sbzzf (contains fish)"; assert_eq!(part1(input), 5); } #[test] fn part2_example() { let i...
code_fim
hard
{ "lang": "rust", "repo": "RoccoDev/aoc-2020", "path": "/src/days/day21.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> { let key = BytesTrieKey(word.clone()); match words.get_descendant(&key) { Some(node) if node.len() > 0 => { if words.get(&key).is_some() { good_word = Some(word.clone()); } } ...
code_fim
hard
{ "lang": "rust", "repo": "silky/shortmantout", "path": "/src/verify.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: silky/shortmantout path: /src/verify.rs extern crate radix_trie; extern crate carrycoat; #[derive(PartialEq, Eq, Debug)] pub struct BytesTrieKey(Vec<u8>); impl ::radix_trie::TrieKey for BytesTrieKey { fn encode(&self) -> Vec<u8> { self.0.to_vec() } } fn verify_contains_all(po...
code_fim
hard
{ "lang": "rust", "repo": "silky/shortmantout", "path": "/src/verify.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("Player Number {}", player_number); let mut cards: VecDeque<usize> = VecDeque::new(); for card in splitted { println!("{}", card); cards.push_back(card.parse::<usize>().unwrap()); } if i == 0 { p1 = Player { ...
code_fim
hard
{ "lang": "rust", "repo": "rgrunbla/AOC", "path": "/2020/22/rust/first/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rgrunbla/AOC path: /2020/22/rust/first/src/main.rs extern crate nom; use std::fmt; use std::fs; use std::collections::{VecDeque, HashMap, HashSet}; use std::iter::FromIterator; struct Player { number: usize, cards: VecDeque<usize> } impl Default for Player { fn default() -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "rgrunbla/AOC", "path": "/2020/22/rust/first/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut paths = BTreeMap::new(); paths.insert(*BUILT_IN_JOLTAGE, 1usize); for adapter in ADAPTERS.iter().copied().rev().chain(Some(0)) { paths.insert( adapter, (1..=3).filter_map(|i| paths.get(&(adapter + i))).sum(), ); } println!("** {}", paths...
code_fim
medium
{ "lang": "rust", "repo": "chryslovelace/advent-of-code-2020", "path": "/src/bin/day10/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chryslovelace/advent-of-code-2020 path: /src/bin/day10/main.rs #![feature(map_first_last)] use itertools::Itertools; use lazy_static::lazy_static; use std::collections::{BTreeMap, BTreeSet}; <|fim_suffix|> let mut paths = BTreeMap::new(); paths.insert(*BUILT_IN_JOLTAGE, 1usize); for ...
code_fim
hard
{ "lang": "rust", "repo": "chryslovelace/advent-of-code-2020", "path": "/src/bin/day10/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut grid = Grid::new(); let wires: Vec<Wire> = input .lines() .map(|line| { line.split(",") .map(|trace| { let direction = trace.chars().nth(0).unwrap(); let steps = trace[1..trace.len()].parse::<usize>().unwr...
code_fim
hard
{ "lang": "rust", "repo": "chutchinson/advent-of-code", "path": "/src/day3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chutchinson/advent-of-code path: /src/day3.rs use std::collections::{HashMap, HashSet}; pub fn solve() { let input = include_str!("./inputs/3.txt"); let grid = trace(input); let min_distance = min_distance(&grid); let min_steps = min_steps(&grid); println!("{}", min_distanc...
code_fim
hard
{ "lang": "rust", "repo": "chutchinson/advent-of-code", "path": "/src/day3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let input = "\ R75,D30,R83,U83,L12,D49,R71,U7,L72 U62,R66,U55,R34,D71,R55,D58,R83"; let grid = trace(input); assert_eq!(159, min_distance(&grid)); } #[test] fn closest_point_has_distance_135() { let input = "\ R98,U47,R26,D63,R33,U87,L62,D20,R33,U53,R51 U98,R91...
code_fim
hard
{ "lang": "rust", "repo": "chutchinson/advent-of-code", "path": "/src/day3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut values = vec![]; let mut cells = vec![]; for (value, cell_coverage) in conv.to_h3(h3_resolution, compact).into_pyresult()? { let len_before = cells.len(); if compact { cells.extend(cell_coverage.into_compacted_iter()); } else { cells.exte...
code_fim
hard
{ "lang": "rust", "repo": "nmandery/h3ronpy", "path": "/src/raster.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nmandery/h3ronpy path: /src/raster.rs use geo_types::Coord; use std::hash::Hash; use std::iter::repeat; use std::str::FromStr; use h3arrow::array::CellIndexArray; use h3arrow::export::arrow2::array::PrimitiveArray; use h3arrow::export::h3o::{CellIndex, Resolution}; use ndarray::ArrayView2; use ...
code_fim
hard
{ "lang": "rust", "repo": "nmandery/h3ronpy", "path": "/src/raster.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ivanceras/diesel path: /diesel/src/mysql/backend.rs use byteorder::NativeEndian; use backend::*; use query_builder::bind_collector::RawBytesBindCollector; use super::query_builder::MysqlQueryBuilder; #[derive(Debug, Copy, Clone)] pub struct Mysql; #[allow(missing_debug_implementations, missin...
code_fim
medium
{ "lang": "rust", "repo": "ivanceras/diesel", "path": "/diesel/src/mysql/backend.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> MysqlType::Date } } impl HasSqlType<::types::Time> for Mysql { fn metadata() -> MysqlType { MysqlType::Time } } impl HasSqlType<::types::Timestamp> for Mysql { fn metadata() -> MysqlType { MysqlType::Timestamp } }<|fim_prefix|>// repo: ivanceras/diesel path: ...
code_fim
hard
{ "lang": "rust", "repo": "ivanceras/diesel", "path": "/diesel/src/mysql/backend.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl TypeMetadata for Mysql { type TypeMetadata = MysqlType; } impl SupportsReturningClause for Mysql {} impl SupportsDefaultKeyword for Mysql {} impl UsesAnsiSavepointSyntax for Mysql {} // FIXME: Move this out of this module use types::HasSqlType; impl HasSqlType<::types::Date> for Mysql { fn...
code_fim
medium
{ "lang": "rust", "repo": "ivanceras/diesel", "path": "/diesel/src/mysql/backend.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Calculate the shortest path from `start` to `end` through the adjacency matrix. /// In cases where there is more than one shortest path, will return the first one /// found. If no path exists, return None. Basically the same algorithm as for the /// adjacency matrix, just re-tooled for...
code_fim
hard
{ "lang": "rust", "repo": "oktak/CodingDojo", "path": "/challenges/2021-10-05-limited-levenshtein-leap/solutions/rust/ericwburden/ericwburden.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oktak/CodingDojo path: /challenges/2021-10-05-limited-levenshtein-leap/solutions/rust/ericwburden/ericwburden.rs use std::collections::{HashMap, HashSet, VecDeque}; use std::hash::Hash; //-------------------------------------------------------------------------------------- //--IsAdjacentTo: A ...
code_fim
hard
{ "lang": "rust", "repo": "oktak/CodingDojo", "path": "/challenges/2021-10-05-limited-levenshtein-leap/solutions/rust/ericwburden/ericwburden.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: agerasev/hypertrace path: /objects/src/background/mod.rs mod basic; use types::{prelude::*, source::SourceTree, Config}; <|fim_suffix|> Self::name() } fn background_source(cfg: &Config) -> SourceTree { Self::source(cfg) } } pub use basic::*;<|fim_middle|>pub trait B...
code_fim
medium
{ "lang": "rust", "repo": "agerasev/hypertrace", "path": "/objects/src/background/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Self::source(cfg) } } pub use basic::*;<|fim_prefix|>// repo: agerasev/hypertrace path: /objects/src/background/mod.rs mod basic; use types::{prelude::*, source::SourceTree, Config}; pub trait Background<G: Geometry>: SizedEntity { fn background_name() -> (String, String) { <|fim_middl...
code_fim
medium
{ "lang": "rust", "repo": "agerasev/hypertrace", "path": "/objects/src/background/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Self::name() } fn background_source(cfg: &Config) -> SourceTree { Self::source(cfg) } } pub use basic::*;<|fim_prefix|>// repo: agerasev/hypertrace path: /objects/src/background/mod.rs mod basic; use types::{prelude::*, source::SourceTree, Config}; <|fim_middle|>pub trait B...
code_fim
medium
{ "lang": "rust", "repo": "agerasev/hypertrace", "path": "/objects/src/background/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self, name: &'static str, len: usize, visitor: V, ) -> DeserializationResult<V::Value> where V: serde::de::Visitor<'x>, { trace!( "RsDeserializer::deserialize_tuple_struct() with name = {}", name ); let mut...
code_fim
hard
{ "lang": "rust", "repo": "windoze/rust-serde_db", "path": "/src/de/rs_deserializer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: windoze/rust-serde_db path: /src/de/rs_deserializer.rs use crate::de::row_deserializer::RowDeserializer; use crate::de::{ DbValue, DeserializableResultset, DeserializableRow, DeserializationError, DeserializationResult, }; use log::trace; use serde::de::Deserialize as SD; #[derive(Debug...
code_fim
hard
{ "lang": "rust", "repo": "windoze/rust-serde_db", "path": "/src/de/rs_deserializer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jiyilanzhou/chw path: /book/tao_of_rust/chp2/6_collection.rs // deque[dek]n.双端队列 // peek[piːk]v&n.窥视,窥探 // peer[pɪə(r)]n.同级,对等 /* 2.8 常用集合类型(序列、映射表[集合]、队列) Rust 标准库 std::collections 模块提供 4 种通用集合类型 a. 线性序列:向量(Vec)、双端队列(VecDeque)、链表(LinkedList) b. Key-Value 映射表:无序哈希表(HashMap)...
code_fim
hard
{ "lang": "rust", "repo": "jiyilanzhou/chw", "path": "/book/tao_of_rust/chp2/6_collection.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/* 2.8.5 集合:HashSet 和 BTreeSet HashSet<K> 和 BTreeSet<K> 其实就是 HashMap<K,V>、BTreeMap<K,V> 将 Value 设置 为空的特定类型,等价于" HashMap<K,()>、BTreeMap<K,()> "故其特性如下: a. 集合中元素唯一:因其为 Key-Value 映射表的 Key b. (同理) HashSet 中的元素应该都是可哈希的类型而 BTreeSet 中的元素须可排序 c. HashSet 应无序而 BTreeSet 应有序 */ // (代码清...
code_fim
hard
{ "lang": "rust", "repo": "jiyilanzhou/chw", "path": "/book/tao_of_rust/chp2/6_collection.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>struct Solution; impl Solution { pub fn merge_two_lists(mut l1: Link, mut l2: Link) -> Link { // leet021, 0ms let mut head = Box::new(ListNode::new(0)); let mut node = &mut head; while l1.is_some() && l2.is_some() { if l1.as_ref().unwr...
code_fim
medium
{ "lang": "rust", "repo": "slayerwalt/LeetCode", "path": "/OJ/leet021/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: slayerwalt/LeetCode path: /OJ/leet021/src/main.rs // Definition for singly-linked list. #[derive(PartialEq, Eq, Clone, Debug)] pub struct ListNode { pub val: i32, pub next: Option<Box<ListNode>> } impl ListNode { #[inline] fn new(val: i32) -> Self { ListNode { next: None, ...
code_fim
hard
{ "lang": "rust", "repo": "slayerwalt/LeetCode", "path": "/OJ/leet021/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Shuumatsu/ros path: /src/main.rs #![no_std] #![no_main] #![feature(const_panic, panic_info_message)] #![feature(lang_items)] #![feature(global_asm, llvm_asm, asm)] #![feature(alloc_error_handler)] #![feature(naked_functions)] // https://doc.rust-lang.org/alloc/prelude/index.html #![feature(alloc...
code_fim
hard
{ "lang": "rust", "repo": "Shuumatsu/ros", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// the -> ! means that this function won't return #[panic_handler] fn panic(info: &core::panic::PanicInfo) -> ! { if let Some(p) = info.location() { kprintln!("Aborting: file {}:{}: \n\t{}", p.file(), p.line(), info.message().unwrap()); } else { kprintln!("Aborting: no information ...
code_fim
medium
{ "lang": "rust", "repo": "Shuumatsu/ros", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match fs::write(path.clone(), contents) { Ok(_) => print_colored( format!(".gitignore file for {} successfully created at {}", lang, path.to_str().unwrap()), Color::Green, ), Err(err...
code_fim
hard
{ "lang": "rust", "repo": "danitrod/gignore", "path": "/src/subcommands/create.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danitrod/gignore path: /src/subcommands/create.rs use super::Executable; use crate::{ services::github::GithubService, utils::{get_language_aliases, print_colored}, }; use async_trait::async_trait; use clap::Parser; use std::{fs, path}; use termcolor::Color; pub const DESCRIPTION: &str ...
code_fim
hard
{ "lang": "rust", "repo": "danitrod/gignore", "path": "/src/subcommands/create.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shakyShane/wf2 path: /wf2_core/src/recipes/wp/services/wp_php_debug.rs use crate::context::Context; use crate::dc_service::DcService; use crate::recipes::m2::services::php::PhpService; use crate::recipes::wp::services::wp_php::WpPhpService; use crate::services::Service; <|fim_suffix|>impl Servi...
code_fim
medium
{ "lang": "rust", "repo": "shakyShane/wf2", "path": "/wf2_core/src/recipes/wp/services/wp_php_debug.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut php_cnt = (WpPhpService).dc_service(ctx, &()); { php_cnt.set_environment(vec!["XDEBUG_ENABLE=true"]); php_cnt.set_name(WpPhpDebugService::NAME); php_cnt.set_container_name(ctx.name(), WpPhpDebugService::NAME); } php_cnt } } #...
code_fim
medium
{ "lang": "rust", "repo": "shakyShane/wf2", "path": "/wf2_core/src/recipes/wp/services/wp_php_debug.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ctx = Context::default(); let actual_dc = (WpPhpDebugService).dc_service(&ctx, &()); let expected = r#" name: php-debug container_name: wf2__wf2_default__php-debug image: "wearejh/php:7.3-m2" volumes: - ".:/var/www"...
code_fim
medium
{ "lang": "rust", "repo": "shakyShane/wf2", "path": "/wf2_core/src/recipes/wp/services/wp_php_debug.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> Parser<'a> for Document { fn parse(input: &'a str) -> IResult<&'a str, Self> { DocumentRef::parse(input).map(|(remains, parsed)| (remains, parsed.into())) } } #[cfg(test)] mod tests { use crate::basic::LiteralRef; use super::*; #[test] fn test_document() { ...
code_fim
hard
{ "lang": "rust", "repo": "ihciah/thrift-parser", "path": "/src/document.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ihciah/thrift-parser path: /src/document.rs use nom::branch::alt; use nom::combinator::{map, opt}; use nom::multi::many0; use nom::sequence::delimited; use nom::IResult; use crate::basic::Separator; use crate::definition::{ Const, ConstRef, Enum, EnumRef, Exception, ExceptionRef, Service, S...
code_fim
hard
{ "lang": "rust", "repo": "ihciah/thrift-parser", "path": "/src/document.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self { includes: r.includes.into_iter().map(Into::into).collect(), cpp_includes: r.cpp_includes.into_iter().map(Into::into).collect(), namespaces: r.namespaces.into_iter().map(Into::into).collect(), typedefs: r.typedefs.into_iter().map(Into::into).co...
code_fim
hard
{ "lang": "rust", "repo": "ihciah/thrift-parser", "path": "/src/document.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for ans in ans { if ans { println!("Yes"); } else { println!("No"); } } }<|fim_prefix|>// repo: ia7ck/competitive-programming path: /AtCoder/abc287/src/bin/d/main.rs use proconio::{input, marker::Bytes}; fn check(c: u8, d: u8) -> bool { c == d ...
code_fim
hard
{ "lang": "rust", "repo": "ia7ck/competitive-programming", "path": "/AtCoder/abc287/src/bin/d/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ia7ck/competitive-programming path: /AtCoder/abc287/src/bin/d/main.rs use proconio::{input, marker::Bytes}; fn check(c: u8, d: u8) -> bool { c == d || c == b'?' || d == b'?' } <|fim_suffix|> input! { s: Bytes, t: Bytes, }; let n = s.len(); let m = t.len(); ...
code_fim
medium
{ "lang": "rust", "repo": "ia7ck/competitive-programming", "path": "/AtCoder/abc287/src/bin/d/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ptrgags/chaos-game-3d path: /src/clusters.rs ing to make this a unit vector, right? ;) x_dir: Vec3, /// y-axis of the circle. You're going to make this a unit vector orthogonal to x_dir, right? ;) y_dir: Vec3, /// The circle starts with a solid color color: Vec3, /// Gene...
code_fim
hard
{ "lang": "rust", "repo": "ptrgags/chaos-game-3d", "path": "/src/clusters.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Cluster for FibonacciDisk { fn generate(&mut self, cluster_copy: u16, cluster_id: u16) -> Vec<InternalPoint> { // Golden ratio let phi = (1.0 + (5.0f64).sqrt()) / 2.0; let n = self.num_points as f64; let color = HalfMultivector::from_vec3(&self.color); ...
code_fim
hard
{ "lang": "rust", "repo": "ptrgags/chaos-game-3d", "path": "/src/clusters.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ptrgags/chaos-game-3d path: /src/clusters.rs let x = (self.width * u - 0.5 * self.width) as f32; let y = (self.height * v - 0.5 * self.height) as f32; let position_vec3 = self.center + self.x_dir * x + self.y_dir * y; let position = HalfMultivector::from_vec...
code_fim
hard
{ "lang": "rust", "repo": "ptrgags/chaos-game-3d", "path": "/src/clusters.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn into_bindings(&self) -> Vec<Binding> { self.plan.into_bindings() } fn datafy(&self) -> Vec<(Eid, Aid, Value)> { let eid = next_id(); let mut data = self.plan.datafy(); if data.is_empty() { Vec::new() } else { let child_eid = ...
code_fim
hard
{ "lang": "rust", "repo": "PEZ/declarative-dataflow", "path": "/src/plan/project.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PEZ/declarative-dataflow path: /src/plan/project.rs //! Projection expression plan. use timely::dataflow::scopes::child::Iterative; use timely::dataflow::Scope; use timely::progress::Timestamp; use differential_dataflow::lattice::Lattice; use crate::binding::Binding; use crate::plan::{next_id...
code_fim
hard
{ "lang": "rust", "repo": "PEZ/declarative-dataflow", "path": "/src/plan/project.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Class { name: class_name.to_string(), derive: class_derive, } } fn parse_members(s: &str) -> Vec<Member> { let re = Regex::new(r"\[members\]\n(?s)[^\[]+").unwrap(); let mat = match re.find(s) { Some(m) => m, None => p...
code_fim
hard
{ "lang": "rust", "repo": "orbitrc/altair", "path": "/src/transpiler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }