text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> while !q.is_empty() { let current = q.pop_front().unwrap(); let current_dist = dist[&current]; for n in current.adjacent() { let mut entry = dist.entry(n.clone()).or_insert(::std::usize::MAX); if *entry > current_dist...
code_fim
hard
{ "lang": "rust", "repo": "lux01/advent-of-code-2016", "path": "/day_11_rust/src/graph.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pf)?; ppf.write(" default ")?; b.fmt(ppf) } SpanExpr::Unwrap(a, b, e, next) => { ppf.write("unwrap ")?; e.fmt(ppf)?; ppf.write(" into ")?; match a { Some(a) => ppf.write(ppf.context().id().var_ident(*a).as_str())?, None => ppf.write("_")? }...
code_fim
hard
{ "lang": "rust", "repo": "chom-parser/ir", "path": "/src/pretty_print/expr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chom-parser/ir path: /src/pretty_print/expr.rs use std::fmt; use crate::{ Namespace, Expr, expr::{ LexerExpr, StreamExpr, StackExpr, SpanExpr, Error }, ty }; use super::{ PrettyPrint, PrettyPrinter }; impl<T: Namespace> PrettyPrint<T> for Expr<T> { fn fmt(&self, ppf: &mut Pret...
code_fim
hard
{ "lang": "rust", "repo": "chom-parser/ir", "path": "/src/pretty_print/expr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wbprice/the-ten-top path: /src/components/plate.rs use amethyst::ecs::prelude::{Component, DenseVecStorage}; <|fim_suffix|>impl Component for Plate { type Storage = DenseVecStorage<Self>; }<|fim_middle|>use crate::{components::Ingredient, resources::Dishes}; #[derive(Debug)] pub struct Pla...
code_fim
hard
{ "lang": "rust", "repo": "wbprice/the-ten-top", "path": "/src/components/plate.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Component for Plate { type Storage = DenseVecStorage<Self>; }<|fim_prefix|>// repo: wbprice/the-ten-top path: /src/components/plate.rs use amethyst::ecs::prelude::{Component, DenseVecStorage}; use crate::{components::Ingredient, resources::Dishes}; <|fim_middle|>#[derive(Debug)] pub struct Pla...
code_fim
hard
{ "lang": "rust", "repo": "wbprice/the-ten-top", "path": "/src/components/plate.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn build_string_index_table(&self) -> Result<(Vec<RowPairString>), IndexError> { let mut index_arr = vec![]; let mut row = 0; let table_meta = &self.table_meta; let bytes_to_slide = table_meta.row_bytes - table_meta.key_bytes; let table_name = table_meta.table_n...
code_fim
hard
{ "lang": "rust", "repo": "Dong513/StellarSQL", "path": "/src/storage/index.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Dong513/StellarSQL path: /src/storage/index.rs use std::fmt; use std::fs::File; use std::io::prelude::*; use std::io::Seek; use std::io::SeekFrom; use std::mem; #[derive(Debug)] pub enum IndexError { OpenFileError, CreateFileError, BuildIntIndexTableError, ReadIntIndexTableError...
code_fim
hard
{ "lang": "rust", "repo": "Dong513/StellarSQL", "path": "/src/storage/index.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cojna/contest path: /atcoder/codefes/2016/final/b.rs #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; fn main(){ let n = readln(); let mut a: Vec<usize> = vec![0;max(10,n)+1]; let mut acc = 0; let mut x = 0; let mut i = 1; while...
code_fim
hard
{ "lang": "rust", "repo": "cojna/contest", "path": "/atcoder/codefes/2016/final/b.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sstadick/gzp path: /src/bgzf.rs //! Bgzf format base implementation. //! //! Bgzf is a multi-gzip format that adds an extra field to the header indicating how large the //! complete block (with header and footer) is. use std::io::Write; use std::io::{self, Read}; use byteorder::{LittleEndian, ...
code_fim
hard
{ "lang": "rust", "repo": "sstadick/gzp", "path": "/src/bgzf.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> if footer_vals.amount != 0 { let _bytes_decompressed = decoder.decompress( &input[..input.len() - 8], output, flate2::FlushDecompress::Finish, )?; decoder.reset(false); } let mut new_check = flate2::Crc::new(); new_check.update(ou...
code_fim
hard
{ "lang": "rust", "repo": "sstadick/gzp", "path": "/src/bgzf.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ilaborie/grass path: /src/atrule/media.rs #![allow(dead_code)] use std::fmt; use crate::{parse::Stmt, selector::Selector}; #[derive(Debug, Clone)] pub(crate) struct MediaRule { pub super_selector: Selector, pub query: String, pub body: Vec<Stmt>, } #[derive(Clone, Debug, Eq, Parti...
code_fim
hard
{ "lang": "rust", "repo": "ilaborie/grass", "path": "/src/atrule/media.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn condition(features: Vec<String>) -> Self { Self { modifier: None, media_type: None, features, } } #[allow(clippy::if_not_else)] fn merge(&self, other: &Self) -> MediaQueryMergeResult { let this_modifier = self.modifier.as_...
code_fim
hard
{ "lang": "rust", "repo": "ilaborie/grass", "path": "/src/atrule/media.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use crate::version::VersionMatcher; let matcher = VersionMatcher::new("1.2.%d"); let latest_version = matcher.match_version(s!("1.2.3")).unwrap(); let version = build_version( VersionRequest::Custom(s!("4.5.3")), "abc123".to_string(), &latest_version, ); a...
code_fim
hard
{ "lang": "rust", "repo": "ethankhall/crom", "path": "/src/commands/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ethankhall/crom path: /src/commands/mod.rs use crate::git_repo; use async_trait::async_trait; use error_chain::bail; use log::{debug, error}; use std::path::PathBuf; mod get; mod init; mod utils; mod write; use crate::cli::VersionRequest; use crate::errors::ErrorKind; use crate::models::CromCo...
code_fim
hard
{ "lang": "rust", "repo": "ethankhall/crom", "path": "/src/commands/mod.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let signal = generate_input(); c.bench_function("estimate_pitch_imperative", |b| b.iter(|| imp::Bitstream::estimate_pitch(black_box(&signal)))); c.bench_function("estimate_pitch_declarative", |b| b.iter(|| decl::Bitstream::estimate_pitch(black_box(&signal)))); } criterion_group!(benches, crit...
code_fim
medium
{ "lang": "rust", "repo": "davlum/cli-tuner", "path": "/benches/bench.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: davlum/cli-tuner path: /benches/bench.rs use criterion::{black_box, criterion_group, criterion_main, Criterion}; use std::f32::consts::PI; use clituner::bac::imp; use clituner::bac::decl; use clituner::bac::conf; const FREQ: f32 = 261.626; const PERIOD: f32 = conf::CONFIG.samples_per_second as ...
code_fim
medium
{ "lang": "rust", "repo": "davlum/cli-tuner", "path": "/benches/bench.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CyberCat3/CahnLang path: /src/utils/mod.rs mod byte_buffer_reader; use {ahash::AHasher, std::hash::Hasher}; <|fim_suffix|>pub fn hash_string(string: &str) -> u64 { let mut hasher = AHasher::default(); hasher.write(string.as_bytes()); hasher.finish() }<|fim_middle|>pub use byte_buff...
code_fim
easy
{ "lang": "rust", "repo": "CyberCat3/CahnLang", "path": "/src/utils/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn hash_string(string: &str) -> u64 { let mut hasher = AHasher::default(); hasher.write(string.as_bytes()); hasher.finish() }<|fim_prefix|>// repo: CyberCat3/CahnLang path: /src/utils/mod.rs mod byte_buffer_reader; use {ahash::AHasher, std::hash::Hasher}; <|fim_middle|>pub use byte_buff...
code_fim
easy
{ "lang": "rust", "repo": "CyberCat3/CahnLang", "path": "/src/utils/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub async fn start(&self) { let rx = self.rx.clone(); let _bus_handle = self.bus_handle.clone(); // let conf = crate::conf::get_conf_struct(&mut bus_handle).await.unwrap(); while let Some(msg) = rx.lock().await.recv().await { // Listen for updates from...
code_fim
hard
{ "lang": "rust", "repo": "bexars/dtn-rust", "path": "/src/processor.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } /// Processes inbound bundles. It's Ellis Island pub async fn process_inbound(&self, mut metabun: MetaBundle) { let config = crate::conf::CONFIGURATION.load(); // Process flags // TODO remove the hardcode EID // Add hopcount block if needed ...
code_fim
hard
{ "lang": "rust", "repo": "bexars/dtn-rust", "path": "/src/processor.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bexars/dtn-rust path: /src/processor.rs use log::*; use bp7::Bundle; use crate::cla::cla_handle::{HandleId}; use crate::bus::ModuleMsgEnum; use crate::system::{ SystemModules, BusHandle }; use tokio::sync::mpsc::*; use tokio::sync::{Mutex, RwLock}; use std::sync::{Arc}; use msgbus::{MsgBusHandle...
code_fim
hard
{ "lang": "rust", "repo": "bexars/dtn-rust", "path": "/src/processor.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: greenfork/project_euler path: /challenge_004/src/main.rs use std::io; fn main() { let mut queries = String::new(); io::stdin().read_line(&mut queries).unwrap(); let queries: usize = queries.trim_right().parse().unwrap(); <|fim_suffix|> if pre_palindrome * 11 < number...
code_fim
hard
{ "lang": "rust", "repo": "greenfork/project_euler", "path": "/challenge_004/src/main.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> for i in (100..1000).rev() { if number % i == 0 && (number * 11 / i).to_string().len() == 3 { return true; } } false }<|fim_prefix|>// repo: greenfork/project_euler path: /challenge_004/src/main.rs use std::io; fn main() { let mut queries = String::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "greenfork/project_euler", "path": "/challenge_004/src/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brl/pH path: /src/devices/mod.rs pub mod ac97; pub mod serial; pub mod rtc; mod virtio_9p; mod virtio_serial; mod virtio_rng; mod virtio_wl;<|fim_suffix|>virtio_9p::VirtioP9; pub use self::virtio_9p::SyntheticFS; pub use self::virtio_rng::VirtioRandom; pub use self::virtio_wl::VirtioWayland; pub...
code_fim
medium
{ "lang": "rust", "repo": "brl/pH", "path": "/src/devices/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>elf::virtio_wl::VirtioWayland; pub use self::virtio_block::VirtioBlock; pub use self::virtio_net::VirtioNet;<|fim_prefix|>// repo: brl/pH path: /src/devices/mod.rs pub mod ac97; pub mod serial; pub mod rtc; mod virtio_9p; mod virtio_serial; mod virtio_rng; mod virtio_wl; mod virtio_block; mod virtio_net;...
code_fim
medium
{ "lang": "rust", "repo": "brl/pH", "path": "/src/devices/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub type BoxedTuple = Box<(Box<A>, Box<B>)>;<|fim_prefix|>// repo: facebook/hhvm path: /hphp/hack/test/rust_to_ocaml/pointers.rs pub type BoxA = Box<A>; pub type RcA = Rc<A>; pub type ArcA = Arc<A>; pub type RcOcA = Arc<A>; <|fim_middle|>pub type StdBoxA = std::boxed::Box<A>; pub type StdRcA = std::rc::...
code_fim
medium
{ "lang": "rust", "repo": "facebook/hhvm", "path": "/hphp/hack/test/rust_to_ocaml/pointers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: facebook/hhvm path: /hphp/hack/test/rust_to_ocaml/pointers.rs pub type BoxA = Box<A>; pub type RcA = Rc<A>; pub type ArcA = Arc<A>; pub type RcOcA = Arc<A>; <|fim_suffix|>pub type BoxedTuple = Box<(Box<A>, Box<B>)>;<|fim_middle|>pub type StdBoxA = std::boxed::Box<A>; pub type StdRcA = std::rc::...
code_fim
medium
{ "lang": "rust", "repo": "facebook/hhvm", "path": "/hphp/hack/test/rust_to_ocaml/pointers.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> html! { <Card title={"Article"}> <p>{ "Just a blog..." }</p> <ArticlePreview/> </Card> } }<|fim_prefix|>// repo: MIracleyin/blog path: /client/src/components/home.rs use yew::prelude::*; use crate::components::{card::Card, article::articles::ArticlePreview...
code_fim
medium
{ "lang": "rust", "repo": "MIracleyin/blog", "path": "/client/src/components/home.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MIracleyin/blog path: /client/src/components/home.rs use yew::prelude::*; use crate::components::{card::Card, article::articles::ArticlePreview}; <|fim_suffix|> html! { <Card title={"Article"}> <p>{ "Just a blog..." }</p> <ArticlePreview/> </Card> ...
code_fim
medium
{ "lang": "rust", "repo": "MIracleyin/blog", "path": "/client/src/components/home.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: keydunov/lisp-in-rust path: /src/main.rs #![allow(unstable)] extern crate readline; use evaluator::Evaluator; mod parser; mod evaluator; fn process_line(line: String, evaluator: &Evaluator) { match parser::parse(line) { Ok(sexpr) => { match evaluator.eval(sexpr) { Ok(val)...
code_fim
medium
{ "lang": "rust", "repo": "keydunov/lisp-in-rust", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match input { Ok(line) => { readline::add_history(line.as_slice()); process_line(line, &evaluator); } Err(_) => { println!("Quiting..."); break; } } } } fn main() { println!("Lisp repl in Rust by Artyom Keydunov"); repl(); }<|fim_prefi...
code_fim
hard
{ "lang": "rust", "repo": "keydunov/lisp-in-rust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> MultipleMessagesVisitor { marker: PhantomData, } } } impl<'de> Visitor<'de> for MultipleMessagesVisitor { type Value = MultipleMessagesIntermediate; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("a sequence") ...
code_fim
hard
{ "lang": "rust", "repo": "daboross/rust-screeps-api", "path": "/src/websocket/parsing/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: daboross/rust-screeps-api path: /src/websocket/parsing/mod.rs //! Parsing messages from Screeps websockets. use std::{borrow::Cow, cmp, convert::AsRef, fmt, marker::PhantomData}; use serde::{ de::{SeqAccess, Visitor}, Deserialize, Deserializer, }; use crate::websocket::types::ChannelUp...
code_fim
hard
{ "lang": "rust", "repo": "daboross/rust-screeps-api", "path": "/src/websocket/parsing/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn cpu_usage(&self) -> Result<usize, ReadoutError> { let mut info = self.sysinfo; let info_ptr: *mut sysinfo = &mut info; let ret = unsafe { sysinfo(info_ptr) }; if ret != -1 { let f_load = 1f64 / (1 << libc::SI_LOAD_SHIFT) as f64; let cpu_usage ...
code_fim
hard
{ "lang": "rust", "repo": "uttarayan21/libmacchina", "path": "/src/android/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uttarayan21/libmacchina path: /src/android/mod.rs mod sysinfo_ffi; mod system_properties; use crate::extra; use crate::traits::*; use itertools::Itertools; use std::ffi::{CStr, CString}; use std::fs; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; use sysinfo_ffi::sysinfo; u...
code_fim
hard
{ "lang": "rust", "repo": "uttarayan21/libmacchina", "path": "/src/android/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let file_name = &args[1]; let mut input_path = env::current_dir().unwrap(); for segment in file_name.split('/') { if segment == "." { input_path.pop(); } else { input_path.push(segment); } } let output_path = env::current_dir()...
code_fim
hard
{ "lang": "rust", "repo": "grimace87/wavefront-converter-rs", "path": "/src/bin/wc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: grimace87/wavefront-converter-rs path: /src/bin/wc.rs use std::env; extern crate wavefront_converter_rs; use wavefront_converter_rs::process_directory; <|fim_suffix|> let output_path = env::current_dir().unwrap(); let collisions_path = env::current_dir().unwrap(); process_dir...
code_fim
hard
{ "lang": "rust", "repo": "grimace87/wavefront-converter-rs", "path": "/src/bin/wc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let output_path = env::current_dir().unwrap(); let collisions_path = env::current_dir().unwrap(); process_directory(&input_path, &output_path, Some(&collisions_path)); }<|fim_prefix|>// repo: grimace87/wavefront-converter-rs path: /src/bin/wc.rs use std::env; extern crate wavefront_conv...
code_fim
hard
{ "lang": "rust", "repo": "grimace87/wavefront-converter-rs", "path": "/src/bin/wc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Update the the request URI head.uri = { // Split the request URI into parts. let mut uri: http::uri::Parts = head.uri.into(); // Update the URI parts, setting hte scheme and authority uri.scheme = self.scheme.clone(); uri.autho...
code_fim
hard
{ "lang": "rust", "repo": "SINHASantos/tonic", "path": "/tonic/src/transport/service/add_origin.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SINHASantos/tonic path: /tonic/src/transport/service/add_origin.rs use crate::transport::BoxFuture; use http::uri::Authority; use http::uri::Scheme; use http::{Request, Uri}; use std::task::{Context, Poll}; use tower_service::Service; #[derive(Debug)] pub(crate) struct AddOrigin<T> { inner:...
code_fim
hard
{ "lang": "rust", "repo": "SINHASantos/tonic", "path": "/tonic/src/transport/service/add_origin.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> http::Uri::from_parts(uri).expect("valid uri") }; let request = Request::from_parts(head, body); let fut = self.inner.call(request); Box::pin(async move { fut.await.map_err(Into::into) }) } }<|fim_prefix|>// repo: SINHASantos/tonic path: /tonic/src/trans...
code_fim
hard
{ "lang": "rust", "repo": "SINHASantos/tonic", "path": "/tonic/src/transport/service/add_origin.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samuelleeuwenburg/euler path: /src/problem08.rs #![allow(dead_code)] use std::cmp::max; // The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. // Find the thirteen adjacent digits in the 1000-digit number that have the greatest product. // ...
code_fim
hard
{ "lang": "rust", "repo": "samuelleeuwenburg/euler", "path": "/src/problem08.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> thousand_digit_number.chars().enumerate() .filter_map(|(i, _)| thousand_digit_number.get(i..i + 13)) .filter(|slice| !slice.chars().any(|c| c == '0')) .fold(0, |y, slice| { let x = slice.chars().fold(1, |acc, c| { acc * c.to_digit(10).unwrap() as u64...
code_fim
hard
{ "lang": "rust", "repo": "samuelleeuwenburg/euler", "path": "/src/problem08.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Techno-coder/example_os path: /kernel/src/keyboard/key_other.rs use core::convert::Into; use super::key_printable::KeyNumber; use super::KeyCode; #[derive(Debug)] pub enum KeyFunction { One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Eleven, Twelve, } impl Into<KeyCode> ...
code_fim
hard
{ "lang": "rust", "repo": "Techno-coder/example_os", "path": "/kernel/src/keyboard/key_other.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> KeyCode::Special(self) } } #[derive(Debug)] pub enum KeyMultimedia { Previous, Next, Mute, Calculator, Play, Stop, VolumeDown, VolumeUp, WebHome, WebSearch, WebFavourites, WebRefresh, WebStop, WebForward, WebBack, Computer, Email, MediaSelect, } impl Into<KeyCode> for KeyMultimedia ...
code_fim
hard
{ "lang": "rust", "repo": "Techno-coder/example_os", "path": "/kernel/src/keyboard/key_other.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub enum KeySpecial { Backspace, CapsLock, Tab, PageUp, PageDown, Escape, Enter, Home, End, Insert, Delete, Pause, PrintScreen, Menu, Power, Sleep, Wake, NumberLock, ScrollLock, } impl Into<KeyCode> for KeySpecial { fn into(self) -> KeyCode { KeyCode::Special(self) ...
code_fim
hard
{ "lang": "rust", "repo": "Techno-coder/example_os", "path": "/kernel/src/keyboard/key_other.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // If the file has not yet been added, there should be no UUIDs. if is_new && !options.force { for c in &cards { if c.uuid.is_some() { throw!(MathemaErrorKind::PreexistingUUID { file: file.display().to_string(), line: c.st...
code_fim
medium
{ "lang": "rust", "repo": "Manishearth/mathema", "path": "/src/add.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Otherwise, we can assign UUIDs to each card. let mut uuids_assigned = 0; for c in &mut cards { if c.uuid.is_none() && !c.is_comment_card() { uuids_assigned += 1; c.uuid = Some(Uuid::fresh()); } } // Now we can write the card file back out, wi...
code_fim
hard
{ "lang": "rust", "repo": "Manishearth/mathema", "path": "/src/add.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Manishearth/mathema path: /src/add.rs //! New subcommand. use crate::prelude::*; crate fn add(options: &MathemaOptions, file: &str) -> Fallible<()> { let repo = &mut MathemaRepository::open(options)?; let file = Path::new(file); let mut cards = cards::parse_cards_file(fil...
code_fim
hard
{ "lang": "rust", "repo": "Manishearth/mathema", "path": "/src/add.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn read_v4_socket_address<R: io::Read>(reader: &mut R) -> io::Result<SocketAddr> { let mut addr = [0; 4]; let mut port = [0; 2]; reader.read_exact(&mut addr)?; reader.read_exact(&mut port)?; Ok(SocketAddr::new( IpAddr::V4(addr.into()), u16::from_be_bytes(port), ...
code_fim
medium
{ "lang": "rust", "repo": "95th/torrent-rs", "path": "/dht/src/detail.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 95th/torrent-rs path: /dht/src/detail.rs use std::io; use std::net::{IpAddr, SocketAddr}; pub fn write_address<W: io::Write>(writer: &mut W, addr: &IpAddr) -> io::Result<()> { match addr { IpAddr::V4(addr) => writer.write_all(&addr.octets())?, IpAddr::V6(addr) => writer.writ...
code_fim
medium
{ "lang": "rust", "repo": "95th/torrent-rs", "path": "/dht/src/detail.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: avhz/QuantMath path: /src/risk/dependencies.rs use crate::dates::datetime::DateTime; use crate::dates::Date; use crate::instruments::DependencyContext; use crate::instruments::RcInstrument; use crate::instruments::SpotRequirement; use std::collections::hash_map::Iter; use std::collections::HashM...
code_fim
hard
{ "lang": "rust", "repo": "avhz/QuantMath", "path": "/src/risk/dependencies.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn vol_surface_hwm(&self, instrument: &RcInstrument) -> Option<Date> { get_hwm(&self.vol_surfaces, instrument) } pub fn forward_curves(&self) -> &HashMap<RcInstrument, Date> { &self.forward_curves } pub fn vol_surfaces(&self) -> &HashMap<RcInstrument, Date> { ...
code_fim
hard
{ "lang": "rust", "repo": "avhz/QuantMath", "path": "/src/risk/dependencies.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> variant as _ } } impl EXTIPSEL5_R { #[doc = "Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> Option<EXTIPSEL5_A> { match self.bits { 0 => Some(EXTIPSEL5_A::PORTA), 1 => Some(EXTIPSEL5_A::PORTB), 2 => Some(EXTIPS...
code_fim
hard
{ "lang": "rust", "repo": "em32-rs/efm32hg-pac", "path": "/src/gpio/extipsell.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> variant as _ } } impl EXTIPSEL7_R { #[doc = "Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> Option<EXTIPSEL7_A> { match self.bits { 0 => Some(EXTIPSEL7_A::PORTA), 1 => Some(EXTIPSEL7_A::PORTB), 2 => Some(EXTIPS...
code_fim
hard
{ "lang": "rust", "repo": "em32-rs/efm32hg-pac", "path": "/src/gpio/extipsell.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: em32-rs/efm32hg-pac path: /src/gpio/extipsell.rs ways)] pub fn variant(&self) -> Option<EXTIPSEL2_A> { match self.bits { 0 => Some(EXTIPSEL2_A::PORTA), 1 => Some(EXTIPSEL2_A::PORTB), 2 => Some(EXTIPSEL2_A::PORTC), 3 => Some(EXTIPSEL2_A:...
code_fim
hard
{ "lang": "rust", "repo": "em32-rs/efm32hg-pac", "path": "/src/gpio/extipsell.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rune-rs/rune path: /crates/rune/src/fmt/tests.rs use crate::no_std::prelude::*; use crate::fmt::FormattingError; pub(crate) fn layout_string(contents: String) -> Result<Vec<u8>, FormattingError> { super::layout_source(&contents) } #[test] fn test_layout_string() { let input = r#" ...
code_fim
hard
{ "lang": "rust", "repo": "rune-rs/rune", "path": "/crates/rune/src/fmt/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let x = 1; let y = 2; x + y } "#; let expected = r#"fn main() { let x = 1; let y = 2; x + y } /// foo fn foo() { let x = 1; let y = 2; x + y } "#; assert_eq!( layout_string(input.to_owned()).unwrap(), expected.as_byte...
code_fim
hard
{ "lang": "rust", "repo": "rune-rs/rune", "path": "/crates/rune/src/fmt/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lilymonad/vip path: /src/ui/vimui.rs use luminance_glfw::{GlfwSurface, Surface, WindowEvent, Action, Key}; use std::{rc::Rc, collections::{HashMap, HashSet}}; use crate::keyboard::{ModSet, KeyboardLayout, CharKeyMod, CharKey, Mod, azerty}; #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] pub ...
code_fim
hard
{ "lang": "rust", "repo": "lilymonad/vip", "path": "/src/ui/vimui.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // check if verb exist let verb = CharKeyMod { key:c, mods }; let object = verb.clone(); if let Some((is_transitive, action)) = self.verbs.get(&verb) { if *is_transitive { ...
code_fim
hard
{ "lang": "rust", "repo": "lilymonad/vip", "path": "/src/ui/vimui.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let signal = ShutdownSignal::new(); signal.shutdown(); } #[tokio::test] async fn test_async() { use std::sync::Arc; let signal = Arc::new(ShutdownSignal::new()); let s1 = signal.clone(); let th1 = tokio::spawn(async move { delay_for...
code_fim
hard
{ "lang": "rust", "repo": "go-numb/matching-engine", "path": "/raft/src/shutdown.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[tokio::test] async fn test_async() { use std::sync::Arc; let signal = Arc::new(ShutdownSignal::new()); let s1 = signal.clone(); let th1 = tokio::spawn(async move { delay_for(Duration::from_millis(200)).await; let signal = s1; s...
code_fim
hard
{ "lang": "rust", "repo": "go-numb/matching-engine", "path": "/raft/src/shutdown.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: go-numb/matching-engine path: /raft/src/shutdown.rs use tokio::sync::Semaphore; // Note: semaphore.add_permits requires this to be less than usize::MAX >> 3 const MAX_SEMAPHORE_PERMITS: usize = 1000; /// A shutdown mechanism that supports three use-cases: /// - sending a shutdown signal, /// ...
code_fim
hard
{ "lang": "rust", "repo": "go-numb/matching-engine", "path": "/raft/src/shutdown.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while curr.value < target_value { let mut cell = curr.next(); cell.value = calc_new_value(&cell, &grid); curr = cell.clone(); grid.insert(cell.location(),cell); } curr.value }<|fim_prefix|>// repo: w4tson/advent-of-code-2017-rust path: /src/day3/p...
code_fim
hard
{ "lang": "rust", "repo": "w4tson/advent-of-code-2017-rust", "path": "/src/day3/part2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: w4tson/advent-of-code-2017-rust path: /src/day3/part2.rs use day3::LocStat; use day3::Location; use day3::Direction; use std::collections::HashMap; #[derive(Clone)] struct GridCell { index: u32, value: u32, locstat: LocStat } impl GridCell { fn location(&self) -> Location { ...
code_fim
medium
{ "lang": "rust", "repo": "w4tson/advent-of-code-2017-rust", "path": "/src/day3/part2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abesto/rktrl path: /src/components/monster.rs use serde::{Deserialize, Serialize}; use type_u<|fim_suffix|>492-4665-9d0d-7842b7029ef9"] pub struct Monster;<|fim_middle|>uid::TypeUuid; #[derive(Clone, Debug, Serialize, Deserialize, TypeUuid)] #[uuid = "d72582fd-e
code_fim
medium
{ "lang": "rust", "repo": "abesto/rktrl", "path": "/src/components/monster.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>e, Deserialize, TypeUuid)] #[uuid = "d72582fd-e492-4665-9d0d-7842b7029ef9"] pub struct Monster;<|fim_prefix|>// repo: abesto/rktrl path: /src/components/monster.rs use serde::{Deserialize, Serialize}; use type_u<|fim_middle|>uid::TypeUuid; #[derive(Clone, Debug, Serializ
code_fim
easy
{ "lang": "rust", "repo": "abesto/rktrl", "path": "/src/components/monster.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn sign(&self, msg: Vec<u8>) -> Signature { Signature(self.0.sign(&msg)) } } impl From<RustSecretKey> for SecretKey { fn from(key: RustSecretKey) -> Self { Self(key) } } pub struct PublicKey(RustPublicKey); impl PublicKey { pub fn verify(&self, sig: Signature, ms...
code_fim
hard
{ "lang": "rust", "repo": "bingyanglin/iota.rs", "path": "/bindings/java/native/src/classes/ed25519.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bingyanglin/iota.rs path: /bindings/java/native/src/classes/ed25519.rs // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 use std::convert::AsMut; use iota_client::crypto::signatures::ed25519::{ PublicKey as RustPublicKey, SecretKey as RustSecretKey, Signature as RustSi...
code_fim
hard
{ "lang": "rust", "repo": "bingyanglin/iota.rs", "path": "/bindings/java/native/src/classes/ed25519.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl PublicKey { pub fn verify(&self, sig: Signature, msg: Vec<u8>) -> bool { self.0.verify(&sig.0, &msg) } pub fn to_compressed_bytes(&self) -> Vec<u8> { self.0.to_compressed_bytes().to_vec() } pub fn from_compressed_bytes(bs: Vec<u8>) -> Result<Self> { match...
code_fim
hard
{ "lang": "rust", "repo": "bingyanglin/iota.rs", "path": "/bindings/java/native/src/classes/ed25519.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wacko-professional/rust-book path: /ownership/references/main/src/main.rs fn main() { let mut s1 = String::from("hello"); // circumventing ownership by passing by reference let len = calculate_length(&s1); //// Mutable references have one big restriction; You can only have one m...
code_fim
medium
{ "lang": "rust", "repo": "wacko-professional/rust-book", "path": "/ownership/references/main/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn change(some_string: &mut String) { // Note: References are immutable by default some_string.push_str(", world"); }<|fim_prefix|>// repo: wacko-professional/rust-book path: /ownership/references/main/src/main.rs fn main() { let mut s1 = String::from("hello"); // circumventing ownership ...
code_fim
medium
{ "lang": "rust", "repo": "wacko-professional/rust-book", "path": "/ownership/references/main/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/nll/promoted-closure-pair.rs // Check that we handle multiple closures in the same promoted constant. <|fim_suffix|> let z = 0; let p = &(|y| y, |y| y); p.0(&z); p.1(&z) //~ ERROR cannot return } fn main() {}<|fim_middle...
code_fim
easy
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/nll/promoted-closure-pair.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let z = 0; let p = &(|y| y, |y| y); p.0(&z); p.1(&z) //~ ERROR cannot return } fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/nll/promoted-closure-pair.rs // Check that we handle multiple closures in the same promoted constant. <|fim_middle...
code_fim
easy
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/nll/promoted-closure-pair.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oshunter/fuchsia path: /src/connectivity/openthread/tests/lib/src/ot_radio_driver_utils.rs // Copyright 2020 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { anyhow::{format_err, Context a...
code_fim
hard
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/src/connectivity/openthread/tests/lib/src/ot_radio_driver_utils.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>/// Schedule unbind of a device pub fn unbind_device(device: &File) -> Result<(), Error> { let channel = fdio::clone_channel(device)?; let mut controller_proxy = ControllerSynchronousProxy::new(channel); controller_proxy .schedule_unbind(zx::Time::INFINITE)? .map_err(|e| zx::St...
code_fim
hard
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/src/connectivity/openthread/tests/lib/src/ot_radio_driver_utils.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> startup_info_ex.StartupInfo.cb = mem::size_of::<STARTUPINFOEXW>() as u32; // Setting this flag but leaving all the handles as default (null) ensures the // PTY process does not inherit any handles from this Alacritty process. startup_info_ex.StartupInfo.dwFlags |= STARTF_USESTDHANDLES; ...
code_fim
hard
{ "lang": "rust", "repo": "alacritty/alacritty", "path": "/alacritty_terminal/src/tty/windows/conpty.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alacritty/alacritty path: /alacritty_terminal/src/tty/windows/conpty.rs use log::info; use std::io::Error; use std::os::windows::io::IntoRawHandle; use std::{mem, ptr}; use mio_anonymous_pipes::{EventedAnonRead, EventedAnonWrite}; use windows_sys::core::{HRESULT, PWSTR}; use windows_sys::Win32...
code_fim
hard
{ "lang": "rust", "repo": "alacritty/alacritty", "path": "/alacritty_terminal/src/tty/windows/conpty.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] #[should_panic] fn test_out_of_bounds_set() { let mut matrix = BitMatrix::new(5, 7); matrix.set((5,1), true); } #[test] #[should_panic] fn test_out_of_bounds_ix_set() { let mut matrix = BitMatrix::new(5, 7); *matrix[1].get_mut(10).unwrap() = true; }<|fim_prefix|>// repo: gahag/bitmatrix pa...
code_fim
medium
{ "lang": "rust", "repo": "gahag/bitmatrix", "path": "/src/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] #[should_panic] fn test_out_of_bounds_set() { let mut matrix = BitMatrix::new(5, 7); matrix.set((5,1), true); } #[test] #[should_panic] fn test_out_of_bounds_ix_set() { let mut matrix = BitMatrix::new(5, 7); *matrix[1].get_mut(10).unwrap() = true; }<|fim_prefix|>// repo: gahag/bitmatrix pat...
code_fim
medium
{ "lang": "rust", "repo": "gahag/bitmatrix", "path": "/src/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gahag/bitmatrix path: /src/tests.rs use super::*; #[test] #[should_panic] fn test_out_of_bounds_tuple() { <|fim_suffix|> let mut matrix = BitMatrix::new(5, 7); *matrix[1].get_mut(10).unwrap() = true; }<|fim_middle|> let matrix = BitMatrix::new(5, 7); let _ = matrix[(1,8)]; } #[test] #[shou...
code_fim
hard
{ "lang": "rust", "repo": "gahag/bitmatrix", "path": "/src/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: avranju/kube-rust path: /src/models/io_k8s_kubernetes_pkg_apis_settings_v1alpha1_pod_preset_spec.rs /* * Kubernetes * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * OpenAPI spec version: v1.7.12 * * Generated by: https://githu...
code_fim
hard
{ "lang": "rust", "repo": "avranju/kube-rust", "path": "/src/models/io_k8s_kubernetes_pkg_apis_settings_v1alpha1_pod_preset_spec.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn with_selector(mut self, selector: ::models::MetaV1LabelSelector) -> SettingsV1alpha1PodPresetSpec { self.selector = Some(selector); self } pub fn selector(&self) -> Option<&::models::MetaV1LabelSelector> { self.selector.as_ref() } pub fn reset_selector(&mut self) { self....
code_fim
hard
{ "lang": "rust", "repo": "avranju/kube-rust", "path": "/src/models/io_k8s_kubernetes_pkg_apis_settings_v1alpha1_pod_preset_spec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// An interpreter for mach BIND opcodes. /// Runs on prebound (non lazy) symbols (usually dylib extern consts and extern variables), /// and lazy symbols (usually dylib functions) pub struct BindInterpreter<'a> { data: &'a [u8], location: Range<usize>, lazy_location: Range<usize>, } impl<'a>...
code_fim
hard
{ "lang": "rust", "repo": "m4b/goblin", "path": "/src/mach/imports.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: m4b/goblin path: /src/mach/imports.rs //! Dynamically linked symbolic imports // table of tuples: // <seg-index, seg-offset, type, symbol-library-ordinal, symbol-name, addend> // symbol flags are undocumented use alloc::vec::Vec; use core::fmt::{self, Debug}; use core::ops::Range; use scroll::...
code_fim
hard
{ "lang": "rust", "repo": "m4b/goblin", "path": "/src/mach/imports.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self, is_lazy: bool, libs: &[&'a str], segments: &[segment::Segment], ctx: container::Ctx, imports: &mut Vec<Import<'a>>, ) -> error::Result<()> { use crate::mach::bind_opcodes::*; let location = if is_lazy { &self.lazy_locat...
code_fim
hard
{ "lang": "rust", "repo": "m4b/goblin", "path": "/src/mach/imports.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: johnstonskj/rust-xml_dom path: /tests/display.rs use xml_dom::level2::convert::{ as_attribute_mut, as_document, as_document_fragment_mut, as_element_mut, }; use xml_dom::level2::ext::convert::as_document_decl_mut; use xml_dom::level2::ext::dom_impl as ext_dom_impl; use xml_dom::level2::ext::...
code_fim
hard
{ "lang": "rust", "repo": "johnstonskj/rust-xml_dom", "path": "/tests/display.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let implementation = get_implementation(); let document_type = implementation .create_document_type( "html", Some("-//W3C//DTD XHTML 1.0 Transitional//EN"), Some("http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"), ) .unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "johnstonskj/rust-xml_dom", "path": "/tests/display.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn it_works() { assert_eq!( Solution::add_operators("123".to_string(), 6), vec!["1+2+3", "1*2*3"] ); assert_eq!( Solution::add_operators("232".to_string(), 8), vec!["2*3+2", "2+3*2"] ); assert_eq!( Solution::add_operators("105".to_string(), 5), vec!["1*0+5", "10...
code_fim
medium
{ "lang": "rust", "repo": "icub3d/puzzles", "path": "/leetcode/expression-add-operators/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( Solution::add_operators("123".to_string(), 6), vec!["1+2+3", "1*2*3"] ); assert_eq!( Solution::add_operators("232".to_string(), 8), vec!["2*3+2", "2+3*2"] ); assert_eq!( Solution::add_operators("105".to_string(), 5), vec!["1*0+5", "10-5"] ); assert_eq!( Solut...
code_fim
medium
{ "lang": "rust", "repo": "icub3d/puzzles", "path": "/leetcode/expression-add-operators/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: icub3d/puzzles path: /leetcode/expression-add-operators/src/lib.rs pub struct Solution; impl Solution { pub fn add_operators(num: String, target: i32) -> Vec<String> { let mut result = vec![]; let mut path = vec![]; let mut num = num.chars().collect::<Vec<char>>(); Self::dfs(&mut re...
code_fim
medium
{ "lang": "rust", "repo": "icub3d/puzzles", "path": "/leetcode/expression-add-operators/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MAGANER/another-lisp path: /src/interpreter/env/arg_parser.rs use super::expression; pub fn parse_list_of_floats(args: &[expression::Expr]) -> Result<Vec<f64>, expression::Err> { args .iter() .map(|x| parse_single_float(x)) .collect() } pub fn parse_single_float(exp: &e...
code_fim
hard
{ "lang": "rust", "repo": "MAGANER/another-lisp", "path": "/src/interpreter/env/arg_parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn parse_list_of_strings(args:&[expression::Expr]) -> Result<Vec<String>, expression::Err> { args .iter() .map(|x| parse_single_string(x)) .collect() } pub fn parse_single_string(expr: &expression::Expr) -> Result<String, expression::Err> { match expr { expression::Expr::Symbol(v...
code_fim
hard
{ "lang": "rust", "repo": "MAGANER/another-lisp", "path": "/src/interpreter/env/arg_parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> const EMPTY_SLICE: &'static [u8] = &[]; #[test] fn test_tcp_parse() { let bytes = [0xc2, 0x1f, /* Source port */ 0x00, 0x50, /* Dest port */ 0x0f, 0xd8, 0x7f, 0x4c, /* Seq no */ 0xeb, 0x2f, 0x05, 0xc8, /* Ack no */ ...
code_fim
hard
{ "lang": "rust", "repo": "moosingin3space/pktparse-rs", "path": "/src/tcp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: moosingin3space/pktparse-rs path: /src/tcp.rs //! Handles parsing of TCP headers use nom::IResult; // TCP Header Format // // // 0 1 2 3 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 // +-+-+-+-+-+-+-+-+-+-+-+-+...
code_fim
hard
{ "lang": "rust", "repo": "moosingin3space/pktparse-rs", "path": "/src/tcp.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_tcp_parse() { let bytes = [0xc2, 0x1f, /* Source port */ 0x00, 0x50, /* Dest port */ 0x0f, 0xd8, 0x7f, 0x4c, /* Seq no */ 0xeb, 0x2f, 0x05, 0xc8, /* Ack no */ 0x50, 0x18, 0x01, 0x00, /* Win...
code_fim
hard
{ "lang": "rust", "repo": "moosingin3space/pktparse-rs", "path": "/src/tcp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AleoHQ/snarkOS path: /node/consensus/src/lib.rs // Copyright (C) 2019-2023 Aleo Systems Inc. // This file is part of the snarkOS library. // 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 co...
code_fim
hard
{ "lang": "rust", "repo": "AleoHQ/snarkOS", "path": "/node/consensus/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Clear the memory pool of unconfirmed transactions that are now invalid. self.memory_pool.clear_invalid_transactions(self); // If this starts a new epoch, clear all unconfirmed solutions from the memory pool. if block.epoch_number() > old_epoch { self.memory_...
code_fim
hard
{ "lang": "rust", "repo": "AleoHQ/snarkOS", "path": "/node/consensus/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> info!("Advanced to block {}", block.height()); Ok(()) } /// Clears the memory pool of invalid solutions and transactions. pub fn refresh_memory_pool(&self) -> Result<()> { // Clear the memory pool of unconfirmed solutions that are now invalid. self.memory_pool....
code_fim
hard
{ "lang": "rust", "repo": "AleoHQ/snarkOS", "path": "/node/consensus/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jtempest/float_eq-rs path: /float_eq_derive/src/lib.rs h to the `#[float_eq(...)]` attribute: /// `ulps_tol` is the name of the type generated for [`FloatEqUlpsTol`] and /// `debug_ulps_diff` the name of the type generated for [`FloatEqDebugUlpsDiff`]. /// Both are required. /// /// If the optio...
code_fim
hard
{ "lang": "rust", "repo": "jtempest/float_eq-rs", "path": "/float_eq_derive/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }