text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> fn input(&mut self, data: &[u8]) { Digest::input(&mut self.hasher, data); } fn result(&mut self) -> Self::Output { let mut out = [0u8; 64]; Digest::result(&mut self.hasher, &mut out); out } } impl Default for Blake2s { fn default() -> Blake2s { ...
code_fim
hard
{ "lang": "rust", "repo": "CertainLach/noise-rust", "path": "/rust-crypto/src/lib.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn remove_should_always_remove_instruction() { // Given let edge = Edge::new(v2(1, 2), v2(1, 3)); let mut build_queue = BuildQueue::default(); let instruction = BuildInstruction { what: Build::Road(edge), when: 0, }; ...
code_fim
hard
{ "lang": "rust", "repo": "TGElder/rust", "path": "/frontier/src/build/build_queue.rs", "mode": "spm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TGElder/rust path: /frontier/src/build/build_queue.rs use super::*; use std::collections::hash_map::Entry; use std::collections::HashMap; #[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)] pub struct BuildQueue { queue: HashMap<BuildKey, BuildInstruction>, } impl BuildQue...
code_fim
hard
{ "lang": "rust", "repo": "TGElder/rust", "path": "/frontier/src/build/build_queue.rs", "mode": "psm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_suffix|> // Then assert_eq!(build_queue.queue, hashmap! {}); } #[test] fn take_instructions_before() { // Given let mut build_queue = BuildQueue::default(); let before_edge = Edge::new(v2(1, 2), v2(1, 3)); let before = BuildInstruction { what...
code_fim
hard
{ "lang": "rust", "repo": "TGElder/rust", "path": "/frontier/src/build/build_queue.rs", "mode": "spm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_suffix|> let order_a = Order::new(1, "1", "1", OrderKind::Limit, OrderSide::Ask); let order_b = Order::new(1, "2", "1", OrderKind::Limit, OrderSide::Ask); assert!(order_a > order_b); } #[test] fn higher_price_should_be_greater_for_bid_order() { let order_a = Order::new(1, "1", "1", OrderKind::Limit, OrderSid...
code_fim
hard
{ "lang": "rust", "repo": "ZangaiFamily/matching", "path": "/src/structs/order.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ZangaiFamily/matching path: /src/structs/order.rs use std::cmp::Ordering; use rust_decimal::Decimal; use std::str::FromStr; use ds::{WithId}; #[derive(Debug, PartialEq)] pub enum OrderKind { Limit, Market } #[derive(Debug, PartialEq)] pub enum OrderSide { Ask, Bid } #[derive(Debug)] pub s...
code_fim
hard
{ "lang": "rust", "repo": "ZangaiFamily/matching", "path": "/src/structs/order.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn gcd(a: i32, b: i32) -> i32 { if b == 0 { return a; } gcd(b, a % b) }<|fim_prefix|>// repo: arcesino/mncalc path: /src/math/mod.rs /// Computes absolute value of a number pub fn abs(number: i32) -> i32 { if number < 0 { <|fim_middle|> number * -1 } else { ...
code_fim
medium
{ "lang": "rust", "repo": "arcesino/mncalc", "path": "/src/math/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arcesino/mncalc path: /src/math/mod.rs /// Computes absolute value of a number pub fn abs(number: i32) -> i32 { if number < 0 { number * -1 } else { number } } /// Computes the GCD of 2 numbers using <|fim_suffix|> fn gcd(a: i32, b: i32) -> i32 { if b == 0 { ...
code_fim
medium
{ "lang": "rust", "repo": "arcesino/mncalc", "path": "/src/math/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nmnick18/rs-mvc path: /src/app/models/user.rs #[derive(RustcEncodable, RustcDecodable)] pub struct User { id : i64, nam<|fim_suffix|>-> User { let user = User { id : id, name : "Nikhil".to_string(), items : vec!["xbox".to_string(), "chopsticks".to_string()] }; user } }<|fim_mid...
code_fim
medium
{ "lang": "rust", "repo": "nmnick18/rs-mvc", "path": "/src/app/models/user.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> items : vec!["xbox".to_string(), "chopsticks".to_string()] }; user } }<|fim_prefix|>// repo: nmnick18/rs-mvc path: /src/app/models/user.rs #[derive(RustcEncodable, RustcDecodable)] pub struct User { id : i64, name : String, items : Vec<String> } impl User { pub fn get_by_id(id : i64) <|fim_mid...
code_fim
medium
{ "lang": "rust", "repo": "nmnick18/rs-mvc", "path": "/src/app/models/user.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>-> User { let user = User { id : id, name : "Nikhil".to_string(), items : vec!["xbox".to_string(), "chopsticks".to_string()] }; user } }<|fim_prefix|>// repo: nmnick18/rs-mvc path: /src/app/models/user.rs #[derive(RustcEncodable, RustcDecodable)] pub struct User { id : i64, nam<|fim_mid...
code_fim
medium
{ "lang": "rust", "repo": "nmnick18/rs-mvc", "path": "/src/app/models/user.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MarkDDR/daily_programmer_386 path: /benches/single_threaded.rs use daily_programmer_386::calc_partition_count; use criterion::{criterion_group, criterion_main, Criterion}; <|fim_suffix|>criterion_group!(benches, criterion_benchmark); criterion_main!(benches);<|fim_middle|>pub fn criterion_bench...
code_fim
medium
{ "lang": "rust", "repo": "MarkDDR/daily_programmer_386", "path": "/benches/single_threaded.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>criterion_group!(benches, criterion_benchmark); criterion_main!(benches);<|fim_prefix|>// repo: MarkDDR/daily_programmer_386 path: /benches/single_threaded.rs use daily_programmer_386::calc_partition_count; use criterion::{criterion_group, criterion_main, Criterion}; <|fim_middle|>pub fn criterion_bench...
code_fim
medium
{ "lang": "rust", "repo": "MarkDDR/daily_programmer_386", "path": "/benches/single_threaded.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(message) } len => Err(Error::SizeMismatch(len)), } } else { Err(Error::InvalidFrameType) } } pub fn id(&self) -> u64 { self.id } pub fn ty(&self) -> u64 { self.ty } pub...
code_fim
hard
{ "lang": "rust", "repo": "interiorem/cocaine-framework-rust", "path": "/src/frame.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let message = Frame { id: id, ty: ty, args: args, meta: meta, }; Ok(message) } len => Err(Error::SizeMismatch(len)), ...
code_fim
hard
{ "lang": "rust", "repo": "interiorem/cocaine-framework-rust", "path": "/src/frame.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: interiorem/cocaine-framework-rust path: /src/frame.rs use std::error; use std::fmt::{self, Display, Formatter}; use rmpv::ValueRef; /// Framing error. #[derive(Clone, Copy, Debug, PartialEq)] pub enum Error { /// Frame must be an array. InvalidFrameType, /// Frame size must be 3 or ...
code_fim
hard
{ "lang": "rust", "repo": "interiorem/cocaine-framework-rust", "path": "/src/frame.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let mut array = vec![1, 0, 2, 3, 0, 4, 5, 0]; duplicate_zeros(&mut array); println!("{:?}", array); let mut array = vec![1, 2, 3]; duplicate_zeros(&mut array); println!("{:?}", array); }<|fim_prefix|>// repo: senofsky/leetcode path: /rust/src/bin/duplicate_zeros.rs //...
code_fim
hard
{ "lang": "rust", "repo": "senofsky/leetcode", "path": "/rust/src/bin/duplicate_zeros.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: senofsky/leetcode path: /rust/src/bin/duplicate_zeros.rs // Given a fixed length array arr of integers, duplicate each occurrence of // zero, shifting the remaining elements to the right. // // Note that elements beyond the length of the original array are not written. // // Do the above modific...
code_fim
hard
{ "lang": "rust", "repo": "senofsky/leetcode", "path": "/rust/src/bin/duplicate_zeros.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FirelightFlagboy/taskmaster path: /src/server/listener.rs use std::sync::{Arc,Mutex}; use serde::Deserialize; use std::fs; use std::io::prelude::*; use std::os::unix::net::{UnixListener, UnixStream}; use std::sync::mpsc::{Sender, Receiver}; use std::thread; use super::{communication::Com, inter...
code_fim
medium
{ "lang": "rust", "repo": "FirelightFlagboy/taskmaster", "path": "/src/server/listener.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Listener { pub fn new() -> Self { Self { sock: UnixListener::bind("/tmp/taskmaster.sock").unwrap(), } } pub fn run(&mut self, sender: Sender<Inter>, receiver: Receiver<Com>) { let listener = self.sock.try_clone().unwrap(); let reference = Arc::...
code_fim
medium
{ "lang": "rust", "repo": "FirelightFlagboy/taskmaster", "path": "/src/server/listener.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: igncp/code-gym path: /rust/advent_of_code_18/21/src/main.rs /* --- Day 21: Chronal Conversion --- You should have been watching where you were going, because as you wander the new North Pole base, you trip and fall into a very deep hole! Just kidding. You're falling through time again. If yo...
code_fim
hard
{ "lang": "rust", "repo": "igncp/code-gym", "path": "/rust/advent_of_code_18/21/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> instruction_text.push_str(&format!("{:02} -> ", instruction_idx)); if instruction.3 == self.instruction_pointer { instruction_text.push_str("GOTO "); } else { instruction_text.push_str(&format!("{} = ", reg_letters[instruction.3])); } match instruction.0 { Instructi...
code_fim
hard
{ "lang": "rust", "repo": "igncp/code-gym", "path": "/rust/advent_of_code_18/21/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elsuizo/Rust_work path: /impl-trait-many-structs/src/main.rs struct A { x: u32, } struct B { x: u32, } trait T { fn double(&self) -> u32; } <|fim_suffix|> self.x * 2 } })* } } impl_T!(for A, B); fn main() { let a = A { x: 2 }; let b...
code_fim
medium
{ "lang": "rust", "repo": "elsuizo/Rust_work", "path": "/impl-trait-many-structs/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.x * 2 } })* } } impl_T!(for A, B); fn main() { let a = A { x: 2 }; let b = B { x: 7 }; println!("a: {:}", a.double()); println!("b: {:}", b.double()); }<|fim_prefix|>// repo: elsuizo/Rust_work path: /impl-trait-many-structs/src/main.rs struct...
code_fim
medium
{ "lang": "rust", "repo": "elsuizo/Rust_work", "path": "/impl-trait-many-structs/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Tbr { #[inline] pub fn decode_from_mftb(data: u16) -> Tbr { debug_assert_eq!(u16_get_section(data, 16 - 5, 5), 0b01000); match data >> 5 { 0b01100 => Tbr::Tbl, 0b01101 => Tbr::Tbu, _ => panic!(), } } } #[derive(Debug, PartialEq)...
code_fim
hard
{ "lang": "rust", "repo": "marius851000/gekkoInterpreter", "path": "/src/register.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub fn update_cr1_f32(&mut self, _value: f32) { todo!("update_cr1 is not yet implemented"); } #[inline] pub fn increment_pc(&mut self) { self.pc += 4; } #[inline] pub fn get_bit_cr(&self, cr_bit: usize) -> bool { (self.cr[cr_bit / 4] >> (...
code_fim
hard
{ "lang": "rust", "repo": "marius851000/gekkoInterpreter", "path": "/src/register.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marius851000/gekkoInterpreter path: /src/register.rs use crate::util::u16_get_section; use crate::BASE_RW_ADRESS; pub struct GekkoRegister { // general purpose register gpr: [u32; 32], // fpr, can be accessed as a pair of f32 // in this case, ps0 is first and ps1 is second ...
code_fim
hard
{ "lang": "rust", "repo": "marius851000/gekkoInterpreter", "path": "/src/register.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0xdeafbeef/ton-labs-node path: /src/block_proof.rs block_id, data, is_link) } pub fn virtualize_block(&self) -> Result<(Block, ton_api::ton::int256)> { let merkle_proof = MerkleProof::construct_from(&mut self.proof.root.clone().into())?; let block_virt_root = merkle_proo...
code_fim
hard
{ "lang": "rust", "repo": "0xdeafbeef/ton-labs-node", "path": "/src/block_proof.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Pre checks if self.proof.signatures.is_none() { fail!(NodeError::InvalidData(format!( "Proof for {} doesn't have signatures to check", self.id(), ))); } let signatures = self.proof.signatures.as_ref().unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "0xdeafbeef/ton-labs-node", "path": "/src/block_proof.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0xdeafbeef/ton-labs-node path: /src/block_proof.rs of { &self.proof } pub fn data(&self) -> &[u8] { &self.data } pub fn check_with_prev_key_block_proof(&self, prev_key_block_proof: &BlockProofStuff) -> Result<()> { let now = std::time::Instant::now(); ...
code_fim
hard
{ "lang": "rust", "repo": "0xdeafbeef/ton-labs-node", "path": "/src/block_proof.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> repo::clone_rust(); let content = fs::read_to_string(FILE).unwrap(); let tokens = TokenStream::from_str(&content).unwrap(); b.iter(|| syn::parse2::<syn::File>(tokens.clone())); }<|fim_prefix|>// repo: google/tock-on-titan path: /third_party/syn-1.0.11/benches/file.rs // $ cargo bench --fe...
code_fim
hard
{ "lang": "rust", "repo": "google/tock-on-titan", "path": "/third_party/syn-1.0.11/benches/file.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: google/tock-on-titan path: /third_party/syn-1.0.11/benches/file.rs // $ cargo bench --features full --bench file #![feature(rustc_private, test)] extern crate test; <|fim_suffix|> repo::clone_rust(); let content = fs::read_to_string(FILE).unwrap(); let tokens = TokenStream::from_st...
code_fim
hard
{ "lang": "rust", "repo": "google/tock-on-titan", "path": "/third_party/syn-1.0.11/benches/file.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>const FILE: &str = "tests/rust/src/libcore/str/mod.rs"; #[bench] fn parse_file(b: &mut Bencher) { repo::clone_rust(); let content = fs::read_to_string(FILE).unwrap(); let tokens = TokenStream::from_str(&content).unwrap(); b.iter(|| syn::parse2::<syn::File>(tokens.clone())); }<|fim_prefix|...
code_fim
medium
{ "lang": "rust", "repo": "google/tock-on-titan", "path": "/third_party/syn-1.0.11/benches/file.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jimblandy/swgl-replay path: /swgl-replay/src/bin/dump-commands.rs use docopt::Docopt; use serde::Deserialize; use std::io; use swgl_replay::{Call, FileRecording}; use gl_replay::replay; const USAGE: &'static str = " Dump swgl-replay command log. Usage: dump-commands <dir>... "; <|fim_suffi...
code_fim
hard
{ "lang": "rust", "repo": "jimblandy/swgl-replay", "path": "/swgl-replay/src/bin/dump-commands.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: preston-evans98/bitcoin-warp path: /serde_derive/src/serialize.rs use proc_macro::TokenStream; use quote::quote; use syn; pub fn impl_ser_macro(ast: &syn::DeriveInput) -> TokenStream { let name = ast.ident.clone(); match ast.data { syn::Data::Struct(ref data) => { le...
code_fim
hard
{ "lang": "rust", "repo": "preston-evans98/bitcoin-warp", "path": "/serde_derive/src/serialize.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// fn serialize_ref(field: &syn::Field) -> quote::__private::TokenStream { // let ident = field // .ident // .clone() // .expect("Can only serialize named fields"); // quote! { #ident.serialize(target)?; } // } fn serialize_variant(variant: &syn::Variant, name: &syn::Ident...
code_fim
hard
{ "lang": "rust", "repo": "preston-evans98/bitcoin-warp", "path": "/serde_derive/src/serialize.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let statements: Vec<quote::__private::TokenStream> = variant .fields .iter() .map(|field| { if let Some(ident) = field.ident.clone() { quote! { #ident.serialize(target)?; } } else { quote! { inner.serialize(target)?;} ...
code_fim
hard
{ "lang": "rust", "repo": "preston-evans98/bitcoin-warp", "path": "/serde_derive/src/serialize.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Fangzhou-Lu/distributary path: /dataflow/src/prelude.rs use petgraph; use std::cell; // core types pub use basics::*; pub use ops::NodeOperator; pub use processing::Ingredient; pub(crate) use processing::{Miss, ProcessingResult, RawProcessingResult, ReplayContext}; // graph types pub use node:...
code_fim
hard
{ "lang": "rust", "repo": "Fangzhou-Lu/distributary", "path": "/dataflow/src/prelude.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// domain local state pub use state::{LookupResult, MemoryState, PersistentState, RecordResult, Row, State}; pub type StateMap = map::Map<Box<State>>; pub type DomainNodes = Map<cell::RefCell<Node>>; pub type ReplicaAddr = (DomainIndex, usize); // persistence configuration pub use DurabilityMode; pub use...
code_fim
hard
{ "lang": "rust", "repo": "Fangzhou-Lu/distributary", "path": "/dataflow/src/prelude.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tower-rs/tower-http path: /tower-http/src/trace/future.rs use super::{OnBodyChunk, OnEos, OnFailure, OnResponse, ResponseBody}; use crate::classify::{ClassifiedResponse, ClassifyResponse}; use http::Response; use http_body::Body; use pin_project_lite::pin_project; use std::{ future::Future, ...
code_fim
hard
{ "lang": "rust", "repo": "tower-rs/tower-http", "path": "/tower-http/src/trace/future.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Poll::Ready(Ok(res)) } ClassifiedResponse::RequiresEos(classify_eos) => { let span = this.span.clone(); let res = res.map(|body| ResponseBody { inner: body, ...
code_fim
hard
{ "lang": "rust", "repo": "tower-rs/tower-http", "path": "/tower-http/src/trace/future.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /rt/nsITreeSelection.rs le type and any /// struct containing it is not safe to send across threads, as XPCOM is /// generally not threadsafe. /// /// XPCOM interfaces in general are not safe to send across threads. __nosync: ::std::marker::Phan...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/rt/nsITreeSelection.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /* void adjustSelection (in long index, in long count); */ pub adjustSelection: unsafe extern "C" fn (this: *const nsITreeSelection, index: libc::int32_t, count: libc::int32_t) -> nsresult, /* attribute boolean selectEventsSuppressed; */ pub get_selectEventsSuppressed: unsafe extern "C" f...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/rt/nsITreeSelection.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /rt/nsITreeSelection.rs able: *const nsITreeSelectionVTable, /// This field is a phantomdata to ensure that the VTable type and any /// struct containing it is not safe to send across threads, as XPCOM is /// generally not threadsafe. /// /// X...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/rt/nsITreeSelection.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub mod s32 { include!(concat!(env!("OUT_DIR"), "/func_fsm_32.rs")); }<|fim_prefix|>// repo: newpavlov/fsm-bench path: /src/func_fsm.rs pub mod s4 { include!(concat!(env!("OUT_DIR"), "/func_fsm_4.rs")); } <|fim_middle|>pub mod s8 { include!(concat!(env!("OUT_DIR"), "/func_fsm_8.rs")); } pub...
code_fim
medium
{ "lang": "rust", "repo": "newpavlov/fsm-bench", "path": "/src/func_fsm.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: newpavlov/fsm-bench path: /src/func_fsm.rs pub mod s4 { include!(concat!(env!("OUT_DIR"), "/func_fsm_4.rs")); } pub mod s8 { include!(concat!(env!("OUT_DIR"), "/func_fsm_8.rs")); } <|fim_suffix|>pub mod s32 { include!(concat!(env!("OUT_DIR"), "/func_fsm_32.rs")); }<|fim_middle|>pub...
code_fim
medium
{ "lang": "rust", "repo": "newpavlov/fsm-bench", "path": "/src/func_fsm.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub mod s16 { include!(concat!(env!("OUT_DIR"), "/func_fsm_16.rs")); } pub mod s32 { include!(concat!(env!("OUT_DIR"), "/func_fsm_32.rs")); }<|fim_prefix|>// repo: newpavlov/fsm-bench path: /src/func_fsm.rs pub mod s4 { include!(concat!(env!("OUT_DIR"), "/func_fsm_4.rs")); } <|fim_middle|>p...
code_fim
medium
{ "lang": "rust", "repo": "newpavlov/fsm-bench", "path": "/src/func_fsm.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let dsorted = external_distribution_sort(&*l); l.sort_unstable(); assert!(l == dsorted); } macro_rules! bench { ($name:ident, $array:expr) => { #[bench] fn $name (b: &mut Bencher) { b.iter(|| external_distribution_sort(&*$array)); ...
code_fim
medium
{ "lang": "rust", "repo": "JustAPerson/rads", "path": "/src/sort/distribution.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JustAPerson/rads path: /src/sort/distribution.rs use util::random_samples; const M: usize = 4096; const B: usize = 64; const sMB: usize = 8; // sqrt(M/B) fn external_distribution_sort<T: Clone+Ord>(array: &[T]) -> Vec<T> { if array.len() <= M { let mut array = array.to_vec(); ...
code_fim
medium
{ "lang": "rust", "repo": "JustAPerson/rads", "path": "/src/sort/distribution.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let cfg = LocalConfig::default(); let mut env = EnvVars::new(); env.insert( "TEST_ENV_VAR".into(), "This is environment variable content ".into(), ); let log = OutputLog::new(); let script = SourceRef::Source( r#" ...
code_fim
hard
{ "lang": "rust", "repo": "opereon/opereon", "path": "/op-core/src/ops/command/local.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: opereon/opereon path: /op-core/src/ops/command/local.rs use crate::ops::SpawnableCommand; use crate::outcome::Outcome; use crate::utils::SharedChildExt; use async_trait::*; use op_engine::operation::OperationResult; use op_engine::{EngineRef, OperationImpl, OperationRef}; use op_exec::command::l...
code_fim
hard
{ "lang": "rust", "repo": "opereon/opereon", "path": "/op-core/src/ops/command/local.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> echo 'Printing to stderr...' echo 'This should go to stderr' >&2 echo 'printing arguments...' echo $@ echo $1 echo $2 echo "listing files..." ls -al echo 'Printing $TEST_ENV_VAR ...' echo $TEST_ENV_VAR exit 2 ...
code_fim
hard
{ "lang": "rust", "repo": "opereon/opereon", "path": "/op-core/src/ops/command/local.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: XuShaohua/nc path: /src/calls/readahead.rs /// Initialize file head into page cache. /// /// # Example /// /// ``` /// let path = "/etc/passwd"; /// let ret = unsafe { nc::openat(nc:<|fim_suffix|> /// let ret = unsafe { nc::close(fd) }; /// assert!(ret.is_ok()); /// ``` pub unsafe fn readahead(f...
code_fim
medium
{ "lang": "rust", "repo": "XuShaohua/nc", "path": "/src/calls/readahead.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// let ret = unsafe { nc::close(fd) }; /// assert!(ret.is_ok()); /// ``` pub unsafe fn readahead(fd: i32, offset: off_t, count: size_t) -> Result<(), Errno> { let fd = fd as usize; let offset = offset as usize; syscall3(SYS_READAHEAD, fd, offset, count).map(drop) }<|fim_prefix|>// repo: XuSh...
code_fim
medium
{ "lang": "rust", "repo": "XuShaohua/nc", "path": "/src/calls/readahead.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>> Result<(), Errno> { let fd = fd as usize; let offset = offset as usize; syscall3(SYS_READAHEAD, fd, offset, count).map(drop) }<|fim_prefix|>// repo: XuShaohua/nc path: /src/calls/readahead.rs /// Initialize file head into page cache. /// /// # Example /// /// ``` /// let path = "/etc/passwd...
code_fim
medium
{ "lang": "rust", "repo": "XuShaohua/nc", "path": "/src/calls/readahead.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] #[should_panic = "Missing `type`"] fn test_missing_type_() { let _: Service = ServiceBuilder::default() .id("did:example:123".parse().unwrap()) .service_endpoint("https://example.com".parse().unwrap()) .build() .unwrap(); } #[test] #[should_panic = "Missing...
code_fim
hard
{ "lang": "rust", "repo": "l1h3r/did_doc", "path": "/src/service/service_builder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: l1h3r/did_doc path: /src/service/service_builder.rs use did_url::DID; use url::Url; use crate::error::Result; use crate::lib::*; use crate::service::Service; use crate::utils::Object; use crate::utils::Value; /// A `ServiceBuilder` is used to generate a customized `Service`. #[derive(Clone, De...
code_fim
hard
{ "lang": "rust", "repo": "l1h3r/did_doc", "path": "/src/service/service_builder.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[bench] fn dct4_even_via_dct3_1000000(b: &mut Bencher) { bench_dct4_via_dct3(b, 1000000); } /// Times just the DCT4 execution (not allocation and pre-calculation) /// for a given length fn bench_dct4_via_fft_odd(b: &mut Bencher, len: usize) { let mut planner = FFTplanner::new(false); let i...
code_fim
hard
{ "lang": "rust", "repo": "abonander/rust_dct", "path": "/benches/bench_dct_via_fft.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> bench_dct2_split(b, 4); } #[bench] fn dct2_power2_split_0008(b: &mut Bencher) { bench_dct2_split(b, 4); } #[bench] fn dct2_power2_split_0016(b: &mut Bencher) { bench_dct2_split(b, 16); } #[bench] fn dct2_power2_split_0064(b: &mut Bencher) { bench_dct2_split(b, 64); } #[bench] fn dct2_power...
code_fim
hard
{ "lang": "rust", "repo": "abonander/rust_dct", "path": "/benches/bench_dct_via_fft.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abonander/rust_dct path: /benches/bench_dct_via_fft.rs #![feature(test)] extern crate test; extern crate rustdct; use std::sync::Arc; use rustdct::rustfft::FFTplanner; use rustdct::DCTplanner; use rustdct::{DCT1, DCT2, DCT3, DCT4, TransformType2And3}; use rustdct::algorithm::*; use rustdct::al...
code_fim
hard
{ "lang": "rust", "repo": "abonander/rust_dct", "path": "/benches/bench_dct_via_fft.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let (e, amount) = (1, 2); let data = vec![ Datom::add(1, ":amount", Number(5)), Datom::add(2, ":amount", Number(10)), Datom::add(2, ":amount", Number(10)), Datom::add(1, ":amount", Number(2)), Datom::add(1, ":amount", Number(4)), Datom::add(1, ":amou...
code_fim
hard
{ "lang": "rust", "repo": "cjsauer/declarative-dataflow", "path": "/tests/aggregation_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cjsauer/declarative-dataflow path: /tests/aggregation_test.rs [:find ?e (count ?amount) :where [?e :amount ?amount]]", plan: Plan::Aggregate(Aggregate { variables: vec![e, amount], plan: Box::new(Plan::match_a(e, ":amount", amount)), ag...
code_fim
hard
{ "lang": "rust", "repo": "cjsauer/declarative-dataflow", "path": "/tests/aggregation_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn median() { let (e, amount) = (1, 2); let data = vec![ Datom::add(1, ":amount", Number(5)), Datom::add(2, ":amount", Number(10)), Datom::add(2, ":amount", Number(10)), Datom::add(1, ":amount", Number(2)), Datom::add(1, ":amount", Number(4)), ...
code_fim
hard
{ "lang": "rust", "repo": "cjsauer/declarative-dataflow", "path": "/tests/aggregation_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let sudoku = simulation_builder::SimulationBuilder::<Sudoku>::new() .fitness(0.0) .threads(2) .add_population(population1) .add_population(population2) .finalize(); match sudoku { Err(simulation_builder::Error::EndIterationTooLow) => println!("more ...
code_fim
hard
{ "lang": "rust", "repo": "rphmeier/darwin-rs", "path": "/examples/sudoku/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // pick free (= not pre set) position while self.original[index] != 0 { index = rng.gen_range(0, self.original.len()); } // and set it to a random value self.solved[index] = rng.gen_range(1, 10); } // fitness means here: how many errors fn ...
code_fim
hard
{ "lang": "rust", "repo": "rphmeier/darwin-rs", "path": "/examples/sudoku/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rphmeier/darwin-rs path: /examples/sudoku/src/main.rs // This example implements a sudoku solver: // https://en.wikipedia.org/wiki/Sudoku // using an evolutionary algorithm. extern crate rand; // internal crates extern crate darwin_rs; use rand::Rng; // internal modules use darwin_rs::indivi...
code_fim
hard
{ "lang": "rust", "repo": "rphmeier/darwin-rs", "path": "/examples/sudoku/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_interrupt_mask<SpiBus: Bus>( &self, bus: &mut SpiBus, mask: u8, ) -> Result<(), SpiBus::Error> { let data = [mask]; bus.write_frame(self.register(), socketn::INTERRUPT_MASK, &data)?; Ok(()) } pub fn command<SpiBus: Bus>( &...
code_fim
hard
{ "lang": "rust", "repo": "jonahbron/w5500", "path": "/src/socket.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonahbron/w5500 path: /src/socket.rs use crate::bus::Bus; use crate::register::socketn; use embedded_nal::Ipv4Addr; pub struct Socket { pub index: u8, register: u8, tx_buffer: u8, rx_buffer: u8, } impl Socket { pub fn new(index: u8) -> Self { /* * Socket 0 ...
code_fim
hard
{ "lang": "rust", "repo": "jonahbron/w5500", "path": "/src/socket.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_tx_read_pointer<SpiBus: Bus>( &self, bus: &mut SpiBus, pointer: u16, ) -> Result<(), SpiBus::Error> { let data = pointer.to_be_bytes(); bus.write_frame(self.register(), socketn::TX_DATA_READ_POINTER, &data)?; Ok(()) } pub fn get_t...
code_fim
hard
{ "lang": "rust", "repo": "jonahbron/w5500", "path": "/src/socket.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Jonesey13/generic_game path: /src/rendering/primitives/circle_part/mod.rs use crate::rendering::*; use crate::geometry::*; use glium; #[derive(Copy, Clone, Debug)] pub struct CirclePart { pub radial_dim: Point, pub angular_dim: Point, pub pos: Point3, pub color: Color, pub f...
code_fim
hard
{ "lang": "rust", "repo": "Jonesey13/generic_game", "path": "/src/rendering/primitives/circle_part/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl From<CirclePart> for CircleVertex { fn from(circ: CirclePart) -> Self { CircleVertex { radial_dim: circ.radial_dim.into(), angular_dim: circ.angular_dim.into(), pos: circ.pos.into(), color: circ.color.get_array_f32(), fixed_pos: ...
code_fim
hard
{ "lang": "rust", "repo": "Jonesey13/generic_game", "path": "/src/rendering/primitives/circle_part/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Smephite/aoc2020 path: /src/day05.rs use aoc_runner_derive::{aoc, aoc_generator}; use std::iter::FromIterator; #[aoc_generator(day5, part1)] #[aoc_generator(day5, part2)] fn parse_passes(input: &str) -> Vec<usize> { input.lines().map(|l| pass_id(l)).collect() } #[aoc_generator(day5, part2,...
code_fim
hard
{ "lang": "rust", "repo": "Smephite/aoc2020", "path": "/src/day05.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( parse_passes("BFFFBBFRRR\nFFFBBBFRRR\nBBFFBBFRLL"), parse_passes2("BFFFBBFRRR\nFFFBBBFRRR\nBBFFBBFRLL") ); } #[test] fn part1_test() { assert_eq!(part1(&parse_passes("BFFFBBFRRR")), Some(567)); assert_eq!(part1(&parse_passes(...
code_fim
hard
{ "lang": "rust", "repo": "Smephite/aoc2020", "path": "/src/day05.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!( "-- Registering service {:?} on corpus at {:?} ...", &service_name, &corpus_path ); let backend = Backend::default(); let service_registered_result = Service::find_by_name(&service_name, &backend.connection); assert!(service_registered_result.is_ok()); let service_registered ...
code_fim
hard
{ "lang": "rust", "repo": "dginev/CorTeX", "path": "/examples/register_service.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dginev/CorTeX path: /examples/register_service.rs // Copyright 2015-2018 Deyan Ginev. See the LICENSE // file at the top-level directory of this distribution. // // Licensed under the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>. // This file may not be copied, modified, or di...
code_fim
hard
{ "lang": "rust", "repo": "dginev/CorTeX", "path": "/examples/register_service.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spytheman/Rocket path: /examples/raw_sqlite/src/main.rs #![feature(plugin)] #![plugin(rocket_codegen)] extern crate rocket; extern crate rusqlite; #[cfg(test)] mod tests; use std::sync::Mutex; use rocket::{Rocket, State}; use rusqlite::{Connection, Error}; <|fim_suffix|> conn.execute("INS...
code_fim
hard
{ "lang": "rust", "repo": "spytheman/Rocket", "path": "/examples/raw_sqlite/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn rocket() -> Rocket { // Open a new in-memory SQLite database. let conn = Connection::open_in_memory().expect("in memory db"); // Initialize the `entries` table in the in-memory database. init_database(&conn); // Have Rocket manage the database pool. rocket::ignite() .m...
code_fim
hard
{ "lang": "rust", "repo": "spytheman/Rocket", "path": "/examples/raw_sqlite/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialicons/action/icon_unpublished.rs pub struct IconUnpublished { props: crate::Props, } impl yew::Component for IconUnpublished { type Properties = crate::Props; type Message = (); fn create(props: Self::Properties, _: yew::prelude:...
code_fim
hard
{ "lang": "rust", "repo": "andoriyu/material-design-icons-rs", "path": "/src/materialicons/action/icon_unpublished.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn next(&mut self) -> Option<Self::Item> { // The terms of the sequence are defined as: // v[i] = value + alpha*i + beta if self.position == self.num { None } else { let r = self.value + (self.direction * self.position as f64 + self.offset); ...
code_fim
hard
{ "lang": "rust", "repo": "sitegui/fast-quantiles", "path": "/src/quantile_generator/sequential.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sitegui/fast-quantiles path: /src/quantile_generator/sequential.rs //! An iterator over an ordered sequence of floats use ordered_float::NotNan; use crate::quantile_to_rank; use std::iter::{ExactSizeIterator, FusedIterator}; use super::QuantileGenerator; /// An iterator that will generate sequ...
code_fim
hard
{ "lang": "rust", "repo": "sitegui/fast-quantiles", "path": "/src/quantile_generator/sequential.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: harpsword/tex-rs path: /src/tex_the_program/section_0529.rs //! @ Here is a routine that manufactures the output file names, assuming that //! |job_name<>0|. It ignores and changes the current settings of |cur_area| //! and |cur_ext|. // // @d pack_cur_name==pack_file_name(cur_name,cur_area,cur_...
code_fim
hard
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0529.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>use crate::section_0004::TeXGlobals; use crate::section_0038::str_number; use crate::section_0519::pack_file_name;<|fim_prefix|>// repo: harpsword/tex-rs path: /src/tex_the_program/section_0529.rs //! @ Here is a routine that manufactures the output file names, assuming that //! |job_name<>0|. It ignores...
code_fim
hard
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0529.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mitsuhiko/elementtree-rust path: /src/xml/util.rs use std::fmt; use std::io::{self, Read}; use std::str; #[derive(Debug)] pub enum CharReadError { UnexpectedEof, Utf8(str::Utf8Error), Io(io::Error), } impl From<str::Utf8Error> for CharReadError { fn from(e: str::Utf8Error) -> C...
code_fim
hard
{ "lang": "rust", "repo": "mitsuhiko/elementtree-rust", "path": "/src/xml/util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut bytes: &[u8] = "правильно".as_bytes(); // correct BMP assert_eq!(super::next_char_from(&mut bytes).unwrap(), Some('п')); let mut bytes: &[u8] = "😊".as_bytes(); // correct non-BMP assert_eq!(super::next_char_from(&mut bytes).unwrap(), Some('😊')); let mut ...
code_fim
hard
{ "lang": "rust", "repo": "mitsuhiko/elementtree-rust", "path": "/src/xml/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut bytes: &[u8] = b"\xff\x9f\x98\x32"; // invalid code point match super::next_char_from(&mut bytes).unwrap_err() { super::CharReadError::Utf8(_) => {} e => panic!("Unexpected result: {:?}", e), }; // error during read struct ErrorReade...
code_fim
hard
{ "lang": "rust", "repo": "mitsuhiko/elementtree-rust", "path": "/src/xml/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CoreRC/rcgenmsg path: /src/main.rs use std::error::Error; use std::fs::File; use std::io::prelude::*; use std::path::Path; //use std::env; extern crate argparse; extern crate crypto; extern crate regex; use argparse::{ArgumentParser, Store, StoreTrue}; extern crate handlebars; extern crate i...
code_fim
hard
{ "lang": "rust", "repo": "CoreRC/rcgenmsg", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> *f.pointer_mut("/typ").unwrap() = type_mapping(ftype).into(); } f.as_object_mut() .unwrap() .insert("id".to_string(), i.into()); i += 1; } } if json_data.get("consts").is_some() { let mut i: i64 =...
code_fim
hard
{ "lang": "rust", "repo": "CoreRC/rcgenmsg", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let mut verbose = false; let mut filename = "".to_string(); let mut namespace = "".to_string(); { // this block limits scope of borrows by ap.refer() method let mut ap = ArgumentParser::new(); ap.set_description("ROS Message Transpiler."); ap.ref...
code_fim
hard
{ "lang": "rust", "repo": "CoreRC/rcgenmsg", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: extrawurst/azure-sdk-for-rust path: /services/mgmt/servicefabricmesh/src/package_2018_07_01_preview/operations.rs _value, } .fail() } } } pub mod list { use crate::{models, models::*}; use reqwest::StatusCode; us...
code_fim
hard
{ "lang": "rust", "repo": "extrawurst/azure-sdk-for-rust", "path": "/services/mgmt/servicefabricmesh/src/package_2018_07_01_preview/operations.rs", "mode": "psm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_suffix|> let body: bytes::Bytes = rsp.bytes().await.context(get::ResponseBytesError)?; let rsp_value: ErrorModel = serde_json::from_slice(&body).context(get::DeserializeError { body })?; get::DefaultResponse { status_code, value: rsp_val...
code_fim
hard
{ "lang": "rust", "repo": "extrawurst/azure-sdk-for-rust", "path": "/services/mgmt/servicefabricmesh/src/package_2018_07_01_preview/operations.rs", "mode": "spm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_suffix|>use crate::front_of_house::hosting; // The following is also valid: // use front_of_house::hosting; pub fn eat_at_restaurant() { // Absolute path crate::front_of_house::hosting::add_to_wishlist(); // Relative path front_of_house::hosting::add_to_wishlist(); // Using `use` import abo...
code_fim
hard
{ "lang": "rust", "repo": "jbduncan/rust-book", "path": "/restaurant_lib/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jbduncan/rust-book path: /restaurant_lib/src/lib.rs use std::collections::HashMap; // mod front_of_house { // pub mod hosting { // pub fn add_to_wishlist() {} // fn seat_at_table() {} // } // pub mod serving { // fn take_order() {} // pub fn serve_...
code_fim
hard
{ "lang": "rust", "repo": "jbduncan/rust-book", "path": "/restaurant_lib/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> { // What if our `use` list ends up quite long? // // use std::io; // use std::cmp::Ordering; // --snip-- // // Well, we can then use nested paths: use std::{cmp::Ordering, io}; } { // What if we want to bring both `std:...
code_fim
hard
{ "lang": "rust", "repo": "jbduncan/rust-book", "path": "/restaurant_lib/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>{ // `/**/` may match a single slash. assert!(pathmatch("foo/**/bar", "foo/bar")); assert!(pathmatch("foo/**/", "foo/")); assert!(!pathmatch("foo/**/", "foo")); assert!(pathmatch("/**/bar", "/bar")); assert!(!pathmatch("/**/bar", "bar")); // to prevent this behavior, you would ...
code_fim
hard
{ "lang": "rust", "repo": "brmmm3/pathmatch", "path": "/src/pathmatch.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brmmm3/pathmatch path: /src/pathmatch.rs use std::clone::Clone; macro_rules! return_if_some { ($arg:expr) => ( match $arg { Some(val) => return val, None => {}, } ); } pub fn pathmatch(pattern: &str, pathstring: &str) -> bool { use std::str::...
code_fim
hard
{ "lang": "rust", "repo": "brmmm3/pathmatch", "path": "/src/pathmatch.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PSeitz/quickcalc path: /src/main.rs use iced::Command; use iced::Application; use iced::Subscription; use calculator::parse; use iced::{executor, text_input, Align, Column, TextInput, Element, Settings, Text}; fn main() { std::env::set_var("FONTCONFIG_FILE", "/etc/fonts"); Counter::run(...
code_fim
hard
{ "lang": "rust", "repo": "PSeitz/quickcalc", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Application for Counter { type Message = Message; type Executor = executor::Default; type Flags = (); fn new(_flags: ()) -> (Self, Command<Self::Message>) { (Self::default(), Command::none()) } fn title(&self) -> String { String::from("QuickCalc") } ...
code_fim
hard
{ "lang": "rust", "repo": "PSeitz/quickcalc", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn call_id_3() { id(return) && id(return); } pub fn main() { }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/unreachable-code-1.rs #![allow(unused_must_use)] #![allow(unreachable_code)] #![allow(unused_variables)] #![allow(dead_code)] fn id(x: bool) -> bool { x } <|fim...
code_fim
easy
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/run-pass/unreachable-code-1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/unreachable-code-1.rs #![allow(unused_must_use)] #![allow(unreachable_code)] <|fim_suffix|> let c = panic!(); id(c); } fn call_id_3() { id(return) && id(return); } pub fn main() { }<|fim_middle|>#![allow(unused_variables)] #![all...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/run-pass/unreachable-code-1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn remove_padding(folder: &str) -> &str { // pass ref to str immutably folder.trim_start_matches('0') }<|fim_prefix|>// repo: szhongren/leetcode path: /rename_folders.rs use std::env; use std::fs::{read_dir, rename}; use std::path::PathBuf; fn main() -> std::io::Result<()> { <|fim_middle|> let cu...
code_fim
hard
{ "lang": "rust", "repo": "szhongren/leetcode", "path": "/rename_folders.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }