text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>/// Generates a [`VecDeque`] that contains elements of type `T`. /// /// The range specifies the length of the [`VecDeque`]. /// /// # Panics /// /// Panics if the range is empty. /// /// # Examples /// /// ``` /// use dicetest::prelude::*; /// use dicetest::{Prng, Limit}; /// /// let mut prng = Prng::fro...
code_fim
hard
{ "lang": "rust", "repo": "jakoschiko/dicetest", "path": "/src/dice/vec_deque.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut vec = VecDeque::with_capacity(elems.len()); vec.extend(elems); vec } } /// Generates a [`VecDeque`] that contains elements of type `T`. /// /// The range specifies the length of the [`VecDeque`]. /// /// # Panics /// /// Panics if the range is empty. /// /// # Examples...
code_fim
hard
{ "lang": "rust", "repo": "jakoschiko/dicetest", "path": "/src/dice/vec_deque.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jakoschiko/dicetest path: /src/dice/vec_deque.rs use crate::dice::{CollectionBuilder, LengthRange}; use crate::prelude::*; use std::collections::VecDeque; /// [`VecDeque`] builder for [`dice::collection`]. /// /// [`dice::collection`]: dice::collection() pub struct VecDequeBuilder; impl VecDeq...
code_fim
hard
{ "lang": "rust", "repo": "jakoschiko/dicetest", "path": "/src/dice/vec_deque.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.colors[idx] = c; return true; } } #[cfg(test)] mod tests { use super::*; #[test] fn test_match_success() { let mut bm = InjectionMatcher::new(); assert!(bm.match_with_char('A', PuyoColor::RED)); assert!(bm.match_with_char('B', PuyoColor::BLUE)...
code_fim
hard
{ "lang": "rust", "repo": "mayah/puyoai.rs", "path": "/puyoai-core/src/pattern/injection_matcher.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mayah/puyoai.rs path: /puyoai-core/src/pattern/injection_matcher.rs use color::{Color, PuyoColor}; pub struct InjectionMatcher { colors: [PuyoColor; 4], } impl InjectionMatcher { pub fn new() -> InjectionMatcher { InjectionMatcher { colors: [PuyoColor::EMPTY; 4], ...
code_fim
hard
{ "lang": "rust", "repo": "mayah/puyoai.rs", "path": "/puyoai-core/src/pattern/injection_matcher.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn install_location(component: Component) -> Option<PathBuf> { use Component::*; let path = match component { AndroidSdkPlatformTools => { Some("Editor/Data/PlaybackEngines/AndroidPlayer/SDK/platform-tools") } AndroidSdkNdkTools => { Some("Editor...
code_fim
medium
{ "lang": "rust", "repo": "Larusso/unity-version-manager", "path": "/uvm_core/src/sys/linux/unity/component.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Larusso/unity-version-manager path: /uvm_core/src/sys/linux/unity/component.rs use crate::unity::Component; use std::path::{Path, PathBuf}; pub fn installpath(component:Component) -> Option<PathBuf> { use Component::*; let path = match component { Mono | VisualStudio | MonoDevel...
code_fim
medium
{ "lang": "rust", "repo": "Larusso/unity-version-manager", "path": "/uvm_core/src/sys/linux/unity/component.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: immunant/c2rust path: /c2rust-analyze/src/borrowck/atoms.rs use polonius_engine::{self, Atom, FactTypes}; use rustc_middle::mir::{BasicBlock, Local, Location, Place, PlaceElem}; use rustc_middle::ty::TyCtxt; use std::collections::hash_map::{Entry, HashMap}; use std::hash::Hash; macro_rules! def...
code_fim
hard
{ "lang": "rust", "repo": "immunant/c2rust", "path": "/c2rust-analyze/src/borrowck/atoms.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, facts: &mut AllFacts, local: Local, projection: &'tcx [PlaceElem<'tcx>], ) -> Path { let (path, new) = self.path.add_new((local, projection)); if new { if projection.is_empty() { let var = self.variable(local); ...
code_fim
hard
{ "lang": "rust", "repo": "immunant/c2rust", "path": "/c2rust-analyze/src/borrowck/atoms.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> items.add_item(item); Ok(()) } pub(super) fn parse_edges<R: gimli::Reader>( _items: &mut ir::ItemsBuilder, _entry: &gimli::DebuggingInformationEntry<R>, ) -> anyhow::Result<()> { // TODO: Add edges representing the call graph. Ok(()) }<|fim_prefix|>// repo: rustwasm/twiggy path: ...
code_fim
hard
{ "lang": "rust", "repo": "rustwasm/twiggy", "path": "/parser/object_parse/die_parse/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rustwasm/twiggy path: /parser/object_parse/die_parse/mod.rs use gimli; use twiggy_ir as ir; mod item_name; mod location_attrs; use self::item_name::item_name; use self::location_attrs::DieLocationAttributes; <|fim_suffix|>pub(super) fn parse_items<R: gimli::Reader>( items: &mut ir::ItemsBu...
code_fim
medium
{ "lang": "rust", "repo": "rustwasm/twiggy", "path": "/parser/object_parse/die_parse/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn print_state(&self) { return; let mut in_wait_rsp = false; match self.cur_state { StateType::WaitPop => { println!("step:{} next_card_ix:{} state:{}", self.cur_step, self.cur_card_ix, self.cur_state.to_string()); }, Stat...
code_fim
hard
{ "lang": "rust", "repo": "SheSnake/game_server", "path": "/src/game/majiang_state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SheSnake/game_server path: /src/game/majiang_state.rs extern crate rand; use rand::seq::SliceRandom; use rand::thread_rng; use std::collections::HashMap; use super::majiang_model::Majiang; use super::majiang_operation::{MajiangOperation , Action}; pub struct MajiangPlayerState { on_hand: Ha...
code_fim
hard
{ "lang": "rust", "repo": "SheSnake/game_server", "path": "/src/game/majiang_state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xy-plus/zCore path: /zCore/src/handler.rs use kernel_hal::{KernelHandler, MMUFlags}; use super::memory; pub struct ZcoreKernelHandler; <|fim_suffix|> fn frame_alloc_contiguous(&self, frame_count: usize, align_log2: usize) -> Option<usize> { memory::frame_alloc_contiguous(frame_coun...
code_fim
medium
{ "lang": "rust", "repo": "xy-plus/zCore", "path": "/zCore/src/handler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn handle_page_fault(&self, fault_vaddr: usize, access_flags: MMUFlags) { panic!("page fault from kernel mode @ {fault_vaddr:#x}({access_flags:?})"); } }<|fim_prefix|>// repo: xy-plus/zCore path: /zCore/src/handler.rs use kernel_hal::{KernelHandler, MMUFlags}; use super::memory; pub str...
code_fim
medium
{ "lang": "rust", "repo": "xy-plus/zCore", "path": "/zCore/src/handler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> memory::frame_dealloc(paddr) } fn handle_page_fault(&self, fault_vaddr: usize, access_flags: MMUFlags) { panic!("page fault from kernel mode @ {fault_vaddr:#x}({access_flags:?})"); } }<|fim_prefix|>// repo: xy-plus/zCore path: /zCore/src/handler.rs use kernel_hal::{KernelHand...
code_fim
hard
{ "lang": "rust", "repo": "xy-plus/zCore", "path": "/zCore/src/handler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> { Some(_window) => { output = Comparison::Superlist; }, None => { output = Comparison::Unequal; } } }, ...
code_fim
hard
{ "lang": "rust", "repo": "vadhri/exercism-rust", "path": "/sublist/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vadhri/exercism-rust path: /sublist/src/lib.rs #[derive(Debug, PartialEq, PartialOrd)] pub enum Comparison { Equal, Sublist, Superlist, Unequal, } pub fn sublist<T: std::fmt::Debug + std::clone::Clone + PartialEq>(_first_list: &[T], _second_list: &[T]) -> Comparison { let ...
code_fim
hard
{ "lang": "rust", "repo": "vadhri/exercism-rust", "path": "/sublist/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod lex; mod parse; struct Session<'a> { lexer: lex::Lexer<std::io::BufReader<'a>>, parser: parse::Parser }<|fim_prefix|>// repo: ptgreen/rfront path: /src/lib.rs #![feature(phase)] #![allow(dead_code)] /* * The goal is to construct existing rustc-frontend types from * libsyntax, but using a ...
code_fim
medium
{ "lang": "rust", "repo": "ptgreen/rfront", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ptgreen/rfront path: /src/lib.rs #![feature(phase)] #![allow(dead_code)] /* * The goal is to construct existing rustc-frontend types from * libsyntax, but using a rustlex lexer and a racc parser. So we link * to libsyntax here in order to get the AST and token types. */ extern crate syntax;...
code_fim
medium
{ "lang": "rust", "repo": "ptgreen/rfront", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>struct Session<'a> { lexer: lex::Lexer<std::io::BufReader<'a>>, parser: parse::Parser }<|fim_prefix|>// repo: ptgreen/rfront path: /src/lib.rs #![feature(phase)] #![allow(dead_code)] /* * The goal is to construct existing rustc-frontend types from * libsyntax, but using a rustlex lexer and a r...
code_fim
medium
{ "lang": "rust", "repo": "ptgreen/rfront", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let opp = s.get_pixel(s.height() - 1, s.width() - 1); println!("(end,end): R: {}, G: {}, B: {}", opp.r, opp.g, opp.b); let mut buf = vec![]; repng::encode(&mut buf, s.width() as u32, s.height() as u32, &s.get_data()).unwrap(); // println!("data:image/png;base64,{}", base64::encode(buf...
code_fim
medium
{ "lang": "rust", "repo": "ayonsaha2011/snip-dxgi", "path": "/examples/screen.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut buf = vec![]; repng::encode(&mut buf, s.width() as u32, s.height() as u32, &s.get_data()).unwrap(); // println!("data:image/png;base64,{}", base64::encode(buf)); image::save_buffer( "test.png", s.as_ref(), s.width() as u32, s.height() as u32, ...
code_fim
hard
{ "lang": "rust", "repo": "ayonsaha2011/snip-dxgi", "path": "/examples/screen.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ayonsaha2011/snip-dxgi path: /examples/screen.rs use image; use snip::screen_capture; fn main() { let s = screen_capture(0).unwrap(); println!( "{} x {} x {} = {} bytes", s.height(), s.width(), s.pixel_width(), s.raw_len() ); let origin...
code_fim
hard
{ "lang": "rust", "repo": "ayonsaha2011/snip-dxgi", "path": "/examples/screen.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn ensure_known_root(id: TreeId, target: Element) -> Result<(), dispatch::DispatchError>; /// Check if a nullifier has been used in a tree or returns /// `InvalidNullifier` fn is_nullifier_used(id: TreeId, nullifier: Element) -> bool; fn ensure_nullifier_unused(id: TreeId, nullifier: Element) -> Res...
code_fim
hard
{ "lang": "rust", "repo": "hoanhsota/protocol-substrate", "path": "/primitives/src/traits/mixer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn ensure_known_root(id: TreeId, target: Element) -> Result<(), dispatch::DispatchError>; /// Check if a nullifier has been used in a tree or returns /// `InvalidNullifier` fn is_nullifier_used(id: TreeId, nullifier: Element) -> bool; fn ensure_nullifier_unused(id: TreeId, nullifier: Element) -> Re...
code_fim
hard
{ "lang": "rust", "repo": "hoanhsota/protocol-substrate", "path": "/primitives/src/traits/mixer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hoanhsota/protocol-substrate path: /primitives/src/traits/mixer.rs //! All the traits exposed to be used in other custom pallets use frame_support::dispatch; /// Mixer trait definition to be used in other pallets pub trait MixerInterface<AccountId, Balance, CurrencyId, TreeId, Element> { // Cr...
code_fim
hard
{ "lang": "rust", "repo": "hoanhsota/protocol-substrate", "path": "/primitives/src/traits/mixer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> proptest! { #[test] fn test_mod_inverse(a: i64, m: u64) { prop_assume!(m > 1); prop_assume!(gcd(&a, &m) == Int::from(1)); let inv = mod_inverse(&a, &m); prop_assert!(inv.is_positive()); let mult_result = rem(&(a * inv), &m); ...
code_fim
medium
{ "lang": "rust", "repo": "itscomputers/ebe-rust", "path": "/src/modular.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: itscomputers/ebe-rust path: /src/modular.rs use crate::types::int::{Int, ToInt}; use crate::division::{bezout, rem}; pub fn mod_inverse<T: ToInt, U: ToInt>(a: &T, m: &U) -> Int { let a = a.to_int(); let m = m.to_int(); if m.lt_int(2) { panic!("Modulus must be at least 2"); ...
code_fim
medium
{ "lang": "rust", "repo": "itscomputers/ebe-rust", "path": "/src/modular.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>const PITCH_BOUND: f32 = std::f32::consts::FRAC_PI_2 - 1E-3; pub fn input_to_look( mut mouse_motion_events: EventReader<MouseMotion>, mut settings: ResMut<MouseSettings>, mut pitch_events: EventWriter<PitchEvent>, mut yaw_events: EventWriter<YawEvent>, mut look_events: EventWriter<Loo...
code_fim
hard
{ "lang": "rust", "repo": "superdump/bevy_prototype_character_controller", "path": "/src/look.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: superdump/bevy_prototype_character_controller path: /src/look.rs // system that converts delta axis events into pitch and yaw use crate::events::{LookDeltaEvent, LookEvent, PitchEvent, YawEvent}; use bevy::{input::mouse::MouseMotion, prelude::*}; #[derive(Clone, Copy)] pub struct LookDirection ...
code_fim
hard
{ "lang": "rust", "repo": "superdump/bevy_prototype_character_controller", "path": "/src/look.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub static ONTOLOGY_VERSION: &str = "0.7.0";<|fim_prefix|>// repo: emmayangemma/snips-nlu-ontology path: /src/lib.rs #[macro_use] extern crate serde_derive; pub mod errors; pub mod language; pub mod macros; <|fim_middle|>pub mod entity; mod ontology; pub use entity::builtin_entity::{ complete_enti...
code_fim
hard
{ "lang": "rust", "repo": "emmayangemma/snips-nlu-ontology", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emmayangemma/snips-nlu-ontology path: /src/lib.rs #[macro_use] extern crate serde_derive; pub mod errors; pub mod language; pub mod macros; pub mod entity; mod ontology; <|fim_suffix|>pub static ONTOLOGY_VERSION: &str = "0.7.0";<|fim_middle|>pub use entity::builtin_entity::{ complete_enti...
code_fim
hard
{ "lang": "rust", "repo": "emmayangemma/snips-nlu-ontology", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Get attributes for this key such as depth, parent fingerprint, /// child number, and chain code. pub fn attrs(&self) -> &ExtendedKeyAttrs { &self.attrs } /// Serialize the raw private key as a byte array. pub fn to_bytes(&self) -> PrivateKeyBytes { self.private...
code_fim
hard
{ "lang": "rust", "repo": "iqlusioninc/crates", "path": "/bip32/src/extended_key/private_key.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iqlusioninc/crates path: /bip32/src/extended_key/private_key.rs //! Extended private keys use crate::{ ChildNumber, Depth, Error, ExtendedKey, ExtendedKeyAttrs, ExtendedPublicKey, HmacSha512, KeyFingerprint, Prefix, PrivateKey, PrivateKeyBytes, PublicKey, Result, KEY_SIZE, }; use core::...
code_fim
hard
{ "lang": "rust", "repo": "iqlusioninc/crates", "path": "/bip32/src/extended_key/private_key.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>Commodity), #[error("no exchange rate supplied, unable to convert commodity {0} to type {1}")] NoExchangeRateSupplied(Commodity, CommodityTypeID), #[error("the account state with the id {0} was requested but cannot be found")] MissingAccountState(AccountID), #[error("the balance assert...
code_fim
hard
{ "lang": "rust", "repo": "kellpossible/doublecount", "path": "/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kellpossible/doublecount path: /src/error.rs use super::{AccountID, AccountStatus, FailedBalanceAssertion, Transaction}; use commodity::exchange_rate::ExchangeRateError; use commodity::{Commodity, CommodityError, CommodityTypeID}; use thiserror::Error; /// An error associated with functionality...
code_fim
hard
{ "lang": "rust", "repo": "kellpossible/doublecount", "path": "/src/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: unclebilly/collatz path: /src/main.rs use structopt::StructOpt; use std::vec::Vec; use plotters::prelude::*; #[derive(Debug, StructOpt)] #[structopt(name = "collatz", about = "Fun with the 3x+1 problem.")] struct Cli { lower: Option<i128>, upper: Option<i128>, } #[derive(Debug)] struct...
code_fim
hard
{ "lang": "rust", "repo": "unclebilly/collatz", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reddysriya/harsark.rs path: /examples/cortex-m4/examples/logging.rs #![no_std] #![no_main] extern crate panic_halt; extern crate stm32f4; use core::cell::RefCell; use cortex_m::peripheral::Peripherals; use cortex_m_rt::entry; use cortex_m_semihosting::hprintln; use harsark::helpers::TaskMask...
code_fim
medium
{ "lang": "rust", "repo": "reddysriya/harsark.rs", "path": "/examples/cortex-m4/examples/logging.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /* Define the task stacks corresponding to each task. Note to specify the stack size according to the task parameters and local variables etc. */ /* Task definition. The first parameter corresponds to the name that will be used to refer to the task. The second variable cor...
code_fim
medium
{ "lang": "rust", "repo": "reddysriya/harsark.rs", "path": "/examples/cortex-m4/examples/logging.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Initializes the kernel in preemptive mode. init(|_| Ok(())); // Releases tasks task1, task2, task3 logging::set_all(true); release(TaskMask::generate([TASK1])); release(TaskMask::generate([TASK2])); release(TaskMask::generate([TASK3])); /* Starts scheduling tasks on...
code_fim
hard
{ "lang": "rust", "repo": "reddysriya/harsark.rs", "path": "/examples/cortex-m4/examples/logging.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[project] fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { #[project] match self.project() { DualTcpStream::Passthrough(abs) => abs.poll_ready(cx), DualTcpStream::Upgrade(abs, _) => abs.poll_ready(cx), } ...
code_fim
hard
{ "lang": "rust", "repo": "aDotInTheVoid/noria", "path": "/noria/src/channel/tcp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<S, T, T2> From<S> for DualTcpStream<S, T, T2, AsyncDestination> { fn from(stream: S) -> Self { DualTcpStream::Passthrough(AsyncBincodeStream::from(stream).for_async()) } } impl<S, T, T2> DualTcpStream<S, T, T2, AsyncDestination> { pub fn upgrade<F: 'static + FnMut(T2) -> T + Send...
code_fim
hard
{ "lang": "rust", "repo": "aDotInTheVoid/noria", "path": "/noria/src/channel/tcp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aDotInTheVoid/noria path: /noria/src/channel/tcp.rs use std::convert::TryFrom; use std::io::{self, Write}; use std::marker::PhantomData; use std::net::{Ipv4Addr, SocketAddr}; use crate::Tagged; use async_bincode::{AsyncBincodeStream, AsyncDestination}; use bufstream::BufStream; use byteorder::{...
code_fim
hard
{ "lang": "rust", "repo": "aDotInTheVoid/noria", "path": "/noria/src/channel/tcp.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[bench] fn addition_benchmarked (b: &mut test::BenchHarness) { let mut sum = 0; b.iter(|| sum += 1); }<|fim_prefix|>// repo: killerswan/rustx path: /src/rustx/main.rs extern crate test; use std::io; <|fim_middle|>#[main] #[cfg(not(test))] fn say_hi () { io::println("Hello!!"); } #[test] fn a...
code_fim
medium
{ "lang": "rust", "repo": "killerswan/rustx", "path": "/src/rustx/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: killerswan/rustx path: /src/rustx/main.rs extern crate test; use std::io; <|fim_suffix|> io::println("Hello!!"); assert! (2 + 2 == 4); } #[bench] fn addition_benchmarked (b: &mut test::BenchHarness) { let mut sum = 0; b.iter(|| sum += 1); }<|fim_middle|>#[main] #[cfg(not(test))] fn...
code_fim
medium
{ "lang": "rust", "repo": "killerswan/rustx", "path": "/src/rustx/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut sum = 0; b.iter(|| sum += 1); }<|fim_prefix|>// repo: killerswan/rustx path: /src/rustx/main.rs extern crate test; use std::io; #[main] #[cfg(not(test))] fn say_hi () { io::println("Hello!!"); } #[test] fn addition_works () { <|fim_middle|> io::println("Hello!!"); assert! (2 + 2 ...
code_fim
medium
{ "lang": "rust", "repo": "killerswan/rustx", "path": "/src/rustx/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: algon-320/ruxv6 path: /kernel/src/file.rs use super::fs; use super::pipe; use spin::Mutex; pub enum FileType { FD_NONE, FD_PIPE, FD_INODE, } pub struct File { file_type: FileType, ref_count: i32, readable: u8, writable: u8, pipe: *const pipe::Pipe, ip: *cons...
code_fim
hard
{ "lang": "rust", "repo": "algon-320/ruxv6", "path": "/kernel/src/file.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// table mapping major device number to // device functions #[derive(Debug, Clone, Copy)] pub struct devsw { pub read: Option<fn(*const Inode, usize) -> *const [u8]>, pub write: Option<fn(*const Inode, *const [u8])>, } impl devsw { pub fn new() -> Self { devsw { read: None...
code_fim
hard
{ "lang": "rust", "repo": "algon-320/ruxv6", "path": "/kernel/src/file.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl devsw { pub fn new() -> Self { devsw { read: None, write: None, } } } pub const CONSOLE: usize = 1;<|fim_prefix|>// repo: algon-320/ruxv6 path: /kernel/src/file.rs use super::fs; use super::pipe; use spin::Mutex; pub enum FileType { FD_NONE, ...
code_fim
hard
{ "lang": "rust", "repo": "algon-320/ruxv6", "path": "/kernel/src/file.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: s3bk/audio path: /src/canvas.rs use std::ops::{Index, IndexMut}; use serde::{Serialize, Deserialize}; use std::path::Path; use std::io::{BufWriter, BufReader}; use std::fs::File; use rayon::prelude::*; #[derive(Serialize, Deserialize)] pub struct Canvas { data: Vec<f32>, width: usize, ...
code_fim
medium
{ "lang": "rust", "repo": "s3bk/audio", "path": "/src/canvas.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Index<(usize, usize)> for Canvas { type Output = f32; fn index(&self, idx: (usize, usize)) -> &f32 { let idx = self.index_of(idx); &self.data[idx] } } impl IndexMut<(usize, usize)> for Canvas { fn index_mut(&mut self, idx: (usize, usize)) -> &mut f32 { let idx...
code_fim
hard
{ "lang": "rust", "repo": "s3bk/audio", "path": "/src/canvas.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ayazhafiz/slide path: /editor/language_server/src/tests/mod.rs //! Module `tests` provides integration tests for the slide langauge server. <|fim_suffix|>mod code_action; mod code_lens; mod completion; mod definitions; mod diagnostics; mod document_symbol; mod folding_range; mod formatting; mod...
code_fim
easy
{ "lang": "rust", "repo": "ayazhafiz/slide", "path": "/editor/language_server/src/tests/mod.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>mod code_action; mod code_lens; mod completion; mod definitions; mod diagnostics; mod document_symbol; mod folding_range; mod formatting; mod highlight; mod hover; mod prepare_rename; mod range_formatting; mod references; mod rename; mod selection_range; mod workspace_symbol;<|fim_prefix|>// repo: ayazhaf...
code_fim
easy
{ "lang": "rust", "repo": "ayazhafiz/slide", "path": "/editor/language_server/src/tests/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let whole_body_vec = whole_body.iter().cloned().collect::<Vec<u8>>(); let value = from_utf8(&whole_body_vec) .to_owned() .expect("Could not convert bytes"); log::info!("Failed to post teams, got err...
code_fim
hard
{ "lang": "rust", "repo": "findelabs/mongo_alerts_2teams", "path": "/src/post.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: findelabs/mongo_alerts_2teams path: /src/post.rs use bytes::Bytes; use hyper::{Body, Client, Request}; use hyper_tls::HttpsConnector; use std::str::from_utf8; use std::{thread, time}; pub async fn post_retry(card_body: &serde_json::Value, url: String) -> Option<bool> { for i in 1..4u16 { ...
code_fim
hard
{ "lang": "rust", "repo": "findelabs/mongo_alerts_2teams", "path": "/src/post.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rustpq/pqcrypto path: /pqcrypto-sphincsplus/src/lib.rs ey_bytes as sphincsharaka128frobust_public_key_bytes, secret_key_bytes as sphincsharaka128frobust_secret_key_bytes, sign as sphincsharaka128frobust_sign, signature_bytes as sphincsharaka128frobust_signature_bytes, verify_deta...
code_fim
hard
{ "lang": "rust", "repo": "rustpq/pqcrypto", "path": "/pqcrypto-sphincsplus/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ha2256srobust_sign, signature_bytes as sphincssha2256srobust_signature_bytes, verify_detached_signature as sphincssha2256srobust_verify_detached_signature, }; pub use crate::sphincssha2256ssimple::{ detached_sign as sphincssha2256ssimple_detached_sign, keypair as sphincssha2256ssimple_keypair,...
code_fim
hard
{ "lang": "rust", "repo": "rustpq/pqcrypto", "path": "/pqcrypto-sphincsplus/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rustpq/pqcrypto path: /pqcrypto-sphincsplus/src/lib.rs verify_detached_signature as sphincsharaka128ssimple_verify_detached_signature, }; pub use crate::sphincsharaka192frobust::{ detached_sign as sphincsharaka192frobust_detached_sign, keypair as sphincsharaka192frobust_keypair, open...
code_fim
hard
{ "lang": "rust", "repo": "rustpq/pqcrypto", "path": "/pqcrypto-sphincsplus/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn Write(&self, writer: &mut dyn Writer) -> bool { let payload_size = self.PayloadSize(); let edition_size = util::EbmlMasterElementSize(MkvId::MkvEditionEntry, payload_size) + payload_size; if !util::WriteEbmlMasterElement(writer, MkvId::MkvChapters, payload_s...
code_fim
hard
{ "lang": "rust", "repo": "rainliu/libwebm", "path": "/src/mkvmuxer/chapters.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rainliu/libwebm path: /src/mkvmuxer/chapters.rs use super::chapter::Chapter; use super::util; use super::writer::Writer; use crate::MkvId; pub struct Chapters { // Array for storage of chapter objects. chapters_: Vec<Chapter>, } impl Chapters { pub fn new() -> Chapters { Ch...
code_fim
hard
{ "lang": "rust", "repo": "rainliu/libwebm", "path": "/src/mkvmuxer/chapters.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if !util::WriteEbmlMasterElement(writer, MkvId::MkvChapters, payload_size) { return false; } let start = writer.get_position(); if !util::WriteEbmlMasterElement(writer, MkvId::MkvEditionEntry, payload_size) { return false; } for ch...
code_fim
hard
{ "lang": "rust", "repo": "rainliu/libwebm", "path": "/src/mkvmuxer/chapters.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joeferner/digital-circuit-simulator path: /src/device/test_probe.rs use crate::device::Device; use crate::Circuit; use crate::CircuitToDeviceMessage; use crate::DeviceData; use crate::DeviceToCircuitMessage; use crate::PinDirection; use std::any::Any; use std::sync::mpsc; #[derive(Debug)] pub s...
code_fim
hard
{ "lang": "rust", "repo": "joeferner/digital-circuit-simulator", "path": "/src/device/test_probe.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn output_low() -> TestProbeSetData { return TestProbeSetData::new(0, PinDirection::Output); } pub fn input() -> TestProbeSetData { return TestProbeSetData::new(0, PinDirection::Input); } pub fn get_value(&self) -> u32 { return self.value; } pub f...
code_fim
hard
{ "lang": "rust", "repo": "joeferner/digital-circuit-simulator", "path": "/src/device/test_probe.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> async fn box_pin_Struct(self: Box<Pin<&Struct>>, f: &u32) -> &u32 { f //[base]~^ ERROR lifetime mismatch //[nll]~^^ ERROR lifetime may not live long enough } } fn main() { }<|fim_prefix|>// repo: pnkfelix/rust path: /src/test/ui/self/elision/ref-struct-async.rs // edition...
code_fim
hard
{ "lang": "rust", "repo": "pnkfelix/rust", "path": "/src/test/ui/self/elision/ref-struct-async.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pnkfelix/rust path: /src/test/ui/self/elision/ref-struct-async.rs // edition:2018 // revisions: base nll // ignore-compare-mode-nll //[nll] compile-flags: -Z borrowck=mir #![allow(non_snake_case)] use std::pin::Pin; <|fim_suffix|> async fn box_box_ref_Struct(self: Box<Box<&Struct>>, f: &u3...
code_fim
hard
{ "lang": "rust", "repo": "pnkfelix/rust", "path": "/src/test/ui/self/elision/ref-struct-async.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { f //[base]~^ ERROR lifetime mismatch //[nll]~^^ ERROR lifetime may not live long enough } async fn box_box_ref_Struct(self: Box<Box<&Struct>>, f: &u32) -> &u32 { f //[base]~^ ERROR lifetime ...
code_fim
medium
{ "lang": "rust", "repo": "pnkfelix/rust", "path": "/src/test/ui/self/elision/ref-struct-async.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Get value of the B field fn b(&self) -> Value; /// Set the value of the B field fn set_b(&mut self, v: Value); /// Get the addressing mode of the B field fn b_mode(&self) -> AddressingMode; /// Set the AddressingMode of the B field fn set_b_mode(&mut self, v: Addres...
code_fim
medium
{ "lang": "rust", "repo": "blt/libcw", "path": "/src/redcode/traits.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: blt/libcw path: /src/redcode/traits.rs //! Traits for describing redcode instructions use super::types::{Value, OpCode, Modifier, AddressingMode}; /// A trait indicating that a the implementing type can be interpreted as an /// redcode instruction pub trait Instruction: Default + Clone { ...
code_fim
hard
{ "lang": "rust", "repo": "blt/libcw", "path": "/src/redcode/traits.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: radogost/ucz-dfs path: /src/datanode/handler.rs use crate::block::Block; use crate::datanode::datanode_storage::DataNodeStorage; use crate::error::Result; use crate::proto; use crate::proto::{ operation::OpCode, Operation, Packet, ReadBlockOperation, WriteBlockOperation, WriteBlockRespon...
code_fim
hard
{ "lang": "rust", "repo": "radogost/ucz-dfs", "path": "/src/datanode/handler.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> async fn handle_write(&mut self) -> Result<()> { let WriteBlockOperation { block, targets } = parse_message(&mut self.socket).await?; let block = block.into(); let block_file = self.storage.start_block_creation(&block).await?; match self.write_block(block_file, &block,...
code_fim
hard
{ "lang": "rust", "repo": "radogost/ucz-dfs", "path": "/src/datanode/handler.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> buffer.resize_with(packet_size as usize, u8::default); blockfile.read_exact(&mut buffer).await?; self.socket.write_all(&buffer).await?; buffer.clear(); } self.socket.flush().await?; Ok(()) } async fn write_block( &mu...
code_fim
hard
{ "lang": "rust", "repo": "radogost/ucz-dfs", "path": "/src/datanode/handler.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> mint { let caller: T::AccountId = whitelisted_caller(); }: mint(RawOrigin::Signed(caller.clone()), Default::default(), Vec::<u8>::default(), TokenData::default()) verify { assert_eq!( last_event(), crate::mock::Event::pallet_gallery(crate::RawEvent::CollectionCreated(0)), ); } ...
code_fim
hard
{ "lang": "rust", "repo": "jam10o-new/kusama_art_gallery", "path": "/art-gallery-pallet/src/benchmarking.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jam10o-new/kusama_art_gallery path: /art-gallery-pallet/src/benchmarking.rs #![cfg(feature = "runtime-benchmarks")] use super::*; use frame_system::RawOrigin; use frame_benchmarking::{benchmarks, account, whitelisted_caller}; use sp_runtime::traits::Bounded; <|fim_suffix|> #[cfg(test)] mod te...
code_fim
hard
{ "lang": "rust", "repo": "jam10o-new/kusama_art_gallery", "path": "/art-gallery-pallet/src/benchmarking.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> let inp = FastInput::new(); let k = inp.next(); let mut cache = HashMap::new(); let (count, _) = search(0, 0, k, &mut cache); println!("{}", count); }<|fim_prefix|>// repo: KlasafGeijerstam/Kattis path: /rust/busskortet.rs mod fast_input; use fast_input::FastInput; use std::collection...
code_fim
hard
{ "lang": "rust", "repo": "KlasafGeijerstam/Kattis", "path": "/rust/busskortet.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KlasafGeijerstam/Kattis path: /rust/busskortet.rs mod fast_input; use fast_input::FastInput; use std::collections::HashMap; fn search(transactions: u16, amount: u16, target: u16, cache: &mut HashMap<(u16, u16), (u16, u16)>) -> (u16, u16) { <|fim_suffix|> let inp = FastInput::new(); let k...
code_fim
hard
{ "lang": "rust", "repo": "KlasafGeijerstam/Kattis", "path": "/rust/busskortet.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl VariableSize { pub fn bytes(&self) -> u8 { match *self { VariableSize::Byte => 1, VariableSize::Word => 2, } } }<|fim_prefix|>// repo: Dzejrou/dzemu path: /src/asm/mod.rs pub mod mcs6502; pub trait Assembler { fn assemble(&mut self, &str); fn ...
code_fim
medium
{ "lang": "rust", "repo": "Dzejrou/dzemu", "path": "/src/asm/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Dzejrou/dzemu path: /src/asm/mod.rs pub mod mcs6502; pub trait Assembler { fn assemble(&mut self, &str); <|fim_suffix|>pub enum VariableSize { Byte, Word } impl VariableSize { pub fn bytes(&self) -> u8 { match *self { VariableSize::Byte => 1, Var...
code_fim
medium
{ "lang": "rust", "repo": "Dzejrou/dzemu", "path": "/src/asm/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub enum VariableSize { Byte, Word } impl VariableSize { pub fn bytes(&self) -> u8 { match *self { VariableSize::Byte => 1, VariableSize::Word => 2, } } }<|fim_prefix|>// repo: Dzejrou/dzemu path: /src/asm/mod.rs pub mod mcs6502; pub trait Assembl...
code_fim
medium
{ "lang": "rust", "repo": "Dzejrou/dzemu", "path": "/src/asm/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: liqcomb/os path: /src/arch/x86_64/mod.rs mod context; mod gdt; mod ide; mod idt; mod io; mod mmu; mod pci; mod pic; mod timer; mod tss; /* exposed child definitions */ pub use self::context::Context; use self::idt::IDT; use self::timer::Timer; pub const HEAP_VIRT: u64 = mmu::HEAP_VIRT; pub co...
code_fim
hard
{ "lang": "rust", "repo": "liqcomb/os", "path": "/src/arch/x86_64/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Unregister a timer handler pub fn unregister_timer(idx: usize) -> Result<(), ::common::error::Error> { Timer::get().unregister_timer(idx) } /// Register a scheduler pub fn register_scheduler(func: fn(u64)) -> Result<(), ::common::error::Error> { Timer::get().register_scheduler(func) } /// In...
code_fim
hard
{ "lang": "rust", "repo": "liqcomb/os", "path": "/src/arch/x86_64/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { foo("hi you"); foo2("hi"); }<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/suggestions/issue-104961.rs // run-rustfix fn foo(x: &str) -> bool { x.starts_with("hi".to_string() + " you") //~^ ERROR expected a `FnMut<(char,)>` closure, found `String` } <|fim_middle|>fn f...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/suggestions/issue-104961.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/suggestions/issue-104961.rs // run-rustfix fn foo(x: &str) -> bool { <|fim_suffix|>fn foo2(x: &str) -> bool { x.starts_with("hi".to_string()) //~^ ERROR expected a `FnMut<(char,)>` closure, found `String` } fn main() { foo("hi you"); foo2("hi"); }...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/suggestions/issue-104961.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Namchee/aoc2020 path: /day2/main1.rs use std::io; use std::vec::Vec; fn main() { let stdin = io::stdin(); let mut count: i32 = 0; let mut buffer = String::new(); while stdin.read_line(&mut buffer).unwrap() > 0 { if buffer.ends_with('\n') { buffer.pop(); ...
code_fim
medium
{ "lang": "rust", "repo": "Namchee/aoc2020", "path": "/day2/main1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if (arr[chara] <= max) && (arr[chara] >= min) { count += 1; } buffer.clear(); } println!("{}", count); }<|fim_prefix|>// repo: Namchee/aoc2020 path: /day2/main1.rs use std::io; use std::vec::Vec; fn main() { let stdin = io::stdin(); let mut count: i...
code_fim
medium
{ "lang": "rust", "repo": "Namchee/aoc2020", "path": "/day2/main1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for c in string.chars() { let code: usize = (c as usize) - 97; arr[code] = arr[code] + 1; } let chara: usize = (chara as usize) - 97; if (arr[chara] <= max) && (arr[chara] >= min) { count += 1; } buffer.clear(); } ...
code_fim
hard
{ "lang": "rust", "repo": "Namchee/aoc2020", "path": "/day2/main1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vlad9486/un-algebra path: /src/com_group/com_group.rs //! //! Algebraic _commutative group_ trait. //! //! An algebraic _commutative group_ (also called an _abelian group_) //! is a _group_ `S`, where the group operation `·` is required to be //! _commutative_. //! //! # Axioms //! //! 1. Group...
code_fim
medium
{ "lang": "rust", "repo": "vlad9486/un-algebra", "path": "/src/com_group/com_group.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> /// Test the axiom of commutivity. fn axiom_commutivity(xs: Pair<Self>) -> bool { let (x, y) = xs; x.op(y) == y.op(x) } }<|fim_prefix|>// repo: vlad9486/un-algebra path: /src/com_group/com_group.rs //! //! Algebraic _commutative group_ trait. //! //! An algebraic _commutative group_ (also ...
code_fim
medium
{ "lang": "rust", "repo": "vlad9486/un-algebra", "path": "/src/com_group/com_group.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> fn tokenize(id: i32) -> String { id.to_string() } } #[test] fn shorten_and_expand() { let mut world = World::empty(); let url1 = "justincampbell.me".to_string(); let url2 = "justincampbell.me".to_string(); let token1 = world.shorten(&url1); let token2 = world.shorten...
code_fim
hard
{ "lang": "rust", "repo": "justincampbell/url-shortener-rust", "path": "/src/shortener.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: justincampbell/url-shortener-rust path: /src/shortener.rs use std::collections::HashMap; type Token = String; type Url = String; pub struct World { id: i32, urls: HashMap<Token, Url> } <|fim_suffix|> fn tokenize(id: i32) -> String { id.to_string() } } #[test] fn shorte...
code_fim
hard
{ "lang": "rust", "repo": "justincampbell/url-shortener-rust", "path": "/src/shortener.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn shorten_and_expand() { let mut world = World::empty(); let url1 = "justincampbell.me".to_string(); let url2 = "justincampbell.me".to_string(); let token1 = world.shorten(&url1); let token2 = world.shorten(&url2); match world.expand(token1) { Some(expanded_url)...
code_fim
medium
{ "lang": "rust", "repo": "justincampbell/url-shortener-rust", "path": "/src/shortener.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>use anyhow::{Context, Result}; use slog::{slog_o, Drain}; use slog_scope::debug; use std::env; fn main() -> Result<()> { // Setup logging. let decorator = slog_term::TermDecorator::new().build(); let drain = slog_term::FullFormat::new(decorator).build().fuse(); let drain = slog_async::Asy...
code_fim
medium
{ "lang": "rust", "repo": "coreos/afterburn", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Setup logging. let decorator = slog_term::TermDecorator::new().build(); let drain = slog_term::FullFormat::new(decorator).build().fuse(); let drain = slog_async::Async::new(drain).build().fuse(); let log = slog::Logger::root(drain, slog_o!()); let _guard = slog_scope::set_global...
code_fim
medium
{ "lang": "rust", "repo": "coreos/afterburn", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coreos/afterburn path: /src/main.rs // Copyright 2017 CoreOS, Inc. // // 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 at // // http://www.apache.org/licenses/LICENSE...
code_fim
medium
{ "lang": "rust", "repo": "coreos/afterburn", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> ParseResult::Err(ParseError { kind, info }) } }, IResult::Incomplete(n) => ParseResult::Incomplete(n), } } #[cfg(test)] mod testing { use super::*; pub fn parse<O, P>(input: &str, parser: P) -> O where P: Fn(&[u8]) -> nom::IResult<&[u8]...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/rust-csp", "path": "/libsecsp/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn parse<O, P>(input: &str, parser: P) -> O where P: Fn(&[u8]) -> nom::IResult<&[u8], O>, { let bytes = input.as_bytes(); let result = parser(bytes); match result { IResult::Done(remaining, output) => output, IResult::Incomplete(e) =...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/rust-csp", "path": "/libsecsp/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fossabot/rust-csp path: /libsecsp/src/lib.rs //! This is the parsing backend library for the CSP language. //! //! The top level `parse` function can be used to parse a list of //! statements from an input source implementing `Read`. The parser combinators //! that this library is built on are ...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/rust-csp", "path": "/libsecsp/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zerovolts/rust-td path: /src/velocity.rs use amethyst::{ core::{math::Vector3, transform::Transform}, ecs::prelude::{Component, DenseVecStorage, Join, ReadStorage, System, WriteStorage}, }; #[derive(Component)] pub struct Velocity { pub vector: Vector3<f32>, } impl Velocity { p...
code_fim
medium
{ "lang": "rust", "repo": "zerovolts/rust-td", "path": "/src/velocity.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn run(&mut self, data: Self::SystemData) { let (mut transforms, velocities) = data; for (transform, velocity) in (&mut transforms, &velocities).join() { transform.append_translation(velocity.vector); } } }<|fim_prefix|>// repo: zerovolts/rust-td path: /src/vel...
code_fim
hard
{ "lang": "rust", "repo": "zerovolts/rust-td", "path": "/src/velocity.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Velocity { pub fn new(vector: Vector3<f32>) -> Self { Velocity { vector: vector } } } pub struct VelocitySystem; impl<'a> System<'a> for VelocitySystem { type SystemData = (WriteStorage<'a, Transform>, ReadStorage<'a, Velocity>); fn run(&mut self, data: Self::SystemData) { ...
code_fim
medium
{ "lang": "rust", "repo": "zerovolts/rust-td", "path": "/src/velocity.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }