text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> for (i, op) in opcodes.enumerate() { let i = i - i_sub; match op.trim().chars().next() { None | Some('#') => { i_sub += 1; continue; } Some(_) => {} } if op.starts_with("buffer_") { buffer_...
code_fim
medium
{ "lang": "rust", "repo": "TyOverby/implicit-gpu", "path": "/util/gpu-interp/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TyOverby/implicit-gpu path: /util/gpu-interp/build.rs use std::env; use std::error::Error; use std::fs::File; use std::io::{Read, Write}; use std::path::Path; fn main() -> Result<(), Box<Error>> { let mut in_file = File::open("./src/gpu/opcodes.txt")?; let mut in_contents = String::new(...
code_fim
hard
{ "lang": "rust", "repo": "TyOverby/implicit-gpu", "path": "/util/gpu-interp/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut rust_file = File::create(&Path::join(dest_path, "opcodes.rs"))?; let mut opencl_file = File::create(&Path::join(dest_path, "opcodes.c"))?; let mut buffer_count = 0; let mut i_sub = 0; for (i, op) in opcodes.enumerate() { let i = i - i_sub; match op.trim().char...
code_fim
medium
{ "lang": "rust", "repo": "TyOverby/implicit-gpu", "path": "/util/gpu-interp/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut interpreter = interpreter::new(); let load_file_name = { if args.len() > 1 { args[1].as_str() } else { "programs/Puzzle.ch8" } }; let result = interpreter.load_file(load_file_name, DEFAULT_PROGRAM_START); match result { O...
code_fim
medium
{ "lang": "rust", "repo": "yoiang/chip-8_rust", "path": "/console/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yoiang/chip-8_rust path: /console/src/main.rs use std::{env, time::Duration}; use chip8_traits::Interpreter; const DEFAULT_PROGRAM_START: usize = 0x200; const MAIN_LOOP_FREQUENCY: Duration = Duration::from_millis(1); <|fim_suffix|>fn main() { let args: Vec<String> = env::args().collect();...
code_fim
medium
{ "lang": "rust", "repo": "yoiang/chip-8_rust", "path": "/console/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leshow/retry_fn path: /src/strategy/immediate.rs //! immediate return //! //! This distribution just returns immediately, using 0 as it's Duration use std::time::Duration; /// Define type for Immediate strategy #[derive(Debug, Default, Copy, Clone)] pub struct Immediate; impl Immediate { /...
code_fim
medium
{ "lang": "rust", "repo": "leshow/retry_fn", "path": "/src/strategy/immediate.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod test { use super::*; #[test] fn fixed() { let mut s = Immediate::new(); assert_eq!(s.next(), Some(Duration::from_millis(0))); assert_eq!(s.next(), Some(Duration::from_millis(0))); assert_eq!(s.next(), Some(Duration::from_millis(0))); } }<|fi...
code_fim
hard
{ "lang": "rust", "repo": "leshow/retry_fn", "path": "/src/strategy/immediate.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WeAreRust/Nes path: /nes/src/cpu/instruction/mod.rs use cpu::{operation::Operation, Core}; use memory::{ReadAddr, WriteAddr}; use std::convert::From; #[cfg(test)] #[macro_export] macro_rules! nes_asm { ($e:expr) => {{ let mut buf = vec![]; // We push a newline into the bytes array bec...
code_fim
hard
{ "lang": "rust", "repo": "WeAreRust/Nes", "path": "/nes/src/cpu/instruction/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[inline(always)] pub fn is_upper_page_boundary(addr: u16) -> bool { addr & 0x00ff == 0x00ff } #[inline(always)] fn get_page(addr: u16) -> usize { usize::from(addr) / 0xff } #[cfg(test)] mod tests { use super::*; use cpu; use cpu::register::Registers; use memory::block::BlockMemory; #[tes...
code_fim
hard
{ "lang": "rust", "repo": "WeAreRust/Nes", "path": "/nes/src/cpu/instruction/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.cycles + is_upper_page_boundary(hi | lo << 8) as usize } ExtraCycle::Branch => { let lo = u16::from(memory.read_addr(core.reg.pc)); let hi = u16::from(memory.read_addr(core.reg.pc + 1)); let extra_cycle = (get_page((lo | hi << 8) + 2) != get_page(core.reg....
code_fim
hard
{ "lang": "rust", "repo": "WeAreRust/Nes", "path": "/nes/src/cpu/instruction/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Frezc/leetcode-solutions path: /src/n0092_reverse_linked_list_ii.rs /** * [92] Reverse Linked List II * * Reverse a linked list from position m to n. Do it in one-pass. * * Note: 1 &le; m &le; n &le; length of list. * * Example: * * * Input: 1->2->3->4->5->NULL, m = 2, n = 4 * Out...
code_fim
hard
{ "lang": "rust", "repo": "Frezc/leetcode-solutions", "path": "/src/n0092_reverse_linked_list_ii.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danitrod/rust-p2p path: /src/lib.rs use std::io; use std::net::Ipv4Addr; mod server; pub use server::start_server; pub const MAX_FILE_SIZE: usize = 65535; pub fn ip_input() -> Ipv4Addr { loop { let mut inp = String::new(); io::stdin() .read_line(&mut inp) ...
code_fim
hard
{ "lang": "rust", "repo": "danitrod/rust-p2p", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn port_input() -> u16 { loop { let mut inp = String::new(); io::stdin() .read_line(&mut inp) .expect("Failed to read line"); let inp: u16 = match inp.trim().parse() { Ok(num) => { if num < 10 { print!(...
code_fim
hard
{ "lang": "rust", "repo": "danitrod/rust-p2p", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn test_first_nul_idx() { let input = b"hello\0world\0"; assert_eq!(Some(5), input.first_nul_idx()); let input = b"no nul byte here!"; assert_eq!(None, input.first_nul_idx()); } #[test] fn test_from_b...
code_fim
hard
{ "lang": "rust", "repo": "connorkuehl/tftp", "path": "/src/bytes.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_from_bytes_u16() { let n = 55u16; let actual = Bytes::from_bytes(&n.to_be_bytes()[..]).unwrap(); assert_eq!(n, actual.into_inner()); } #[test] fn test_into_bytes_u16() { let n = 55u16; let b = Bytes::new(n); assert_eq!(&n...
code_fim
hard
{ "lang": "rust", "repo": "connorkuehl/tftp", "path": "/src/bytes.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: connorkuehl/tftp path: /src/bytes.rs use std::convert::AsRef; use std::ffi::{CStr, CString}; use std::io::{self, ErrorKind}; use std::mem::size_of; pub trait FromBytes: Sized { type Error; fn from_bytes<T: AsRef<[u8]>>(bytes: T) -> Result<Self, Self::Error>; } pub trait IntoBytes { ...
code_fim
hard
{ "lang": "rust", "repo": "connorkuehl/tftp", "path": "/src/bytes.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhangying098/libnuma path: /workspace/libnuma/src/masks/Mask.rs // This file is part of libnuma. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/libnuma/master/COPYRIGHT. No part of ...
code_fim
hard
{ "lang": "rust", "repo": "zhangying098/libnuma", "path": "/workspace/libnuma/src/masks/Mask.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> { self.bit_mask().clear_all_bits() } #[inline(always)] fn set_all(&self) { self.bit_mask().set_all_bits() } #[inline(always)] fn weight_x(&self) -> usize { self.bit_mask().weight() } }<|fim_prefix|>// repo: zhangying098/libnuma path: /workspace/libnuma/src/masks/Mask.rs // This file is...
code_fim
hard
{ "lang": "rust", "repo": "zhangying098/libnuma", "path": "/workspace/libnuma/src/masks/Mask.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Dielectric { pub fn new(refraction_index: f64) -> Self { Self { refraction_index } } pub fn as_ref(self) -> Arc<Self> { Arc::new(self) } fn reflectance(cosine: f64, refraction_index: f64) -> f64 { // Use Schlick's approximation for reflectance. le...
code_fim
hard
{ "lang": "rust", "repo": "yue4u/RayTracingBookSeries", "path": "/ray-tracing-utility/src/materials.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yue4u/RayTracingBookSeries path: /ray-tracing-utility/src/materials.rs use crate::*; use std::sync::Arc; pub trait Material { fn scatter( &self, ray_in: &Ray, record: &HitRecord, attenuation: &mut Color, scattered: &mut Ray, ) -> bool; } #[derive(C...
code_fim
hard
{ "lang": "rust", "repo": "yue4u/RayTracingBookSeries", "path": "/ray-tracing-utility/src/materials.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let cannot_refract = refraction_ratio * sin_theta > 1.; let direction = if cannot_refract || Dielectric::reflectance(cos_theta, refraction_ratio) > rand::random::<f64>() { unit_direction.reflect(record.normal) } else { unit_direction.ref...
code_fim
hard
{ "lang": "rust", "repo": "yue4u/RayTracingBookSeries", "path": "/ray-tracing-utility/src/materials.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( client.deposit_confirmations().await?, cfg.config.eth_watch.confirmations_for_eth_event ); assert_eq!( client.network().await?, cfg.config.chain.eth.network.to_string() ); assert_eq!( client.co...
code_fim
hard
{ "lang": "rust", "repo": "euevew/zksync", "path": "/core/bin/zksync_api/src/api_server/rest/v1/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: euevew/zksync path: /core/bin/zksync_api/src/api_server/rest/v1/config.rs //! Config part of API implementation. // Built-in uses // External uses use actix_web::{web, Scope}; // Workspace uses use zksync_api_client::rest::v1::Contracts; use zksync_config::ZkSyncConfig; use zksync_types::{net...
code_fim
hard
{ "lang": "rust", "repo": "euevew/zksync", "path": "/core/bin/zksync_api/src/api_server/rest/v1/config.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( client.network().await?, cfg.config.chain.eth.network.to_string() ); assert_eq!( client.contracts().await?, Contracts { contract: cfg.config.contracts.contract_addr }, ); server...
code_fim
hard
{ "lang": "rust", "repo": "euevew/zksync", "path": "/core/bin/zksync_api/src/api_server/rest/v1/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wess/zi path: /zi/src/components/text.rs use unicode_width::UnicodeWidthStr; use crate::{layout::Layout, Canvas, Component, ComponentLink, Rect, ShouldRender, Size, Style}; #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum TextAlign { Left, Centre, Right, } impl Default for Te...
code_fim
hard
{ "lang": "rust", "repo": "wess/zi", "path": "/zi/src/components/text.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn resize(&mut self, frame: Rect) -> ShouldRender { if self.frame != frame { self.frame = frame; ShouldRender::Yes } else { ShouldRender::No } } fn view(&self) -> Layout { let Self { frame, properties:...
code_fim
hard
{ "lang": "rust", "repo": "wess/zi", "path": "/zi/src/components/text.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: artfly/rust-course path: /lectures/01-intro/tuples/main.rs fn main() { let t = (92,); println!("{:?}", &t as *const (i32,)); println!("{:?}", <|fim_suffix|>8] = unsafe { &*(&y as *const (i32, i32) as *const [u8; 8])}; println!("{:02X?}", y_view); }<|fim_middle|>&t.0 as *const i32...
code_fim
medium
{ "lang": "rust", "repo": "artfly/rust-course", "path": "/lectures/01-intro/tuples/main.rs", "mode": "psm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_suffix|>*(&x as *const i32 as *const [u8; 4])}; println!("{:02X?}", x_view); let y_view: &[u8; 8] = unsafe { &*(&y as *const (i32, i32) as *const [u8; 8])}; println!("{:02X?}", y_view); }<|fim_prefix|>// repo: artfly/rust-course path: /lectures/01-intro/tuples/main.rs fn main() { let t = (92,); ...
code_fim
medium
{ "lang": "rust", "repo": "artfly/rust-course", "path": "/lectures/01-intro/tuples/main.rs", "mode": "spm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tearitco/FactorishWasm path: /src/items.rs use super::{FactorishState, ImageBundle}; use serde::{Deserialize, Serialize}; use wasm_bindgen::prelude::*; use web_sys::CanvasRenderingContext2d; #[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, Serialize, Deserialize)] pub(crate) enum ItemType { ...
code_fim
hard
{ "lang": "rust", "repo": "tearitco/FactorishWasm", "path": "/src/items.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ItemType::TransportBelt => &state.image_belt.as_ref().unwrap().url, ItemType::Chest => &state.image_chest.as_ref().unwrap().url, ItemType::Inserter => &state.image_inserter.as_ref().unwrap().url, ItemType::OreMine => &state.image_mine.as_ref().unwrap().url, ItemType...
code_fim
hard
{ "lang": "rust", "repo": "tearitco/FactorishWasm", "path": "/src/items.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: raz-a/msp432_razcal path: /src/spi/mod.rs //! # SPI //! The `spi` module includes structures and functions to utilize the Serial Peripheral Interface //! (SPI) protocol. use crate::Edge; // // Represents different SPI typestate configurations. // /// Represents a SPI Clock Polarity ...
code_fim
hard
{ "lang": "rust", "repo": "raz-a/msp432_razcal", "path": "/src/spi/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Edge::RisingEdge } } /// A zero-size typedtate indicating data sampling on falling edge. pub struct FallingEdgeSample; impl ClockPhase for FallingEdgeSample { /// Gets the data sampling clock edge. /// /// # Returns /// `RisingEdge` if data is sampled at the rising e...
code_fim
hard
{ "lang": "rust", "repo": "raz-a/msp432_razcal", "path": "/src/spi/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let pi: f32 = total / incirkle; println!("{:.1}", pi); }<|fim_prefix|>// repo: arte921/misc path: /rust/pi.rs use rand::prelude::*; const TOTAL = 100; <|fim_middle|>fn main () { let mut rng = rand::thread_rng(); let mut incirkle = 0; for _i in 0..TOTAL { if (sqr...
code_fim
hard
{ "lang": "rust", "repo": "arte921/misc", "path": "/rust/pi.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for _i in 0..TOTAL { if (sqrt(rng.gen().pow(2) + rng.gen().pow(2)) < 1) { incirkle += 1; } } let pi: f32 = total / incirkle; println!("{:.1}", pi); }<|fim_prefix|>// repo: arte921/misc path: /rust/pi.rs use rand::prelude::*; const TOTAL = 100; fn main ...
code_fim
medium
{ "lang": "rust", "repo": "arte921/misc", "path": "/rust/pi.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arte921/misc path: /rust/pi.rs use rand::prelude::*; const TOTAL = 100; fn main () { let mut rng = rand::thread_rng(); <|fim_suffix|> let pi: f32 = total / incirkle; println!("{:.1}", pi); }<|fim_middle|> let mut incirkle = 0; for _i in 0..TOTAL { if (sqr...
code_fim
medium
{ "lang": "rust", "repo": "arte921/misc", "path": "/rust/pi.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn execute(&mut self, message: &str, output_messages:&mut Vec<(&str, ActorView)>); fn kill(&mut self); fn get_id(&self)->i32; fn is_alive(&self)->bool; }<|fim_prefix|>// repo: beatgammit/rusteroids path: /src/actor.rs use std::fmt::Show; use std::cmp::PartialEq; #[deriving(Clone, Show, P...
code_fim
medium
{ "lang": "rust", "repo": "beatgammit/rusteroids", "path": "/src/actor.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn get_view(&self) -> ActorView; fn execute(&mut self, message: &str, output_messages:&mut Vec<(&str, ActorView)>); fn kill(&mut self); fn get_id(&self)->i32; fn is_alive(&self)->bool; }<|fim_prefix|>// repo: beatgammit/rusteroids path: /src/actor.rs use std::fmt::Show; use std::cmp::...
code_fim
hard
{ "lang": "rust", "repo": "beatgammit/rusteroids", "path": "/src/actor.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: beatgammit/rusteroids path: /src/actor.rs use std::fmt::Show; use std::cmp::PartialEq; #[deriving(Clone, Show, PartialEq)] pub enum CollisionType{ Collide, Collect, Ignore } #[deriving(Clone, Show, PartialEq)] pub struct ActorView{ pub id: i32, pub parent: i32, pub x: f...
code_fim
medium
{ "lang": "rust", "repo": "beatgammit/rusteroids", "path": "/src/actor.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: clucompany/cluConstData path: /examples/dyn_generic.rs #[macro_use] extern crate cluConstData; use std::marker::PhantomData; pub trait TypeTrait { const TYPE: &'static str; #[inline] fn as_type_str() -> &'static str { Self::TYPE } } impl TypeTrait for usize { const TYPE: &'static st...
code_fim
hard
{ "lang": "rust", "repo": "clucompany/cluConstData", "path": "/examples/dyn_generic.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> println!("#2 {:?}", <(usize, usize)>::as_type_str()); assert_eq!(<(usize, usize)>::as_type_str(), "usize + usize"); } /* impl<A, B> TypeTrait for (A, B) where A: TypeTrait, B: TypeTrait { const_data! { const TYPE: &'static str = A::TYPE, B::TYPE; } }*/ /* error[E0599]: no associated item named `RAW...
code_fim
medium
{ "lang": "rust", "repo": "clucompany/cluConstData", "path": "/examples/dyn_generic.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/* impl<A, B> TypeTrait for (A, B) where A: TypeTrait, B: TypeTrait { const_data! { const TYPE: &'static str = A::TYPE, B::TYPE; } }*/ /* error[E0599]: no associated item named `RAW_TYPE` found for type `A` in the current scope --> examples/trait_use.rs:53:38 | 53 | const RAW_TYPE: &'stat...
code_fim
medium
{ "lang": "rust", "repo": "clucompany/cluConstData", "path": "/examples/dyn_generic.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Then assert_eq!(result, "fizzbuzz"); } #[test] fn should_return_nunmber_as_string_otherwise() { // Given let input = 4; // When let result = get_result(input); // Then assert_eq!(result, "4"); } }<|fim_prefix|>// repo: m...
code_fim
hard
{ "lang": "rust", "repo": "mavericks065/rust-playground", "path": "/src/fizzbuzz.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // When let result = get_result(input); // Then assert_eq!(result, "fizzbuzz"); } #[test] fn should_return_nunmber_as_string_otherwise() { // Given let input = 4; // When let result = get_result(input); // Then ...
code_fim
hard
{ "lang": "rust", "repo": "mavericks065/rust-playground", "path": "/src/fizzbuzz.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mavericks065/rust-playground path: /src/fizzbuzz.rs fn get_result(number: u16) -> String { if number % 15 == 0 { return String::from("fizzbuzz"); } if number % 3 == 0 { return String::from("fizz"); } if number % 5 == 0 { return String::from("buzz"); ...
code_fim
hard
{ "lang": "rust", "repo": "mavericks065/rust-playground", "path": "/src/fizzbuzz.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut board = starting_board; let plies = 0; // half moves played loop { if board.turn == fry_color { let mut read_buf = String::new(); print!("move> "); let player_move = std::io::stdin().read_line(&mut read_buf); // board.turn ...
code_fim
hard
{ "lang": "rust", "repo": "ergor/fry", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ergor/fry path: /src/main.rs mod chess_structs; #[macro_use] mod generator; mod evaluator; mod minimax; mod game_state; mod libmappings; mod args; use std::process; use args::FryArgs; use crate::chess_structs::{Board, Piece, Kind, Color}; use crate::game_state::GameState; use crate::args::ArgEr...
code_fim
hard
{ "lang": "rust", "repo": "ergor/fry", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_zero() { // Arrange let mut rp = RunningProduct::new(5); rp.add(0); rp.add(4); rp.add(5); rp.add(6); rp.add(7); // Act rp.add(8); // Assert assert_eq!(rp.get(), 4 * 5 * 6 * 7 * 8); } ...
code_fim
hard
{ "lang": "rust", "repo": "svenschmidt75/Rust", "path": "/DSandAlg/CodingProblems/John/GoogleProblem7/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: svenschmidt75/Rust path: /DSandAlg/CodingProblems/John/GoogleProblem7/src/lib.rs use std::cmp; use std::collections::VecDeque; struct RunningProduct { k: usize, buffer: VecDeque<i64>, position: usize, product: i64, time_to_remove_zero: usize, } impl RunningProduct { fn ...
code_fim
hard
{ "lang": "rust", "repo": "svenschmidt75/Rust", "path": "/DSandAlg/CodingProblems/John/GoogleProblem7/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if self.position < self.k { self.buffer.push_back(value); self.position += 1; self.product *= value; } else { // SS: overflow let overflow_element = self.buffer[0]; // SS: using a queue or a circular array can avoid t...
code_fim
hard
{ "lang": "rust", "repo": "svenschmidt75/Rust", "path": "/DSandAlg/CodingProblems/John/GoogleProblem7/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ev = serde_json::from_value(json!({ "type": "m.room.name", "content": { "name": "foo" } })) .unwrap(); assert_matches!(ev, AnyInitialStateEvent::RoomName(ev)); assert_eq!(ev.content.name.as_deref(), Some("foo")); }<|fim_prefix|>// repo: ruma/ruma path: /crates/ruma...
code_fim
easy
{ "lang": "rust", "repo": "ruma/ruma", "path": "/crates/ruma-events/tests/it/initial_state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ruma/ruma path: /crates/ruma-events/tests/it/initial_state.rs use assert_matches2::assert_matches; use ruma_events::AnyInitialStateEvent; use serde_json::json; <|fim_suffix|> let ev = serde_json::from_value(json!({ "type": "m.room.name", "content": { "name": "foo" } })) ...
code_fim
easy
{ "lang": "rust", "repo": "ruma/ruma", "path": "/crates/ruma-events/tests/it/initial_state.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn ipv6_translation(address: &str) -> String { // example entry: 000080FE00000000DCE3A8A94F3E8895:C9D6 = // fe80::a9a8:e3dc:9:51670 let addr_port: Vec<&str> = address.split(":").collect(); // we need 8 u16 values to form an ipv6 addr // we just have this string to work with: 000080FE00...
code_fim
hard
{ "lang": "rust", "repo": "KurSh/nantup", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KurSh/nantup path: /src/main.rs use std::fs; use std::net::{Ipv4Addr, Ipv6Addr}; use glob::glob; use regex::Regex; use std::collections::HashMap; use std::io::BufReader; use std::io::prelude::*; use std::fs::File; pub struct Entry { protocol: String, local: String, remote: Stri...
code_fim
hard
{ "lang": "rust", "repo": "KurSh/nantup", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match int_optional_some { Optional::CSome(value) => println!("value is {}", value), Optional::CNone => println!("none value") } }<|fim_prefix|>// repo: zhuohuwu0603/rust-scala path: /rust/simple/src/bin/adt.rs enum Optional<T> { CNone, CSome(T) } fn main() { <|fim_middle|> let int_option...
code_fim
medium
{ "lang": "rust", "repo": "zhuohuwu0603/rust-scala", "path": "/rust/simple/src/bin/adt.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhuohuwu0603/rust-scala path: /rust/simple/src/bin/adt.rs enum Optional<T> { CNone, CSome(T) } <|fim_suffix|> match int_optional_some { Optional::CSome(value) => println!("value is {}", value), Optional::CNone => println!("none value") } }<|fim_middle|>fn main() { let int_option...
code_fim
medium
{ "lang": "rust", "repo": "zhuohuwu0603/rust-scala", "path": "/rust/simple/src/bin/adt.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: petitviolet/rsstable path: /src/sst.rs //! SSTable(Sorted String Table) in Rust //! Basically, this is a Key-Value store on top of local file storage. use log; use std::io; mod disktable; mod memtable; mod rich_file; pub struct SSTable { // Sorted *String* Table :) memtable: Box<dyn me...
code_fim
hard
{ "lang": "rust", "repo": "petitviolet/rsstable", "path": "/src/sst.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_sstabl_tombstones() { let key = |i| format!("key-{}", i); let value = |i| format!("value-{}", i); let mut sst = SSTable::new("./test_tmp2", 3); assert!(sst.clear().is_ok()); (1..=5).for_each(|i| { sst.insert(key(i), value(i)).expe...
code_fim
hard
{ "lang": "rust", "repo": "petitviolet/rsstable", "path": "/src/sst.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if ip4::scan( DATA.s.offset(i as (isize)) as (*const u8), ip.offset(iplen as (isize)), ) != 0 { if byte::diff( ...
code_fim
hard
{ "lang": "rust", "repo": "neuroradiology/drdns", "path": "/src/dns/rcip.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: neuroradiology/drdns path: /src/dns/rcip.rs //! `dns/resolvconf.rs`: Functions for interacting with resolv.conf use byte; use ip4; use libc; use openreadclose::openreadclose; use stralloc::StrAlloc; use tai::Tai; use taia::TaiA; static mut DATA: StrAlloc = StrAlloc { s: 0i32 as (*mut u8), ...
code_fim
hard
{ "lang": "rust", "repo": "neuroradiology/drdns", "path": "/src/dns/rcip.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iqlusioninc/abscissa path: /core/src/thread/kill_switch.rs //! Kill switches are a cooperative approach to requesting a thread terminate, //! by setting a flag in one thread that another thread can periodically check //! in order to determine if it should exit. <|fim_suffix|> /// Throw the k...
code_fim
hard
{ "lang": "rust", "repo": "iqlusioninc/abscissa", "path": "/core/src/thread/kill_switch.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Check whether the kill switch for this thread has been thrown. /// /// Panics if no kill switch is configured for the current thread. pub(super) fn is_thrown() -> bool { KILL_SWITCH.with(|ks| { ks.borrow() .as_ref() .expect("no kill switch configured for current thr...
code_fim
hard
{ "lang": "rust", "repo": "iqlusioninc/abscissa", "path": "/core/src/thread/kill_switch.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn p1(s: &str) -> usize { parse(s) .filter_map(|(name, id, ck_sum)| { let mut counts = Counter::<char>::default(); for c in name.chars() { if c == '-' { continue; }; counts.inc(c); } let mut order: Vec<_> = counts .into_iter() ...
code_fim
hard
{ "lang": "rust", "repo": "azdavis/advent-of-code", "path": "/years/y2016/src/d04.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: azdavis/advent-of-code path: /years/y2016/src/d04.rs use helpers::{static_regex, Counter}; use std::cmp::Reverse; static_regex!(RE = r"^([a-z\-]+)-(\d+)\[([a-z]+)\]$"); fn parse(s: &str) -> impl Iterator<Item = (&str, usize, &str)> + '_ { <|fim_suffix|>pub fn p2(s: &str) -> usize { parse(s) ...
code_fim
hard
{ "lang": "rust", "repo": "azdavis/advent-of-code", "path": "/years/y2016/src/d04.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn p2(s: &str) -> usize { parse(s) .map(|(name, id, _)| { let shifted_name: String = name .bytes() .map(move |c| { if c == b'-' { ' ' } else { let n: u8 = ((usize::from(c - b'a') + id) % 26).try_into().unwrap(); char::...
code_fim
hard
{ "lang": "rust", "repo": "azdavis/advent-of-code", "path": "/years/y2016/src/d04.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aristotle9/qt_generator-output path: /qt_gui/src/accessible_text_interface.rs /// C++ type: <span style='color: green;'>```QAccessibleTextInterface```</span> #[repr(C)] pub struct AccessibleTextInterface(u8); impl AccessibleTextInterface { /// C++ method: <span style='color: green;'>```pure v...
code_fim
hard
{ "lang": "rust", "repo": "aristotle9/qt_generator-output", "path": "/qt_gui/src/accessible_text_interface.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// C++ method: <span style='color: green;'>```virtual QString QAccessibleTextInterface::textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType, int* startOffset, int* endOffset) const```</span> /// /// pub unsafe fn text_before_offset(&self, off...
code_fim
hard
{ "lang": "rust", "repo": "aristotle9/qt_generator-output", "path": "/qt_gui/src/accessible_text_interface.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// C++ method: <span style='color: green;'>```virtual QString QAccessibleTextInterface::textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, int* startOffset, int* endOffset) const```</span> /// /// pub unsafe fn text_after_offset(&self, offset...
code_fim
hard
{ "lang": "rust", "repo": "aristotle9/qt_generator-output", "path": "/qt_gui/src/accessible_text_interface.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gerardabello/rusty-monkey path: /parser/tests/integration_test.rs true; false; "; let expected_ast = vec![ ast::Statement::ExpressionStatement { expression: ast::Expression::IntegerLiteral { value: 42 }, }, ast::Statement::ExpressionS...
code_fim
hard
{ "lang": "rust", "repo": "gerardabello/rusty-monkey", "path": "/parser/tests/integration_test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let expected_ast = vec![ast::Statement::ReturnStatement { expression: ast::Expression::FunctionExpression { arguments: vec![String::from("a")], body: vec![ast::Statement::ReturnStatement { expression: ast::Expression::InfixExpression { ...
code_fim
hard
{ "lang": "rust", "repo": "gerardabello/rusty-monkey", "path": "/parser/tests/integration_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_if_else_expression() { let program = " if (x <= 7) { let z = x * 2; z } else { 14 }; "; let expected_ast = vec![ast::Statement::ExpressionStatement { expression: ast::Expression::IfExpression { ...
code_fim
hard
{ "lang": "rust", "repo": "gerardabello/rusty-monkey", "path": "/parser/tests/integration_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Render background highlight let brush = &mut self.glyph_brushes .get_mut(&ui_text.brush_id.unwrap()) .unwrap(); // Maintain the glyph cache (used by the input code). ui_text.cached_glyphs.clear(); ...
code_fim
hard
{ "lang": "rust", "repo": "amethyst/ludumdare42", "path": "/amethyst/amethyst_ui/src/pass.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: amethyst/ludumdare42 path: /amethyst/amethyst_ui/src/pass.rs bitset.remove(entity.id()); } keep }); } for &mut (ref mut z, entity) in &mut self.cached_draw_order.cache { *z = ui_transform.get(entity).unwrap().global_z; ...
code_fim
hard
{ "lang": "rust", "repo": "amethyst/ludumdare42", "path": "/amethyst/amethyst_ui/src/pass.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // For the number of cards we can have in our hand. for i in 0..MAX_HAND_SIZE { // For each type of possible card for j in 0..Card::CardMax as usize { // Enter a 1.0 if that card is in this position, or a 0.0 if it isn't. if game.get_current_player().card_is_at_position_hand(i, &j) { ...
code_fim
hard
{ "lang": "rust", "repo": "Icey1717/SushiGoNN", "path": "/src/neural_network_game/model_a.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Icey1717/SushiGoNN path: /src/neural_network_game/model_a.rs use super::neural_network::*; use super::game::*; use super::game::player::card::*; // Use the feed forward algorithm to pick a card from the players current hand. pub fn pick_cards(game: &SushiGoGame, nn: &NeuralNetwork) -> Vec<Card...
code_fim
hard
{ "lang": "rust", "repo": "Icey1717/SushiGoNN", "path": "/src/neural_network_game/model_a.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matt-thomson/advent-of-code path: /2015/day07/src/circuit.rs use gate::{Action, Gate, Input}; use std::collections::HashMap; pub struct Circuit { gates: HashMap<String, Action> } impl Circuit { pub fn parse(lines: &mut Iterator<Item = String>) -> Circuit { let mut gates = Hash...
code_fim
hard
{ "lang": "rust", "repo": "matt-thomson/advent-of-code", "path": "/2015/day07/src/circuit.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(circuit.result("z"), 2); } #[test] fn test_computes_or() { let input = vec!["3 -> x".to_string(), "6 -> y".to_string(), "x OR y -> z".to_string()]; let circuit = Circuit::parse(&mut input.into_iter()); assert_eq!(circuit.result("z"), 7); } ...
code_fim
hard
{ "lang": "rust", "repo": "matt-thomson/advent-of-code", "path": "/2015/day07/src/circuit.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let ref action = circuit.gates["y"]; assert_eq!(*action, Action::Literal(Input::Number(2))); } #[test] fn test_computes_literal() { let input = vec!["1 -> x".to_string()]; let circuit = Circuit::parse(&mut input.into_iter()); assert_eq!(circuit.result(...
code_fim
hard
{ "lang": "rust", "repo": "matt-thomson/advent-of-code", "path": "/2015/day07/src/circuit.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self } } impl Reader { fn find_existing_local_conf(paths: Vec<std::path::PathBuf>) -> Result<std::path::PathBuf, ReaderError> { match paths.into_iter().find(|path| path.exists()) { Some(path) => Ok(path), None => Err(ReaderError{}), } ...
code_fim
hard
{ "lang": "rust", "repo": "im-0/syslinux-conf", "path": "/src/lib/reader.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>macro_rules! resolve_some { ($var: expr, $root_dir: ident, $conf_dir: ident) => { match $var { Some(obj_with_path) => { Some(obj_with_path.resolve($root_dir, $conf_dir)) }, None => None, } } } impl PathResolver for types::Kernel...
code_fim
hard
{ "lang": "rust", "repo": "im-0/syslinux-conf", "path": "/src/lib/reader.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: im-0/syslinux-conf path: /src/lib/reader.rs use std; extern crate enum_derive; extern crate nom; use types; custom_derive! { #[derive(Debug, IterVariants(LocalConfTypeVariants))] pub enum LocalConfType { SysLinux, // syslinux/syslinux.cfg IsoLinux, // isolinux/isolin...
code_fim
hard
{ "lang": "rust", "repo": "im-0/syslinux-conf", "path": "/src/lib/reader.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Mechasaure/Rust-Monster path: /src/command_words.rs //! This contains all the key command words the bot understands. //! Adding words to this file automatically adds them to the help system and event listener. use anyhow::{Result, anyhow}; use crate::discord::{DiscordReferences}; /// Respond t...
code_fim
hard
{ "lang": "rust", "repo": "Mechasaure/Rust-Monster", "path": "/src/command_words.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> response } const ALL_WORDS: [&[Word];3] = [&VERBS,&NOUNS,&TARGETS]; /////////////////////////////////////////////////////// // VERBS /////////////////////////////////////////////////////// pub const VERBS: [Word; 4] = [ Word{ term: "add", kind: WordType::Verb, short_help...
code_fim
hard
{ "lang": "rust", "repo": "Mechasaure/Rust-Monster", "path": "/src/command_words.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() -> std::io::Result<()> { let init_state = CoffeeState { brewing: false, last_brewed: None, }; let lock = Arc::new(RwLock::new(init_state)); start_poller_and_reader(lock.clone()); rocket::ignite() .mount("/", routes![index]) .manage(lock) ...
code_fim
hard
{ "lang": "rust", "repo": "appcues/coffeecues", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: appcues/coffeecues path: /src/main.rs #![feature(proc_macro_hygiene, decl_macro)] use std::fs::File; use std::io::prelude::*; use std::thread; use std::sync::{mpsc, Arc, RwLock}; use std::sync::mpsc::{Receiver, Sender}; use std::time::Duration; use chrono::prelude::*; use rocket::State; // sta...
code_fim
hard
{ "lang": "rust", "repo": "appcues/coffeecues", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pablo-mansanet-bluefruit/efm32gg11b path: /src/usb.rs rate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [doep0dmaaddr](doep0dmaaddr) module"] pub type DOEP0DMAADDR = crate::Reg<u32, _DOEP0DMAADDR>; #[allow(mis...
code_fim
hard
{ "lang": "rust", "repo": "pablo-mansanet-bluefruit/efm32gg11b", "path": "/src/usb.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>d--modify--write-api).\n\nFor information about available fields see [hc2_splt](hc2_splt) module"] pub type HC2_SPLT = crate::Reg<u32, _HC2_SPLT>; #[allow(missing_docs)] #[doc(hidden)] pub struct _HC2_SPLT; #[doc = "`read()` method returns [hc2_splt::R](hc2_splt::R) reader structure"] impl crate::Readable...
code_fim
hard
{ "lang": "rust", "repo": "pablo-mansanet-bluefruit/efm32gg11b", "path": "/src/usb.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pablo-mansanet-bluefruit/efm32gg11b path: /src/usb.rs e"] impl crate::Writable for DIEP0_CTL {} #[doc = "Device Control IN Endpoint x+1 Control Register"] pub mod diep0_ctl; #[doc = "Device IN Endpoint x+1 Interrupt Register\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`]...
code_fim
hard
{ "lang": "rust", "repo": "pablo-mansanet-bluefruit/efm32gg11b", "path": "/src/usb.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let dog = Dog { name: String::from("dog"), weight: 100.0, height: 100.0, }; let name = dog.get_name(); println!("name = {}", name); }<|fim_prefix|>// repo: uran0sH/notes path: /rust/essential_rust/exercise_impl.rs struct Dog { name: String, weig...
code_fim
medium
{ "lang": "rust", "repo": "uran0sH/notes", "path": "/rust/essential_rust/exercise_impl.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uran0sH/notes path: /rust/essential_rust/exercise_impl.rs struct Dog { name: String, weight: f32, height: f32, } <|fim_suffix|> &self.name } } fn main() { let dog = Dog { name: String::from("dog"), weight: 100.0, height: 100.0, }; let ...
code_fim
easy
{ "lang": "rust", "repo": "uran0sH/notes", "path": "/rust/essential_rust/exercise_impl.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let dog = Dog { name: String::from("dog"), weight: 100.0, height: 100.0, }; let name = dog.get_name(); println!("name = {}", name); }<|fim_prefix|>// repo: uran0sH/notes path: /rust/essential_rust/exercise_impl.rs struct Dog { name: String, weight: f32, ...
code_fim
easy
{ "lang": "rust", "repo": "uran0sH/notes", "path": "/rust/essential_rust/exercise_impl.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> server_tx .send((daddr.to_string(), recv_data.clone())) .await .or(Err("close"))?; } } }, { ...
code_fim
hard
{ "lang": "rust", "repo": "FH0/stn", "path": "/stn/src/dns/out_udp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FH0/stn path: /stn/src/dns/out_udp.rs use log::*; use std::{sync::Arc, time::Duration}; use trust_dns_proto::op::{Message, Query}; #[async_trait::async_trait] impl crate::route::OutUdp for super::Out { async fn udp_bind( self: Arc<Self>, saddr: String, client_tx: tok...
code_fim
hard
{ "lang": "rust", "repo": "FH0/stn", "path": "/stn/src/dns/out_udp.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>//db以下にファイルを作成(data1, data2...)しており,最終番号を取得する. // 引数 : 無し // 返り値: i32型 fn get_tail_id() -> i32 { // db以下のファイル名を取得 let paths = fs::read_dir("db/").unwrap(); let mut id_list = Vec::new(); for path in paths { id_list.push(path.unwrap().path().display().to_string()); } let fil...
code_fim
hard
{ "lang": "rust", "repo": "fujiwara-yu/ERIM", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fujiwara-yu/ERIM path: /src/main.rs #![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate rocket; #[macro_use] extern crate serde_derive; extern crate serde_json; use std::fs; use std::collections::HashMap; use std::io::{BufRead, BufReader, Read, Write}; use std::fs::File; use ...
code_fim
hard
{ "lang": "rust", "repo": "fujiwara-yu/ERIM", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> serde_json::from_str(&data).unwrap() } //db以下のファイル一覧を取得する. // 引数 : 無し // 返り値: String型の配列 fn get_files() -> Vec<String> { // db以下のファイル名を取得 let paths = fs::read_dir("db/").unwrap(); let mut files = Vec::new(); for path in paths { files.push(path.unwrap().path().display().to_stri...
code_fim
hard
{ "lang": "rust", "repo": "fujiwara-yu/ERIM", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Redeem::get_open_redeem_request_from_id.mock_safe(|_| { MockResult::Return(Ok(RedeemRequest { period: 0, vault: VAULT, opentime: 0, fee: 0, amount_btc: 0, premium: 0, redeeme...
code_fim
hard
{ "lang": "rust", "repo": "Polkadex-Substrate/interbtc", "path": "/crates/redeem/src/tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Polkadex-Substrate/interbtc path: /crates/redeem/src/tests.rs { BtcPublicKey([ 2, 205, 114, 218, 156, 16, 235, 172, 106, 37, 18, 153, 202, 140, 176, 91, 207, 51, 187, 55, 18, 45, 222, 180, 119, 54, 243, 97, 173, 150, 161, 169, 230, ]) } fn default_vault() -> DefaultVault...
code_fim
hard
{ "lang": "rust", "repo": "Polkadex-Substrate/interbtc", "path": "/crates/redeem/src/tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Polkadex-Substrate/interbtc path: /crates/redeem/src/tests.rs rapped, account| { assert_eq!(account, &redeemer); assert_eq!(amount_wrapped, &wrapped(amount)); MockResult::Return(Ok(())) }); ext::security::get_secure_id::<Test>.mock_safe(move ...
code_fim
hard
{ "lang": "rust", "repo": "Polkadex-Substrate/interbtc", "path": "/crates/redeem/src/tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut output1: Vec<f32> = Vec::new(); let mut output2: Vec<f32> = Vec::new(); while let Some(Ok(packet)) = packets.next() { self.decoder.send_packet(&packet.1).unwrap(); self.decode(&mut output1, &mut output2); /* read all the output frames (in...
code_fim
hard
{ "lang": "rust", "repo": "sonata-chen/simplePlayer", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sonata-chen/simplePlayer path: /src/main.rs #![allow(non_snake_case)] #![allow(unused_imports)] use ffmpeg::codec::Context as CodecContext; use ffmpeg::decoder; use ffmpeg::format; use ffmpeg::format::context::input::PacketIter; use ffmpeg::format::context::Input as InputContext; use ffmpeg::fo...
code_fim
hard
{ "lang": "rust", "repo": "sonata-chen/simplePlayer", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }