text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let tests = get_tests(); let mut all_good = true; for (i, TestCase { fen, expected, depth: max_depth }) in tests.iter().enumerate() { let mut ok = true; println!("\nTest case {}. FEN '{}'", i+1, fen); for depth in 1..=*max_depth { let value = expected[depth-...
code_fim
hard
{ "lang": "rust", "repo": "wjzz/chess-in-rust", "path": "/src/bin/perft.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wjzz/chess-in-rust path: /src/bin/perft.rs use std::env; use std::time; use ansi_term::Colour; use rust_chess::Position; fn parse_args(args: Vec<String>) -> u32 { let default = 4; args.get(1) .map(|s| s.parse().ok()) .flatten() .unwrap_or(default) } struct Test...
code_fim
hard
{ "lang": "rust", "repo": "wjzz/chess-in-rust", "path": "/src/bin/perft.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl From<Vec<Protocol<i32>>> for File { fn from(mut ps: Vec<Protocol<i32>>) -> File { let mut res = Vec::new(); for prot in &mut ps { res.append(match *prot { Protocol::FileBatch { ref mut data, .. } => data, _ => unreachable!() ...
code_fim
hard
{ "lang": "rust", "repo": "AlexNav73/Rust", "path": "/tanks2D_online/tanks2D_online_server/src/data/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlexNav73/Rust path: /tanks2D_online/tanks2D_online_server/src/data/mod.rs pub use rustc_serialize as rs; mod simple_test_object; pub use self::simple_test_object::SimpleTestObject; const PACKET_MAX_SIZE: usize = 15; #[derive(RustcEncodable, RustcDecodable, Debug)] pub enum Protocol<T: rs::...
code_fim
medium
{ "lang": "rust", "repo": "AlexNav73/Rust", "path": "/tanks2D_online/tanks2D_online_server/src/data/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for prot in &mut ps { res.append(match *prot { Protocol::FileBatch { ref mut data, .. } => data, _ => unreachable!() }); } File(res) } } impl<'a, T: rs::Decodable + rs::Encodable + Copy> From<&'a T> for Protocol<T> { ...
code_fim
medium
{ "lang": "rust", "repo": "AlexNav73/Rust", "path": "/tanks2D_online/tanks2D_online_server/src/data/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (src, mut dst) = prepare_buffer(); c.bench_function("scalar", move |b| { b.iter(|| interleave_71_inner(&src, &mut dst)) }); let (src, mut dst) = prepare_buffer(); c.bench_function("scalar itertools", move |b| { b.iter(|| interleave_71_inner_iter_tools(&src, &mut dst...
code_fim
hard
{ "lang": "rust", "repo": "nickwilcox/blog_multiple_targets", "path": "/benches/benchmark.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nickwilcox/blog_multiple_targets path: /benches/benchmark.rs use blog_multiple_targets::*; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use std::default::Default; const BENCHMARK_SAMPLES: usize = 100_000; fn prepare_buffer() -> (DeinterleavedBuffer71, InterleavedBuff...
code_fim
medium
{ "lang": "rust", "repo": "nickwilcox/blog_multiple_targets", "path": "/benches/benchmark.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn make_vec_accessor<M, V>( name: &'static str, get_vec: for<'a> fn(&'a M) -> &'a Vec<<V::RuntimeType as RuntimeType>::Value>, mut_vec: for<'a> fn(&'a mut M) -> &'a mut Vec<<V::RuntimeType as RuntimeType>::Value>, ) -> FieldAccessor where M: Message + 'static, V: ProtobufType + 'st...
code_fim
hard
{ "lang": "rust", "repo": "pantsbuild/rust-protobuf", "path": "/protobuf/src/reflect/accessor/repeated.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let m = m.downcast_ref().unwrap(); let repeated = self.fns.get_field(m); ReflectRepeatedRef { repeated, dynamic: V::RuntimeType::dynamic(), } } fn mut_reflect<'a>(&self, m: &'a mut Message) -> ReflectRepeatedMut<'a> { let m = m.downc...
code_fim
hard
{ "lang": "rust", "repo": "pantsbuild/rust-protobuf", "path": "/protobuf/src/reflect/accessor/repeated.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pantsbuild/rust-protobuf path: /protobuf/src/reflect/accessor/repeated.rs use std::marker; use Message; use RepeatedField; use reflect::accessor::AccessorKind; use reflect::accessor::FieldAccessor; use reflect::repeated::ReflectRepeated; use reflect::repeated::ReflectRepeatedMut; use reflect::...
code_fim
hard
{ "lang": "rust", "repo": "pantsbuild/rust-protobuf", "path": "/protobuf/src/reflect/accessor/repeated.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Set the value pub fn set_value(&mut self, value: &str) { self.state.set_value(value); } /// Set the size pub fn set_size(&mut self, size: u32) { self.state.set_size(size); } /// Set the stretched flag to true pub fn set_stretched(&mut self) { s...
code_fim
hard
{ "lang": "rust", "repo": "henrywoo/neutrino", "path": "/src/widgets/textinput.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: henrywoo/neutrino path: /src/widgets/textinput.rs use crate::utils::event::Event; use crate::widgets::widget::Widget; /// # The state of a TextInput /// /// ## Fields /// /// ```text /// value: String /// size: u32 /// stretched: bool /// ``` pub struct TextInputState { value: String, s...
code_fim
hard
{ "lang": "rust", "repo": "henrywoo/neutrino", "path": "/src/widgets/textinput.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn age() -> u32 { 15 } fn ex07() { println!("Tell me what type of person you are"); match age() { 0 => println!("I haven't celebrated my first birthday yet"), n @ 1..=12 => println!("I'm a child of age {:?}", n), n @ 13..=19 => println!("I'm a teen of age {:?}",n), ...
code_fim
hard
{ "lang": "rust", "repo": "hongry18/rust-tutorial", "path": "/rust-by-example/08.FlowOfControl/8-5-match.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hongry18/rust-tutorial path: /rust-by-example/08.FlowOfControl/8-5-match.rs fn ex01() { let number = 13; println!("Tell me about{}", number); match number { 1 => println!("One"), 2 | 3 | 5 | 7 | 11 => println!("This is a prime"), 13..=19 => println!("A teen")...
code_fim
hard
{ "lang": "rust", "repo": "hongry18/rust-tutorial", "path": "/rust-by-example/08.FlowOfControl/8-5-match.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn ex04() { // ponters/ref let reference = &4; match reference { &val => println!("Gott a value via destructuring: {:?}", val), } match *reference { val => println!("Gott a value via destructuring: {:?}", val), } let _not_a_reference = 3; let ref _is_a_re...
code_fim
hard
{ "lang": "rust", "repo": "hongry18/rust-tutorial", "path": "/rust-by-example/08.FlowOfControl/8-5-match.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let cts = load_cts(); let (line, count) = cts.iter() .map(|ct| matasano::cracks::find_dup_blocks(&ct, 16)) .enumerate() .max_by(|a,b| a.1.cmp(&b.1)).expect("Somehow couldn't find an ordering on integers!"); println!("MaxDupCount: {}\nLine: {}", count, line); ...
code_fim
hard
{ "lang": "rust", "repo": "queenp/matasano-rs", "path": "/examples/s1_c8.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: queenp/matasano-rs path: /examples/s1_c8.rs extern crate matasano; extern crate hex; use std::fs::File; use std::io::prelude::*; use std::io; <|fim_suffix|> let f = io::BufReader::new( File::open("examples/8.txt").expect("Couldn't open challenge file") ); f.lines() ...
code_fim
medium
{ "lang": "rust", "repo": "queenp/matasano-rs", "path": "/examples/s1_c8.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: forkkit/aquavm path: /air/src/execution_step/boxed_value/jvaluable/stream.rs /* * Copyright 2021 Fluence Labs Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License...
code_fim
hard
{ "lang": "rust", "repo": "forkkit/aquavm", "path": "/air/src/execution_step/boxed_value/jvaluable/stream.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<'stream> StreamJvaluableIngredients<'stream> { pub(crate) fn new(stream: std::cell::Ref<'stream, Stream>, generation: Generation) -> Self { Self { stream, generation } } pub(self) fn iter(&self) -> ExecutionResult<StreamIter<'_>> { use super::ExecutionError::StreamDontHav...
code_fim
hard
{ "lang": "rust", "repo": "forkkit/aquavm", "path": "/air/src/execution_step/boxed_value/jvaluable/stream.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> id }) } pub fn nearby(storage: DB) -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone { warp::get() .and(with_storage(storage)) .and(warp::path::param::<String>()) .and(warp::path("nearby")) ...
code_fim
hard
{ "lang": "rust", "repo": "mrlotfi/gquery", "path": "/src/server.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mrlotfi/gquery path: /src/server.rs use geojson::GeoJson; use serde::{Deserialize, Serialize}; use crate::collection::Storage; use crate::config::{get_conf, WELCOME_MESSAGE}; use colored::*; use parking_lot::RwLock; use std::sync::Arc; use tokio::time::{interval, Duration}; use warp::http::Resp...
code_fim
hard
{ "lang": "rust", "repo": "mrlotfi/gquery", "path": "/src/server.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brettkolodny/incantation-catastrophe path: /src/systems/spawn_systems/pawn_spawn.rs use amethyst::core::{math::Vector3, Time, Transform}; use amethyst::ecs::{Entities, Read, System, WriteStorage}; use amethyst::renderer::SpriteRender; use rand::Rng; use crate::components::{ CurrentDirection...
code_fim
hard
{ "lang": "rust", "repo": "brettkolodny/incantation-catastrophe", "path": "/src/systems/spawn_systems/pawn_spawn.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return; } if self.time_since_spawn >= self.spawn_timer { let angle = rand::thread_rng().gen_range(0, 360) as f32; let (x, y) = ( (RADIUS * angle.sin() + GAMEPLAY_AREA_WIDTH / 2.), (RADIUS * angle.cos() + GAMEPLAY_AREA_HE...
code_fim
hard
{ "lang": "rust", "repo": "brettkolodny/incantation-catastrophe", "path": "/src/systems/spawn_systems/pawn_spawn.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sainath05/raytracing path: /src/camera.rs use crate::ray::Ray; use crate::vec3::Vec3; use std::f64::consts::PI; use rand::prelude::*; fn random_in_unit_disk() -> Vec3 { let mut rng = rand::thread_rng(); let mut p = Vec3::new(1.0, 1.0, 1.0); while p.dot(p) >= 1.0 { p = Vec3:...
code_fim
hard
{ "lang": "rust", "repo": "sainath05/raytracing", "path": "/src/camera.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.origin } fn horizontal(&self) -> Vec3 { self.horizontal } fn vertical(&self) -> Vec3 { self.vertical } fn lower_left_corner(&self) -> Vec3 { self.lower_left_corner } fn u(&self) -> Vec3 { self.u } fn v(&self) -> Vec3...
code_fim
hard
{ "lang": "rust", "repo": "sainath05/raytracing", "path": "/src/camera.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wangchao0502/rust-leetcode path: /src/p105_build_tree.rs #![allow(dead_code)] // use mods use leetcode_prelude::TreeNode; use std::cell::RefCell; use std::rc::Rc; pub struct Solution {} // problem description // Given preorder and inorder traversal of a tree, construct the binary tree. // 对于...
code_fim
hard
{ "lang": "rust", "repo": "wangchao0502/rust-leetcode", "path": "/src/p105_build_tree.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn p105_build_tree(preorder: Vec<i32>, inorder: Vec<i32>) -> Option<Rc<RefCell<TreeNode>>> { // solution 1 Self::helper(&preorder, (0, preorder.len()), &inorder, (0, inorder.len())) // solution 2, use slice // fn bt(preorder: &[i32], inorder: &[i32]) -> Option<Rc<R...
code_fim
hard
{ "lang": "rust", "repo": "wangchao0502/rust-leetcode", "path": "/src/p105_build_tree.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let room_bounds = caolo_sim::prelude::Hexagon::from_radius( world .view::<caolo_sim::indices::ConfigKey, caolo_sim::components::RoomProperties>() .unwrap_value() .radius as i32, ); let terrain = world .view::<caolo_sim::prelude::WorldPositio...
code_fim
hard
{ "lang": "rust", "repo": "kissmikijr/caolo-backend", "path": "/sim/worker/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kissmikijr/caolo-backend path: /sim/worker/src/main.rs mod config; mod game_loop; mod input; mod protos; mod command_service; mod health_service; mod scripting_service; mod users_service; mod world_service; use crate::protos::cao_commands::command_server::CommandServer; use crate::protos::cao_...
code_fim
hard
{ "lang": "rust", "repo": "kissmikijr/caolo-backend", "path": "/sim/worker/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> { let mut p = ArgumentParser::new(); p.set_description("Livy Manager - Web UI for Managing Apache Livy Sessions"); p.refer(&mut conf_path) .add_option(&["-c", "--conf-path"], Store, "Configu...
code_fim
hard
{ "lang": "rust", "repo": "kjmrknsn/dataopen", "path": "/src/web/args.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kjmrknsn/dataopen path: /src/web/args.rs use argparse::{ArgumentParser, Store, StoreTrue}; #[derive(Debug)] pub struct Args { pub conf_path: String, pub print_version: bool, } <|fim_suffix|> { let mut p = ArgumentParser::new(); p.set_description("Livy Man...
code_fim
hard
{ "lang": "rust", "repo": "kjmrknsn/dataopen", "path": "/src/web/args.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ngynkvn/blobntree path: /src/lib/ecs/ecs.rs use crate::HashMap; use crate::HashSet; use core::any::Any; /** * This was my attempt at an entity component system using the techniques described in * Catherine West's closing keynote at Rust Conf 2018. * * It's a great talk about game development...
code_fim
hard
{ "lang": "rust", "repo": "ngynkvn/blobntree", "path": "/src/lib/ecs/ecs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn create_entity(&mut self) -> EntityBuilder { let entity = self.new_entity(); EntityBuilder { world: self, entity, } } pub fn run_system<'b, S>(&'b mut self, system: &mut S, components: &[TypeId]) where S: System, { ...
code_fim
hard
{ "lang": "rust", "repo": "ngynkvn/blobntree", "path": "/src/lib/ecs/ecs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (and, and_mut) = option("and"); let (or, or_mut) = option("or"); let (xor, xor_mut) = option("xor"); Self { styler, styler_mut, styler_index, styler_index_mut, to_style, style, style_mu...
code_fim
hard
{ "lang": "rust", "repo": "truchi/lay", "path": "/generation/src/lay/styler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: truchi/lay path: /generation/src/lay/styler.rs use crate::*; #[derive(Clone, Default, Debug)] pub struct Styler { pub styler: Ident, pub styler_mut: Ident, pub styler_index: Ident, pub styler_index_mut: Ident, pub to_style: StylerFn, pub style...
code_fim
hard
{ "lang": "rust", "repo": "truchi/lay", "path": "/generation/src/lay/styler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn delete_window(&self, window: &Window) { xcb::grab_server(&self.connection); if self .get_wm_protocols(window) .contains(&self.atoms.WM_DELETE_WINDOW) { let data = xcb::ClientMessageData::from_data32([ self.atoms.WM_DELE...
code_fim
hard
{ "lang": "rust", "repo": "elyuu/worm", "path": "/src/x.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn unmap_window(&self, window: &Window) { xcb::unmap_window(&self.connection, window.as_xcb_window()); } fn key_press(&self, event: &xcb::KeyPressEvent) -> Option<XEvent> { let key_symbols = keysyms::KeySymbols::new(&self.connection); let key = key_symbols.press_lo...
code_fim
hard
{ "lang": "rust", "repo": "elyuu/worm", "path": "/src/x.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elyuu/worm path: /src/x.rs use xcb; use xcb_util::{ewmh, icccm, keysyms}; use crate::key::*; #[derive(Debug)] #[allow(non_snake_case)] struct InternedAtoms { WM_PROTOCOLS: xcb::Atom, WM_DELETE_WINDOW: xcb::Atom, } #[allow(non_snake_case)] impl InternedAtoms { pub fn new(connection...
code_fim
hard
{ "lang": "rust", "repo": "elyuu/worm", "path": "/src/x.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Dynisious/parser path: /src/result.rs //! Defines the result types for parsers. //! //! Author --- DMorgan //! Last Moddified --- 2021-03-31 use core::{ fmt, ops::Try, }; mod result; pub use self::result::*; /// The output of a parse. #[derive(PartialEq, Eq, Clone, Copy,)] pub struct ...
code_fim
hard
{ "lang": "rust", "repo": "Dynisious/parser", "path": "/src/result.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<T, I,> From<(T, I,)> for Parse<T, I,> { #[inline] fn from((value, unused,): (T, I,),) -> Self { Self::new(value, unused,) } } impl<T, I,> fmt::Debug for Parse<T, I,> where T: fmt::Debug, I: fmt::Debug, { fn fmt(&self, fmt: &mut fmt::Formatter,) -> fmt::Result { write!(fmt, "{:?}: >{:...
code_fim
hard
{ "lang": "rust", "repo": "Dynisious/parser", "path": "/src/result.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32l0xx-hal path: /src/watchdog.rs use crate::hal::watchdog; use crate::pac::{IWDG, WWDG}; use crate::rcc::{Enable, Rcc}; use embedded_time::rate::Hertz; pub struct IndependedWatchdog { iwdg: IWDG, } impl IndependedWatchdog { pub fn set_config(&mut self, pre: u8, reload: u16...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32l0xx-hal", "path": "/src/watchdog.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub trait WindowWatchdogExt { fn watchdog(self, rcc: &mut Rcc) -> WindowWatchdog; } impl WindowWatchdogExt for WWDG { fn watchdog(self, rcc: &mut Rcc) -> WindowWatchdog { WWDG::enable(rcc); WindowWatchdog { wwdg: self, clk: rcc.clocks.apb1_clk().0 / 4096, ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32l0xx-hal", "path": "/src/watchdog.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> self.wwdg.cr.write(|w| w.t().bits(0xFF)); } } impl WindowWatchdog { pub fn set_window<T>(&mut self, window: T) where T: Into<Hertz>, { let freq = window.into().0; let mut ticks = self.clk / freq; let mut pre = 0; let mut threshold = 0; ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32l0xx-hal", "path": "/src/watchdog.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> pub fn allergies(&self) -> Vec<Allergen> { Allergen::iter() .filter(|allergen| self.is_allergic_to(allergen)) .copied() .collect() } }<|fim_prefix|>// repo: snowfrogdev/Exercism path: /rust/allergies/src/lib.rs use self::Allergen::*; use std::slice::Ite...
code_fim
medium
{ "lang": "rust", "repo": "snowfrogdev/Exercism", "path": "/rust/allergies/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: snowfrogdev/Exercism path: /rust/allergies/src/lib.rs use self::Allergen::*; use std::slice::Iter; pub struct Allergies(u32); #[derive(Debug, PartialEq, Copy, Clone)] pub enum Allergen { Eggs, Peanuts, Shellfish, Strawberries, Tomatoes, Chocolate, Pollen, Cats, ...
code_fim
medium
{ "lang": "rust", "repo": "snowfrogdev/Exercism", "path": "/rust/allergies/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// The `crossterm` result type. pub type Result<T> = std::result::Result<T, ErrorKind>; pub type ErrorKind = io::Error;<|fim_prefix|>// repo: colin-vandervoort/crossterm path: /src/error.rs //! Module containing error handling logic. <|fim_middle|>use std::io;
code_fim
easy
{ "lang": "rust", "repo": "colin-vandervoort/crossterm", "path": "/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: colin-vandervoort/crossterm path: /src/error.rs //! Module containing error handling logic. use std::io; <|fim_suffix|>pub type ErrorKind = io::Error;<|fim_middle|>/// The `crossterm` result type. pub type Result<T> = std::result::Result<T, ErrorKind>;
code_fim
medium
{ "lang": "rust", "repo": "colin-vandervoort/crossterm", "path": "/src/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: babblet/HackCompiler path: /src/main.rs use ::std::ffi::OsString; use ::std::fs::File; use ::std::io::Read; use ::std::io::prelude::*; use ::std::path::Path; use hack_compiler::models::token::Token; use hack_compiler::classes::arguments::Arguments; use hack_compiler::classes::tokenizer::Tokeniz...
code_fim
hard
{ "lang": "rust", "repo": "babblet/HackCompiler", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // unsure if this is needed... Should actually sync everything with // the tokens if I am not mistaken, and if so then this is a bad implementation. //let compilation_engine = CompilationEngine::new(tokenizer_path, Path::new("c.xml")); //compilation_engine.compile_class(); }<|fim_prefix|>// repo: ...
code_fim
hard
{ "lang": "rust", "repo": "babblet/HackCompiler", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut file_buffer = String::new(); let mut tokenizer = Tokenizer::new(&input_lines); let mut tokens: Vec<Token> = Vec::new(); loop { match tokenizer.advance() { Ok(token) => { file_buffer.push_str( format!("<{}> {} </{}>\n", token.element.as_string, ...
code_fim
hard
{ "lang": "rust", "repo": "babblet/HackCompiler", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Recv a packet from the socket fn poll_recv<'a>( &mut self, cx: &mut Context<'_>, buf: &'a mut [MaybeUninit<u8>], ) -> Poll<Result<usize>>; /// Recv a packet from the socket fn try_recv(&mut self, buf: &mut [MaybeUninit<u8>]) -> Result<usize>; /// Tells...
code_fim
hard
{ "lang": "rust", "repo": "SINHASantos/wasmer", "path": "/lib/vnet/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum SocketStatus { Opening, Opened, Closed, Failed, } #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum StreamSecurity { Unencrypted, AnyEncyption, ClassicEncryption, DoubleEncryption, } /// Connected sockets have a pe...
code_fim
hard
{ "lang": "rust", "repo": "SINHASantos/wasmer", "path": "/lib/vnet/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SINHASantos/wasmer path: /lib/vnet/src/lib.rs pub cidr: IpCidr, pub via_router: IpAddr, pub preferred_until: Option<Duration>, pub expires_at: Option<Duration>, } /// An implementation of virtual networking #[async_trait::async_trait] #[allow(unused_variables)] pub trait VirtualN...
code_fim
hard
{ "lang": "rust", "repo": "SINHASantos/wasmer", "path": "/lib/vnet/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn parse_connected<'a>(m: &Captures<'a>, msg_type: LogMessageType) -> ParseResult<'a> { let server_id = get_server_id!(m); let target_uid = m.get(3).map_or("-1", |g| g.as_str()).parse::<i32>().unwrap_or(-1); if target_uid == -1 { return Err(ParseError::RegexFail); } Ok(LogMessage...
code_fim
hard
{ "lang": "rust", "repo": "Dreae/Yamcha", "path": "/src/ingress/logparse.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Dreae/Yamcha path: /src/ingress/logparse.rs use std::mem; use std::str; use regex::{Regex, Captures}; #[derive(Debug, PartialEq)] pub enum ParseError { ByteBufferTooShort, HeaderMissing, WrongMsgType, RegexFail, NotAString, InvalidServerId, } pub type ParseResult<'a...
code_fim
hard
{ "lang": "rust", "repo": "Dreae/Yamcha", "path": "/src/ingress/logparse.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shadowmint/relay path: /crates/relay-auth/src/auth_provider_config.rs use crate::auth_secret_provider::AuthSecretProvider; pub struct AuthProviderConfig { /// Min length for keys pub min_key_length: usize, <|fim_suffix|> /// The set of secrets for this server pub secret_store: B...
code_fim
medium
{ "lang": "rust", "repo": "shadowmint/relay", "path": "/crates/relay-auth/src/auth_provider_config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// No token can be allowed to exist for longer than this pub max_token_expiry: i64, /// The set of secrets for this server pub secret_store: Box<dyn AuthSecretProvider>, }<|fim_prefix|>// repo: shadowmint/relay path: /crates/relay-auth/src/auth_provider_config.rs use crate::auth_secret_...
code_fim
medium
{ "lang": "rust", "repo": "shadowmint/relay", "path": "/crates/relay-auth/src/auth_provider_config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// The set of secrets for this server pub secret_store: Box<dyn AuthSecretProvider>, }<|fim_prefix|>// repo: shadowmint/relay path: /crates/relay-auth/src/auth_provider_config.rs use crate::auth_secret_provider::AuthSecretProvider; <|fim_middle|>pub struct AuthProviderConfig { /// Min lengt...
code_fim
medium
{ "lang": "rust", "repo": "shadowmint/relay", "path": "/crates/relay-auth/src/auth_provider_config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn build_tcp_transport( own_identity: Identity, ) -> boxed::BoxedTransport<(Identity, impl StreamMultiplexer), impl ::std::error::Error> { let tcp_transport = tcp::TcpTransport::default(); tcp_transport .and_then(|socket, origin| { async move { let muxe...
code_fim
hard
{ "lang": "rust", "repo": "xpeerchain/xpeerchain", "path": "/network/src/transport.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xpeerchain/xpeerchain path: /network/src/transport.rs // Copyright (c) The XPeer Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{ common::NetworkPublicKeys, protocols::identity::{exchange_identity, Identity}, }; use crypto::x25519::{X25519PrivateKey, X25519PublicKey...
code_fim
hard
{ "lang": "rust", "repo": "xpeerchain/xpeerchain", "path": "/network/src/transport.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> memory_transport .and_then(|socket, origin| { async move { let muxer = Yamux::upgrade_connection(socket, origin).await?; Ok(muxer) } }) .and_then(move |muxer, origin| { async move { let (identit...
code_fim
hard
{ "lang": "rust", "repo": "xpeerchain/xpeerchain", "path": "/network/src/transport.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> GetPresenceOptions { user: user.into(), ..Default::default() } } } impl From<GetPresenceOptions> for String { fn from(options: GetPresenceOptions) -> Self { // This should never fail, so calling unwrap() on the result. // There might be a bett...
code_fim
hard
{ "lang": "rust", "repo": "mre/slack", "path": "/src/users/get_presence.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Create a new instance of GetPresenceOptions fn new<S: Into<String>>(user: S) -> GetPresenceOptions { GetPresenceOptions { user: user.into(), ..Default::default() } } } impl From<GetPresenceOptions> for String { fn from(options: GetPresenceOptions...
code_fim
hard
{ "lang": "rust", "repo": "mre/slack", "path": "/src/users/get_presence.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mre/slack path: /src/users/get_presence.rs //! # users_get_presence //! //! This method lets you find out information about a user's presence. //! Consult the presence documentation for more details. //! See https://api.slack.com/methods/users.getPresence //! //! ## Required arguments: //...
code_fim
hard
{ "lang": "rust", "repo": "mre/slack", "path": "/src/users/get_presence.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wrfsh/hypervisor-framework-rs path: /src/lib.rs = 0x00000808, VMCS_GUEST_GS = 0x0000080a, VMCS_GUEST_LDTR = 0x0000080c, VMCS_GUEST_TR = 0x0000080e, VMCS_GUEST_INT_STATUS = 0x00000810, VMCS_HOST_...
code_fim
hard
{ "lang": "rust", "repo": "wrfsh/hypervisor-framework-rs", "path": "/src/lib.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub const VMEXIT_SAVE_DBG_CONTROLS: u32 = (1 << 2); pub const VMEXIT_HOST_IA32E: u32 = (1 << 9); pub const VMEXIT_LOAD_IA32_PERF_GLOBAL_CTRL: u32 = (1 << 12); pub const VMEXIT_ACK_INTR: u32 = (1 << 15); pub const VMEXIT_SAVE_IA32_PAT: u32 =...
code_fim
hard
{ "lang": "rust", "repo": "wrfsh/hypervisor-framework-rs", "path": "/src/lib.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wrfsh/hypervisor-framework-rs path: /src/lib.rs x00000004, VMCS_GUEST_ES = 0x00000800, VMCS_GUEST_CS = 0x00000802, VMCS_GUEST_SS = 0x00000804, VMCS_GUEST_DS = 0x00000806, VMCS_GUEST_FS ...
code_fim
hard
{ "lang": "rust", "repo": "wrfsh/hypervisor-framework-rs", "path": "/src/lib.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>/// Convenience function to deserialize an object that implements the `Grammar` trait. pub fn deserialize<T: Grammar, Iter: Iterator<Item=u8>>(iter: &mut Iter) -> Result<T> { <T as Grammar>::deserialize(iter) } pub mod unsigned; pub mod signed; pub mod byte; pub mod vec; pub mod string; pub mod float...
code_fim
hard
{ "lang": "rust", "repo": "jprendes/whasm", "path": "/whasm/src/grammar/core/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jprendes/whasm path: /whasm/src/grammar/core/mod.rs //! This module provides the building blocks to declaratively define the grammar in the //! [WebAssembly Specification](https://webassembly.github.io/spec/). //! //! With the current functionalities in `whasm::grammar::core`, almost all the gr...
code_fim
hard
{ "lang": "rust", "repo": "jprendes/whasm", "path": "/whasm/src/grammar/core/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} /// Convenience function to deserialize an object that implements the `Grammar` trait. pub fn deserialize<T: Grammar, Iter: Iterator<Item=u8>>(iter: &mut Iter) -> Result<T> { <T as Grammar>::deserialize(iter) } pub mod unsigned; pub mod signed; pub mod byte; pub mod vec; pub mod string; pub mod fl...
code_fim
hard
{ "lang": "rust", "repo": "jprendes/whasm", "path": "/whasm/src/grammar/core/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arlyon/holding path: /holding_kronos/src/util.rs pub fn div_rem<T: std::ops::Div<Output = T><|fim_suffix|> / y; let rem = x % y; (quot, rem) }<|fim_middle|> + std::ops::Rem<Output = T> + Copy>( x: T, y: T, ) -> (T, T) { let quot = x
code_fim
medium
{ "lang": "rust", "repo": "arlyon/holding", "path": "/holding_kronos/src/util.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> / y; let rem = x % y; (quot, rem) }<|fim_prefix|>// repo: arlyon/holding path: /holding_kronos/src/util.rs pub fn div_rem<T: std::ops::Div<Output = T><|fim_middle|> + std::ops::Rem<Output = T> + Copy>( x: T, y: T, ) -> (T, T) { let quot = x
code_fim
medium
{ "lang": "rust", "repo": "arlyon/holding", "path": "/holding_kronos/src/util.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> vtx(x1, y1, z1), vtx(x1, y1, z2), vtx(x2, y1, z1), vtx(x2, y1, z2), vtx(x1, y2, z1), vtx(x1, y2, z2), vtx(x2, y2, z1), vtx(x2, y2, z2), ] } #[macro_export] macro_rules! unwrap( ($option:expr) => ( match $option { None => fail!("unwrap() on None"), Some(x) => x, } ...
code_fim
hard
{ "lang": "rust", "repo": "gmorenz/playform", "path": "/src/common.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gmorenz/playform path: /src/common.rs #![macro_escape] use glw::color::Color4; use glw::vertex::{ColoredVertex}; use nalgebra::na::Vec3; use ncollide3df32::bounding_volume::aabb::AABB; pub static WINDOW_WIDTH: uint = 800; pub static WINDOW_HEIGHT: uint = 600; <|fim_suffix|> vtx(x1, y1, z1...
code_fim
hard
{ "lang": "rust", "repo": "gmorenz/playform", "path": "/src/common.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> [ vtx(x1, y1, z1), vtx(x2, y1, z1), vtx(x1, y2, z1), vtx(x2, y2, z1), vtx(x1, y1, z2), vtx(x2, y1, z2), vtx(x1, y2, z2), vtx(x2, y2, z2), vtx(x1, y1, z1), vtx(x1, y2, z1), vtx(x2, y1, z1), vtx(x2, y2, z1), vtx(x1, y1, z2), vtx(x1, y2, z2), vtx(x2, y1, z2), vtx(x2, y2, z2...
code_fim
hard
{ "lang": "rust", "repo": "gmorenz/playform", "path": "/src/common.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/glif path: /src/ipc.rs use log::error; use mfek_ipc::{self, IPCInfo}; use crate::renderer::{Guideline, GuidelineType}; use crate::STATE; use std::{process, str}; pub fn fetch_metrics() { let qmdbin = mfek_ipc::module_name("MFEKmetadata".into()); let filename = STATE.with(|v| v...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/glif", "path": "/src/ipc.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> v.borrow_mut() .glyph .as_mut() .unwrap() .guidelines .push(guideline); } } }); } ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/glif", "path": "/src/ipc.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: liyuntao/adventofcode2018 path: /examples/day10.rs #[macro_use] extern crate lazy_static; extern crate regex; use regex::Regex; use std::fs::File; use std::io::{BufRead, BufReader}; #[derive(Debug)] struct Node { x: i32, y: i32, vx: i32, vy: i32, } impl Node { fn tick(&mut...
code_fim
hard
{ "lang": "rust", "repo": "liyuntao/adventofcode2018", "path": "/examples/day10.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut visualized: [[char; 100]; 10] = [['.'; 100]; 10]; nodes .iter() .for_each(|n| visualized[(n.y - min_y) as usize][(n.x - min_x) as usize] = '#'); visualized.iter().for_each(|line| { line.iter().for_each(|c| print!("{}", c)); println!(); }); } fn main...
code_fim
hard
{ "lang": "rust", "repo": "liyuntao/adventofcode2018", "path": "/examples/day10.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match config.group { Some(gid) => unistd::setgid(gid).unwrap(), None => {} } match config.user { Some(uid) => unistd::setuid(uid).unwrap(), None => {} } let req_attr = MqAttr::new(0, config.queues_len as c_long, mem::size_of::<RawFd>() as c_long, 0); let req_qname = CString:...
code_fim
hard
{ "lang": "rust", "repo": "abbradar/nets-server", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abbradar/nets-server path: /src/main.rs extern crate nix; extern crate libc; extern crate regex; #[macro_use] extern crate lazy_static; extern crate time; extern crate tempfile; extern crate tempdir; extern crate rustc_serialize; mod smtp; mod logger; mod util; mod resolv; use std::{env, mem, ...
code_fim
hard
{ "lang": "rust", "repo": "abbradar/nets-server", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gallynaut/sol-wap path: /src/lib/candles.rs use core::f64; use core::fmt; use serde::Deserialize; #[derive(Debug, Deserialize, Clone, Copy)] pub struct OHLC { pub open_time: Option<f64>, pub open: Option<f64>, pub high: Option<f64>, pub low: Option<f64>, pub close: Option<f6...
code_fim
hard
{ "lang": "rust", "repo": "gallynaut/sol-wap", "path": "/src/lib/candles.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for c in candles.iter() { if !c.is_valid() { continue; } if low == None || low.unwrap() > c.low.unwrap() { low = c.low } if high == None || high.unwrap() < c.high.unwrap() { high = c.high ...
code_fim
hard
{ "lang": "rust", "repo": "gallynaut/sol-wap", "path": "/src/lib/candles.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arata-nvm/cubize path: /src/cpu.rs #[derive(Debug)] pub struct CPU { pub register_a: u8, pub register_x: u8, pub register_y: u8, pub status: u8, pub program_counter: u16, memory: [u8; 0xffff], } #[derive(Debug, Clone, Copy)] pub enum AddressingMode { Immediate, ...
code_fim
hard
{ "lang": "rust", "repo": "arata-nvm/cubize", "path": "/src/cpu.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn reset(&mut self) { self.register_a = 0; self.register_x = 0; self.status = 0; self.program_counter = self.mem_read_u16(0xfffc); } pub fn run(&mut self) { use self::Mnemonic::*; loop { let opcode = self.mem_read(self.program_...
code_fim
hard
{ "lang": "rust", "repo": "arata-nvm/cubize", "path": "/src/cpu.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for c in s.bytes().into_iter() { if !self.output_queue.enqueue(c) { self._flush()?; if !self.output_queue.enqueue(c) { return Err(fmt::Error {}); } } if c == '\n' as u8 { self._f...
code_fim
hard
{ "lang": "rust", "repo": "dalalsunil1986/Methylenix", "path": "/src/kernel/tty.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dalalsunil1986/Methylenix path: /src/kernel/tty.rs //! //! TTY Manager //! use crate::arch::target_arch::device::cpu::is_interrupt_enabled; use crate::kernel::collections::fifo::Fifo; use crate::kernel::manager_cluster::get_kernel_manager_cluster; use crate::kernel::sync::spin_lock::SpinLockFl...
code_fim
hard
{ "lang": "rust", "repo": "dalalsunil1986/Methylenix", "path": "/src/kernel/tty.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[track_caller] pub fn print_debug_message(level: usize, args: fmt::Arguments) { use core::panic::Location; let level_str = match level { 3 => "[ERROR]", 4 => "[WARN]", 5 => "[NOTICE]", 6 => "[INFO]", _ => "[???]", }; let file = Location::caller().fi...
code_fim
hard
{ "lang": "rust", "repo": "dalalsunil1986/Methylenix", "path": "/src/kernel/tty.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.pairs.iter().any(|p| p.1.is_null()) } fn add_autogen_value<V>(&mut self, value: V) -> bool where V: Into<PrismaValue>, { for pair in self.pairs.iter_mut() { if pair.1.is_null() { pair.1 = value.into(); return true; ...
code_fim
hard
{ "lang": "rust", "repo": "prisma/prisma-engines", "path": "/query-engine/connectors/sql-query-connector/src/model_extensions/selection_result.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: prisma/prisma-engines path: /query-engine/connectors/sql-query-connector/src/model_extensions/selection_result.rs use super::ScalarFieldExt; use prisma_models::{PrismaValue, SelectedField, SelectionResult}; use quaint::Value; pub(crate) trait SelectionResultExt { fn misses_autogen_value(&se...
code_fim
medium
{ "lang": "rust", "repo": "prisma/prisma-engines", "path": "/query-engine/connectors/sql-query-connector/src/model_extensions/selection_result.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn add_autogen_value<V>(&mut self, value: V) -> bool where V: Into<PrismaValue>, { for pair in self.pairs.iter_mut() { if pair.1.is_null() { pair.1 = value.into(); return true; } } false } fn db_v...
code_fim
hard
{ "lang": "rust", "repo": "prisma/prisma-engines", "path": "/query-engine/connectors/sql-query-connector/src/model_extensions/selection_result.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TyOverby/implicit path: /examples/badge.rs extern crate lux; extern crate implicit; extern crate flame; mod helper; mod display; <|fim_suffix|>fn main() { let card_size = Rect::from_point_and_size(&Point{x: 0.0, y: 0.0}, &Vector{x: CARD_WIDTH, y: CARD_HEIGHT}); let card_size_expanded =...
code_fim
medium
{ "lang": "rust", "repo": "TyOverby/implicit", "path": "/examples/badge.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let front = backing.and_not(cutout); helper::display(&[&front]); }<|fim_prefix|>// repo: TyOverby/implicit path: /examples/badge.rs extern crate lux; extern crate implicit; extern crate flame; mod helper; mod display; use implicit::*; use implicit::geom::*; const CARD_WIDTH: f32 = 300.0; con...
code_fim
medium
{ "lang": "rust", "repo": "TyOverby/implicit", "path": "/examples/badge.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 4t145/mirai-ws path: /src/protocol/recieve.rs use serde::Deserialize; use crate::protocol::common::*; #[derive(Deserialize, Debug)] #[serde(rename_all = "PascalCase", tag="type")] pub enum Msg { #[serde(rename_all = "camelCase")] FriendMessage { sender: PersonalSender, me...
code_fim
hard
{ "lang": "rust", "repo": "4t145/mirai-ws", "path": "/src/protocol/recieve.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> BotNoAuth = 10, BotMuted = 20, MessageTooLong = 30, WrongVisit = 400 } #[derive(Deserialize, Debug)] #[serde(rename_all = "PascalCase", tag="type")] pub enum Evt { #[serde(rename_all = "camelCase")] GroupRecallEvent { author_id: i64, message_id: i32, time:...
code_fim
hard
{ "lang": "rust", "repo": "4t145/mirai-ws", "path": "/src/protocol/recieve.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Deserialize, Debug)] #[serde(rename_all = "PascalCase", tag="type")] pub enum Evt { #[serde(rename_all = "camelCase")] GroupRecallEvent { author_id: i64, message_id: i32, time: i32, group: GroupInfo, operator: GroupSender } }<|fim_prefix|>// rep...
code_fim
hard
{ "lang": "rust", "repo": "4t145/mirai-ws", "path": "/src/protocol/recieve.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) mod commits; pub use commits::CommitsTable; pub(crate) mod tags; pub use tags::TagsTable;<|fim_prefix|>// repo: NickHackman/git_detective-rs path: /gd/src/table/mod.rs pub(crate) mod final_contributions; pub use final_contributions::FinalContributionsTable; <|fim_middle|>pub(crate) mod diff_...
code_fim
medium
{ "lang": "rust", "repo": "NickHackman/git_detective-rs", "path": "/gd/src/table/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NickHackman/git_detective-rs path: /gd/src/table/mod.rs pub(crate) mod final_contributions; pub use final_contributions::FinalContributionsTable; pub(crate) mod diff_stats; pub use diff_stats::DiffStatsTable; <|fim_suffix|>pub(crate) mod tags; pub use tags::TagsTable;<|fim_middle|>pub(crate) m...
code_fim
easy
{ "lang": "rust", "repo": "NickHackman/git_detective-rs", "path": "/gd/src/table/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn is_password(num: u64, is_standalone_pair: bool) -> bool { let digits = get_digits(num); digits.len() == 6 && is_non_decreasing(&digits) && check_consecutive_duplicates(&digits, is_standalone_pair) } fn solve(is_standalone_pair: bool) -> i32 { let mut count = 0; for num ...
code_fim
hard
{ "lang": "rust", "repo": "1u0/puzzles", "path": "/advent-of-code-2019/day-4/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn solve(is_standalone_pair: bool) -> i32 { let mut count = 0; for num in 367479..=893698 { if is_password(num, is_standalone_pair) { count += 1; } } count } fn solve1() -> i32 { solve(false) } fn solve2() -> i32 { solve(true) } fn main() { printl...
code_fim
hard
{ "lang": "rust", "repo": "1u0/puzzles", "path": "/advent-of-code-2019/day-4/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }