text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: fabura/icu4x path: /provider/fs/src/export/serializers/json.rs // This file is part of ICU4X. For terms of use, please see the file // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). use super::AbstractSerializer;...
code_fim
hard
{ "lang": "rust", "repo": "fabura/icu4x", "path": "/provider/fs/src/export/serializers/json.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DengYiping/ycoin path: /src/blockchain.rs use super::block::Block; use super::hashable::Hashable; use super::primitives::*; use std::fmt::{Debug, Display}; use std::collections::HashSet; pub struct Blockchain { pub blocks: Vec<Block>, unspent_output: HashSet<YHash>, } #[derive(Debug)] ...
code_fim
hard
{ "lang": "rust", "repo": "DengYiping/ycoin", "path": "/src/blockchain.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn verify_chain( prev_hash: &YHash, prev_timestamp: &u128, chain: &[Block], index: u32 ) -> Result<(), BlockValidationErr> { if chain.len() == 0 { Ok(()) } else { let head = &chain[0]; if head.index != index { Err(BlockValidationErr::MismatchedIn...
code_fim
hard
{ "lang": "rust", "repo": "DengYiping/ycoin", "path": "/src/blockchain.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mitchmindtree/sound_stream path: /src/stream/output.rs use error::Error; use portaudio::pa; use portaudio::pa::Sample as PaSample; use sample::{Sample, Wave}; use settings::{Channels, Settings, Frames, SampleHz}; use std::collections::VecDeque; use std::marker::PhantomData; use super::{ Bu...
code_fim
hard
{ "lang": "rust", "repo": "mitchmindtree/sound_stream", "path": "/src/stream/output.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if user_buffer.len() > 0 { buffer.extend(user_buffer.iter().map(|&sample| sample)); user_buffer.clear(); } loop { // How many frames are available for writing on the output stream? let available_frames = match wait_for_stream(|| str...
code_fim
hard
{ "lang": "rust", "repo": "mitchmindtree/sound_stream", "path": "/src/stream/output.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BreD1810/rust-search-sort path: /src/algorithms/quick.rs use super::{Array, Algorithm}; pub struct QuickSort; impl Algorithm for QuickSort { fn run(&self, array: &Array) { let high = array.len() as isize - 1; self.sort_partition(array, 0, high); } } <|fim_suffix|> ...
code_fim
hard
{ "lang": "rust", "repo": "BreD1810/rust-search-sort", "path": "/src/algorithms/quick.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let pivot = array.get(high as usize); let mut i = low; for j in low..high { if array.get(j as usize) < pivot { array.swap(i as usize, j as usize); i += 1; } self.wait(); } array.swap(i as usize, hig...
code_fim
hard
{ "lang": "rust", "repo": "BreD1810/rust-search-sort", "path": "/src/algorithms/quick.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ivfranco/raytracing path: /src/image_builder.rs use std::{ fs::File, io::{BufWriter, Write}, path::Path, }; use anyhow::Context; use image::ImageEncoder; use crate::{color::Rgb, Error}; fn cast_channel(channel: f64) -> anyhow::Result<u8> { if (0.0..=1.0).contains(&channel) { ...
code_fim
hard
{ "lang": "rust", "repo": "ivfranco/raytracing", "path": "/src/image_builder.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn gradient<B: ImageBuilder>() -> B { const WIDTH: u32 = 256; const HEIGHT: u32 = 256; let mut builder = B::with_dimensions(WIDTH, HEIGHT); for j in 0..HEIGHT { for i in 0..WIDTH { let pixel = Rgb::new(i as f64 / WIDTH as f64, j as f64 / HE...
code_fim
hard
{ "lang": "rust", "repo": "ivfranco/raytracing", "path": "/src/image_builder.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(mul_div_u64(1_000_000_000_001, 1_000_000_000, 1_000_000), 1_000_000_000_001_000); }<|fim_prefix|>// repo: solana-labs/rust-bpf-sysroot path: /src/std/src/sys_common/tests.rs use super::mul_div_u64; <|fim_middle|>#[test] fn test_muldiv() {
code_fim
easy
{ "lang": "rust", "repo": "solana-labs/rust-bpf-sysroot", "path": "/src/std/src/sys_common/tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: solana-labs/rust-bpf-sysroot path: /src/std/src/sys_common/tests.rs use super::mul_div_u64; <|fim_suffix|> assert_eq!(mul_div_u64(1_000_000_000_001, 1_000_000_000, 1_000_000), 1_000_000_000_001_000); }<|fim_middle|>#[test] fn test_muldiv() {
code_fim
easy
{ "lang": "rust", "repo": "solana-labs/rust-bpf-sysroot", "path": "/src/std/src/sys_common/tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fbsource/orjson path: /src/serialize/uuid.rs // SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::typeref::*; use serde::ser::{Serialize, Serializer}; use smallvec::SmallVec; use std::io::Write; use std::os::raw::c_uchar; pub type UUIDBuffer = smallvec::SmallVec<[u8; 64]>; pub struct UU...
code_fim
hard
{ "lang": "rust", "repo": "fbsource/orjson", "path": "/src/serialize/uuid.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut hexadecimal: SmallVec<[u8; 32]> = SmallVec::with_capacity(32); write!(hexadecimal, "{:032x}", value).unwrap(); buf.extend_from_slice(&hexadecimal[..8]); buf.push(b'-'); buf.extend_from_slice(&hexadecimal[8..12]); buf.push(b'-'); buf.extend_f...
code_fim
hard
{ "lang": "rust", "repo": "fbsource/orjson", "path": "/src/serialize/uuid.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // step 0: rebuild b and z_p, c_p, v_p let mut hash_input: Vec<u8> = vec![]; assert!(pk.serialize(&mut hash_input).is_ok()); hash_input = [pp.digest.as_ref(), hash_input.as_ref(), message.as_ref()].concat(); let mut hasher = Sha512::new(); hasher.update(hash...
code_fim
hard
{ "lang": "rust", "repo": "fimbault/lb-vrf", "path": "/src/lbvrf.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fimbault/lb-vrf path: /src/lbvrf.rs #![allow(clippy::many_single_char_names)] // use crate::keypair::PublicKey; use crate::param::*; use crate::poly::PolyArith; use crate::poly256::*; use crate::poly32::poly32_inner_product; use crate::poly32::Poly32; // use rand::{CryptoRng, RngCore}; // use cr...
code_fim
hard
{ "lang": "rust", "repo": "fimbault/lb-vrf", "path": "/src/lbvrf.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // we start rejection sampling here loop { rs += 1; // step 3: sample y for e in y.iter_mut() { *e = Poly256::rand_mod_beta(&mut rng); } let y_p: Vec<Poly32> = y.iter().map(|x| (*x).into()).collect(); // step 4: w1 = Ay, w2 = by ...
code_fim
hard
{ "lang": "rust", "repo": "fimbault/lb-vrf", "path": "/src/lbvrf.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if num < -MOVEMENT_SPEED { -MOVEMENT_SPEED } else if num > MOVEMENT_SPEED { MOVEMENT_SPEED } else { num } } let diff_x = clamp(next.x - x); let diff_y = clamp(next.y - y); let diff_z = clamp(next.z - z); transform.append_translation_xyz(d...
code_fim
hard
{ "lang": "rust", "repo": "woubuc/amethyst-test", "path": "/src/systems/movement.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut path = match std::mem::replace(&mut movement.path, None) { Some(path) => path, None => { let destination = match movement.destination { Some(destination) => { if movement.current == destination { let destination = Pos { x: rng.gen_range(0, 100), y: rng.gen_rang...
code_fim
hard
{ "lang": "rust", "repo": "woubuc/amethyst-test", "path": "/src/systems/movement.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: woubuc/amethyst-test path: /src/systems/movement.rs use amethyst::renderer::camera::Camera; use amethyst::core::Transform; use amethyst::input::{InputHandler, StringBindings}; use amethyst::ecs::{System, WriteStorage, ReadStorage, Read, Join}; use rand::{thread_rng, Rng}; use crate::resources::...
code_fim
hard
{ "lang": "rust", "repo": "woubuc/amethyst-test", "path": "/src/systems/movement.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rot256/portage path: /src/tests.rs use rand::Rng; use test::Bencher; use super::*; #[bench] fn encode(b: &mut Bencher) { let mut sk = EncodingKey::new(); let bytes = vec![0; 1024]; let file = File::new(&bytes[..]); let (_, shards) = file.shards(0); let mut enc: Vec<Encode...
code_fim
hard
{ "lang": "rust", "repo": "rot256/portage", "path": "/src/tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[bench] fn decode(b: &mut Bencher) { let sk = EncodingKey::new(); let bytes = vec![0; 1024]; let mut pk = sk.decoding(); let file = File::new(&bytes[..]); let (_, shards) = file.shards(0); let mut enc: Vec<EncodedShard> = shards.into_iter().map(|s| s.pack()).collect(); b.it...
code_fim
hard
{ "lang": "rust", "repo": "rot256/portage", "path": "/src/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elaffey/bewbew path: /types/src/lib.rs use error::Error; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] pub enum Req { PlusOne(PlusOneReq), SignUpReq(SignUpReq), Login(LoginReq), } #[derive(Serialize, Deserialize, Debug)] pub struct PlusOneReq { p...
code_fim
hard
{ "lang": "rust", "repo": "elaffey/bewbew", "path": "/types/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn ser<T: ?Sized>(value: &T) -> Result<Vec<u8>, Error> where T: Serialize, { bincode::serialize(value).map_err(|e| Error::wrap("ser", e)) } pub fn de<'a, T>(bytes: &'a [u8]) -> Result<T, Error> where T: Deserialize<'a>, { bincode::deserialize(bytes).map_err(|e| Error::wrap("de", e)) }...
code_fim
hard
{ "lang": "rust", "repo": "elaffey/bewbew", "path": "/types/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn de<'a, T>(bytes: &'a [u8]) -> Result<T, Error> where T: Deserialize<'a>, { bincode::deserialize(bytes).map_err(|e| Error::wrap("de", e)) } pub fn de_from<R, T>(reader: R) -> Result<T, Error> where R: std::io::Read, T: serde::de::DeserializeOwned, { bincode::deserialize_from(rea...
code_fim
hard
{ "lang": "rust", "repo": "elaffey/bewbew", "path": "/types/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if (file.name()).ends_with("/") { fs::create_dir_all(outpath)?; } else { fs::create_dir_all(parent)?; let mut outfile = fs::File::create(&outpath)?; io::copy(&mut file, &mut outfile)?; } } Ok(()) }<|fim_prefix|>// repo: illim/launcher path: /src/launcher/u...
code_fim
hard
{ "lang": "rust", "repo": "illim/launcher", "path": "/src/launcher/unzip.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: illim/launcher path: /src/launcher/unzip.rs extern crate zip; use std::io; use std::fs; use std::path::Path; use errors::*; <|fim_suffix|> if (file.name()).ends_with("/") { fs::create_dir_all(outpath)?; } else { fs::create_dir_all(parent)?; let mut outfile =...
code_fim
hard
{ "lang": "rust", "repo": "illim/launcher", "path": "/src/launcher/unzip.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lulf/stm32wl-hal path: /hal/src/util.rs //! Miscellaneous utilities use crate::pac; use core::ptr::write_volatile; use cortex_m::{delay::Delay, peripheral::syst::SystClkSource}; <|fim_suffix|>/// Reset the cycle counter to zero. /// /// This function will be removed upon the next release of [`c...
code_fim
hard
{ "lang": "rust", "repo": "lulf/stm32wl-hal", "path": "/hal/src/util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Reset the cycle counter to zero. /// /// This function will be removed upon the next release of [`cortex_m`] that /// includes this functionality. See [#347] for details. /// /// # Example /// /// ```no_run /// use stm32wl_hal::{pac, util::reset_cycle_count}; /// /// let mut cp = pac::CorePeripherals:...
code_fim
hard
{ "lang": "rust", "repo": "lulf/stm32wl-hal", "path": "/hal/src/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Troinnn/snake path: /src/models/scene.rs use models::{field::Field, snake::{Snake, Apple, Direction}}; use piston::input::{RenderArgs, Button, Key, UpdateArgs}; use opengl_graphics::GlGraphics; use models::state::{GameState, GameCmd}; use piston::input::Button::Keyboard; use std::collections::Ve...
code_fim
hard
{ "lang": "rust", "repo": "Troinnn/snake", "path": "/src/models/scene.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut squares: VecDeque<(i32, i32)> = VecDeque::new(); for rect in self.snake.body.iter() { squares.push_back(*rect); } squares.pop_front().expect("Нет первого элемента!"); for square in squares { if self.snake.body.front() ...
code_fim
hard
{ "lang": "rust", "repo": "Troinnn/snake", "path": "/src/models/scene.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maidsafe/sn-testnet-deploy path: /src/setup.rs // Copyright (c) 2023, MaidSafe. // All rights reserved. // // This SAFE Network Software is licensed under the BSD-3-Clause license. // Please see the LICENSE file for more details. use crate::error::{Error, Result}; use inquire::{Select, Text}; ...
code_fim
hard
{ "lang": "rust", "repo": "maidsafe/sn-testnet-deploy", "path": "/src/setup.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> std::fs::write(".env", contents.trim())?; Ok(()) } fn get_ssh_key_file_candidates() -> Result<Vec<String>> { let ssh_dir_path = dirs_next::home_dir() .ok_or_else(|| Error::SetupError)? .join(".ssh"); let entries = std::fs::read_dir(ssh_dir_path)?; let ssh_files: Vec<St...
code_fim
hard
{ "lang": "rust", "repo": "maidsafe/sn-testnet-deploy", "path": "/src/setup.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>fn get_ssh_key_file_candidates() -> Result<Vec<String>> { let ssh_dir_path = dirs_next::home_dir() .ok_or_else(|| Error::SetupError)? .join(".ssh"); let entries = std::fs::read_dir(ssh_dir_path)?; let ssh_files: Vec<String> = entries .filter_map(Result::ok) .map...
code_fim
hard
{ "lang": "rust", "repo": "maidsafe/sn-testnet-deploy", "path": "/src/setup.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) unsafe fn try_arc_unwrap<M>(mut arc: Arc<M>) -> Option<M> { if is_arc_unique(&mut arc) { Some(arc_unwrap(arc)) } else { None } }<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/gpu-alloc/src/util.rs use alloc::sync::Arc; ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/gpu-alloc/src/util.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) unsafe fn try_arc_unwrap<M>(mut arc: Arc<M>) -> Option<M> { if is_arc_unique(&mut arc) { Some(arc_unwrap(arc)) } else { None } }<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/gpu-alloc/src/util.rs use alloc::sync::Arc; ...
code_fim
medium
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/gpu-alloc/src/util.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/gpu-alloc/src/util.rs use alloc::sync::Arc; pub(crate) fn is_arc_unique<M>(arc: &mut Arc<M>) -> bool { let strong_count = Arc::strong_count(&*arc); debug_assert_ne!(strong_count, 0, "This Arc should exist"); debug_a...
code_fim
medium
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/gpu-alloc/src/util.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bugsbunny1101/rust-skia path: /skia-safe/src/core/surface.rs use std::ptr; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; use crate::prelude::*; use crate::gpu::{Context, BackendTexture, BackendRenderTarget, SurfaceOrigin}; use crate::core::{ImageInfo, SurfaceProps, Paint, C...
code_fim
hard
{ "lang": "rust", "repo": "bugsbunny1101/rust-skia", "path": "/skia-safe/src/core/surface.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn flush(&mut self) { unsafe { self.native_mut().flush(); } } // TODO: flushAndSignalSemaphores() // TODO: wait() // TODO: characterize() // TODO: draw() } // A lifetime bound surface. pub struct OwnedSurface<'a> { surface: Surface, phantom: Pha...
code_fim
hard
{ "lang": "rust", "repo": "bugsbunny1101/rust-skia", "path": "/skia-safe/src/core/surface.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// ------ view_articles helpers ------ fn view_article_preview( viewer: Option<&Viewer>, article: &Article, ) -> Node<Msg> { div![ class!["article-preview"], div![ class!["article-meta"], a![ attrs! {At::Href => Route::Profile(Cow::Borro...
code_fim
hard
{ "lang": "rust", "repo": "MartinKavik/seed-realworld-darklang", "path": "/crate/src/entity/article/feed.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn view_article_preview( viewer: Option<&Viewer>, article: &Article, ) -> Node<Msg> { div![ class!["article-preview"], div![ class!["article-meta"], a![ attrs! {At::Href => Route::Profile(Cow::Borrowed(article.author.username())).to_strin...
code_fim
hard
{ "lang": "rust", "repo": "MartinKavik/seed-realworld-darklang", "path": "/crate/src/entity/article/feed.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MartinKavik/seed-realworld-darklang path: /crate/src/entity/article/feed.rs use crate::{ entity::{ author, timestamp, Article, ErrorMessage, PageNumber, PaginatedList, Slug, Tag, Viewer, }, logger, page, request, GMsg, Route, Session, }; use seed::prelude::*; use std:...
code_fim
hard
{ "lang": "rust", "repo": "MartinKavik/seed-realworld-darklang", "path": "/crate/src/entity/article/feed.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Returns the `n` smallest items with a key extraction function. /// /// The key function is called only once per element, but for simple key functions `sort_by_key` /// is likely to be faster. /// /// This function is stable, i.e. it preserves the order of equal elements. /// /// # Panics /// Panics if...
code_fim
hard
{ "lang": "rust", "repo": "evenorog/out", "path": "/src/slice.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: evenorog/out path: /src/slice.rs //! Functions for use with slices. use core::{cmp::Ordering, mem}; /// Implementation based on https://doc.rust-lang.org/std/primitive.slice.html#method.sort_by_cached_key. #[cfg(feature = "alloc")] macro_rules! find_n { ($t:ty, $slice:ident, $n:ident, $f: ...
code_fim
hard
{ "lang": "rust", "repo": "evenorog/out", "path": "/src/slice.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: renuacpro/rust-ul-sys path: /build.rs use std::env; use std::path::PathBuf; fn main() { println!("cargo:rustc-flags=-L /usr/local/lib/"); println!("cargo:rustc-link-search=/usr/local/lib/"); if cfg!(target_os = "macos") { println!("cargo:rustc-link-lib=dylib=Ultralight"); ...
code_fim
hard
{ "lang": "rust", "repo": "renuacpro/rust-ul-sys", "path": "/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); bindings .write_to_file(out_path.join("bindings.rs")) .expect("Couldn't write bindings!"); }<|fim_prefix|>// repo: renuacpro/rust-ul-sys path: /build.rs use std::env; use std::path::PathBuf; fn main() { println!("ca...
code_fim
hard
{ "lang": "rust", "repo": "renuacpro/rust-ul-sys", "path": "/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn to_string(&self) -> String { self.text.clone() } }<|fim_prefix|>// repo: dgront/BioShell path: /bioshell-pdb/src/pdb_title.rs pub struct PdbTitle { text: String, } <|fim_middle|>impl PdbTitle { pub fn new(line: &str) -> Self { Self { text: line[10..73]...
code_fim
medium
{ "lang": "rust", "repo": "dgront/BioShell", "path": "/bioshell-pdb/src/pdb_title.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dgront/BioShell path: /bioshell-pdb/src/pdb_title.rs pub struct PdbTitle { text: String, } <|fim_suffix|> pub fn to_string(&self) -> String { self.text.clone() } }<|fim_middle|>impl PdbTitle { pub fn new(line: &str) -> Self { Self { text: line[10..73]...
code_fim
medium
{ "lang": "rust", "repo": "dgront/BioShell", "path": "/bioshell-pdb/src/pdb_title.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>macro_rules! assert_eq { ($left:expr, $right:expr) => ({ match (&$left, &$right) { (left_val, right_val) => { if !(*left_val == *right_val) { Err(Error::from(ErrorKind::AssertionFailed(format!( "assertion failed: `(left ==...
code_fim
hard
{ "lang": "rust", "repo": "oberien/dilobo", "path": "/src/errors.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oberien/dilobo path: /src/errors.rs use discord::model::ServerId; error_chain! { foreign_links { Io(::std::io::Error); Discord(::discord::Error); } errors { AssertionFailed(msg: String) { description("assertion failed") display("asser...
code_fim
hard
{ "lang": "rust", "repo": "oberien/dilobo", "path": "/src/errors.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>macro_rules! assert_ne { ($left:expr, $right:expr) => ({ match (&$left, &$right) { (left_val, right_val) => { if *left_val == *right_val { Err(Error::from(ErrorKind::AssertionFailed(format!( "assertion failed: `(left != ri...
code_fim
hard
{ "lang": "rust", "repo": "oberien/dilobo", "path": "/src/errors.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: loiclec/fuzzcheck-rs path: /fuzzcheck/src/mutators/grammar/grammar.rs use std::ops::{Range, RangeBounds, RangeInclusive}; use std::rc::{Rc, Weak}; #[cfg(feature = "regex_grammar")] use crate::mutators::grammar::regex::grammar_from_regex; #[derive(Clone, Debug)] /// A grammar which can be used ...
code_fim
hard
{ "lang": "rust", "repo": "loiclec/fuzzcheck-rs", "path": "/fuzzcheck/src/mutators/grammar/grammar.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[no_coverage] /// Repeats the provided grammar some number of times in the given range. pub fn repetition<R>(gs: Rc<Grammar>, range: R) -> Rc<Grammar> where R: RangeBounds<usize>, { let start = match range.start_bound() { std::ops::Bound::Included(x) => *x, std::ops::Bound::Exclud...
code_fim
hard
{ "lang": "rust", "repo": "loiclec/fuzzcheck-rs", "path": "/fuzzcheck/src/mutators/grammar/grammar.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut acc = None; while let Some(node) = term(tokens) { if let Some(lhs) = acc { acc = Some(Node::Add(Box::new(lhs), Box::new(node))); } else { acc = Some(node); } if let Some(&"+") = tokens.front() { tokens.pop_front(); ...
code_fim
hard
{ "lang": "rust", "repo": "skrap/aoc2020", "path": "/day18/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: skrap/aoc2020 path: /day18/src/main.rs use regex::Regex; use std::{collections::VecDeque, unimplemented}; fn do_math(syms: &mut VecDeque<&str>) -> i64 { let mut op = None; let mut tot = 0; while let Some(sym) = syms.pop_front() { if let Some(val) = match sym { ")...
code_fim
hard
{ "lang": "rust", "repo": "skrap/aoc2020", "path": "/day18/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self { Node::Add(a, b) => a.eval() + b.eval(), Node::Mul(a, b) => a.eval() * b.eval(), Node::Number(n) => *n, } } } type Tokens<'a> = VecDeque<&'a str>; fn expr(tokens: &mut Tokens) -> Option<Node> { if let Some("(") = tokens.front().copi...
code_fim
hard
{ "lang": "rust", "repo": "skrap/aoc2020", "path": "/day18/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert!(!is_palindromic(2323)); } #[test] fn check() { assert_eq!(solve(), 906_609); } }<|fim_prefix|>// repo: pecorarista/euler path: /src/problem_04.rs pub fn is_palindromic(n: u64) -> bool { let s = n.to_string(); let m = s.len() / 2; let xs = s.bytes().tak...
code_fim
medium
{ "lang": "rust", "repo": "pecorarista/euler", "path": "/src/problem_04.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert!(!is_palindromic(123)); } #[test] fn is_palindromic_4() { assert!(is_palindromic(2332)); } #[test] fn is_not_palindromic_4() { assert!(!is_palindromic(2323)); } #[test] fn check() { assert_eq!(solve(), 906_609); } }<|fim_pre...
code_fim
medium
{ "lang": "rust", "repo": "pecorarista/euler", "path": "/src/problem_04.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pecorarista/euler path: /src/problem_04.rs pub fn is_palindromic(n: u64) -> bool { let s = n.to_string(); let m = s.len() / 2; let xs = s.bytes().take(m); let ys = s.bytes().rev().take(m); xs.zip(ys).all(|(x, y)| x == y) } pub fn solve() -> u64 { let mut m = 0; for i...
code_fim
medium
{ "lang": "rust", "repo": "pecorarista/euler", "path": "/src/problem_04.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> regex::Quantifier::Between(least, most) => { assert!(least <= most); let (start, min) = thompson_construct_repeat(nfa, subnode, least); let mut last = min; let end = nfa.unique_state(); // From here we let every node skip to the end wit...
code_fim
hard
{ "lang": "rust", "repo": "LPeter1997/yoakke_rs", "path": "/yk_dense_fsa/src/nfa.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LPeter1997/yoakke_rs path: /yk_dense_fsa/src/nfa.rs /** * Generic dense nondeterministic finite automaton representation. */ use std::collections::{BTreeMap, BTreeSet}; use yk_intervals::{Interval, IntervalMap, IntervalSet, LowerBound, UpperBound}; use yk_regex_parse as regex; #[derive(Debug...
code_fim
hard
{ "lang": "rust", "repo": "LPeter1997/yoakke_rs", "path": "/yk_dense_fsa/src/nfa.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> nfa.add_epsilon_transition(l_e, r_s); (l_s, r_e) } fn thompson_construct_quantified<AcceptingValue>(nfa: &mut Automaton<char, AcceptingValue>, subnode: &regex::Node, quantifier: regex::Quantifier) -> (State, State) { match quantifier { regex::Quantifier::AtLeast(count) => { ...
code_fim
hard
{ "lang": "rust", "repo": "LPeter1997/yoakke_rs", "path": "/yk_dense_fsa/src/nfa.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_hanoi_2_disks() { let result = hanoi(2, Peg::A, Peg::B, Peg::C); assert_eq!(vec![(Peg::A, Peg::B), (Peg::A, Peg::C), (Peg::B, Peg::C)], result); assert_eq!(3, result.len()); }<|fim_prefix|>// repo: jacobmorzinski/cis198-2016s path: /hw01...
code_fim
medium
{ "lang": "rust", "repo": "jacobmorzinski/cis198-2016s", "path": "/hw01/src/tests_student.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// // Problem 4 // #[test] fn test_hanoi_2_disks() { let result = hanoi(2, Peg::A, Peg::B, Peg::C); assert_eq!(vec![(Peg::A, Peg::B), (Peg::A, Peg::C), (Peg::B, Peg::C)], result); assert_eq!(3, result.len()); }<|fim_prefix|>// repo: jacobmorzinski/cis19...
code_fim
hard
{ "lang": "rust", "repo": "jacobmorzinski/cis198-2016s", "path": "/hw01/src/tests_student.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jacobmorzinski/cis198-2016s path: /hw01/src/tests_student.rs #![cfg(test)] use problem1::{sum}; use problem2::{mat_mult}; use problem3::{sieve}; use problem4::{hanoi,Peg}; <|fim_suffix|>#[test] fn test_sum() { let array = [1,1,2,3,5,8]; assert_eq!(sum(&array), 20); } // // Problem 2 /...
code_fim
medium
{ "lang": "rust", "repo": "jacobmorzinski/cis198-2016s", "path": "/hw01/src/tests_student.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for stream in listener.incoming() { if !*accept_more.lock().unwrap() { break } match stream { Ok(stream) => { let hello: ClientPacket = bincode::deserialize_from(&stream).unwrap(); match hello { Client...
code_fim
hard
{ "lang": "rust", "repo": "LFalch/arsehole", "path": "/src/server.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LFalch/arsehole path: /src/server.rs extern crate arsehole; extern crate bincode; use std::net::{TcpListener, TcpStream, Shutdown}; use std::thread; use std::time::Duration; use std::sync::{Mutex, Arc}; use arsehole::game::Game; use arsehole::mp::{ClientPacket, ServerPacket}; fn main() -> std...
code_fim
hard
{ "lang": "rust", "repo": "LFalch/arsehole", "path": "/src/server.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Event::Key(Key::Ctrl('z')) } } impl Signal for SIGQUIT { fn to_sig() -> CSig { libc::SIGQUIT } fn default_event() -> Event { Event::Key(Key::Ctrl('\\')) } } /// Raises signals which will be passed to the underlying terminal. pub struct SignalBehavior { map...
code_fim
hard
{ "lang": "rust", "repo": "ftilde/unsegen_signals", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ftilde/unsegen_signals path: /src/lib.rs //! Use `unsegen`'s input module to raise signals on the usual key combinations (e.g., SIGINT on CTRL-C) //! //! # Example: //! ```should_panic //! extern crate unsegen; //! extern crate unsegen_signals; //! //! use unsegen::input::*; //! use unsegen_sign...
code_fim
hard
{ "lang": "rust", "repo": "ftilde/unsegen_signals", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Event::Key(Key::Ctrl('\\')) } } /// Raises signals which will be passed to the underlying terminal. pub struct SignalBehavior { mapping: HashMap<Event, CSig>, } impl SignalBehavior { /// Create the Behavior without any triggers. /// /// Add triggers using `on` or `on_default`...
code_fim
hard
{ "lang": "rust", "repo": "ftilde/unsegen_signals", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: polyhorn/polyhorn-cli path: /src/core/cargo_build.rs use cargo_metadata::MetadataCommand; use std::io::Result; use std::path::{Path, PathBuf}; use std::process::Command; use super::change_crate_type; /// Builder for cargo build commands. #[derive(Default)] pub struct CargoBuild { manifest_...
code_fim
hard
{ "lang": "rust", "repo": "polyhorn/polyhorn-cli", "path": "/src/core/cargo_build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut targets = package.targets.iter(); let target = if let Some(crate_type) = self.crate_type.as_ref() { targets.find(|target| target.kind == vec![crate_type.to_owned()]) } else { targets.next() }; Ok(target.unwrap().name.replace("-", "_...
code_fim
hard
{ "lang": "rust", "repo": "polyhorn/polyhorn-cli", "path": "/src/core/cargo_build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marcinioski/rust_playground path: /advanced_traits/src/main.rs use std::ops::Add; trait SampleTrait { type Item; fn call1(&mut self) -> Option<Self::Item>; } struct SampleStruct { x: i32, } impl SampleTrait for SampleStruct { type Item = i32; fn call1(&mut self) -> Option<...
code_fim
hard
{ "lang": "rust", "repo": "marcinioski/rust_playground", "path": "/advanced_traits/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn call2(self, rhs: SampleStruct) -> i32 { self.x + rhs.x } } mod self_functions; fn main() { println!("Hello, world!"); self_functions::call1(); }<|fim_prefix|>// repo: marcinioski/rust_playground path: /advanced_traits/src/main.rs use std::ops::Add; trait SampleTrait { ty...
code_fim
medium
{ "lang": "rust", "repo": "marcinioski/rust_playground", "path": "/advanced_traits/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} struct OwnStruct { x: i32, } impl OwnTrait for OwnStruct { type Output = i32; fn call2(self, rhs: OwnStruct) -> Self::Output { self.x + rhs.x } } impl OwnTrait<SampleStruct> for OwnStruct { type Output = i32; fn call2(self, rhs: SampleStruct) -> i32 { self.x +...
code_fim
medium
{ "lang": "rust", "repo": "marcinioski/rust_playground", "path": "/advanced_traits/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn mbr() { let table = get_partitions_from_file("./resources/disk_mbr.img", LogicalBlockSize::Lb512).unwrap().unwrap(); assert_eq!(&table.partitions, &[ Partition { flags: None, name: None, uuid: None, size: 3, start_lba: ...
code_fim
hard
{ "lang": "rust", "repo": "planet-s/partitionlib", "path": "/tests/test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let table = get_partitions_from_file("./resources/disk_mbr.img", LogicalBlockSize::Lb512).unwrap().unwrap(); assert_eq!(&table.partitions, &[ Partition { flags: None, name: None, uuid: None, size: 3, start_lba: 1, } ])...
code_fim
hard
{ "lang": "rust", "repo": "planet-s/partitionlib", "path": "/tests/test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: planet-s/partitionlib path: /tests/test.rs extern crate partitionlib; use partitionlib::{get_partitions_from_file, LogicalBlockSize, Partition}; #[test] fn part_is_gpt() { assert!(dbg!( get_partitions_from_file("./resources/disk.img", LogicalBlockSize::Lb512) .unwrap() ...
code_fim
hard
{ "lang": "rust", "repo": "planet-s/partitionlib", "path": "/tests/test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: flier/rust-t1ha path: /src/t1ha2.rs Default)] pub struct T1ha2Hasher { state: State, buffer: [u8; 32], partial: usize, total: usize, } #[derive(Debug, Default)] struct State { a: u64, b: u64, c: u64, d: u64, } impl State { #[inline(always)] pub fn init_a...
code_fim
hard
{ "lang": "rust", "repo": "flier/rust-t1ha", "path": "/src/t1ha2.rs", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_prefix|>// repo: flier/rust-t1ha path: /src/t1ha2.rs = t1ha2_loop::<T>(&mut state, data); } } unsafe { t1ha2_tail_abcd::<T>(&mut state, data) } } impl T1ha2Hasher { pub fn with_seeds(seed_x: u64, seed_y: u64) -> Self { let mut h = Self::default(); h.state.init_ab(seed_x, see...
code_fim
hard
{ "lang": "rust", "repo": "flier/rust-t1ha", "path": "/src/t1ha2.rs", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|>#[inline(always)] fn final128(state: &mut State) -> u128 { mixup64( &mut state.a, &mut state.b, rot64(state.c, 41) ^ state.d, PRIME_0, ); mixup64( &mut state.b, &mut state.c, rot64(state.d, 23) ^ state.a, PRIME_6, ); mixup...
code_fim
hard
{ "lang": "rust", "repo": "flier/rust-t1ha", "path": "/src/t1ha2.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_prefix|>// repo: avik-das/gitters path: /src/objects.rs //! Provides functionality for reading/writing the objects that make up the content-addressable //! database that is git. use commits; use flate2::read::ZlibDecoder; use std::{env, fmt, io, path, str}; use std::error::Error as StdError; use std::fs::File...
code_fim
hard
{ "lang": "rust", "repo": "avik-das/gitters", "path": "/src/objects.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>fn read_type<R>(mut reader: &mut R) -> Result<Type, Error> where R: BufRead, { let type_str = try!(read_until(&mut reader, ' ')); let object_type = try!(match type_str.as_ref() { "blob" => Ok(Type::Blob), "tree" => Ok(Type::Tree), "commit" => Ok(Type::Commit), ...
code_fim
hard
{ "lang": "rust", "repo": "avik-das/gitters", "path": "/src/objects.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jjfiv/antique path: /src/galago/index.rs use super::field::GalagoField; use super::postings::PositionsPostings; use super::stemmer::Stemmer; use crate::galago::btree::*; use crate::galago::corpus::CorpusDoc; use crate::galago::lang::expr_to_eval; use crate::galago::postings::IndexPartType; use c...
code_fim
hard
{ "lang": "rust", "repo": "jjfiv/antique", "path": "/src/galago/index.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // If we can't find the term, its frequencies stay at zero. let part = self.postings_for_field(field)?; if let Some(value) = part.find_str(term)? { PositionsPostings::new(value)?.get_stats(&mut stats); } O...
code_fim
hard
{ "lang": "rust", "repo": "jjfiv/antique", "path": "/src/galago/index.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn lookup_id_for_name(&mut self, name: &str) -> Result<Option<DocId>, Error> { if let Some(result) = self.names_reverse.find_str(name)? { return Ok(Some(DocId(result.stream().read_u64()? as u32))); } Ok(None) } pub fn lookup_name_for_id(&mut self, id: D...
code_fim
hard
{ "lang": "rust", "repo": "jjfiv/antique", "path": "/src/galago/index.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[thread_local] static mut TLS: u8 = 0; struct SendRaw(*const u8); unsafe impl Send for SendRaw {} fn main() { unsafe { let dangling_ptr = std::thread::spawn(|| SendRaw(&TLS as *const u8)).join().unwrap(); let _val = *dangling_ptr.0; //~ ERROR: has been freed } }<|fim_prefix|>// ...
code_fim
easy
{ "lang": "rust", "repo": "rust-lang/miri", "path": "/tests/fail/concurrency/thread_local_static_dealloc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/miri path: /tests/fail/concurrency/thread_local_static_dealloc.rs //! Ensure that thread-local statics get deallocated when the thread dies. #![feature(thread_local)] <|fim_suffix|>struct SendRaw(*const u8); unsafe impl Send for SendRaw {} fn main() { unsafe { let dangli...
code_fim
easy
{ "lang": "rust", "repo": "rust-lang/miri", "path": "/tests/fail/concurrency/thread_local_static_dealloc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ssssota/font-cli-test path: /src/main.rs mod input; mod list; mod load; mod search; <|fim_suffix|>fn main() { let opt = CliOptions::from_args(); match opt { CliOptions::List => list_fonts(), CliOptions::Search { search_text } => search_font(&search_text[..]), Cli...
code_fim
medium
{ "lang": "rust", "repo": "ssssota/font-cli-test", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ssssota/font-cli-test path: /src/main.rs mod input; mod list; mod load; mod search; use input::CliOptions; use list::list_fonts; use load::load_font; use search::search_font; use structopt::StructOpt; <|fim_suffix|> let opt = CliOptions::from_args(); match opt { CliOptions::List...
code_fim
easy
{ "lang": "rust", "repo": "ssssota/font-cli-test", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let opt = CliOptions::from_args(); match opt { CliOptions::List => list_fonts(), CliOptions::Search { search_text } => search_font(&search_text[..]), CliOptions::Details { input } => load_font(input), }; }<|fim_prefix|>// repo: ssssota/font-cli-test path: /...
code_fim
medium
{ "lang": "rust", "repo": "ssssota/font-cli-test", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let shared = buf.clone(); let push = warp::post() .and(warp::path!("pushEvent")) .and(warp::body::json()) .and(warp::any().map(move || shared.clone())) .and_then(|event: Event, buf: Arc<Mutex<String>>| async move { let mut buf = buf.lock().await; ...
code_fim
hard
{ "lang": "rust", "repo": "Nouzan/echo-event", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Nouzan/echo-event path: /src/main.rs use serde::{Deserialize, Serialize}; use std::sync::Arc; use tokio::sync::Mutex; use warp::Filter; #[derive(Debug, Serialize, Deserialize)] struct Event { level: String, message: String, } #[tokio::main] async fn main() { let buf = Arc::new(Mute...
code_fim
hard
{ "lang": "rust", "repo": "Nouzan/echo-event", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hexj/QUANTAXIS path: /qapro-rs/src/qaprotocol/qifi/default.rs pub fn default_f64() -> f64 { 0f64 } <|fim_suffix|>pub fn default_bool() -> bool { false } pub fn default_i128() -> i128 { 0i128 } pub fn default_i32() -> i32 { 0i32 } pub fn default_string() -> String { "".to_...
code_fim
easy
{ "lang": "rust", "repo": "hexj/QUANTAXIS", "path": "/qapro-rs/src/qaprotocol/qifi/default.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn default_i128() -> i128 { 0i128 } pub fn default_i32() -> i32 { 0i32 } pub fn default_string() -> String { "".to_string() }<|fim_prefix|>// repo: hexj/QUANTAXIS path: /qapro-rs/src/qaprotocol/qifi/default.rs pub fn default_f64() -> f64 { 0f64 } <|fim_middle|>pub fn default_i64() ...
code_fim
medium
{ "lang": "rust", "repo": "hexj/QUANTAXIS", "path": "/qapro-rs/src/qaprotocol/qifi/default.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn default_string() -> String { "".to_string() }<|fim_prefix|>// repo: hexj/QUANTAXIS path: /qapro-rs/src/qaprotocol/qifi/default.rs pub fn default_f64() -> f64 { 0f64 } pub fn default_i64() -> i64 { 0i64 } pub fn default_bool() -> bool { false } <|fim_middle|>pub fn default_i128()...
code_fim
medium
{ "lang": "rust", "repo": "hexj/QUANTAXIS", "path": "/qapro-rs/src/qaprotocol/qifi/default.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let test_v = test.get(&"124".as_bytes().to_vec()); print!("{:?}", test_v); }<|fim_prefix|>// repo: tuoersitai/Genesis path: /GenesisRust/src/main.rs extern crate gen_core; extern crate rlp; extern crate db; use gen_core::mpt::trie::*; use rlp::RLPSerialize; use db::manager::*; <|fim_middle|>fn ...
code_fim
hard
{ "lang": "rust", "repo": "tuoersitai/Genesis", "path": "/GenesisRust/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tuoersitai/Genesis path: /GenesisRust/src/main.rs extern crate gen_core; extern crate rlp; extern crate db; <|fim_suffix|>fn main() { let mut test = Trie::new(&SHARED_MANAGER); for i in 1 .. 10000 { print!("{}\n",i); let key = format!("{}", i); test.update(&key.a...
code_fim
medium
{ "lang": "rust", "repo": "tuoersitai/Genesis", "path": "/GenesisRust/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(6, calc_decompressed_length2("ADVENT")); assert_eq!(7, calc_decompressed_length2("A(1x5)BC")); assert_eq!(9, calc_decompressed_length2("(3x3)XYZ")); assert_eq!(20, calc_decompressed_length2("X(8x2)(3x3)ABCY")); assert_eq!(241920, calc_decompressed_length2("(27...
code_fim
hard
{ "lang": "rust", "repo": "davidsullins/AdventOfRust2016", "path": "/src/bin/advent9.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: davidsullins/AdventOfRust2016 path: /src/bin/advent9.rs // advent9.rs // simple RLE decompression use std::io; fn main() { let mut input = String::new(); io::stdin().read_line(&mut input).expect("Failed to read line"); let compressed = input.trim(); let length = calc_decompres...
code_fim
hard
{ "lang": "rust", "repo": "davidsullins/AdventOfRust2016", "path": "/src/bin/advent9.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: clucompany/cluFlock path: /examples/exclusive_slice_file.rs use cluFlock::ExclusiveFlock; use std::fs::File; fn main() -> Result<(), std::io::Error> { <|fim_suffix|> { let file_lock = ExclusiveFlock::wait_lock(&file)?; // file_lock, type: FlockLock<&File> println!("{:?}", file_lock); }...
code_fim
easy
{ "lang": "rust", "repo": "clucompany/cluFlock", "path": "/examples/exclusive_slice_file.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }