text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: dmvoiper/rusty-shooter path: /src/level.rs use rg3d::{ resource::{ model::Model, texture::TextureKind, }, event::WindowEvent, scene::{ Scene, SceneInterfaceMut, base::{AsBase, BaseBuilder}, particle_system::{ ParticleSys...
code_fim
hard
{ "lang": "rust", "repo": "dmvoiper/rusty-shooter", "path": "/src/level.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Supercip971/NoNameKernel path: /src/utils/panic.rs use crate::lib::vga::Writer; use crate::lib::vga_color::{Color, ColorCode}; use core::fmt::Write; use core::panic::PanicInfo; <|fim_suffix|> let mut buffer = Writer::default(); let panic_message = match _info.message() { Some(ar...
code_fim
medium
{ "lang": "rust", "repo": "Supercip971/NoNameKernel", "path": "/src/utils/panic.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> let mut buffer = Writer::default(); let panic_message = match _info.message() { Some(arg) => arg.as_str().unwrap_or("No Message Error"), None => "No message Error", }; let location = match _info.location() { Some(e) => e, None => { buffer.color_...
code_fim
medium
{ "lang": "rust", "repo": "Supercip971/NoNameKernel", "path": "/src/utils/panic.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Haaztre/toy-rsa path: /src/lib.rs extern crate rand; use std::convert::TryFrom; ///modexp takes three u64 values, x, y, and m, then recursively determines the resulting exponentiation of x and y, mod m. Errors if m is zero fn modexp(x: u64, y: u64, m: u64) -> u64 { if m == 0 { error...
code_fim
hard
{ "lang": "rust", "repo": "Haaztre/toy-rsa", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn genkey() -> (u64, u64) { let p: u64 = primegen(); let mut q: u64 = primegen(); let e: u64 = 65537; while e >= lcm(p - 1, q - 1) && gcd(e, lcm(p - 1, q - 1)) != 1 { q = primegen(); } (p, q) } pub fn encrypt(msg: u64) -> (u64,u64,u64) { let key: (u64, u64) = genk...
code_fim
hard
{ "lang": "rust", "repo": "Haaztre/toy-rsa", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match codec.encode(&mut con, message) { Encode::Success => { self.insert(reactor_id, (con, codec)); Some(()) } Encode::Fail => { self.data.remove(&reactor_id); None } } } }<|...
code_fim
hard
{ "lang": "rust", "repo": "togglebyte/thegame", "path": "/server/src/connections.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn send(&mut self, reactor_id: u64, message: U::Item) -> Option<()> { let (mut con, mut codec) = self.remove(&reactor_id).unwrap(); match codec.encode(&mut con, message) { Encode::Success => { self.insert(reactor_id, (con, codec)); Some(...
code_fim
hard
{ "lang": "rust", "repo": "togglebyte/thegame", "path": "/server/src/connections.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: togglebyte/thegame path: /server/src/connections.rs use std::collections::HashMap; use std::io::ErrorKind::WouldBlock; use std::io::{Read, Write}; use std::ops::{Deref, DerefMut}; use std::os::unix::io::AsRawFd; use netlib::{Event, PollReactor}; use crate::codec::{Codec, Decode, Encode}; // -...
code_fim
hard
{ "lang": "rust", "repo": "togglebyte/thegame", "path": "/server/src/connections.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: graycl/rust_turorial path: /hw01/src/tests_provided.rs #![cfg(test)] use problem1::{sum, dedup, filter}; use problem2::mat_mult; use problem3::sieve; use problem4::{hanoi, Peg}; // // Problem 1 // // Part 1 #[test] fn test_sum_small() { let array = [1,2,3,4,5]; assert_eq!(sum(&array)...
code_fim
hard
{ "lang": "rust", "repo": "graycl/rust_turorial", "path": "/hw01/src/tests_provided.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// // Problem 4 // #[test] fn test_hanoi_1_disks() { let result = hanoi(1, Peg::A, Peg::B, Peg::C); assert_eq!(vec![(Peg::A, Peg::C)], result); assert_eq!(1, result.len()); } #[test] fn test_hanoi_2_disks() { let result = hanoi(2, Peg::A, Peg::B, Peg::C); assert_eq!(vec![(Peg::A, Peg...
code_fim
hard
{ "lang": "rust", "repo": "graycl/rust_turorial", "path": "/hw01/src/tests_provided.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mat1 = vec![vec![2., 3.], vec![2., 5.]]; let mat2 = vec![vec![3., 5.], vec![6., 2.]]; let matres = vec![vec![24.,16.], vec![36.,20.]]; let result = mat_mult(&mat1, &mat2); println!("result is {} x {}", result.len(), result[0].len()); for i in 0..result.len() { for j in ...
code_fim
hard
{ "lang": "rust", "repo": "graycl/rust_turorial", "path": "/hw01/src/tests_provided.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub fn with_system_on_single_thread<AT: AccessType>( mut self, name: &str, system: System, dependencies: &[&str], ) -> Result<Self, PipelineBuilderError> { self.install_system_on_single_thread::<AT>(name, system, dependencies)?; Ok(self...
code_fim
hard
{ "lang": "rust", "repo": "PsichiX/Oxygengine", "path": "/engine/core/src/app.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PsichiX/Oxygengine path: /engine/core/src/app.rs use crate::{ ecs::{ commands::UniverseCommands, hierarchy::{hierarchy_system, Hierarchy, HierarchySystemResources}, life_cycle::EntityChanges, pipeline::{PipelineBuilder, PipelineBuilderError, PipelineEngine, Pi...
code_fim
hard
{ "lang": "rust", "repo": "PsichiX/Oxygengine", "path": "/engine/core/src/app.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub fn install_bundle<ABI, D>( &mut self, mut installer: ABI, data: D, ) -> Result<(), PipelineBuilderError> where ABI: FnMut(&mut AppBuilder<PB>, D) -> Result<(), PipelineBuilderError>, { installer(self, data)?; Ok(()) } ...
code_fim
hard
{ "lang": "rust", "repo": "PsichiX/Oxygengine", "path": "/engine/core/src/app.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // If it contains any letter in the alphabet let has_letter = trimmed.contains(char::is_alphabetic); // If it contains any letter and all letters are in uppercase let a_yell = has_letter && trimmed == trimmed.to_ascii_uppercase(); if trimmed.is_empty() { "Fine. Be that way!" ...
code_fim
medium
{ "lang": "rust", "repo": "bmkrocks1/exercism", "path": "/rust/bob/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bmkrocks1/exercism path: /rust/bob/src/lib.rs pub fn reply(message: &str) -> &str { let trimmed = message.trim(); <|fim_suffix|> // If it contains any letter in the alphabet let has_letter = trimmed.contains(char::is_alphabetic); // If it contains any letter and all letters are ...
code_fim
medium
{ "lang": "rust", "repo": "bmkrocks1/exercism", "path": "/rust/bob/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: teasp00n/notcurses path: /rust/examples/direct-cursor.rs //! Example 'direct-cursor' //! //! Explore cursor functions in direct mode //! use libnotcurses_sys::*; fn main() -> NcResult<()> { let ncd = NcDirect::new()?; let cols = ncd.dim_x(); let rows = ncd.dim_y(); println!("t...
code_fim
medium
{ "lang": "rust", "repo": "teasp00n/notcurses", "path": "/rust/examples/direct-cursor.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let cols = ncd.dim_x(); let rows = ncd.dim_y(); println!("terminal size (rows, cols): {}, {}", rows, cols); ncd.putstr(0, "The current coordinates are")?; for _n in 0..40 { fsleep![ncd, 0, 30]; ncd.putstr(0, ".")?; } let (cy, cx) = ncd.cursor_yx()?; ncd.p...
code_fim
medium
{ "lang": "rust", "repo": "teasp00n/notcurses", "path": "/rust/examples/direct-cursor.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let sentence = vec!["And", "now", "I", "will", "clear", "the", "screen", ".", ".", "."]; for word in sentence { ncd.putstr(0, &format!["{} ", word])?; fsleep![ncd, 0, 150]; } sleep![0, 300]; ncd.putstr(0, "\nbye!\n\n")?; fsleep![ncd, 0, 600]; ncd.clear()?; ...
code_fim
hard
{ "lang": "rust", "repo": "teasp00n/notcurses", "path": "/rust/examples/direct-cursor.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>'mouse & keyboard' 'Maus & Tastatur' '3D GL graphics' '3D GL Graphik' 'about' 'Info' #endif<|fim_prefix|>// repo: GunterMueller/ST_STX_Fork path: /build/stx/clients/GLdemos/resources/RubicsCubeView.rs #if (Language == #german) or:[Language == #de] 'file' 'Date...
code_fim
hard
{ "lang": "rust", "repo": "GunterMueller/ST_STX_Fork", "path": "/build/stx/clients/GLdemos/resources/RubicsCubeView.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GunterMueller/ST_STX_Fork path: /build/stx/clients/GLdemos/resources/RubicsCubeView.rs #if (Language == #german) or:[Language == #de] 'file' 'Datei' 'cube' 'W�rfel' 'about ...' 'Information ...' 'quit' 'Beeenden' <|fim_suffix|>'mous...
code_fim
hard
{ "lang": "rust", "repo": "GunterMueller/ST_STX_Fork", "path": "/build/stx/clients/GLdemos/resources/RubicsCubeView.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kalkyl/aoc-2020 path: /src/bin/3b.rs use std::fs::File; use std::io::{BufRead, BufReader, Error}; fn count_trees(rows: &[String], slope: &(usize, usize)) -> usize { let &(xs, ys) = slope; rows.iter() .step_by(ys) .enumerate() .filter(|(y, r)| r.chars().nth(xs * y...
code_fim
medium
{ "lang": "rust", "repo": "kalkyl/aoc-2020", "path": "/src/bin/3b.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let rows = BufReader::new(File::open("./input/3.txt")?) .lines() .collect::<Result<Vec<_>, _>>()?; let slopes = [(1, 1), (3, 1), (5, 1), (7, 1), (1, 2)]; let result = slopes .iter() .fold(1, |acc, slope| acc * count_trees(&rows, slope)); println!("{}", resul...
code_fim
medium
{ "lang": "rust", "repo": "kalkyl/aoc-2020", "path": "/src/bin/3b.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl LocalVars { pub fn put(&mut self, key: &str, value: Json) { match key { "first" => self.first = Some(value), "last" => self.last = Some(value), "index" => self.index = Some(value), "key" => self.key = Some(value), _ => { ...
code_fim
medium
{ "lang": "rust", "repo": "sunng87/handlebars-rust", "path": "/src/local_vars.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sunng87/handlebars-rust path: /src/local_vars.rs use std::collections::BTreeMap; use serde_json::value::Value as Json; #[derive(Default, Debug, Clone)] pub struct LocalVars { first: Option<Json>, last: Option<Json>, index: Option<Json>, key: Option<Json>, <|fim_suffix|> pub...
code_fim
hard
{ "lang": "rust", "repo": "sunng87/handlebars-rust", "path": "/src/local_vars.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let view = handle.create_view(&TextureViewDescriptor::default()); let sampler = device.create_sampler(&SamplerDescriptor { address_mode_u: AddressMode::ClampToEdge, address_mode_v: AddressMode::ClampToEdge, address_mode_w: AddressMode::ClampToEdge, mag_filter: FilterMode::Linear, min_...
code_fim
hard
{ "lang": "rust", "repo": "travistrue2008/rs-ff4", "path": "/game/src/graphics/texture.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let bind_group = Self::create_bind_group(device, layout, &view, &sampler); Texture { width, height, handle, sampler, view, bind_group, } } pub fn from_image(device: &Device, layout: &BindGroupLayout, queue: &Queue, image: &Image) -> Texture { let frame = image.get_frame(0); ...
code_fim
hard
{ "lang": "rust", "repo": "travistrue2008/rs-ff4", "path": "/game/src/graphics/texture.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: travistrue2008/rs-ff4 path: /game/src/graphics/texture.rs use tim2::Image; use wgpu::*; pub struct Texture { width: u32, height: u32, handle: wgpu::Texture, sampler: Sampler, view: TextureView, bind_group: BindGroup, } impl Texture { pub fn new(device: &Device, layout: &BindGroupLayout,...
code_fim
hard
{ "lang": "rust", "repo": "travistrue2008/rs-ff4", "path": "/game/src/graphics/texture.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl CastPtr for *const u8 { type RustType = *const u8; } /// If the provided pointer is non-null, convert it to a reference. /// Otherwise, return NullParameter, or an appropriate default (false, 0, NULL) /// based on the context; /// Example: /// let config: &mut ClientConfig = try_ref_from_ptr!(...
code_fim
hard
{ "lang": "rust", "repo": "djc/crustls", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: djc/crustls path: /src/lib.rs #![crate_type = "staticlib"] #![allow(non_camel_case_types)] use libc::{c_char, size_t}; use std::cmp::min; use std::io::ErrorKind::ConnectionAborted; use std::sync::Arc; use std::{io, mem, slice}; mod cipher; mod client; mod enums; mod error; mod panic; mod rslice...
code_fim
hard
{ "lang": "rust", "repo": "djc/crustls", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ajunlonglive/CoCreate-openebs path: /src/mayastor/src/bdev/nexus/nexus_bdev_children.rs //! //! `add_child` will construct a new `NexusChild` and add the bdev given by the //! uri to the nexus. The nexus will transition to degraded mode as the new //! child requires rebuild first. If the rebuil...
code_fim
hard
{ "lang": "rust", "repo": "ajunlonglive/CoCreate-openebs", "path": "/src/mayastor/src/bdev/nexus/nexus_bdev_children.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(child) = self.children.iter_mut().find(|c| c.name == name) { child.offline().await; } else { return Err(Error::ChildNotFound { name: self.name.clone(), child: name.to_owned(), }); } self.reconf...
code_fim
hard
{ "lang": "rust", "repo": "ajunlonglive/CoCreate-openebs", "path": "/src/mayastor/src/bdev/nexus/nexus_bdev_children.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ajunlonglive/CoCreate-openebs path: /src/mayastor/src/bdev/nexus/nexus_bdev_children.rs o //! the IO path of the nexus currently, online of a child will default the nexus //! into the degraded mode as it (may) require a rebuild. This will be changed //! in the near future -- online child will no...
code_fim
hard
{ "lang": "rust", "repo": "ajunlonglive/CoCreate-openebs", "path": "/src/mayastor/src/bdev/nexus/nexus_bdev_children.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: miker1423/atsamv71q21 path: /src/efc/fsr.rs #[doc = "Register `FSR` reader"] pub struct R(crate::R<FSR_SPEC>); impl core::ops::Deref for R { type Target = crate::R<FSR_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl core::convert::From<crate::...
code_fim
hard
{ "lang": "rust", "repo": "miker1423/atsamv71q21", "path": "/src/efc/fsr.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } impl R { #[doc = "Bit 0 - Flash Ready Status (cleared when Flash is busy)"] #[inline(always)] pub fn frdy(&self) -> FRDY_R { FRDY_R::new((self.bits & 0x01) != 0) } #[doc = "Bit 1 - Flash Command Error Status (cleared on read or by writing EEFC_FCR)"] ...
code_fim
hard
{ "lang": "rust", "repo": "miker1423/atsamv71q21", "path": "/src/efc/fsr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ogham/rust-numerals path: /src/lib.rs //! This is a set of libraries for converting to and from various numeric systems. //! /<|fim_suffix|>al_numeric_casts)] #![warn(unreachable_pub)] #![warn(unused)] pub mod bt; pub mod roman;<|fim_middle|>/! For more information, see the documentation for a ...
code_fim
medium
{ "lang": "rust", "repo": "ogham/rust-numerals", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>al_numeric_casts)] #![warn(unreachable_pub)] #![warn(unused)] pub mod bt; pub mod roman;<|fim_prefix|>// repo: ogham/rust-numerals path: /src/lib.rs //! This is a set of libraries for converting to and from various numeric systems. //! //! For more information, see the documentation for a particular mod...
code_fim
medium
{ "lang": "rust", "repo": "ogham/rust-numerals", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tamiyo/Pineapple path: /src/pineapple_codegen_ssa/src/analysis/basic_block.rs use std::{cell::RefCell, rc::Rc}; use pineapple_ir::mir::Stmt; type Statement = Rc<RefCell<Stmt>>; #[derive(Debug, Clone, PartialEq)] pub enum BlockEntry { Entry(Statement), None, } #[derive(Debug, Clone, P...
code_fim
medium
{ "lang": "rust", "repo": "Tamiyo/Pineapple", "path": "/src/pineapple_codegen_ssa/src/analysis/basic_block.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl BasicBlock { pub fn new(index: usize) -> Self { BasicBlock { index, entry: BlockEntry::None, statements: vec![], exit: BlockExit::None, } } }<|fim_prefix|>// repo: Tamiyo/Pineapple path: /src/pineapple_codegen_ssa/src/analysis/b...
code_fim
medium
{ "lang": "rust", "repo": "Tamiyo/Pineapple", "path": "/src/pineapple_codegen_ssa/src/analysis/basic_block.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kgv/rustapi path: /src/um/d3d11/device/create_pixel_shader.rs use crate::r#macro::FnOnce; use anyhow::{ensure, Result}; use std::{mem::MaybeUninit, ptr::null_mut}; use typed_builder::TypedBuilder; use winapi::{ shared::winerror::SUCCEEDED, um::{ d3d11::{ID3D11ClassLinkage, ID3D11...
code_fim
hard
{ "lang": "rust", "repo": "kgv/rustapi", "path": "/src/um/d3d11/device/create_pixel_shader.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let custom_charsets: Vec<&str> = args .values_of("custom-charset") .map(|x| x.collect()) .unwrap_or_else(Vec::new); let wordlists: Vec<&str> = args .values_of("wordlist") .map(|x| x.collect()) .unwrap_or_else(Vec::new); for mask in masks { ...
code_fim
hard
{ "lang": "rust", "repo": "IQ-SCM/cracken", "path": "/src/runner.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // create output file let mut out: Box<dyn Write> = match outfile { Some(fname) => match File::create(fname) { Ok(fp) => Box::new(fp), Err(e) => bail!("cannot open file {}: {}", fname, e), }, None => Box::new(stdout()), }; let custom_charset...
code_fim
hard
{ "lang": "rust", "repo": "IQ-SCM/cracken", "path": "/src/runner.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IQ-SCM/cracken path: /src/runner.rs # same as above, write output to pwds.txt instead of stdout cracken -o pwds.txt ?u?l?l?l?l?l?l?d # custom charset - all hex values cracken -c 0123456789abcdef '?1?1?1?1' # 4 custom charsets - the order determines the id of the charset cracken -c 0...
code_fim
hard
{ "lang": "rust", "repo": "IQ-SCM/cracken", "path": "/src/runner.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (image_num, acquire_future) = match swapchain::acquire_next_image(swapchain.clone(), None) { Ok(r) => r, Err(AcquireError::OutOfDate) => { recreate_swapchain = true; continue; } ...
code_fim
hard
{ "lang": "rust", "repo": "andrewhickman/vulkano-glyph", "path": "/examples/basic.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andrewhickman/vulkano-glyph path: /examples/basic.rs use std::fs::File; use std::io::Read; use std::mem; use std::path::PathBuf; use std::sync::Arc; use rusttype::{point, Font, Scale}; use structopt::StructOpt; use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer}; use vulkano::command_buffer...
code_fim
hard
{ "lang": "rust", "repo": "andrewhickman/vulkano-glyph", "path": "/examples/basic.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let second_file = dir.path().join("second_file"); fs::write(&second_file, "second data").unwrap(); let files = vec!["second_file"]; super::stage(&dir, &files).unwrap(); super::commit(&dir, "Added second_file").unwrap(); } #[test] fn commit_files_new_r...
code_fim
hard
{ "lang": "rust", "repo": "AlexanderThaller/githelper", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn commit_file_new_repo() { let dir = tempdir().unwrap(); super::init(&dir).unwrap(); let first_file = dir.path().join("first_file"); fs::write(&first_file, "first data").unwrap(); let files = vec!["first_file"]; super::stage(&dir, &files)....
code_fim
hard
{ "lang": "rust", "repo": "AlexanderThaller/githelper", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlexanderThaller/githelper path: /src/lib.rs //! Helper crate around git2 with functions for common tasks related to git //! repositories. #![deny(missing_docs)] #![warn(rust_2018_idioms)] pub mod error; pub use crate::error::Error; use std::path::Path; use git2::{ self, Repository,...
code_fim
hard
{ "lang": "rust", "repo": "AlexanderThaller/githelper", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YushiOMOTE/ert path: /tests/global.rs mod helper; use self::helper::Checker; use ert::prelude::*; use futures::prelude::*; #[tokio::test] async fn global() { Router::new(100).set_as_global(); let c = Checker::new(); <|fim_suffix|> let f = futures::future::join_all(futs).then(|_| f...
code_fim
hard
{ "lang": "rust", "repo": "YushiOMOTE/ert", "path": "/tests/global.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let c2 = c.clone(); let futs2: Vec<_> = (0u64..10000) .map(move |i| { let i = i % 100; let c2 = c2.clone(); async move { c2.check(i); } .via_g(i) }) .collect(); let f = futures::future::join_al...
code_fim
hard
{ "lang": "rust", "repo": "YushiOMOTE/ert", "path": "/tests/global.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let f = futures::future::join_all(futs).then(|_| futures::future::join_all(futs2)); f.await; }<|fim_prefix|>// repo: YushiOMOTE/ert path: /tests/global.rs mod helper; use self::helper::Checker; use ert::prelude::*; use futures::prelude::*; #[tokio::test] async fn global() { Router::new(100...
code_fim
hard
{ "lang": "rust", "repo": "YushiOMOTE/ert", "path": "/tests/global.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/starcoin path: /node/tests/test_node_run.rs // Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 <|fim_suffix|> let mut node_config = NodeConfig::random_for_test(); node_config.network.disable_seed = true; let config = Arc::new(node_config); ...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/starcoin", "path": "/node/tests/test_node_run.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut node_config = NodeConfig::random_for_test(); node_config.network.disable_seed = true; let config = Arc::new(node_config); let handle = run_node(config).unwrap(); thread::sleep(Duration::from_secs(5)); handle.stop().unwrap() }<|fim_prefix|>// repo: isgasho/starcoin path: /n...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/starcoin", "path": "/node/tests/test_node_run.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wirefunc/wirefunc path: /src/pointer.rs extern crate byteorder; /// There are three types of pointers: /// /// 1. Segment Pointers /// 2. Composite Pointers /// /// If the last bit (out of 64) is a 0, we're dealing with a Segment Pointer. /// Otherwise it's a Composite Pointer. /// /// A Segmen...
code_fim
hard
{ "lang": "rust", "repo": "wirefunc/wirefunc", "path": "/src/pointer.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> /// Length of data within the segment, in whatever units are appropriate for /// the data's type. For Composite Pointers, the data's type is Pointer. /// In all other cases, the data's type is hardcoded in generated code. pub length: u16, /// Type pub is_composite: bool, } #[inli...
code_fim
hard
{ "lang": "rust", "repo": "wirefunc/wirefunc", "path": "/src/pointer.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yingliufengpeng/rust_language path: /ch98_little_book_of_macro/src/ch4_4_push_down_accumulation.rs macro_rules! init_array { (@accum (0, $_e:expr) -> ($($body:tt)*) ) => { init_array!(@as_expr [ $($body), * ] ) // 最后一步构建[]列表数组结构 }; (@accum (1, $e:expr) -> ($($body:tt)*) )...
code_fim
hard
{ "lang": "rust", "repo": "yingliufengpeng/rust_language", "path": "/ch98_little_book_of_macro/src/ch4_4_push_down_accumulation.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} // However, this would require each intermediate step to expand to an incomplete expression. // Even though the intermediate results will never be used outside of a macro context, it is // still forbidden. #[cfg(test)] mod tests { #[test] fn test_002() { // let r = init_array2![0; 2...
code_fim
hard
{ "lang": "rust", "repo": "yingliufengpeng/rust_language", "path": "/ch98_little_book_of_macro/src/ch4_4_push_down_accumulation.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(test)] mod tests { #[test] fn test_002() { // let r = init_array2![0; 2]; // init_array2这个宏是个失败的写法 // println!("{:?}", r); } #[test] fn test_001() { let r:[&str; 4] = init_array!["33"; 4]; println!("{:?}", r); let r: [i32; 4] = init...
code_fim
hard
{ "lang": "rust", "repo": "yingliufengpeng/rust_language", "path": "/ch98_little_book_of_macro/src/ch4_4_push_down_accumulation.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub trait FixVersion { fn add_fix(&mut self) -> Result<(), std::num::ParseIntError>; }<|fim_prefix|>// repo: mwallner/aer path: /aer_version/src/versions.rs // Copyright (c) 2021 Kim J. Nordmo and WormieCorp. // Licensed under the MIT license. See LICENSE.txt file in the project <|fim_middle|>pub mo...
code_fim
easy
{ "lang": "rust", "repo": "mwallner/aer", "path": "/aer_version/src/versions.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mwallner/aer path: /aer_version/src/versions.rs // Copyright (c) 2021 Kim J. Nordmo and WormieCorp. // Licensed under the MIT license. See LICENSE.txt file in the project <|fim_suffix|>pub trait FixVersion { fn add_fix(&mut self) -> Result<(), std::num::ParseIntError>; }<|fim_middle|>pub mo...
code_fim
easy
{ "lang": "rust", "repo": "mwallner/aer", "path": "/aer_version/src/versions.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>st XTAL_4_91MHZ: u32 = 0x00000200; // External crystal is 4.9152MHz pub const XTAL_5MHZ: u32 = 0x00000240; // External crystal is 5MHz pub const XTAL_5_12MHZ: u32 = 0x00000280; // External crystal is 5.12MHz pub const XTAL_6MHZ: u32 = 0x000002C0; // External crystal is 6MHz pub const XTAL_6_14MHZ: u32...
code_fim
hard
{ "lang": "rust", "repo": "knielsen/corrosion", "path": "/src/tm4c123x/rom/SysCtl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: knielsen/corrosion path: /src/tm4c123x/rom/SysCtl.rs 0xf0003400; // CAN 0 pub const PERIPH_CAN1: u32 = 0xf0003401; // CAN 1 pub const PERIPH_COMP0: u32 = 0xf0003c00; // Analog Comparator Module 0 pub const PERIPH_EMAC0: u32 = 0xf0009c00; // Ethernet MAC0 pub const PERIPH_EPHY0: u32 = 0xf000...
code_fim
hard
{ "lang": "rust", "repo": "knielsen/corrosion", "path": "/src/tm4c123x/rom/SysCtl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>//***************************************************************************** // // The following are values that can be passed to the SysCtlClockSet() API as // the ui32Config parameter. // //***************************************************************************** pub const SYSDIV_1: u32 = 0x07800...
code_fim
hard
{ "lang": "rust", "repo": "knielsen/corrosion", "path": "/src/tm4c123x/rom/SysCtl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leetie/Fe-chat-server path: /src/bin/client.rs use std::io::{BufRead, BufReader, Read, Write}; use std::net::TcpStream; use std::sync::mpsc; use std::thread; use std::time::Duration; fn main() { let mut stream = TcpStream::connect("0.0.0.0:2222").unwrap(); let mut stream_tx = stream.try_clon...
code_fim
hard
{ "lang": "rust", "repo": "leetie/Fe-chat-server", "path": "/src/bin/client.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let stream_tx_thread = thread::spawn(move || loop { match msg_rx.recv() { Ok(msg) => match stream_tx.write(msg) { Ok(_) => { continue; } Err(e) => println!("Error writing to server: {}", e), }, Err(_) => continue, } }); // RECEIVE MESSAGES...
code_fim
medium
{ "lang": "rust", "repo": "leetie/Fe-chat-server", "path": "/src/bin/client.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn write_vec_tuple(tuple_vec: &Vec<(&String, &u32)>, filename: &String) { let mut out_file = File::create(filename) .expect("Unable to open file to write"); for el in tuple_vec.iter() { if el.0 != "" { out_file.write_fmt(format_args!("{}:{}\n", el.0, el....
code_fim
hard
{ "lang": "rust", "repo": "iyuroch/rust_word_counter", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iyuroch/rust_word_counter path: /src/main.rs #![feature(io)] extern crate spmc; extern crate serde; extern crate serde_json; extern crate rayon; extern crate crossbeam; extern crate crossbeam_channel; #[macro_use] extern crate serde_derive; use std::io::BufRead; use std::sync::{Arc, Mutex}; us...
code_fim
hard
{ "lang": "rust", "repo": "iyuroch/rust_word_counter", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for ch_vec in f.split(b' ') { let word = Box::new(ch_vec.unwrap().to_owned()); if words_vec.len() == 100 { tx.send(words_vec.clone()).expect("Cannot send word to channel"); words_vec = Box::new(vec![]); } words_vec.push(word.clone()); ...
code_fim
hard
{ "lang": "rust", "repo": "iyuroch/rust_word_counter", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gtestault/cdma-decoder path: /src/main.rs use std::env; use std::fs; const GPS_REGISTER_PROPS: [(u16, u16); 24] = [ (2, 6), (3, 7), (4, 8), (5, 9), (1, 9), (2, 10), (1, 8), (2, 9), (3, 10), (2, 3), (3, 4), (5, 6), (6, 7), (7, 8), (8, 9...
code_fim
hard
{ "lang": "rust", "repo": "gtestault/cdma-decoder", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn get_bit_test() { assert_eq!(1, ShiftRegGPS::get_bit(2, 0b0000_0001_0000_0000)); assert_eq!(0, ShiftRegGPS::get_bit(2, 0b1111_1110_1111_1111)); assert_eq!(1, ShiftRegGPS::get_bit(10, 0b0000_0000_0000_0001)); assert_eq!(0, ShiftRegGPS::get_bit(10, 0b1111_11...
code_fim
hard
{ "lang": "rust", "repo": "gtestault/cdma-decoder", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: moozzyk/AdventOfCode2018 path: /day06/src/main.rs use std::io::prelude::*; use std::io::BufReader; use std::fs::File; use std::path::Path; use std::collections::HashMap; use std::collections::HashSet; fn lines_from_file<P>(filename: P) -> Vec<String> where P: AsRef<Path>, { let file = F...
code_fim
hard
{ "lang": "rust", "repo": "moozzyk/AdventOfCode2018", "path": "/day06/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut result = 0; for x in 0..1000 { for y in 0..1000 { let mut total_dist = 0; for i in 0..coordinates.len() { total_dist += distance((x - 500, y - 500), coordinates[i]); } if total_dist < 10000 { result += ...
code_fim
hard
{ "lang": "rust", "repo": "moozzyk/AdventOfCode2018", "path": "/day06/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/winapi_util/v0_1/crate/src/file.rs use std::io; use std::mem; use winapi::shared::minwindef::FILETIME; use winapi::shared::winerror::NO_ERROR; use winapi::um::errhandlingapi::GetLastError; use winapi::um::fileapi::{ GetFileInformationByHandle, GetFi...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/winapi_util/v0_1/crate/src/file.rs", "mode": "psm", "license": "GPL-1.0-or-later", "source": "the-stack-v2" }
<|fim_suffix|>/// Represents a Windows file type. /// /// This wraps the result of [`GetFileType`]. /// /// [`GetFileType`]: https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfiletype #[derive(Clone)] pub struct Type(u32); impl Type { /// Returns true if this type represents a character fi...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/winapi_util/v0_1/crate/src/file.rs", "mode": "spm", "license": "GPL-1.0-or-later", "source": "the-stack-v2" }
<|fim_suffix|> /// Return the serial number of the volume that the file is on. /// /// This corresponds to `dwVolumeSerialNumber`. pub fn volume_serial_number(&self) -> u64 { self.0.dwVolumeSerialNumber as u64 } /// Return the file size, in bytes. /// /// This corresponds to `nFi...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/winapi_util/v0_1/crate/src/file.rs", "mode": "spm", "license": "GPL-1.0-or-later", "source": "the-stack-v2" }
<|fim_suffix|> .help("Sets verbosity level"), ).arg( Arg::with_name("color") .short("t") .long("color") .help("Set color tint terminal output. 0 to disable, 1 to enable") .default_value("1") .possible_value...
code_fim
hard
{ "lang": "rust", "repo": "tathanhdinh/hex", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tathanhdinh/hex path: /src/main.rs extern crate clap; #[macro_use] extern crate failure; mod lib; use clap::{App, Arg}; use std::process; /// Central application entry point. fn main() { let matches = App::new(env!("CARGO_PKG_NAME")) .version(env!("CARGO_PKG_VERSION")) .abo...
code_fim
hard
{ "lang": "rust", "repo": "tathanhdinh/hex", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Byron/effective-java-examples path: /src/main/rust/chapter06/item30/src/op.rs use std::str::FromStr; use self::Operation::*; pub enum Operation { Plus, Minus, Times, Divide, } <|fim_suffix|> Ok(match s { "+" => Plus, "-" => Minus, "...
code_fim
hard
{ "lang": "rust", "repo": "Byron/effective-java-examples", "path": "/src/main/rust/chapter06/item30/src/op.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match *self { Plus => "+", Minus => "-", Times => "*", Divide => "/" } } } impl FromStr for Operation { type Err = String; fn from_str(s: &str) -> Result<Self, Self::Err> { Ok(match s { "+" => Plus, ...
code_fim
medium
{ "lang": "rust", "repo": "Byron/effective-java-examples", "path": "/src/main/rust/chapter06/item30/src/op.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>table! { admin (admidx) { admidx -> Integer, admid -> Varchar, admpw -> Varchar, admname -> Nullable<Varchar>, admmemo -> Nullable<Varchar>, admregdate -> Timestamp, } } allow_tables_to_appear_in_same_query!(info_of_action, users, info_of_location, ...
code_fim
hard
{ "lang": "rust", "repo": "leepl37/server_for_file_transer", "path": "/src/schema.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leepl37/server_for_file_transer path: /src/schema.rs table! { info_of_location (site_idx) { site_idx -> Integer, site_id -> Varchar, site_pw -> Varchar, site_name -> Varchar, site_type -> Nullable<Varchar>, open_date -> Nullable<Timestamp>, ...
code_fim
medium
{ "lang": "rust", "repo": "leepl37/server_for_file_transer", "path": "/src/schema.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gefjon/selene path: /src/err.rs use crate::lisp; #[derive(Debug)] pub enum Error { Io(std::io::Error), UnknownCompilerForm(lisp::List), StackUnderflow, TypeError(TypeError), } pub fn type_error() -> Error { Error::TypeError(TypeError {}) } #[derive(Clone, Debug)] pub struc...
code_fim
medium
{ "lang": "rust", "repo": "gefjon/selene", "path": "/src/err.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl From<std::io::Error> for Error { fn from(e: std::io::Error) -> Error { Error::Io(e) } } impl From<TypeError> for Error { fn from(e: TypeError) -> Self { Error::TypeError(e) } } pub type Result<T> = std::result::Result<T, Error>;<|fim_prefix|>// repo: gefjon/selene p...
code_fim
medium
{ "lang": "rust", "repo": "gefjon/selene", "path": "/src/err.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SuhasHebbar/chalk path: /chalk-ir/src/fold/subst.rs use super::*; use crate::fold::shift::Shift; pub struct Subst<'s, I: Interner> { /// Values to substitute. A reference to a free variable with /// index `i` will be mapped to `parameters[i]` -- if `i > /// parameters.len()`, then w...
code_fim
hard
{ "lang": "rust", "repo": "SuhasHebbar/chalk", "path": "/chalk-ir/src/fold/subst.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if depth >= self.parameters.len() { Ok(LifetimeData::<I>::BoundVar(depth - self.parameters.len() + binders).intern()) } else { match self.parameters[depth].data() { ParameterKind::Lifetime(l) => Ok(l.shifted_in(binders)), _ => panic!(...
code_fim
medium
{ "lang": "rust", "repo": "SuhasHebbar/chalk", "path": "/chalk-ir/src/fold/subst.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> fn fold_free_var_lifetime(&mut self, depth: usize, binders: usize) -> Fallible<Lifetime<I>> { if depth >= self.parameters.len() { Ok(LifetimeData::<I>::BoundVar(depth - self.parameters.len() + binders).intern()) } else { match self.parameters[depth].data() { ...
code_fim
hard
{ "lang": "rust", "repo": "SuhasHebbar/chalk", "path": "/chalk-ir/src/fold/subst.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tophatsteve/bucket path: /src/bucket.rs use super::event_handlers::{CreatedEvent, EventHandler, RemovedEvent, UpdatedEvent}; use super::file_system; use super::storage; use failure::err_msg; use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher}; use sentry::integrations::failure::capture...
code_fim
hard
{ "lang": "rust", "repo": "tophatsteve/bucket", "path": "/src/bucket.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_create_event_calls_create_handler() { let mock_file_system = MockFileSystem::new(); let mock_storage = MockStorage::new(); let mock_create_handler = MockPathEventHandler::new(); let mock_remove_handler = MockPathEventHandler::new(); let mock_...
code_fim
hard
{ "lang": "rust", "repo": "tophatsteve/bucket", "path": "/src/bucket.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Logicalshift/flowbetween path: /flo/src/model/canvas_invalidation.rs /// /// Indicates a part of the main canvas that can have become invalid <|fim_suffix|>come invalid (identified by the FrameLayerModel layer ID) Layer(u64) }<|fim_middle|>/// #[derive(Clone, Copy, Debug)] pub enum CanvasInv...
code_fim
medium
{ "lang": "rust", "repo": "Logicalshift/flowbetween", "path": "/flo/src/model/canvas_invalidation.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>he whole canvas needs refreshing WholeCanvas, /// A layer has become invalid (identified by the FrameLayerModel layer ID) Layer(u64) }<|fim_prefix|>// repo: Logicalshift/flowbetween path: /flo/src/model/canvas_invalidation.rs /// /// Indicates a part of the main canvas that can have become i...
code_fim
medium
{ "lang": "rust", "repo": "Logicalshift/flowbetween", "path": "/flo/src/model/canvas_invalidation.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drahnr/plem path: /src/header.rs use log::{error, info, trace, warn}; use indexmap::IndexMap; use std::collections::{HashMap, HashSet}; use lazy_static::*; use std::cmp::{Eq, Ord, PartialEq, PartialOrd}; #[derive(Default, Debug, Clone, Eq, PartialEq)] pub(crate) struct HeaderInfo { pub r...
code_fim
hard
{ "lang": "rust", "repo": "drahnr/plem", "path": "/src/header.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn unquote_val<'i>(input: &'i str) -> IResult<&'i str, &'i str> { preceded( tuple((char('\"'), space0)), terminated(take_until("\""), tuple((char('\"'), space0))), )(input) } fn string_val<'i>(input: &'i str) -> IResult<&'i str, Value> { match map_parser(take_until(","), unquo...
code_fim
hard
{ "lang": "rust", "repo": "drahnr/plem", "path": "/src/header.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{}", r2); for idx in (0..r1.len()).rev(){ let b1 = r1.as_bytes()[idx] as u32 - '0' as u32; let b2 = r2.as_bytes()[idx] as u32 - '0' as u32; s = b1 + b2 + carry; if s == 2{ bit = '0'; carry = 1; }else if s == 3{ bit ...
code_fim
hard
{ "lang": "rust", "repo": "isaigm/leetcode", "path": "/add-binary/Compile Error/3-8-2020, 1_23_35 PM/Solution.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isaigm/leetcode path: /add-binary/Compile Error/3-8-2020, 1_23_35 PM/Solution.rs // https://leetcode.com/problems/add-binary impl Solution { pub fn fill_with_zeros(st : &mut String, n : usize){ let mut z = 0; while z < n{ st.insert(0, '0'); z += 1; } } pub fn ad...
code_fim
hard
{ "lang": "rust", "repo": "isaigm/leetcode", "path": "/add-binary/Compile Error/3-8-2020, 1_23_35 PM/Solution.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn skips_the_local_0_address() { let str = "10.192.4.1/24"; let actual = parse_ip_string(str).unwrap(); assert_eq!(actual.first().unwrap(), &Ipv4Addr::new(10, 192, 4, 1)); } #[test] fn skips_the_gateway_address() { let str = "10.192.4.1/24"; ...
code_fim
hard
{ "lang": "rust", "repo": "jonkgrimes/nbtscanner", "path": "/src/ip_range.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let str = "10.192.4.35-37"; let expected = vec![ Ipv4Addr::new(10, 192, 4, 35), Ipv4Addr::new(10, 192, 4, 36), Ipv4Addr::new(10, 192, 4, 37), ]; let actual = parse_ip_string(str).unwrap(); assert_eq!(actual, expected); } ...
code_fim
hard
{ "lang": "rust", "repo": "jonkgrimes/nbtscanner", "path": "/src/ip_range.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonkgrimes/nbtscanner path: /src/ip_range.rs use self::IpParserError::*; use std::error::Error; use std::net::Ipv4Addr; use std::str::FromStr; use std::vec::Vec; use std::{fmt, u32, u8}; pub fn parse_ip_string(ip_str: &str) -> IpParserResult<Vec<Ipv4Addr>, IpParserError> { // check base ip ...
code_fim
hard
{ "lang": "rust", "repo": "jonkgrimes/nbtscanner", "path": "/src/ip_range.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[macro_export] macro_rules! verror { ($($arg:tt)*) => {{ let res = ValidationError { message: format!($($arg)*) }; res }} }<|fim_prefix|>// repo: Katsutoshii/twine-terminal-rs path: /src/kataru/error.rs use std::fmt; /// Error type for validating the kataru y...
code_fim
hard
{ "lang": "rust", "repo": "Katsutoshii/twine-terminal-rs", "path": "/src/kataru/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Katsutoshii/twine-terminal-rs path: /src/kataru/error.rs use std::fmt; /// Error type for validating the kataru yml script. pub struct ValidationError { pub message: String, } <|fim_suffix|>impl fmt::Debug for ValidationError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ...
code_fim
medium
{ "lang": "rust", "repo": "Katsutoshii/twine-terminal-rs", "path": "/src/kataru/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> write!(f, "{}, {{ file: {}, line: {} }}", self, file!(), line!()) } } #[macro_export] macro_rules! verror { ($($arg:tt)*) => {{ let res = ValidationError { message: format!($($arg)*) }; res }} }<|fim_prefix|>// repo: Katsutoshii/twine-terminal-rs p...
code_fim
medium
{ "lang": "rust", "repo": "Katsutoshii/twine-terminal-rs", "path": "/src/kataru/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }