text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: usamec/cntk-rs path: /src/axis.rs cpp! {{ #include <CNTKLibrary.h> #include <cstdio> #include <vector> using namespace CNTK; using namespace std; }} pub(super) type AxisInner = [u64; 6usize]; pub struct Axis { pub(super) payload: AxisInner } impl Axis { pub fn all() -> Axis...
code_fim
hard
{ "lang": "rust", "repo": "usamec/cntk-rs", "path": "/src/axis.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 38/d4-format path: /d4/src/stab/sparse_array/record.rs /// The trait that describes a single record in the Key-Value sparse table pub trait Record: Sized + Copy + Send + 'static { /// An ID used by the metadata for this record format const FORMAT_NAME: &'static str; /// The size of t...
code_fim
hard
{ "lang": "rust", "repo": "38/d4-format", "path": "/d4/src/stab/sparse_array/record.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (left, right) = self.effective_range(); new_left = left.max(new_left); if new_left >= right { None } else { Some(Self { left: (new_left + 1), size_enc: ((right - new_left - 1) as u16).to_le(), value...
code_fim
hard
{ "lang": "rust", "repo": "38/d4-format", "path": "/d4/src/stab/sparse_array/record.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ehuss/test path: /gfetch/src/main.rs use std::path::Path; use anyhow::*; fn main() { if let Err(e) = doit() { eprintln!("{:?}", e); std::process::exit(1); } } fn doit() -> Result<(), Error> { <|fim_suffix|> let mut cmd = std::process::Command::new("git"); cmd.arg...
code_fim
medium
{ "lang": "rust", "repo": "ehuss/test", "path": "/gfetch/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut cmd = std::process::Command::new("git"); cmd.arg("fetch"); cmd.arg("--force") // handle force pushes .arg("--update-head-ok") // see discussion in #2078 .arg("https://github.com/rust-lang/crates.io-index") .arg("HEAD:refs/remotes/origin/HEAD") // If carg...
code_fim
hard
{ "lang": "rust", "repo": "ehuss/test", "path": "/gfetch/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> mod test_restack; mod test_smartlog; mod test_undo; }<|fim_prefix|>// repo: PiDelport/git-branchless path: /tests/mod.rs mod util; mod core { mod test_eventlog; mod test_gc; mod test_hooks; } mod command { mod test_hide; m<|fim_middle|>od test_init; mod test_move; m...
code_fim
medium
{ "lang": "rust", "repo": "PiDelport/git-branchless", "path": "/tests/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PiDelport/git-branchless path: /tests/mod.rs mod util; mod core { mod test_eventlog; mod test_gc; mod test_hooks; } mod command { mod test_hide; m<|fim_suffix|> mod test_restack; mod test_smartlog; mod test_undo; }<|fim_middle|>od test_init; mod test_move; m...
code_fim
medium
{ "lang": "rust", "repo": "PiDelport/git-branchless", "path": "/tests/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PriTanir/adder1 path: /src/asm.rs /* * This file contains the type of our assembly instructions, their * arguments, register etc. */ #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Reg { Rax, Rsp, } #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct MemRef { pub reg:...
code_fim
hard
{ "lang": "rust", "repo": "PriTanir/adder1", "path": "/src/asm.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn instr_to_string(i: Instr) -> String { match i { Instr::Mov(args) => { format!(" mov {}", mov_args_to_string(args)) } Instr::Add(args) => { format!(" add {}", bin_args_to_string(args)) } Instr::Sub(args) => { ...
code_fim
hard
{ "lang": "rust", "repo": "PriTanir/adder1", "path": "/src/asm.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DanaL/AdventOfCode path: /2019/src/day_eleven.rs use std::fs; use std::i32; use std::collections::HashMap; use crate::intcode_vm; #[derive(Debug)] enum Dir { N, S, E, W, } #[derive(Debug)] struct Bot { sqs_painted: HashMap<(i32, i32), char>, dir: Dir, loc: (i32, i32), } impl Bot { pub...
code_fim
hard
{ "lang": "rust", "repo": "DanaL/AdventOfCode", "path": "/2019/src/day_eleven.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { vm.run(); match vm.state { intcode_vm::VMState::Halted => break, _ => { bot.paint(vm.output_buffer); vm.run(); bot.do_move(vm.output_buffer); vm.write_to_buff(bot.curr_panel()); } } } println!("Sqs painted: {}", bot.total_painted()); if print { bot.print_art(...
code_fim
hard
{ "lang": "rust", "repo": "DanaL/AdventOfCode", "path": "/2019/src/day_eleven.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: klbarrus/adventofcode2020 path: /aoc-08/src/main.rs // Advent of Code 2020 Day 08 use aoclib; use itertools::Itertools; use std::collections::HashSet; use std::io; fn run_prog( prog_data: &Vec<(&str, i64)>, start_inst: usize, error_inst: Option<usize>, ) -> (bool, i64) { let mu...
code_fim
hard
{ "lang": "rust", "repo": "klbarrus/adventofcode2020", "path": "/aoc-08/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match curr_op { "acc" => { acc_val += curr_val; curr_inst += 1; } "jmp" => { if curr_val >= 0 { curr_inst += curr_val as usize; } else { curr_inst -= curr_val...
code_fim
hard
{ "lang": "rust", "repo": "klbarrus/adventofcode2020", "path": "/aoc-08/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yohandev/voxels path: /ezgfx/src/bind/mod.rs mod uniform; mod texture; mod sampler; mod group; pub use uniform::*; pub use texture::*; pub use sampler::*; pub use group::*; <|fim_suffix|> /// get the actual wgpu resource for self. fn resource(&self) -> wgpu::BindingResource; }<|fim_midd...
code_fim
hard
{ "lang": "rust", "repo": "yohandev/voxels", "path": "/ezgfx/src/bind/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// get the actual wgpu resource for self. fn resource(&self) -> wgpu::BindingResource; }<|fim_prefix|>// repo: yohandev/voxels path: /ezgfx/src/bind/mod.rs mod uniform; mod texture; mod sampler; mod group; pub use uniform::*; pub use texture::*; pub use sampler::*; pub use group::*; <|fim_mid...
code_fim
hard
{ "lang": "rust", "repo": "yohandev/voxels", "path": "/ezgfx/src/bind/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// get the actual wgpu resource for self. fn resource(&self) -> wgpu::BindingResource; }<|fim_prefix|>// repo: yohandev/voxels path: /ezgfx/src/bind/mod.rs mod uniform; mod texture; mod sampler; mod group; pub use uniform::*; pub use texture::*; pub use sampler::*; pub use group::*; <|fim_midd...
code_fim
hard
{ "lang": "rust", "repo": "yohandev/voxels", "path": "/ezgfx/src/bind/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KlasafGeijerstam/Kattis path: /rust/bokforing.rs mod fast_input; use fast_input::{FastInput}; use std::io::{Write, BufWriter, stdout}; fn main() { let stdout = stdout(); let mut w = BufWriter::new(stdout.lock()); let inp = FastInput::new(); let (n, q) = inp.next_tuple(); let...
code_fim
hard
{ "lang": "rust", "repo": "KlasafGeijerstam/Kattis", "path": "/rust/bokforing.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> { writeln!(w, "{}", people[person - 1].0).ok(); } else { writeln!(w, "{}", reset_amount).ok(); } } else { reset_amount = i.next().unwrap().parse().unwrap(); reset_time = time; } } }<|fim_prefix|>// repo: ...
code_fim
hard
{ "lang": "rust", "repo": "KlasafGeijerstam/Kattis", "path": "/rust/bokforing.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: idangws/try-rust path: /src/into.rs struct Person { name: String } impl Person { // fn new(name: &str) -> Person { // Person { name: name.to_string() } // } // fn new<S: Into<String>>(name: S) -> Person { // Person { name: name.into()} // } fn new<S>(nam...
code_fim
medium
{ "lang": "rust", "repo": "idangws/try-rust", "path": "/src/into.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let name = "Jane".to_string(); let _jane = Person::new(name/*.as_ref()*/); }<|fim_prefix|>// repo: idangws/try-rust path: /src/into.rs struct Person { name: String } impl Person { // fn new(name: &str) -> Person { // Person { name: name.to_string() } // } // fn new<S: I...
code_fim
medium
{ "lang": "rust", "repo": "idangws/try-rust", "path": "/src/into.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/swindon path: /src/config/read.rs use std::cell::RefCell; use std::collections::HashMap; use std::fmt; use std::fs::{File, Metadata, metadata}; use std::io::{self, Read}; use std::path::{PathBuf, Path, Component}; use std::rc::Rc; use std::sync::Arc; use quire::{self, Pos, Include, Erro...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/swindon", "path": "/src/config/read.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> handlers: src.handlers, authorizers: src.authorizers, session_pools: src.session_pools, http_destinations: src.http_destinations, ldap_destinations: src.ldap_destinations, networks: src.networks, log_formats: src.log_formats, disk_pools: src....
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/swindon", "path": "/src/config/read.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Telixia/leetcode-3 path: /Medium/1328-Break a Palindrome/Solution.rs impl Solution { pub fn break_palindrome(palindrome: String) -> String { if palindrome.len() == 1 { return String::new(); } let mut palindrome = palindrome.into_bytes(); for i in...
code_fim
hard
{ "lang": "rust", "repo": "Telixia/leetcode-3", "path": "/Medium/1328-Break a Palindrome/Solution.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> String::from_utf8(palindrome).unwrap() } }<|fim_prefix|>// repo: Telixia/leetcode-3 path: /Medium/1328-Break a Palindrome/Solution.rs impl Solution { pub fn break_palindrome(palindrome: String) -> String { if palindrome.len() == 1 { return String::new(); } <|f...
code_fim
hard
{ "lang": "rust", "repo": "Telixia/leetcode-3", "path": "/Medium/1328-Break a Palindrome/Solution.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sonos/tract path: /core/src/ops/einsum/eval.rs use super::AxesMapping; use crate::internal::*; use tract_data::itertools::Itertools; use tract_linalg::Scaler; use tract_ndarray::{Axis, Dimension}; use tract_num_traits::{One, Zero}; pub fn output_shape<D: DimLike>(expr: &AxesMapping, inputs: &[&...
code_fim
hard
{ "lang": "rust", "repo": "sonos/tract", "path": "/core/src/ops/einsum/eval.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if bias.rank() == 0 { output += inputs[2].cast_to_scalar::<i32>()?; } else { let mut bias_shape = tvec!(1; output.ndim()); bias_shape[expr.axis((InOut::In(2), 0))?.outputs[0][0]] = bias.len(); let bias = bias.to_array_view::<i32>()?.into_shape(&*bias_shape)?; ...
code_fim
hard
{ "lang": "rust", "repo": "sonos/tract", "path": "/core/src/ops/einsum/eval.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: khusseini/xersize-rust-git2 path: /src/stupiddb/models.rs use serde::Deserialize; use serde::Serialize; use validator::Validate; #[derive(Deserialize, Serialize, Debug, Validate)] pub struct StupidDbRepositoryConfig { #[validate(regex = "crate::stupiddb::regex::NAME")] pub name: String,...
code_fim
medium
{ "lang": "rust", "repo": "khusseini/xersize-rust-git2", "path": "/src/stupiddb/models.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Serialize, Deserialize)] pub struct StupidConfig { pub root_dir: String, } impl ::std::default::Default for StupidConfig { fn default() -> Self { Self { root_dir: "/var/lib/stupiddb/".into(), } } } pub struct StupidEntry { pub entry: git2::IndexEntry, ...
code_fim
hard
{ "lang": "rust", "repo": "khusseini/xersize-rust-git2", "path": "/src/stupiddb/models.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_iterator_multiline() { let iterator = RawConnections::new(String::from(FULL_RAW_OUTPUT)); let connections: Vec<RawConnection> = iterator.collect(); assert_eq!(connections.len(), 4); } #[test] fn test_iterator() { let iterator = RawConnec...
code_fim
hard
{ "lang": "rust", "repo": "novemberde/bandwhich", "path": "/src/os/lsof_utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: novemberde/bandwhich path: /src/os/lsof_utils.rs use crate::network::Protocol; use lazy_static::lazy_static; use regex::Regex; use std::ffi::OsStr; use std::net::IpAddr; use std::process::Command; #[derive(Debug, Clone)] pub struct RawConnection { ip: String, local_port: String, rem...
code_fim
hard
{ "lang": "rust", "repo": "novemberde/bandwhich", "path": "/src/os/lsof_utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self::none() } } #[derive(Copy, Clone)] pub struct IrqStatus { inner: u16, } impl From<u16> for IrqStatus { fn from(status: u16) -> Self { Self { inner: status } } } impl core::fmt::Debug for IrqStatus { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::R...
code_fim
hard
{ "lang": "rust", "repo": "lupyuen/sx126x-rs-nuttx", "path": "/src/op/irq.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lupyuen/sx126x-rs-nuttx path: /src/op/irq.rs #[repr(u16)] #[derive(Copy, Clone)] pub enum IrqMaskBit { None = 0x0000, TxDone = 1 << 0, RxDone = 1 << 1, PreambleDetected = 1 << 2, SyncwordValid = 1 << 3, HeaderValid = 1 << 4, HeaderError = 1 << 5, CrcErr = 1 << 6, ...
code_fim
hard
{ "lang": "rust", "repo": "lupyuen/sx126x-rs-nuttx", "path": "/src/op/irq.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let path = builder.build(); let mut glyph_mesh: Mesh = Mesh::new(); let mut tessellator = FillTessellator::new(); tessellator .tessellate_path( path.path_iter(), &FillOptions::tolerance(0.005).with_nor...
code_fim
hard
{ "lang": "rust", "repo": "CryZe/livesplit-rendering", "path": "/src/glyph_cache.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CryZe/livesplit-rendering path: /src/glyph_cache.rs use lyon::{ path::{builder::*, default::Path, math::point}, tessellation::{FillOptions, FillTessellator}, }; use mesh::{fill_builder, Mesh}; use rusttype::{Font, GlyphId, Scale, Segment}; use std::collections::HashMap; use {Backend, Ind...
code_fim
hard
{ "lang": "rust", "repo": "CryZe/livesplit-rendering", "path": "/src/glyph_cache.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub type AllocationId = String; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Allocation { pub id: AllocationId, pub worker_count: u64, pub queued_at: SystemTime, pub status: AllocationStatus, pub working_dir: PathBuf, } impl Allocation { /// Returns true if the allo...
code_fim
hard
{ "lang": "rust", "repo": "mdzik/hyperqueue", "path": "/crates/hyperqueue/src/server/autoalloc/state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mdzik/hyperqueue path: /crates/hyperqueue/src/server/autoalloc/state.rs use std::collections::VecDeque; use std::path::PathBuf; use std::time::{Duration, SystemTime}; use serde::{Deserialize, Serialize}; use crate::common::idcounter::IdCounter; use crate::server::autoalloc::descriptor::QueueDe...
code_fim
hard
{ "lang": "rust", "repo": "mdzik/hyperqueue", "path": "/crates/hyperqueue/src/server/autoalloc/state.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alvarogonzalezsotillo/pruebas-rust path: /src/search.rs use std::fmt::{Display, Formatter, Result}; use std::hash::Hash; use std::hash::Hasher; use crate::ravioli::O; pub mod astar; // pub mod astar_vec; fn simple_hash<T: Hash>(object: &T) -> u64 { let mut hasher = std::collections::hash_...
code_fim
hard
{ "lang": "rust", "repo": "alvarogonzalezsotillo/pruebas-rust", "path": "/src/search.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("level: {} state: {:?}", current.borrow().level, state); let search_data = current.borrow().search; if search_data.is_goal(state) { return Some(current.clone()); } match search_data.max_depth() { Some(max) => { if c...
code_fim
hard
{ "lang": "rust", "repo": "alvarogonzalezsotillo/pruebas-rust", "path": "/src/search.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ($num:literal) => {{ gen_to_add!($num => new_address!().0) }}; } macro_rules! rpc { () => {}; ( $(then)? mine $nb:expr; $($tail:tt)* ) => { { mine!($nb); rpc!($($tail)*); } }; ( $(then)? broadcast $tx:expr; $($tail:tt)* ) => { ...
code_fim
hard
{ "lang": "rust", "repo": "pseudoscalar/farcaster-core", "path": "/chains/tests/rpc/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pseudoscalar/farcaster-core path: /chains/tests/rpc/mod.rs use bitcoincore_rpc::{Auth, Client}; lazy_static::lazy_static! { pub static ref CLIENT: Client = { Client::new( "http://127.0.0.1:18443".into(), Auth::UserPass( "test".into(), ...
code_fim
hard
{ "lang": "rust", "repo": "pseudoscalar/farcaster-core", "path": "/chains/tests/rpc/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ms_i = self.scd_ms(self.node_id); let mut temp_sn = 0; let sn_reasonable = ms_i < (self.sn); //&& (self.sn - 1) <= (ms + self.scd_buffer_unit_size()*self.node_ids.len() as i32); let msp = self.scd_msp(); // Extra stored sequence numbers let low = cmp:...
code_fim
hard
{ "lang": "rust", "repo": "eladschiller/self-stabilizing-cloud", "path": "/self-stabilizing-communication-abstractions/application/src/merge/scd.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> None, base: Some(Spanning(Reg::Ecx, 2, 1, Some(0b111))), index: Some(Spanning(Reg::Ecx, 2, 1, Some(0b111 << 3))), scale: Some(Spanning(Scale::Two, 2, 1, Some(0b11 << 6))), }, 1, ...
code_fim
hard
{ "lang": "rust", "repo": "disassemb-ly/dasha", "path": "/tests/dis.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: disassemb-ly/dasha path: /tests/dis.rs use dasha::{Inst, Op, Reg, Scale, Spanning}; #[test] fn test_dasha_disasm() { // addb %al, (%eax) [opcode + mod-reg-r/m] assert_eq!( dasha::disasm([Spanning(0x00, 0, 1, None), Spanning(0x00, 1, 1, None)]), Ok(vec![Spanning( ...
code_fim
hard
{ "lang": "rust", "repo": "disassemb-ly/dasha", "path": "/tests/dis.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub type DbgWriter = serial::Serial<pac::USART2, (PA2<Alternate<AF7>>, serial::NoRx)>; } #[cfg(feature = "debug-buffer")] pub mod debug { pub struct DbgWriter { buffer: &'static mut [u8], len: usize, } impl DbgWriter { pub fn using_buffer(buffer: &'static mut [u8])...
code_fim
hard
{ "lang": "rust", "repo": "ithinuel/usbd-dfu", "path": "/src/nucleo_f401re/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> impl ::core::fmt::Write for DbgWriter { fn write_str(&mut self, s: &str) -> ::core::fmt::Result { if self.len > self.buffer.len() { // invalid state, that sucks self.len = 0; } let len = core::cmp::min(self.buffer.len() - self...
code_fim
hard
{ "lang": "rust", "repo": "ithinuel/usbd-dfu", "path": "/src/nucleo_f401re/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ithinuel/usbd-dfu path: /src/nucleo_f401re/mod.rs //! This DFU bootloader demo follows the following map : //! | Sector | Start | End | Size (in KiB) | use //! |--------|-------------|-------------|---------------|---- //! | 0 | 0x0800_0000 | 0x0800_3FFF | 16 | Boot...
code_fim
hard
{ "lang": "rust", "repo": "ithinuel/usbd-dfu", "path": "/src/nucleo_f401re/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vbkaisetsu/transformer-prima-undine path: /src/layer_normalization.rs use prima_undine::functions::{ArithmeticFunctions, BasicFunctions}; use prima_undine::{initializers as I, shape, Device, Model, Parameter}; use prima_undine_contrib::functions::ContribFunctions; use serde::{Deserialize, Seria...
code_fim
medium
{ "lang": "rust", "repo": "vbkaisetsu/transformer-prima-undine", "path": "/src/layer_normalization.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'arg, 'dev, T> LayerNormalization<T> where 'dev: 'arg, T: From<&'arg mut Parameter<'dev>> + ArithmeticFunctions<T> + BasicFunctions + ContribFunctions, for<'a> &'a T: ArithmeticFunctions<T>, { pub fn new(eps: f32, params: &'arg mut LayerNormalizationParams<'dev>) -> Self { Sel...
code_fim
hard
{ "lang": "rust", "repo": "vbkaisetsu/transformer-prima-undine", "path": "/src/layer_normalization.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'dev> LayerNormalizationParams<'dev> { pub fn new(device: &'dev Device, n_units: u32) -> Self { Self { pg: device.new_parameter(shape![1, n_units], &I::Constant::new(1.)), pb: device.new_parameter(shape![1, n_units], &I::Constant::new(0.)), } } } pub s...
code_fim
medium
{ "lang": "rust", "repo": "vbkaisetsu/transformer-prima-undine", "path": "/src/layer_normalization.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mangolang/compiler path: /src/parselet/body/code_body.rs use crate::lexeme::Lexeme; use crate::parselet::body::lazy::{LazyParselet, Parseable}; <|fim_suffix|> ResolvedCodeBodyParselet { //TODO @mark: } } } pub type CodeBodyParselet = LazyParselet<ResolvedCodeBody...
code_fim
medium
{ "lang": "rust", "repo": "mangolang/compiler", "path": "/src/parselet/body/code_body.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Parseable for ResolvedCodeBodyParselet { fn parse(_lexemes: &[Lexeme]) -> Self { ResolvedCodeBodyParselet { //TODO @mark: } } } pub type CodeBodyParselet = LazyParselet<ResolvedCodeBodyParselet>;<|fim_prefix|>// repo: mangolang/compiler path: /src/parselet/body/c...
code_fim
medium
{ "lang": "rust", "repo": "mangolang/compiler", "path": "/src/parselet/body/code_body.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn assert_serializes_to<C: Command>( command: C, result: &str, variant: &SupplyVariant, ) { expect_serializes_to(command, result, variant).verify(); } pub fn expect_serializes_to<C: Command>( command: C, result: &str, variant: &SupplyVariant, ) -> Expectation { let mut...
code_fim
hard
{ "lang": "rust", "repo": "austinglaser/bk168xb-rs", "path": "/src/command/test_util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: austinglaser/bk168xb-rs path: /src/command/test_util.rs //! Assertions specific to dealing with BK168xB commands. use crate::{ command::{Command, CommandSink, Error, Result}, SupplyVariant, }; use galvanic_assert::{ get_expectation_for, matchers::*, Expectation, MatchResult, Ma...
code_fim
medium
{ "lang": "rust", "repo": "austinglaser/bk168xb-rs", "path": "/src/command/test_util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn expect_serializes_to<C: Command>( command: C, result: &str, variant: &SupplyVariant, ) -> Expectation { let mut sink = Vec::new(); sink.send_command(&command, variant).unwrap(); let written = str::from_utf8(&sink).unwrap(); get_expectation_for!(&written, eq(result)) }<...
code_fim
hard
{ "lang": "rust", "repo": "austinglaser/bk168xb-rs", "path": "/src/command/test_util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cyberbono3/intro-to-Rust path: /ownership.rs struct Foo { ints: Vec<i32> } impl Foo { fn new(xs: Vec<i32>) -> Foo { <|fim_suffix|> let mut xs = vec![1, 2, 3, 4]; xs.push(5); let foo = Foo::new(xs); xs.push(92); }<|fim_middle|> return Foo { ints: xs }; } } fn ma...
code_fim
easy
{ "lang": "rust", "repo": "cyberbono3/intro-to-Rust", "path": "/ownership.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut xs = vec![1, 2, 3, 4]; xs.push(5); let foo = Foo::new(xs); xs.push(92); }<|fim_prefix|>// repo: cyberbono3/intro-to-Rust path: /ownership.rs struct Foo { ints: Vec<i32> } impl Foo { fn new(xs: Vec<i32>) -> Foo { <|fim_middle|> return Foo { ints: xs }; } } fn ma...
code_fim
easy
{ "lang": "rust", "repo": "cyberbono3/intro-to-Rust", "path": "/ownership.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for key in keys.iter() { found = environment::exists(key); if !found { break; } } found }<|fim_prefix|>// repo: sagiegurari/envmnt path: /src/bulk.rs //! # bulk //! //! Wrapper for env related functions which work on bulk of variables at once. //! #[cfg(...
code_fim
hard
{ "lang": "rust", "repo": "sagiegurari/envmnt", "path": "/src/bulk.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) fn is_all_exists<K: AsRef<OsStr>>(keys: &Vec<K>) -> bool { let mut found = false; for key in keys.iter() { found = environment::exists(key); if !found { break; } } found }<|fim_prefix|>// repo: sagiegurari/envmnt path: /src/bulk.rs //! # b...
code_fim
hard
{ "lang": "rust", "repo": "sagiegurari/envmnt", "path": "/src/bulk.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sagiegurari/envmnt path: /src/bulk.rs //! # bulk //! //! Wrapper for env related functions which work on bulk of variables at once. //! #[cfg(test)] #[path = "./bulk_test.rs"] mod bulk_test; use crate::environment; use indexmap::IndexMap; use std::ffi::OsStr; pub(crate) fn remove_all<K: AsRef...
code_fim
hard
{ "lang": "rust", "repo": "sagiegurari/envmnt", "path": "/src/bulk.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fifth-postulate/plan path: /server/src/server/mod.rs // Server related code. mod plan; use iron::Chain; use logger::Logger; use mount::Mount; use solver; use staticfile::Static; use std::path::Path; use std::sync::mpsc::Sender; pub fn chain(tx: Sender<solver::Message>) -> Chain { let mut c...
code_fim
medium
{ "lang": "rust", "repo": "fifth-postulate/plan", "path": "/server/src/server/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut mounter = Mount::new(); mounter.mount("/", Static::new(Path::new("static/"))); mounter.mount("/plan", plan::router(tx)); mounter }<|fim_prefix|>// repo: fifth-postulate/plan path: /server/src/server/mod.rs // Server related code. mod plan; use iron::Chain; use logger::Logger; u...
code_fim
medium
{ "lang": "rust", "repo": "fifth-postulate/plan", "path": "/server/src/server/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aaron-human/RoboExplore path: /rust/src/color.rs use crate::externals::*; use crate::static_singletons::is_browser_little_endian; pub trait ColorExportable { fn raw_export(&self, output : &mut Vec<ColorMagnitude>); } /// A class for storing colors. #[derive(Clone)] pub struct Color { pub red...
code_fim
hard
{ "lang": "rust", "repo": "aaron-human/RoboExplore", "path": "/rust/src/color.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl TexturePositionAsColor { pub fn new(x : u16, y : u16) -> TexturePositionAsColor { TexturePositionAsColor { x, y } } } impl ColorExportable for TexturePositionAsColor { fn raw_export(&self, output : &mut Vec<ColorMagnitude>) { let x_pieces; let y_pieces; // Unfortunately browsers use the s...
code_fim
hard
{ "lang": "rust", "repo": "aaron-human/RoboExplore", "path": "/rust/src/color.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// A class for storing texture positions as colors. #[derive(Clone)] pub struct TexturePositionAsColor { pub x : u16, pub y : u16, } impl TexturePositionAsColor { pub fn new(x : u16, y : u16) -> TexturePositionAsColor { TexturePositionAsColor { x, y } } } impl ColorExportable for TexturePositionA...
code_fim
hard
{ "lang": "rust", "repo": "aaron-human/RoboExplore", "path": "/rust/src/color.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oshunter/fuchsia path: /garnet/bin/setui/src/internal/switchboard.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 crate::message_hub_definition; use crate::switchboard::bas...
code_fim
hard
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/garnet/bin/setui/src/internal/switchboard.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone, Debug)] pub enum Action { // Defines a request to be acted upon the specified `SettingType`. Request(SettingType, SettingRequest), // Contains the response to the last request. Response(SettingResponseResult), } message_hub_definition!(Payload, Address);<|fim_prefix|>// re...
code_fim
hard
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/garnet/bin/setui/src/internal/switchboard.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> fn from_str(input: &str) -> Result<ContributionType, ThothError> { match input { "Author" => Ok(ContributionType::Author), "Editor" => Ok(ContributionType::Editor), "Translator" => Ok(ContributionType::Translator), "Photographer" => Ok(Contributi...
code_fim
hard
{ "lang": "rust", "repo": "tosteiner/thoth", "path": "/thoth-api/src/contribution/model.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tosteiner/thoth path: /thoth-api/src/contribution/model.rs use serde::{Deserialize, Serialize}; use std::fmt; use std::str::FromStr; use uuid::Uuid; use crate::errors::ThothError; #[cfg(feature = "backend")] use crate::schema::contribution; #[cfg_attr(feature = "backend", derive(DbEnum, junipe...
code_fim
hard
{ "lang": "rust", "repo": "tosteiner/thoth", "path": "/thoth-api/src/contribution/model.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_contributiontype_fromstr() { assert_eq!( ContributionType::from_str("Author").unwrap(), ContributionType::Author ); assert_eq!( ContributionType::from_str("Editor").unwrap(), ContributionType::Editor ); assert_eq!( ContributionTyp...
code_fim
hard
{ "lang": "rust", "repo": "tosteiner/thoth", "path": "/thoth-api/src/contribution/model.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut rng = SmallRng::from_entropy(); #bvh_code } }) } pub fn final_scene_static(switch: bool) -> proc_macro::TokenStream { if !switch { return proc_macro::TokenStream::from(quote! { fn final_scene_static_bvh() -> (Box<dyn Object>, Box<dyn Obje...
code_fim
hard
{ "lang": "rust", "repo": "stneng/Ray-Tracing", "path": "/codegen/src/scenes_gen.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (Box::new(ObjectList { objects: vec![] }), Box::new(ObjectList { objects: vec![] })) } }); } let mut rng = SmallRng::from_entropy(); let mut objects1 = vec![]; for i in 0..20 { for j in 0..20 { let w = 100.0; let x1 = -100...
code_fim
hard
{ "lang": "rust", "repo": "stneng/Ray-Tracing", "path": "/codegen/src/scenes_gen.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stneng/Ray-Tracing path: /codegen/src/scenes_gen.rs use proc_macro2::TokenStream; use quote::quote; use rand::{rngs::SmallRng, Rng, SeedableRng}; use crate::vec3::*; struct Object { pub bounding_box_min: Vec3, pub code: TokenStream, } fn bvh_build(objects: &mut Vec<Object>) -> TokenStr...
code_fim
hard
{ "lang": "rust", "repo": "stneng/Ray-Tracing", "path": "/codegen/src/scenes_gen.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: markomanninen/pico-sdk path: /sdk/tests/load_drivers.rs use pico_common::Driver; use pico_download::{cache_resolution, download_drivers_to_cache}; use pico_driver::LoadDriverExt; #[test] fn load_all_drivers() { let drivers = [ Driver::PS2000, Driver::PS2000A, ...
code_fim
medium
{ "lang": "rust", "repo": "markomanninen/pico-sdk", "path": "/sdk/tests/load_drivers.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if loaded.is_err() { download_drivers_to_cache(&[*d]).unwrap(); loaded = d.try_load_with_resolution(&cache_resolution); } assert!(loaded.is_ok()); let loaded = loaded.unwrap(); assert!(loaded.get_version().is_ok()); }); }<|fim...
code_fim
hard
{ "lang": "rust", "repo": "markomanninen/pico-sdk", "path": "/sdk/tests/load_drivers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> type Item = &'a Token; fn into_iter(self) -> Self::IntoIter { self.0.iter() } } /// An owned string of tokens, similar to the [`String`] or [`Vec<char>`] types. #[derive(Clone, Default, Eq, Hash, PartialEq)] #[repr(transparent)] pub struct TokenString(Vec<Token>); impl TokenString {...
code_fim
hard
{ "lang": "rust", "repo": "zyxw59/rssc", "path": "/src/token/string.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zyxw59/rssc path: /src/token/string.rs use std::{ cmp::Ordering, fmt::{self, Write}, ops::{Deref, DerefMut}, }; use super::{EscapeArgs, Token}; /// A string of tokens, similar to the [`str`] or [`[char]`](slice) types. It is usually seen in /// borrowed form, `&TokenStr`. #[derive(...
code_fim
hard
{ "lang": "rust", "repo": "zyxw59/rssc", "path": "/src/token/string.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Display for TokenString { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&**self, f) } } impl Deref for TokenString { type Target = TokenStr; fn deref(&self) -> &Self::Target { // SAFETY: `TokenStr` is a `repr(transparent)` wrapper arou...
code_fim
hard
{ "lang": "rust", "repo": "zyxw59/rssc", "path": "/src/token/string.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leoleogo/rust-by-example path: /src/ch8/flow_of_control.rs #![allow(unreachable_code)] pub fn test_foc() { let n = 5; if n < 0 { print!("{} is negative", n); } else if n > 0 { print!("{} is positive", n); } else { print!("{} is zero", n); } let ...
code_fim
hard
{ "lang": "rust", "repo": "leoleogo/rust-by-example", "path": "/src/ch8/flow_of_control.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Provide an altered failing condition. let i_like_letters = false; if let Some(i) = emoticon { println!("Matched {:?}!", i); // Destructure failed. Evaluate an `else if` condition to see if the // alternate failure branch should be taken: } else if i_like_letters { ...
code_fim
hard
{ "lang": "rust", "repo": "leoleogo/rust-by-example", "path": "/src/ch8/flow_of_control.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn age() -> u32 { 15 } match age() { 0 => println!("I'am not born yet I guess"), n @ 1 ..= 12 => println!("I'am a child of age {:?}", n), n => println!("I'am a person of age {}", n), } // All have type `Option<i32>` let number = Some(7); le...
code_fim
hard
{ "lang": "rust", "repo": "leoleogo/rust-by-example", "path": "/src/ch8/flow_of_control.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Danue1/paradox-clausewitz path: /src/parse/mod.rs mod ast; mod error; #[cfg(test)] mod test; use crate::{Symbol, Token, Tokens}; pub use ast::*; pub use error::*; pub type ParseResult<T> = Result<T, ParseError>; pub fn parse(tokens: Tokens) -> Result<Ast, ParseError> { Context::new(tokens...
code_fim
hard
{ "lang": "rust", "repo": "Danue1/paradox-clausewitz", "path": "/src/parse/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while let Some(current_token) = self.peek() { match current_token { Token::Symbol(symbol) => match symbol { Symbol::RightBrace | Symbol::RightBracket | Symbol::RightChevron => { self.consume() } ...
code_fim
hard
{ "lang": "rust", "repo": "Danue1/paradox-clausewitz", "path": "/src/parse/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn parse_right(&mut self) -> ParseResult<Option<Right>> { match self.peek() { Some(Token::Symbol(Symbol::Equal)) => { self.consume(); } Some(Token::Symbol(symbol)) => return unexpected_symbol!(symbol.to_owned()), Some(Token::Scala...
code_fim
hard
{ "lang": "rust", "repo": "Danue1/paradox-clausewitz", "path": "/src/parse/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustPython/RustPython path: /vm/src/builtins/dict.rs s; if let Some(keys) = vm.get_method(other.clone(), vm.ctx.intern_str("keys")) { let keys = keys?.call((), vm)?.get_iter(vm)?; while let PyIterReturn::Return(key) = keys.next(vm)? { let val = oth...
code_fim
hard
{ "lang": "rust", "repo": "RustPython/RustPython", "path": "/vm/src/builtins/dict.rs", "mode": "psm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct DictIter<'a> { dict: &'a PyDict, position: usize, } impl<'a> DictIter<'a> { pub fn new(dict: &'a PyDict) -> Self { DictIter { dict, position: 0 } } } impl Iterator for DictIter<'_> { type Item = (PyObjectRef, PyObjectRef); fn next(&mut self) -> Option<Self::It...
code_fim
hard
{ "lang": "rust", "repo": "RustPython/RustPython", "path": "/vm/src/builtins/dict.rs", "mode": "spm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustPython/RustPython path: /vm/src/builtins/dict.rs } else { zelf.inner_delitem(needle, vm) } }), }; &AS_MAPPING } } impl AsSequence for PyDict { fn as_sequence() -> &'static PySequenceMethods { sta...
code_fim
hard
{ "lang": "rust", "repo": "RustPython/RustPython", "path": "/vm/src/builtins/dict.rs", "mode": "psm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fwcd/socha-client-rust-2020 path: /src/protocol/player_score.rs use crate::util::{SCResult, FromXmlNode, XmlNode}; use super::ScoreCause; <|fim_suffix|>impl FromXmlNode for PlayerScore { fn from_node(node: &XmlNode) -> SCResult<Self> { Ok(Self { cause: node.attribute("ca...
code_fim
medium
{ "lang": "rust", "repo": "fwcd/socha-client-rust-2020", "path": "/src/protocol/player_score.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(Self { cause: node.attribute("cause")?.parse()?, reason: node.attribute("reason").map(|s| s.to_owned()).unwrap_or_default() }) } }<|fim_prefix|>// repo: fwcd/socha-client-rust-2020 path: /src/protocol/player_score.rs use crate::util::{SCResult, FromXmlNode, ...
code_fim
medium
{ "lang": "rust", "repo": "fwcd/socha-client-rust-2020", "path": "/src/protocol/player_score.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pablo-mansanet-bluefruit/efm32gg11b path: /src/etm/etmidr.rs #[doc = "Reader of register ETMIDR"] pub type R = crate::R<u32, super::ETMIDR>; #[doc = "Reader of field `IMPVER`"] pub type IMPVER_R = crate::R<u8, u8>; #[doc = "Reader of field `ETMMINVER`"] pub type ETMMINVER_R = crate::R<u8, u8>; #...
code_fim
hard
{ "lang": "rust", "repo": "pablo-mansanet-bluefruit/efm32gg11b", "path": "/src/etm/etmidr.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn thumbt(&self) -> THUMBT_R { THUMBT_R::new(((self.bits >> 18) & 0x01) != 0) } #[doc = "Bit 19 - Security Extension Support"] #[inline(always)] pub fn secext(&self) -> SECEXT_R { SECEXT_R::new(((self.bits >> 19) & 0x01) != 0) } #[doc = "Bit 20 - Branch Packet Encoding"] #[inline...
code_fim
hard
{ "lang": "rust", "repo": "pablo-mansanet-bluefruit/efm32gg11b", "path": "/src/etm/etmidr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danielsvitols/tornado path: /tornado/icinga2_collector/src/error.rs use failure_derive::Fail; #[derive(Fail, Debug)] pub enum Icinga2Coll<|fim_suffix|>sage)] CannotPerformHttpRequest { message: String }, #[fail(display = "UnexpectedEndOfHttpRequest")] UnexpectedEndOfHttpRequest, }<|...
code_fim
medium
{ "lang": "rust", "repo": "danielsvitols/tornado", "path": "/tornado/icinga2_collector/src/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>play = "UnexpectedEndOfHttpRequest")] UnexpectedEndOfHttpRequest, }<|fim_prefix|>// repo: danielsvitols/tornado path: /tornado/icinga2_collector/src/error.rs use failure_derive::Fail; #[derive(Fail, Debug)] pub enum Icinga2Coll<|fim_middle|>ectorError { #[fail(display = "CannotPerformHttpRequest...
code_fim
medium
{ "lang": "rust", "repo": "danielsvitols/tornado", "path": "/tornado/icinga2_collector/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>sage)] CannotPerformHttpRequest { message: String }, #[fail(display = "UnexpectedEndOfHttpRequest")] UnexpectedEndOfHttpRequest, }<|fim_prefix|>// repo: danielsvitols/tornado path: /tornado/icinga2_collector/src/error.rs use failure_derive::Fail; #[derive(Fail, Debug)] pub enum Icinga2Coll<|...
code_fim
medium
{ "lang": "rust", "repo": "danielsvitols/tornado", "path": "/tornado/icinga2_collector/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /** Returns if the word is in the data structure. A word could contain the dot character '.' to represent any one letter. */ fn search(&self, word: String) -> bool { let word: Vec<char> = word.chars().chain("\n".chars()).collect(); return self.trie.search(&word[..], 0); } } /*...
code_fim
hard
{ "lang": "rust", "repo": "sym233/leetcode_problems", "path": "/211. Add and Search Word - Data structure design/211. Add and Search Word - Data structure design.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sym233/leetcode_problems path: /211. Add and Search Word - Data structure design/211. Add and Search Word - Data structure design.rs const LEN: usize = 27usize; const DOT: usize = 27usize; fn lton(letter: char) -> usize { // '\n' -> 0 // 'a' -> 1 // ... // 'z' -> 26 // '.' -...
code_fim
hard
{ "lang": "rust", "repo": "sym233/leetcode_problems", "path": "/211. Add and Search Word - Data structure design/211. Add and Search Word - Data structure design.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: takumioba/conc_ytakano path: /chap4/4.1/ch4_1_philosophers/src/main.rs use std::sync::{Arc, Mutex}; use std::thread; fn main() { // 箸が2本 <1> let c0 = Arc::new(Mutex::new(())); let c1 = Arc::new(Mutex::new(())); let c0_p0 = c0.clone(); let c1_p0 = c1.clone(); <|fim_suffix|>...
code_fim
hard
{ "lang": "rust", "repo": "takumioba/conc_ytakano", "path": "/chap4/4.1/ch4_1_philosophers/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // 哲学者1 let p0 = thread::spawn(move || { for _ in 0..100000 { let _n1 = c0_p0.lock().unwrap(); // <2> let _n2 = c1_p0.lock().unwrap(); println!("0: eating"); } }); // 哲学者2 let p1 = thread::spawn(move || { for _ in 0..100000 {...
code_fim
medium
{ "lang": "rust", "repo": "takumioba/conc_ytakano", "path": "/chap4/4.1/ch4_1_philosophers/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut emp_list = EmployeeList::from_file("employees.txt"); emp_list.dump(); loop { println!(); let name = readln::read_string("Enter an employee name to remove: ").unwrap(); emp_list.remove(&name); println!(); if emp_list.is_empty() { break } else { em...
code_fim
easy
{ "lang": "rust", "repo": "bjnord/coding_practice", "path": "/hogan-57/7-struct/emp_list/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bjnord/coding_practice path: /hogan-57/7-struct/emp_list/src/main.rs extern crate interact_io; use emp_list::EmployeeList; use interact_io::readln; <|fim_suffix|> let mut emp_list = EmployeeList::from_file("employees.txt"); emp_list.dump(); loop { println!(); let name...
code_fim
easy
{ "lang": "rust", "repo": "bjnord/coding_practice", "path": "/hogan-57/7-struct/emp_list/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut input = String::new(); io::stdin().lock().read_to_string(&mut input).unwrap(); let input = &input[..]; let (_rest, instructions) = parse_instructions(input).unwrap(); let mut registers: HashMap<&str, i32> = HashMap::new(); let mut max_reg_val = 0; for i in instruction...
code_fim
hard
{ "lang": "rust", "repo": "ToonSpin/advent-of-code-2017-rust", "path": "/src/bin/day08.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }