text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>// misc recognize_tag!(sizeof, "sizeof", Token::SizeOf); /* the identifier can not be a reserved word */ named!(ident(CompleteStr) -> Token, do_parse!( peek!(alt!(nom::alpha | tag!("_"))) >> ident: verify!(take_while1!(|c: char| c.is_alphanumeric() || c == '_'), |s: CompleteStr| !is_keyword(&s)) ...
code_fim
hard
{ "lang": "rust", "repo": "aHeraud/cc", "path": "/lexer/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aHeraud/cc path: /lexer/src/lib.rs #[macro_use] extern crate nom; #[macro_use] extern crate lazy_static; use std::ffi::OsString; use std::collections::HashSet; use std::rc::Rc; use nom::types::CompleteStr; mod tokens; mod error; mod integer_literals; #[cfg(test)] mod tests; use self::intege...
code_fim
hard
{ "lang": "rust", "repo": "aHeraud/cc", "path": "/lexer/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>32 - 1i32 { k.offset( ((i >> 0i32 + 6i32 + 8i32 + 9i32 & !((!(0i32 as Instruction)) << 9i32) << 0i32) as lua_int & !(1i32 << 9i32 - 1i32))...
code_fim
hard
{ "lang": "rust", "repo": "yibit/lua-rs", "path": "/src/lvm.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yibit/lua-rs path: /src/lvm.rs ffset(::std::mem::size_of::<UTString>() as lua_ulong as isize), &mut v, ) == if (*((*obj).value_.gc as *mut GCUnion)).ts.tt as lua_int == 4i32 | 0i32 << 4i32 { (*((*obj).value_.gc as *mut GCUnion)).ts.shrlen as lua_ulong } el...
code_fim
hard
{ "lang": "rust", "repo": "yibit/lua-rs", "path": "/src/lvm.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> as lua_int - (*(*cl).p).numparams as lua_int - 1i32; /* less arguments than parameters? */ if n_0 < 0i32 { /* no vararg arguments */ n_0 = 0i32 ...
code_fim
hard
{ "lang": "rust", "repo": "yibit/lua-rs", "path": "/src/lvm.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> where D1: Data, D2: Data, L: FnMut(&S::Timestamp, D1) -> D2 + 'static, { self.inner .map_named(name, move |(data, time, diff)| { (logic(&time, data), time, diff) }) .as_collection() } #[inline] fn map_...
code_fim
hard
{ "lang": "rust", "repo": "therustmonk/ddshow", "path": "/src/dataflow/operators/map.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: therustmonk/ddshow path: /src/dataflow/operators/map.rs use differential_dataflow::{difference::Semigroup, AsCollection, Collection}; use timely::{ communication::message::RefOrMut, dataflow::{channels::pact::Pipeline, operators::Operator, Scope, Stream}, Data, }; pub trait MapExt<D...
code_fim
hard
{ "lang": "rust", "repo": "therustmonk/ddshow", "path": "/src/dataflow/operators/map.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<S, D> MapInPlace<D> for Stream<S, D> where S: Scope, D: Data, { type Output = Stream<S, D>; fn map_in_place_named<L>(&self, name: &str, mut logic: L) -> Self::Output where D: Data, L: FnMut(&mut D) + 'static, { let mut buffer = Vec::new(); sel...
code_fim
hard
{ "lang": "rust", "repo": "therustmonk/ddshow", "path": "/src/dataflow/operators/map.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut v = Vec::new(); for i in 0..10 { v.push(|| *x = String::new()); //~ ERROR } } fn main() {}<|fim_prefix|>// repo: unnsa/rust path: /src/test/ui/nll/closures-in-loops.rs // Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this ...
code_fim
hard
{ "lang": "rust", "repo": "unnsa/rust", "path": "/src/test/ui/nll/closures-in-loops.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: unnsa/rust path: /src/test/ui/nll/closures-in-loops.rs // Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // htt...
code_fim
medium
{ "lang": "rust", "repo": "unnsa/rust", "path": "/src/test/ui/nll/closures-in-loops.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let file_string = fs::read_to_string("data/input.txt").expect("Error reading input data"); let mut seat_ids: Vec<i32> = Vec::new(); for line in file_string.lines() { seat_ids.push(get_seat_id_from_sequence(line)); } let max = seat_ids.iter().max().unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "sarkahn/rust-aoc", "path": "/day5/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sarkahn/rust-aoc path: /day5/src/main.rs use std::fs; fn split_sequence(sequence: &str, mut low: i32, mut high: i32) -> i32 { for ch in sequence.chars() { split_value(ch, &mut low, &mut high); } low } fn split_value(split_type: char, low: &mut i32, high: &mut i32) { let...
code_fim
hard
{ "lang": "rust", "repo": "sarkahn/rust-aoc", "path": "/day5/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> seat_ids.sort(); for i in 0..seat_ids.len() - 1 { let curr = seat_ids[i]; let next = seat_ids[i + 1]; if curr + 1 != next { println!("Missing seat between {} and {}", curr, next); } } }<|fim_prefix|>// repo: sarkahn/rust-aoc path: /day5/src/main.rs...
code_fim
hard
{ "lang": "rust", "repo": "sarkahn/rust-aoc", "path": "/day5/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 22116/onset_detector path: /src/utils.rs use std::env; pub fn get_path() -> String<|fim_suffix|>expect("Path required") .clone(); }<|fim_middle|> { let args: Vec<String> = env::args().collect(); return args.get(1) .
code_fim
medium
{ "lang": "rust", "repo": "22116/onset_detector", "path": "/src/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>collect(); return args.get(1) .expect("Path required") .clone(); }<|fim_prefix|>// repo: 22116/onset_detector path: /src/utils.rs use std::env; pub fn get_path() -> String<|fim_middle|> { let args: Vec<String> = env::args().
code_fim
easy
{ "lang": "rust", "repo": "22116/onset_detector", "path": "/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/const-generics/min_const_generics/forbid-self-no-normalize.rs trait AlwaysApplicable { type Assoc; } impl<T: ?Sized> AlwaysApplicable for T { type Assoc = usize; } trait BindsParam<T> { type Array<|fim_suffix|> ArrayTy = [u8; Self::MAX]; //~ ERROR gene...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/const-generics/min_const_generics/forbid-self-no-normalize.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> ArrayTy = [u8; Self::MAX]; //~ ERROR generic `Self` types } fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/const-generics/min_const_generics/forbid-self-no-normalize.rs trait AlwaysApplicable { type Assoc; } impl<T: ?Sized> AlwaysApplicable for T { type Assoc = usize; } trai...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/const-generics/min_const_generics/forbid-self-no-normalize.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>Ty; } impl<T> BindsParam<T> for <T as AlwaysApplicable>::Assoc { type ArrayTy = [u8; Self::MAX]; //~ ERROR generic `Self` types } fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/const-generics/min_const_generics/forbid-self-no-normalize.rs trait AlwaysApplicable { type Assoc; }...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/const-generics/min_const_generics/forbid-self-no-normalize.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vedantroy/automerge-rs path: /automerge-frontend/src/state_tree/state_tree_change.rs use std::ops::{Add, AddAssign}; use automerge_protocol as amp; use super::{Cursors, StateTreeComposite}; #[derive(Clone)] pub struct StateTreeChange { objects: im_rc::HashMap<amp::ObjectId, StateTreeCompo...
code_fim
medium
{ "lang": "rust", "repo": "vedantroy/automerge-rs", "path": "/automerge-frontend/src/state_tree/state_tree_change.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub(super) fn new_cursors(&self) -> Cursors { self.new_cursors.clone() } } impl Add for &StateTreeChange { type Output = StateTreeChange; fn add(self, rhs: &StateTreeChange) -> Self::Output { StateTreeChange { objects: self.objects.clone().union(rhs.objects.cl...
code_fim
medium
{ "lang": "rust", "repo": "vedantroy/automerge-rs", "path": "/automerge-frontend/src/state_tree/state_tree_change.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn add(self, rhs: StateTreeChange) -> Self::Output { &self + &rhs } } impl AddAssign for StateTreeChange { fn add_assign(&mut self, rhs: StateTreeChange) { self.objects = self.objects.clone().union(rhs.objects); self.new_cursors = self.new_cursors.clone().union(rhs.new...
code_fim
hard
{ "lang": "rust", "repo": "vedantroy/automerge-rs", "path": "/automerge-frontend/src/state_tree/state_tree_change.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// KeyScope represents a restricted key scope from the primary root key within // the HD chain. From the root manager (m/) we can create a nearly arbitrary // number of ScopedKeyManagers of key derivation path: m/purpose'/cointype'. // These scoped managers can then me managed indecently, as they house th...
code_fim
hard
{ "lang": "rust", "repo": "alishahusain/lpd", "path": "/wallet/src/key_manager.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alishahusain/lpd path: /wallet/src/key_manager.rs use dependencies::bitcoin; use dependencies::secp256k1; use bitcoin::util::bip32::{ExtendedPrivKey, ChildNumber}; use bitcoin::network::constants::Network; use secp256k1::Secp256k1; use std::error::Error; use crate::scoped_manager::ScopedManag...
code_fim
hard
{ "lang": "rust", "repo": "alishahusain/lpd", "path": "/wallet/src/key_manager.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // TODO(evg): use another key derivation scheme? // pub fn derive_public_key_from_path(&self, key_scope: &KeyScope, derivation_path: &DerivationPath) -> Result<ExtendedPubKey, Box<Error>> { // let extended_priv_key = self.derive_private_key_from_path(key_scope, derivation_path)?; // O...
code_fim
hard
{ "lang": "rust", "repo": "alishahusain/lpd", "path": "/wallet/src/key_manager.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: evq/blue-pill path: /examples/spi2.rs //! Interfacing the MPU9250 using SPI2 #![deny(unsafe_code)] #![deny(warnings)] #![feature(proc_macro)] #![no_std] extern crate blue_pill; #[macro_use(iprint, iprintln)] extern crate cortex_m; extern crate cortex_m_rtfm as rtfm; use blue_pill::Spi; use bl...
code_fim
hard
{ "lang": "rust", "repo": "evq/blue-pill", "path": "/examples/spi2.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> while spi.send(JUNK).is_err() {} let ans = loop { if let Ok(byte) = spi.read() { break byte; } }; spi.disable(); iprintln!(&r.ITM.stim[0], "TESTING ..."); assert_eq!(ans, ANS); iprintln!(&r.ITM.stim[0], "OK"); // Sleep loop { rt...
code_fim
hard
{ "lang": "rust", "repo": "evq/blue-pill", "path": "/examples/spi2.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) async fn serve(app: ArcApp) -> anyhow::Result<()> { let _rocket = rocket::build() .manage(app) .mount("/", routes![state,]) .launch() .await?; Ok(()) }<|fim_prefix|>// repo: Phala-Network/phala-blockchain path: /standalone/phat-poller/src/web_api.rs use ...
code_fim
medium
{ "lang": "rust", "repo": "Phala-Network/phala-blockchain", "path": "/standalone/phat-poller/src/web_api.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Phala-Network/phala-blockchain path: /standalone/phat-poller/src/web_api.rs use crate::app::ArcApp; use rocket::{get, routes, State}; <|fim_suffix|>pub(crate) async fn serve(app: ArcApp) -> anyhow::Result<()> { let _rocket = rocket::build() .manage(app) .mount("/", routes![...
code_fim
medium
{ "lang": "rust", "repo": "Phala-Network/phala-blockchain", "path": "/standalone/phat-poller/src/web_api.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: frugalos/frugalos path: /frugalos_mds/src/error.rs use fibers::sync::oneshot::MonitorError; use libfrugalos::entity::object::ObjectVersion; use std::sync::mpsc::SendError; use std::{io, net, num, string}; use trackable::error::TrackableError; use trackable::error::{ErrorKind as TrackableErrorKin...
code_fim
hard
{ "lang": "rust", "repo": "frugalos/frugalos", "path": "/frugalos_mds/src/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> f.unwrap_or_else(|| { ErrorKind::Other .cause("Monitoring channel is disconnected") .into() }) } } impl<T> From<SendError<T>> for Error { fn from(_: SendError<T>) -> Self { ErrorKind::Other.cause("Channel disconnected").into() ...
code_fim
hard
{ "lang": "rust", "repo": "frugalos/frugalos", "path": "/frugalos_mds/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: romatthe/remoc path: /remoc/src/rch/interlock.rs /// Interlocks sender and receiver against both being sent. pub(crate) struct Interlock { pub sender: Location, pub receiver: Location, } <|fim_suffix|> // Start sending and return confirmation channel. pub fn start_send(&mut self)...
code_fim
hard
{ "lang": "rust", "repo": "romatthe/remoc", "path": "/remoc/src/rch/interlock.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Start sending and return confirmation channel. pub fn start_send(&mut self) -> tokio::sync::oneshot::Sender<()> { let (tx, rx) = tokio::sync::oneshot::channel(); *self = Self::Sending(rx); tx } }<|fim_prefix|>// repo: romatthe/remoc path: /remoc/src/rch/interlock.rs...
code_fim
hard
{ "lang": "rust", "repo": "romatthe/remoc", "path": "/remoc/src/rch/interlock.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> ret.insert(0, c); } return ret; }<|fim_prefix|>// repo: thebitfarm/Exercism path: /rust/reverse-string/src/lib.rs pub fn reverse(input: &str) -> String { let m<|fim_middle|>ut ret : String = String::new(); for c in input.chars() { println!("char is {}", c);
code_fim
medium
{ "lang": "rust", "repo": "thebitfarm/Exercism", "path": "/rust/reverse-string/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>put.chars() { println!("char is {}", c); ret.insert(0, c); } return ret; }<|fim_prefix|>// repo: thebitfarm/Exercism path: /rust/reverse-string/src/lib.rs pub fn reverse(input: &str) -> String { let m<|fim_middle|>ut ret : String = String::new(); for c in in
code_fim
easy
{ "lang": "rust", "repo": "thebitfarm/Exercism", "path": "/rust/reverse-string/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thebitfarm/Exercism path: /rust/reverse-string/src/lib.rs pub fn reverse(input: &str) -> String { let m<|fim_suffix|>put.chars() { println!("char is {}", c); ret.insert(0, c); } return ret; }<|fim_middle|>ut ret : String = String::new(); for c in in
code_fim
easy
{ "lang": "rust", "repo": "thebitfarm/Exercism", "path": "/rust/reverse-string/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // TODO: Possibly temporary pub value: String, } impl <T> Token<T> { pub fn shift(&mut self, offset: isize) { let start = self.range.start; let start = isize::try_from(start).unwrap() + offset; let start = usize::try_from(start).unwrap(); let end = self.range....
code_fim
hard
{ "lang": "rust", "repo": "LPeter1997/yoakke_rs", "path": "/yk_lexer/src/token.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LPeter1997/yoakke_rs path: /yk_lexer/src/token.rs /** * Token definition. */ use std::convert::TryFrom; use std::ops::Range; use crate::position::Position; use crate::lexer::{LexerState, StandardLexer}; /// A generic token that's being returned by the lexer. #[derive(Debug, Clone, PartialEq,...
code_fim
hard
{ "lang": "rust", "repo": "LPeter1997/yoakke_rs", "path": "/yk_lexer/src/token.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let end = self.range.end; let end = isize::try_from(end).unwrap() + offset; let end = usize::try_from(end).unwrap(); self.range.start = start; self.range.end = end; } } /// The type that the derive-macro implements on the user-defined enum. /// This is where t...
code_fim
hard
{ "lang": "rust", "repo": "LPeter1997/yoakke_rs", "path": "/yk_lexer/src/token.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[allow(clippy::needless_range_loop)] //Start check within a square box around the player for row in if player_pos_p.row >= view_distance { player_pos_p.row - view_distance } else { 0 }..=(player_pos_p.row + view_distance) { ...
code_fim
hard
{ "lang": "rust", "repo": "jotingen/rust-dungeoncrawler", "path": "/src/levels/level/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jotingen/rust-dungeoncrawler path: /src/levels/level/mod.rs mod generation; use crate::levels::level::generation::*; use crate::utils::*; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] enum TileType { Floor, Wall, StairDown, Stai...
code_fim
hard
{ "lang": "rust", "repo": "jotingen/rust-dungeoncrawler", "path": "/src/levels/level/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-25746-bool-transmute.rs // run-pass use std::mem::transmute; <|fim_suffix|> unsafe { let _: i8 = transmute(false); let _: i8 = transmute(true); let _: bool = transmute(0u8); let _: bool = transmut...
code_fim
easy
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/issues/issue-25746-bool-transmute.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { let _: i8 = transmute(false); let _: i8 = transmute(true); let _: bool = transmute(0u8); let _: bool = transmute(1u8); } }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-25746-bool-transmute.rs // run-pass use std::me...
code_fim
easy
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/issues/issue-25746-bool-transmute.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match fn { type_ => || ffi::gtk_list_base_get_type(), } } impl ListBase { pub const NONE: Option<&'static ListBase> = None; } impl fmt::Display for ListBase { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("ListBase") } }<|fim_prefix|>// repo: zeca...
code_fim
hard
{ "lang": "rust", "repo": "zecakeh/gtk4-rs", "path": "/gtk4/src/auto/list_base.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zecakeh/gtk4-rs path: /gtk4/src/auto/list_base.rs // This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT <|fim_suffix|>glib::wrapper! { #[doc(alias = "GtkListBase")] pub struct ListBase(Object<ffi::GtkList...
code_fim
medium
{ "lang": "rust", "repo": "zecakeh/gtk4-rs", "path": "/gtk4/src/auto/list_base.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mverleg/atadb path: /src/librarian/control/operation.rs /// The request type is important for the type of lock. #[derive(Debug, Serialize, Deserialize)] pub enum Operation { DDL, // Locks schema and data Modify, // Locks data for writing (no readers allowed) Read, // Doesn't loc...
code_fim
hard
{ "lang": "rust", "repo": "mverleg/atadb", "path": "/src/librarian/control/operation.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize)] pub struct SelectOperation {}<|fim_prefix|>// repo: mverleg/atadb path: /src/librarian/control/operation.rs /// The request type is important for the type of lock. #[derive(Debug, Serialize, Deserialize)] pub enum Operation { DDL, // Locks schema and data ...
code_fim
medium
{ "lang": "rust", "repo": "mverleg/atadb", "path": "/src/librarian/control/operation.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match self { $( #[allow(unused_doc_comments)] $( #[$meta] )* Self::$body(x) => $crate::space_elements_internal!(@call is_in_input_region; x, point) ),*, ...
code_fim
hard
{ "lang": "rust", "repo": "Smithay/smithay", "path": "/src/desktop/space/element/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Smithay/smithay path: /src/desktop/space/element/mod.rs -> bool; /// Gets the z-index of this element fn z_index(&self) -> u8 { RenderZindex::Overlay as u8 } /// Set the rendered state to activated, if applicable to this element fn set_activate(&self, activated: boo...
code_fim
hard
{ "lang": "rust", "repo": "Smithay/smithay", "path": "/src/desktop/space/element/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn day8_test1() { let test = "b inc 5 if a > 1 a inc 1 if b < 5 c dec -10 if a >= 1 c inc -20 if c == 10"; assert_eq!("1", Day8.solve_a(test)); assert_eq!("10", Day8.solve_b(test)); } }<|fim_prefix|>// repo: Shnitz/aoc path: /src/days/day8.rs use aoc::*; use da...
code_fim
hard
{ "lang": "rust", "repo": "Shnitz/aoc", "path": "/src/days/day8.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Shnitz/aoc path: /src/days/day8.rs use aoc::*; use days::ChristmasDay; use std::collections::HashMap; pub struct Day8; impl ChristmasDay for Day8 { fn solve(&self, data: &str, prob: ProblemPart) -> String { let mut registers: HashMap<&str, i32> = HashMap::new(); let mut max...
code_fim
hard
{ "lang": "rust", "repo": "Shnitz/aoc", "path": "/src/days/day8.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } } #[cfg(test)] mod test { use super::*; #[test] fn day8_test1() { let test = "b inc 5 if a > 1 a inc 1 if b < 5 c dec -10 if a >= 1 c inc -20 if c == 10"; assert_eq!("1", Day8.solve_a(test)); assert_eq!("10", Day8.solve_b(test)); } }<|fim_prefix|>// repo: Sh...
code_fim
hard
{ "lang": "rust", "repo": "Shnitz/aoc", "path": "/src/days/day8.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xfoxfu/SYSU-Homework path: /DCS216/fatpart/src/struct/fat_table.rs use super::FAT16BPB; use crate::read_u16_le; use core::ops::Range; pub struct FAT16Table<'a> { data: &'a [u8], bpb: &'a FAT16BPB, } <|fim_suffix|> /// 获取第 id 个 FAT 表项对应的扇区范围 pub fn cluster_sector(&self, id: u16) ...
code_fim
hard
{ "lang": "rust", "repo": "xfoxfu/SYSU-Homework", "path": "/DCS216/fatpart/src/struct/fat_table.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// 获取第 id 个 FAT 表项的下一个 FAT 表项 pub fn next_cluster(&self, id: u16) -> Option<u16> { let raw = read_u16_le(self.data, 2 * id as usize); if raw > 0x0001 && raw < 0xFFF0 { Some(raw) } else { None } } }<|fim_prefix|>// repo: xfoxfu/SYSU-Homew...
code_fim
hard
{ "lang": "rust", "repo": "xfoxfu/SYSU-Homework", "path": "/DCS216/fatpart/src/struct/fat_table.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn transferring_amount_more_than_available_balance_should_not_work() { new_test_ext().execute_with(|| { assert_ok!(Assets::issue(Origin::signed(1), 100)); assert_eq!(Assets::balance(0, 1), 100); assert_ok!(Assets::transfer(Origin::signed(1), 0, 2, 50)); assert_eq!(Assets::balance(0...
code_fim
hard
{ "lang": "rust", "repo": "IPSE-TEAM/ipse-core", "path": "/frame/assets/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>decl_storage! { trait Store for Module<T: Trait> as Assets { /// The number of units of assets held by any given account. Balances: map hasher(blake2_128_concat) (T::AssetId, T::AccountId) => T::Balance; /// The next asset identifier up for grabs. NextAssetId get(fn next_asset_id): T::AssetId; ...
code_fim
hard
{ "lang": "rust", "repo": "IPSE-TEAM/ipse-core", "path": "/frame/assets/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IPSE-TEAM/ipse-core path: /frame/assets/src/lib.rs // This file is part of Substrate. // Copyright (C) 2017-2020 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compli...
code_fim
hard
{ "lang": "rust", "repo": "IPSE-TEAM/ipse-core", "path": "/frame/assets/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BuggStream/crustatious path: /src/tron.rs use std::convert::{TryFrom, TryInto}; use std::fmt::{Formatter, Display}; use std::error::Error; #[derive(Debug)] pub struct GameConfiguration { pub player_id: char, pub field_width: u32, pub field_height: u32, } impl TryFrom<&str> for Game...
code_fim
hard
{ "lang": "rust", "repo": "BuggStream/crustatious", "path": "/src/tron.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Display for Orientation { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { Orientation::North => write!(f, "north"), Orientation::East => write!(f, "east"), Orientation::South => write!(f, "south"), Orientation::West =...
code_fim
hard
{ "lang": "rust", "repo": "BuggStream/crustatious", "path": "/src/tron.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub enum Orientation { North, East, South, West, } impl Display for Orientation { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { Orientation::North => write!(f, "north"), Orientation::East => write!(f, "east"), ...
code_fim
hard
{ "lang": "rust", "repo": "BuggStream/crustatious", "path": "/src/tron.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> debug_assert!(self.tables.is_empty()); self.tables.reserve_exact(module.tables.len()); for table in &module.tables { let len = table.size; let mut v = Vec::with_capacity(len); v.resize(len, 0); self.tables.push(v); } f...
code_fim
hard
{ "lang": "rust", "repo": "pepyakin/wasmtime", "path": "/lib/execute/src/instance.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pepyakin/wasmtime path: /lib/execute/src/instance.rs //! An `Instance` contains all the runtime state used by execution of a wasm //! module. use cranelift_codegen::ir; use cranelift_wasm::GlobalIndex; use wasmtime_environ::{DataInitializer, Module, TableElements}; const PAGE_SIZE: usize = 655...
code_fim
hard
{ "lang": "rust", "repo": "pepyakin/wasmtime", "path": "/lib/execute/src/instance.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Allocate memory in `instance` for just the memories of the current module. fn instantiate_memories(&mut self, module: &Module, data_initializers: &[DataInitializer]) { debug_assert!(self.memories.is_empty()); // Allocate the underlying memory and initialize it to all zeros. ...
code_fim
hard
{ "lang": "rust", "repo": "pepyakin/wasmtime", "path": "/lib/execute/src/instance.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eminence/sc2rs path: /build.rs extern crate protoc_rust; use std::fs::{File, read_dir}; use std::io::{Read, Write}; fn main() { println!("cargo:rerun-if-changed=s2client-proto/s2clientprotocol/"); for entry in read_dir("s2client-proto/s2clientprotocol").unwrap() { let entry = e...
code_fim
medium
{ "lang": "rust", "repo": "eminence/sc2rs", "path": "/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let s = { let mut raw = File::open("sc2-protobuf/src/protos/raw.rs").unwrap(); let mut s = String::new(); raw.read_to_string(&mut s).unwrap(); s }; let mut raw = File::create("sc2-protobuf/src/protos/raw.rs").unwrap(); raw.write_all(s.as_bytes()).unwrap(); ...
code_fim
medium
{ "lang": "rust", "repo": "eminence/sc2rs", "path": "/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<TSpec: EthSpec> std::convert::From<Response<TSpec>> for RPCCodedResponse<TSpec> { fn from(resp: Response<TSpec>) -> RPCCodedResponse<TSpec> { match resp { Response::BlocksByRoot(r) => match r { Some(b) => RPCCodedResponse::Success(RPCResponse::BlocksByRoot(b)),...
code_fim
hard
{ "lang": "rust", "repo": "sigp/lighthouse", "path": "/beacon_node/lighthouse_network/src/service/api_types.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match resp { Response::BlocksByRoot(r) => match r { Some(b) => RPCCodedResponse::Success(RPCResponse::BlocksByRoot(b)), None => RPCCodedResponse::StreamTermination(ResponseTermination::BlocksByRoot), }, Response::BlocksByRange(r) ...
code_fim
hard
{ "lang": "rust", "repo": "sigp/lighthouse", "path": "/beacon_node/lighthouse_network/src/service/api_types.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sigp/lighthouse path: /beacon_node/lighthouse_network/src/service/api_types.rs use std::sync::Arc; use libp2p::swarm::ConnectionId; use types::light_client_bootstrap::LightClientBootstrap; use types::{EthSpec, SignedBeaconBlock}; use crate::rpc::{ methods::{ BlocksByRangeRequest, B...
code_fim
hard
{ "lang": "rust", "repo": "sigp/lighthouse", "path": "/beacon_node/lighthouse_network/src/service/api_types.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: Clone> Clone for MatchingPair<T> { fn clone(&self) -> Self { MatchingPair::new(self.first.clone(), self.second.clone()) } } fn main() { let ps_in_a_pod: MatchingPair<char> = MatchingPair::new('p', 'P'); println!("two ps in a pod: {}", ps_in_a_pod); let my_some_five: M...
code_fim
medium
{ "lang": "rust", "repo": "Schenk75/CS110L-code", "path": "/lecture-5/generics/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Schenk75/CS110L-code path: /lecture-5/generics/src/main.rs use std::fmt; pub struct MatchingPair<T> { first: T, second: T, } pub enum MyOption<T> { Sumthin(T), Nuthin } // impl fmt::Display for MyOption<u32> { // fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // ...
code_fim
hard
{ "lang": "rust", "repo": "Schenk75/CS110L-code", "path": "/lecture-5/generics/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn run() { let limit = 100000000; let mut sum = 1; // 1 is valid so including it in the sum for i in (2..=limit).step_by(2) { if check_divisors(i) { sum += i; } } println!("Result: {}", sum); }<|fim_prefix|>// repo: david-sk/projecteuler path: /src/prob...
code_fim
medium
{ "lang": "rust", "repo": "david-sk/projecteuler", "path": "/src/problems/0357_prime_generating_integers/v1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: david-sk/projecteuler path: /src/problems/0357_prime_generating_integers/v1.rs // // Prime generating integers, v1 // https://projecteuler.net/problem=357 // // Consider the divisors of 30: 1,2,3,5,6,10,15,30. // It can be seen that for every divisor d of 30, d+30/d is prime. // Find the sum of ...
code_fim
hard
{ "lang": "rust", "repo": "david-sk/projecteuler", "path": "/src/problems/0357_prime_generating_integers/v1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: swatteau/tmx path: /src/model/property.rs // This file is part of tmx // Copyright 2017 Sébastien Watteau // // 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 // // ...
code_fim
hard
{ "lang": "rust", "repo": "swatteau/tmx", "path": "/src/model/property.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match name { "name" => { property.set_name(value); } "type" => { property.set_property_type(PropertyType::from_str(value)?); } "value" => { property.set_value(value); } ...
code_fim
hard
{ "lang": "rust", "repo": "swatteau/tmx", "path": "/src/model/property.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yueyuanwendy/differential-dataflow path: /src/trace/implementations/batcher_merge.rs //! A general purpose `Batcher` implementation based on radix sort. use timely::progress::frontier::Antichain; use timely_sort::{MSBRadixSorter, RadixSorterBase}; use ::Diff; use hashable::Hashable; use latti...
code_fim
hard
{ "lang": "rust", "repo": "yueyuanwendy/differential-dataflow", "path": "/src/trace/implementations/batcher_merge.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // TODO: make this `clear()` when that lands. self.frontier = Antichain::new(); self.compact(); if let Some(batch) = self.sorted.take() { let mut cursor = batch.cursor(); while cursor.key_valid() { let key: K = cursor.key().clone();...
code_fim
hard
{ "lang": "rust", "repo": "yueyuanwendy/differential-dataflow", "path": "/src/trace/implementations/batcher_merge.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> builder.body(data.into()).map_err(anyhow::Error::from) } pub fn scale_cover(path: impl AsRef<Path> + std::fmt::Debug) -> Result<Vec<u8>> { use image::imageops::FilterType; let img = if is_audio(&path) { let data = extract_cover(&path) .ok_or_else(|| anyhow::Error::msg("Cov...
code_fim
hard
{ "lang": "rust", "repo": "izderadicka/audioserve", "path": "/src/services/icon/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn scale_cover(path: impl AsRef<Path> + std::fmt::Debug) -> Result<Vec<u8>> { use image::imageops::FilterType; let img = if is_audio(&path) { let data = extract_cover(&path) .ok_or_else(|| anyhow::Error::msg("Cover is missing, but is expected"))?; ImageReader::new(C...
code_fim
hard
{ "lang": "rust", "repo": "izderadicka/audioserve", "path": "/src/services/icon/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: izderadicka/audioserve path: /src/services/icon/mod.rs use anyhow::Result; use collection::{audio_meta::is_audio, extract_cover}; use headers::{ContentLength, ContentType}; use hyper::{Body, Response}; use image::io::Reader as ImageReader; use image::ImageOutputFormat; use simple_file_cache::Fil...
code_fim
hard
{ "lang": "rust", "repo": "izderadicka/audioserve", "path": "/src/services/icon/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: benpope82/led path: /src/editor/mod.rs line_ending_histogram[3] += 1; } LineEnding::CR => { line_ending_histogram[4] += 1; } LineEnding::NEL => { line_ending_histogram[5] += 1; ...
code_fim
hard
{ "lang": "rust", "repo": "benpope82/led", "path": "/src/editor/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.dirty = true; self.cursors.make_consistent(); } } pub fn redo(&mut self) { // TODO: handle multiple cursors properly if let Some(pos) = self.buffer.redo() { self.cursors.truncate(1); self.cursors[0].range.0 = pos; ...
code_fim
hard
{ "lang": "rust", "repo": "benpope82/led", "path": "/src/editor/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Adjust view self.move_view_to_cursor(); } pub fn cursor_up(&mut self, n: usize) { for c in self.cursors.iter_mut() { let vmove = -1 * (n * self.formatter.single_line_height()) as isize; let mut temp_index = self.formatter.index_offset_vertical_v...
code_fim
hard
{ "lang": "rust", "repo": "benpope82/led", "path": "/src/editor/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pklazy/lpc54628-rust path: /src/sct0.rs #[doc = "0x118 - SCT capture register of capture channel"] #[inline(always)] pub fn sctcap6(&self) -> &SCTCAP6 { unsafe { &*(((self as *const Self) as *const u8).add(280usize) as *const SCTCAP6) } } #[doc = "0x118 - SCT capture re...
code_fim
hard
{ "lang": "rust", "repo": "pklazy/lpc54628-rust", "path": "/src/sct0.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>gister of match channels"] pub struct SCTMATCH0 { register: vcell::VolatileCell<u32>, } #[doc = "SCT match value register of match channels"] pub mod sctmatch0; #[doc = "SCT capture register of capture channel"] pub struct SCTCAP1 { register: vcell::VolatileCell<u32>, } #[doc = "SCT capture regist...
code_fim
hard
{ "lang": "rust", "repo": "pklazy/lpc54628-rust", "path": "/src/sct0.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pklazy/lpc54628-rust path: /src/sct0.rs #[doc = "0xf0 - SCT event interrupt enable register"] pub even: EVEN, #[doc = "0xf4 - SCT event flag register"] pub evflag: EVFLAG, #[doc = "0xf8 - SCT conflict interrupt enable register"] pub conen: CONEN, #[doc = "0xfc - SCT conf...
code_fim
hard
{ "lang": "rust", "repo": "pklazy/lpc54628-rust", "path": "/src/sct0.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maidsafe/sn-testnet-deploy path: /src/tests/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 super::*; use crate::s3::MockS3RepositoryInterface; use...
code_fim
hard
{ "lang": "rust", "repo": "maidsafe/sn-testnet-deploy", "path": "/src/tests/setup.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub fn setup_default_s3_repository( env_name: &str, working_dir: &ChildPath, ) -> Result<MockS3RepositoryInterface> { let saved_archive_path = working_dir .to_path_buf() .join("rpc_client-latest-x86_64-unknown-linux-musl.tar.gz"); let rpc_client_archive_path = create_fake_r...
code_fim
hard
{ "lang": "rust", "repo": "maidsafe/sn-testnet-deploy", "path": "/src/tests/setup.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let mut fake_rpc_client_bin_file = File::open(fake_rpc_client_bin.path())?; let gz_encoder = GzEncoder::new( File::create(rpc_client_archive.path())?, Compression::default(), ); let mut builder = tar::Builder::new(gz_encoder); builder.append_file(RPC_CLIENT_BIN_NAME, &m...
code_fim
hard
{ "lang": "rust", "repo": "maidsafe/sn-testnet-deploy", "path": "/src/tests/setup.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_initialize() { let fee_numerator = 1; let fee_denominator = 2; let token_a_amount = 1000; let token_b_amount = 2000; let swap_accounts = initialize_swap( fee_numerator, fee_denominator, token_a_amount, ...
code_fim
hard
{ "lang": "rust", "repo": "dmelosantos/solana-program-library", "path": "/token-swap/program/src/processor.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dmelosantos/solana-program-library path: /token-swap/program/src/processor.rs decode_error::DecodeError, entrypoint::ProgramResult, info, program_error::PrintProgramError, program_error::ProgramError, pubkey::Pubkey, }; use spl_token::pack::Pack; // Test program id for the...
code_fim
hard
{ "lang": "rust", "repo": "dmelosantos/solana-program-library", "path": "/token-swap/program/src/processor.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let resp = self.get_response_from_api(api_endpoint, method, query_params)?; if resp.status_code != 200 { return Err(DockerApiError::InvalidApiResponseError( resp.status_code, resp.body, )); } let images_in...
code_fim
hard
{ "lang": "rust", "repo": "MaloPolese/docker.rs", "path": "/src/api/images.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MaloPolese/docker.rs path: /src/api/images.rs #![allow(non_snake_case)] use std::collections::HashMap; use api::DockerApiClient; use utils; use serde_json; use errors::DockerApiError; #[derive(Serialize, Deserialize, Debug)] pub struct ImageCompactInfo { pub Id: String, pub ParentId...
code_fim
hard
{ "lang": "rust", "repo": "MaloPolese/docker.rs", "path": "/src/api/images.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(output) = &self.output { let mut file = OpenOptions::new() .write(true) .create(true) .truncate(true) .open(output) .context("Failed to open output file")?; serde_json::to_writer_pre...
code_fim
hard
{ "lang": "rust", "repo": "nyantec/udp-benchmark", "path": "/client/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nyantec/udp-benchmark path: /client/src/lib.rs mod results; use std::sync::atomic::AtomicBool; use crate::results::{JsonResultState, JsonResults, Results}; use anyhow::{bail, Context, Result}; use async_std::io; use async_std::net::{ Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddr...
code_fim
hard
{ "lang": "rust", "repo": "nyantec/udp-benchmark", "path": "/client/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dtynn/wal-rs path: /src/lib.rs //! This crate is implementation of an on-disk write-ahead-log //! #![warn(missing_docs)] <|fim_suffix|>mod config; mod fileext; mod segment; mod wal; #[cfg(test)] mod mock; pub use config::Config; pub use wal::WAL;<|fim_middle|>extern crate byteorder; extern c...
code_fim
medium
{ "lang": "rust", "repo": "dtynn/wal-rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod mock; pub use config::Config; pub use wal::WAL;<|fim_prefix|>// repo: dtynn/wal-rs path: /src/lib.rs //! This crate is implementation of an on-disk write-ahead-log //! #![warn(missing_docs)] <|fim_middle|>extern crate byteorder; extern crate crc; extern crate fs2; extern crate hex; #...
code_fim
medium
{ "lang": "rust", "repo": "dtynn/wal-rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leviathanbeak/stock_ticker_service path: /stock/src/lib.rs use rand::{self, prelude::ThreadRng, Rng}; use std::collections::HashMap; use utils::{get_trend, moving_average}; mod utils; use serde::{Deserialize, Serialize}; const STOCKS: [&'static str; 6] = ["GOOG", "APPL", "TSLA", "AMZN", "MSFT",...
code_fim
hard
{ "lang": "rust", "repo": "leviathanbeak/stock_ticker_service", "path": "/stock/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(current_price) = self.highest.get(stock) { match current_price { Some(v) => { if price > *v { self.highest.insert(stock, Some(price)); } } None => { ...
code_fim
hard
{ "lang": "rust", "repo": "leviathanbeak/stock_ticker_service", "path": "/stock/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns this descriptor's integer value. #[inline] pub const fn into_int(self) -> u32 { self.0 } /// Returns this descriptor's 4-character code. #[inline] pub const fn into_chars(self) -> [u8; 4] { self.0.to_be_bytes() } /// Returns `true` if all o...
code_fim
hard
{ "lang": "rust", "repo": "bbqsrc/fruity", "path": "/src/core/four_char_code.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bbqsrc/fruity path: /src/core/four_char_code.rs use std::{ ascii, fmt::{self, Write}, }; /// A four-character code. /// /// The characters are stored in big-endian byte order. /// /// See [documentation](https://developer.apple.com/documentation/kernel/fourcharcode?language=objc). /// /...
code_fim
hard
{ "lang": "rust", "repo": "bbqsrc/fruity", "path": "/src/core/four_char_code.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> write!(f, "\"") } } impl FourCharCode { /// Returns an instance from the integer value. #[inline] pub const fn from_int(int: u32) -> Self { Self(int) } /// Returns an instance from the 4-character code. #[inline] pub const fn from_chars(chars: [u8; 4]) -> ...
code_fim
hard
{ "lang": "rust", "repo": "bbqsrc/fruity", "path": "/src/core/four_char_code.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }