text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let context = zmq::Context::new(); let publisher = context.socket(zmq::PUB).unwrap(); publisher .bind("tcp://*:5567") .expect("failed binding publisher"); let mut state = NavState::new(); thread::spawn(move || { let ticker = tic...
code_fim
hard
{ "lang": "rust", "repo": "CoreTrackProject/good-bug", "path": "/rust/src/navigator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CoreTrackProject/good-bug path: /rust/src/navigator.rs use crate::types::*; use crossbeam_channel::{select, tick, unbounded, Sender}; use nalgebra as na; use std::thread; use std::time::{Duration, Instant}; use zmq; type Iso3 = na::Isometry3<f64>; fn angle_difference(bearing_from: f64, bearing...
code_fim
hard
{ "lang": "rust", "repo": "CoreTrackProject/good-bug", "path": "/rust/src/navigator.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn load_rk(&mut self, reg: &mut usize, expr: &ExprNode, cnst: Rc<Value>) -> i32 { let cindex = self.const_index(cnst) as i32; if cindex < opMaxIndexRk { rk_ask(cindex) } else { let ret = *reg; *reg += 1; self.code.add_ABx(OP_LOADK...
code_fim
hard
{ "lang": "rust", "repo": "bluven/lua-rs", "path": "/src/compiler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bluven/lua-rs path: /src/compiler.rs let left = lennames - namesassigned - 1; self.code.add_ABC(OP_LOADNIL, reg as i32, (reg + left) as i32, 0, line); reg += left; } for i in namesassigned..lenexprs { let opt = if i != lenexprs - 1 { 0 } els...
code_fim
hard
{ "lang": "rust", "repo": "bluven/lua-rs", "path": "/src/compiler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bluven/lua-rs path: /src/compiler.rs ef lhs, ref rhs) => { let mut crange = 1; let mut current = rhs; loop { match current.inner() { Expr::BinaryOp(BinaryOpr::Concat, _sublhs, ref subrhs) => { ...
code_fim
hard
{ "lang": "rust", "repo": "bluven/lua-rs", "path": "/src/compiler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: apphacker/fe path: /src/main.rs #[macro_use] extern crate clap; extern crate glob; use clap::App; mod find; mod ignore; #[derive(Debug)] pub struct Options { verbose: bool, very_verbose: bool, insensitive: bool, search_names_only: bool, } fn main() { <|fim_suffix|> // Unwra...
code_fim
medium
{ "lang": "rust", "repo": "apphacker/fe", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let options = Options { verbose: matches.is_present("verbose"), very_verbose: matches.occurrences_of("verbose") > 1, insensitive: matches.is_present("insensitive"), search_names_only: matches.is_present("name"), }; if options.verbose { println!("Search pattern i...
code_fim
hard
{ "lang": "rust", "repo": "apphacker/fe", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ngoluuduythai/Cardano.swift path: /rust/src/transaction_hash.rs use super::data::CData; use super::error::CError; use super::panic::*; use super::ptr::Ptr; use crate::transaction_body::TransactionBody; use cardano_serialization_lib::{ crypto::TransactionHash as RTransactionHash, utils::hash_tr...
code_fim
hard
{ "lang": "rust", "repo": "ngoluuduythai/Cardano.swift", "path": "/rust/src/transaction_hash.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl TryFrom<RTransactionHash> for TransactionHash { type Error = CError; fn try_from(transaction_hash: RTransactionHash) -> Result<Self> { let bytes: [u8; 32] = transaction_hash .to_bytes() .try_into() .map_err(|_| CError::DataLengthMismatch)?; Ok(Self(bytes)) } } impl F...
code_fim
medium
{ "lang": "rust", "repo": "ngoluuduythai/Cardano.swift", "path": "/rust/src/transaction_hash.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qeda/qeda-cli path: /src/packages/mod.rs mod chip; mod sop; use std::collections::HashMap; use std::fmt::{self, Debug}; use crate::config::Config; use crate::drawing::Drawing; use crate::error::*; use chip::ChipPackage; use sop::SopPackage; #[derive(Debug)] pub enum PackageType { Unknown...
code_fim
medium
{ "lang": "rust", "repo": "qeda/qeda-cli", "path": "/src/packages/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} impl Debug for dyn PackageHandler { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "PackageHandler") } } #[derive(Debug)] pub struct Packages { handlers: HashMap<&'static str, Box<dyn PackageHandler>>, } impl Packages { /// Creates an empty `Packages`. pu...
code_fim
hard
{ "lang": "rust", "repo": "qeda/qeda-cli", "path": "/src/packages/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::PMINSB, operand1: Some(Direct(XMM7)), operand2: Some(IndirectScaledIndexedDisplaced(RDI, RBX, Eight, 1699663306, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, b...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_pminsb.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn pminsb_2() { run_test(&Instruction { mnemonic: Mnemonic::PMINSB, operand1: Some(Direct(XMM2)), operand2: Some(IndirectDisplaced(EAX, 1779304913, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, br...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_pminsb.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/instr_pminsb.rs use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[t...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_pminsb.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod test { use super::*; use std::fs; #[test] fn range_hash() { let tmp = tempdir::TempDir::new("hashtest").expect("tmp"); let path = &tmp.path().join("a"); fs::write(path, "aaa\n").expect("write"); let mut file = LazyFile::new(path); ...
code_fim
hard
{ "lang": "rust", "repo": "kornelski/dupe-krill", "path": "/src/hasher.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kornelski/dupe-krill path: /src/hasher.rs use crate::lazyfile::LazyFile; use smallvec::SmallVec; use std::cmp::{min, Ordering}; use std::convert::TryInto; use std::io; use std::io::{Read, Seek, SeekFrom}; use std::path::Path; /// A hashed chunk of data of arbitrary size. Files are compared a bi...
code_fim
hard
{ "lang": "rust", "repo": "kornelski/dupe-krill", "path": "/src/hasher.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe fn creat:ORIG_CREAT(path: *const c_char, mode: mode_t) -> c_int { let fs_mode = mode | 0o600; let ret = ORIG_CREAT(path, fs_mode); open_base(ret, fs_mode, mode); Ok(ret) } } #[cfg(not(target_os = "linux"))] wrap! { unsafe fn mknod:ORIG_MKNOD(path: *const...
code_fim
hard
{ "lang": "rust", "repo": "PlasmaPower/borg-test-wrapper", "path": "/src/lib/creation.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe fn open:ORIG_OPEN(path: *const c_char, flags: c_int, mode: mode_t) -> c_int { let fs_mode = if flags & libc::O_CREAT == libc::O_CREAT { mode | 0o600 } else { mode }; let ret = ORIG_OPEN(path, flags, fs_mode); open_base(ret, fs_mode...
code_fim
hard
{ "lang": "rust", "repo": "PlasmaPower/borg-test-wrapper", "path": "/src/lib/creation.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PlasmaPower/borg-test-wrapper path: /src/lib/creation.rs use std::os::raw::*; use shared::*; use libc::{self, mode_t, dev_t}; use errno::errno; fn override_base(path: CPath, mode: mode_t, mask: mode_t) { if let Ok(id) = path.get_id() { let _ = message(Message::OverrideMode(id, mod...
code_fim
hard
{ "lang": "rust", "repo": "PlasmaPower/borg-test-wrapper", "path": "/src/lib/creation.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>use std::env; use std::fs; use std::thread; pub fn run() -> Result<()> { let args: Vec<String> = env::args().collect(); let wasm_path = args.get(1).expect("Not enough arguments passed"); let wasm = fs::read(wasm_path).expect("Can't open WASM file"); let module = module::LunaticModule::ne...
code_fim
medium
{ "lang": "rust", "repo": "bkolobara/lunatic", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bkolobara/lunatic path: /src/lib.rs #![feature(available_concurrency)] pub mod channel; pub mod linker; pub mod memory; pub mod module; pub mod networking; pub mod normalisation; pub mod process; pub mod wasi; use anyhow::Result; use easy_parallel::Parallel; use process::{FunctionLookup, Memo...
code_fim
hard
{ "lang": "rust", "repo": "bkolobara/lunatic", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'el> DataMember<'el> { /// Create a new `DataMember` attributes. #[allow(unused)] pub fn new(name: Cons<'el>) -> DataMember { DataMember { name: name, emit_default_value: false, } } } impl<'el> IntoTokens<'el, Csharp<'el>> for DataMember<'el> {...
code_fim
hard
{ "lang": "rust", "repo": "nmaraston/reproto", "path": "/lib/backend-csharp/src/utils.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<'el> IntoTokens<'el, Csharp<'el>> for DataMember<'el> { fn into_tokens(self) -> Tokens<'el, Csharp<'el>> { let data_member = using("System.Runtime.Serialization", "DataMember"); let mut args: Tokens<'el, Csharp<'el>> = Tokens::new(); args.append(toks!["Name = ", self.name...
code_fim
hard
{ "lang": "rust", "repo": "nmaraston/reproto", "path": "/lib/backend-csharp/src/utils.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nmaraston/reproto path: /lib/backend-csharp/src/utils.rs use core::{RpName, RpType, RpVersionedPackage}; use core::errors::*; use genco::{Cons, Csharp, IntoTokens, Quoted, Tokens}; use genco::csharp::{self, array, struct_, using}; use processor::Processor; use std::rc::Rc; use trans::Environment...
code_fim
hard
{ "lang": "rust", "repo": "nmaraston/reproto", "path": "/lib/backend-csharp/src/utils.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jlewiskilgore/RustyOregonTrail path: /src/main.rs extern crate rand; use std::io; use std::cmp::Ordering; use rand::Rng; fn main() { print_introduction(); //Give player instructions if they choose let mut need_instructions = String::new(); io::stdin() .read_line(&mut need_instructions)...
code_fim
hard
{ "lang": "rust", "repo": "jlewiskilgore/RustyOregonTrail", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!(""); //Player can spend between 200 and 300 on Oxen println!("HOW MUCH DO YOU WANT TO SPEND ON YOUR OXEN TEAM"); let mut amount = String::new(); io::stdin().read_line(&mut amount).expect("failed to read line"); let amount: u32 = amount.trim().parse().expect("Please type a number!"); if ...
code_fim
hard
{ "lang": "rust", "repo": "jlewiskilgore/RustyOregonTrail", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Fantom-foundation/libsignature-minisign path: /src/lib.rs use libhash::Hash as LibHash; use libsignature::Signature as LibSignature; use minisign::SignatureBox as MiniSignature; use serde::{Deserialize, Serialize}; use std::marker::PhantomData; <|fim_suffix|>#[cfg(test)] mod tests { #[test]...
code_fim
hard
{ "lang": "rust", "repo": "Fantom-foundation/libsignature-minisign", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sgaliamov/ergo-balance path: /src/models/digraphs.rs use serde_json::{Map, Value}; use std::collections::HashMap; use std::error::Error; use std::path::PathBuf; #[derive(Debug)] pub struct Digraphs { map: DigraphsMap, } pub type DigraphsMap = HashMap<char, HashMap<char, f64>>; impl Digrap...
code_fim
hard
{ "lang": "rust", "repo": "sgaliamov/ergo-balance", "path": "/src/models/digraphs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(actual, 0.); } #[test] pub fn test_child_iterator() { let a = vec![1, 2, 3]; let mut iter = a.iter(); iter.next(); let mut child_iter = iter.clone().into_iter(); assert_eq!(*child_iter.next().unwrap(), 2); assert_eq!(*child_...
code_fim
hard
{ "lang": "rust", "repo": "sgaliamov/ergo-balance", "path": "/src/models/digraphs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ret = VecData::new(); Ok(ret) } fn receive_trusted_rpc(&self, _data: &RpcData) -> Result<VecRpcData, Error> { Err(failure::format_err!("No Trusted Rpc for {:?}", SCHEMA_URL)) } fn receive_untrusted_rpc(&self, _data: &RpcData) -> Result<VecRpcData, Error> { ...
code_fim
medium
{ "lang": "rust", "repo": "zutils/create-protocols-plugin", "path": "/templates/schema_interface.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut ret = VecModuleInfo::new(); ret.vec = protobuf::RepeatedField::from_vec(vec![info]); Ok(ret) } fn generate_message(&self, data: &GenerateMessageInfo) -> Result<Data, Error> { let template = data.get_template(); let _args = data.get_args(); m...
code_fim
hard
{ "lang": "rust", "repo": "zutils/create-protocols-plugin", "path": "/templates/schema_interface.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zutils/create-protocols-plugin path: /templates/schema_interface.rs use crate::__PROTOCOL_NAME___autogen::__PROTOCOL_NAME__; use failure::Error; use protocols::{CommonModule, Data, ModuleInfo, VecModuleInfo, VecData, Destination, GenerateMessageInfo, VecRpcData, RpcData}; use protocols::utils::{...
code_fim
hard
{ "lang": "rust", "repo": "zutils/create-protocols-plugin", "path": "/templates/schema_interface.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let cli = ClientBuilder::new(user, host) .port(port) .catalog(catalog) .build() .unwrap(); let s = cli.get_stream::<Row>(sql); pin_mut!(s); while let Some(value) = s.next().await { let v = value.unwrap().into_vec(); for e in v { ...
code_fim
hard
{ "lang": "rust", "repo": "dawsongzhao/prusto", "path": "/examples/stream.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dawsongzhao/prusto path: /examples/stream.rs #![allow(incomplete_features)] #![feature(generic_associated_types)] use std::env::var; <|fim_suffix|> let cli = ClientBuilder::new(user, host) .port(port) .catalog(catalog) .build() .unwrap(); let s = cli.get...
code_fim
hard
{ "lang": "rust", "repo": "dawsongzhao/prusto", "path": "/examples/stream.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/cargo path: /src/cargo/util/vcs.rs use crate::util::CargoResult; use cargo_util::paths; use cargo_util::ProcessBuilder; use std::path::Path; // Check if we are in an existing repo. We define that to be true if either: // // 1. We are in a git repo and the path to the new package is no...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/cargo", "path": "/src/cargo/util/vcs.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> // then create the fossil DB in that location ProcessBuilder::new("fossil") .cwd(cwd) .arg("init") .arg("--") .arg(&db_path) .exec()?; // open it in that new directory ProcessBuilder::new("fossil") .cw...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/cargo", "path": "/src/cargo/util/vcs.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fredlahde/aoc2020 path: /days/day14/day14_2_refactor/src/main.rs use std::collections::BTreeMap; mod custom_integer; use custom_integer::CustomInteger; use regex::Regex; use std::path::Path; struct Mem { mem: BTreeMap<u128, u128>, } impl Mem { fn new() -> Self { Self { ...
code_fim
hard
{ "lang": "rust", "repo": "fredlahde/aoc2020", "path": "/days/day14/day14_2_refactor/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let width = 3; let permutations = generate_bit_permutations(width); assert_eq!(8, permutations.len()); assert_eq!( ["000", "001", "010", "011", "100", "101", "110", "111"] .iter() .map(|x| x.to_string()) .collect::...
code_fim
hard
{ "lang": "rust", "repo": "fredlahde/aoc2020", "path": "/days/day14/day14_2_refactor/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tommilligan/symbolgen path: /symbolgen/src/main.rs use std::fs::File; use std::io::{stdout, Write}; use std::path::PathBuf; use cairo::{Context, Format, ImageSurface, LineCap}; use structopt::StructOpt; use symbolgen_core::{Alphabet, Motif, Symmetry, Vector}; #[derive(Debug, StructOpt)] #[stru...
code_fim
hard
{ "lang": "rust", "repo": "tommilligan/symbolgen", "path": "/symbolgen/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let alphabet = Alphabet::new(row_number + 2, 3, options.symmetry.clone(), Motif::Diagonal); for column_number in 0..columns { let glyph_number = row_number * columns + column_number; let offset_x = spacing + ((scale + spacing) * column_number as f64); le...
code_fim
hard
{ "lang": "rust", "repo": "tommilligan/symbolgen", "path": "/symbolgen/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: microsoft/DiskANN path: /rust/diskann/benches/neighbor_bench.rs /* * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT license. */ use std::time::Duration; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use diskann::model::{Neighbor,...
code_fim
hard
{ "lang": "rust", "repo": "microsoft/DiskANN", "path": "/rust/diskann/benches/neighbor_bench.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> black_box(&1) }); }); } fn generate_random_floats() -> Vec<Neighbor> { let seed: [u8; 32] = [73; 32]; let mut rng: StdRng = SeedableRng::from_seed(seed); let range = Uniform::new(0.0, 1.0); let mut random_floats = Vec::with_capacity(100); for i in 0..100 { ...
code_fim
hard
{ "lang": "rust", "repo": "microsoft/DiskANN", "path": "/rust/diskann/benches/neighbor_bench.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let buf = "hello world\n"; unsafe { write(libc::STDERR_FILENO, buf.as_ptr() as *const _, buf.len()); } }<|fim_prefix|>// repo: jyotsna-penumaka/enarx path: /integration-tests/src/bin/write_stderr.rs // SPDX-License-Identifier: Apache-2.0 <|fim_middle|>use libc::write;
code_fim
easy
{ "lang": "rust", "repo": "jyotsna-penumaka/enarx", "path": "/integration-tests/src/bin/write_stderr.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jyotsna-penumaka/enarx path: /integration-tests/src/bin/write_stderr.rs // SPDX-License-Identifier: Apache-2.0 <|fim_suffix|> let buf = "hello world\n"; unsafe { write(libc::STDERR_FILENO, buf.as_ptr() as *const _, buf.len()); } }<|fim_middle|>use libc::write; fn main() {
code_fim
easy
{ "lang": "rust", "repo": "jyotsna-penumaka/enarx", "path": "/integration-tests/src/bin/write_stderr.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[must_use] pub fn pop(&mut self) -> Option<u16> { if self.len > 0 && self.len < MAX_STACK { self.len -= 1; Some(self.storage[self.len]) } else { None } } }<|fim_prefix|>// repo: tesuji/chip8emu path: /src/stack.rs #[cfg(test)] mod t...
code_fim
hard
{ "lang": "rust", "repo": "tesuji/chip8emu", "path": "/src/stack.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tesuji/chip8emu path: /src/stack.rs #[cfg(test)] mod tests; const MAX_STACK: usize = 16; pub struct Stack { storage: [u16; MAX_STACK], len: usize, } <|fim_suffix|> #[must_use] pub fn push(&mut self, item: u16) -> Option<()> { if self.len >= MAX_STACK { None ...
code_fim
medium
{ "lang": "rust", "repo": "tesuji/chip8emu", "path": "/src/stack.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ZackPierce/aho-corasick path: /bench/src/sherlock.rs use criterion::Criterion; use input::*; use define_aho_corasick; /// These benchmarks test various words on natural language text. /// /// These benchmarks were mostly taken from the regex crate's benchmarks. For /// example, the case insens...
code_fim
hard
{ "lang": "rust", "repo": "ZackPierce/aho-corasick", "path": "/bench/src/sherlock.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> //Set lengths of longest of each for rendering the text nicely let mut long_name: usize = 0; let mut long_path: usize = 0; let mut long_desc: usize = 0; for script in &self.scripts { if script.description.len() > long_desc { long_desc = s...
code_fim
hard
{ "lang": "rust", "repo": "twick00/ruscripter", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: twick00/ruscripter path: /src/lib.rs use serde::{Deserialize, Serialize}; use std::path::{PathBuf, Iter}; use clap::{App, Arg, ArgMatches}; use std::fmt::{Display, Formatter, Error}; use std::fs::File; use std::io::{BufReader, Write}; #[derive(Serialize, Deserialize, Debug)] pub struct Config {...
code_fim
hard
{ "lang": "rust", "repo": "twick00/ruscripter", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pjedge/rust-spoa path: /build.rs // build.rs extern crate cc; extern crate cmake; use cmake::Config; use std::env; fn main() { let dst = Config::new("src/spoa") .define("CMAKE_BUILD_TYPE","Release") .build(); println!("cargo:rustc-link-search=native={}", dst.di...
code_fim
medium
{ "lang": "rust", "repo": "pjedge/rust-spoa", "path": "/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let out_dir = env::var("OUT_DIR").unwrap(); println!("cargo:rustc-flags=-L {}/lib64/ -L {}/lib/", &out_dir, &out_dir); cc::Build::new() .cpp(true) .shared_flag(false) .static_flag(true) .flag_if_supported("-O3") .flag_if_supported("-D_GNU_SOURCE") ...
code_fim
hard
{ "lang": "rust", "repo": "pjedge/rust-spoa", "path": "/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // optional GUI for the current screen fn update_gui(&mut self, _ui: &mut UiCell, _ids: &Ids) {} // these are optional fn key(&mut self, _key: Key, _pressed: bool) {} fn mouse(&mut self, _button: MouseButton, _pressed: bool) {} fn mouse_cursor(&mut self, _x: f64, _y: f64) {} f...
code_fim
hard
{ "lang": "rust", "repo": "svercl/awfulbots", "path": "/src/screen/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn mouse(&mut self, _button: MouseButton, _pressed: bool) {} fn mouse_cursor(&mut self, _x: f64, _y: f64) {} fn mouse_relative(&mut self, _x: f64, _y: f64) {} fn mouse_scroll(&mut self, _x: f64, _y: f64) {} fn resize(&mut self, _width: f64, _height: f64) {} }<|fim_prefix|>// repo: sver...
code_fim
medium
{ "lang": "rust", "repo": "svercl/awfulbots", "path": "/src/screen/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: svercl/awfulbots path: /src/screen/mod.rs use crate::gui::Ids; use conrod_core::UiCell; use graphics::Context; use opengl_graphics::{GlGraphics, GlyphCache}; use piston::input::{Key, MouseButton}; mod game; mod menu; pub use self::game::GameScreen; pub use self::menu::MenuScreen; <|fim_suffix...
code_fim
hard
{ "lang": "rust", "repo": "svercl/awfulbots", "path": "/src/screen/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: baitcenter/tezos-rs path: /networking/tests/encoding_current_head.rs use failure::Error; use networking::p2p::encoding::prelude::*; use networking::p2p::binary_message::BinaryMessage; #[test] fn can_serialize_get_current_head_message() -> Result<(), Error> { let response: PeerMessageRespon...
code_fim
hard
{ "lang": "rust", "repo": "baitcenter/tezos-rs", "path": "/networking/tests/encoding_current_head.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let message_bytes = hex::decode("0000012400148eceda2f000000ce0003cad5019b6feff784b018e609632b3bb66248a13c9efcaaaef34ddb805f07b4b2191760000000005c917b62045a8e2646ea6a2cf1ed392de0d4e2a45696a9662c0af212de73b72544357d757f00000011000000010000000008000000000072a3ce162dfbadfbdc34b00d694ba656c165b660643f6af52...
code_fim
hard
{ "lang": "rust", "repo": "baitcenter/tezos-rs", "path": "/networking/tests/encoding_current_head.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: l4l/rustc_codegen_cranelift path: /src/allocator.rs // Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http:/...
code_fim
hard
{ "lang": "rust", "repo": "l4l/rustc_codegen_cranelift", "path": "/src/allocator.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let call_inst = bcx.ins().call(callee_func_ref, &args); let results = bcx.inst_results(call_inst).to_vec(); // Clone to prevent borrow error bcx.ins().return_(&results); bcx.seal_all_blocks(); bcx.finalize(); } module.define_func...
code_fim
hard
{ "lang": "rust", "repo": "l4l/rustc_codegen_cranelift", "path": "/src/allocator.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[allow(dead_code)] pub unsafe fn mut_from_term(t: Term) -> RtResult<*mut Self> { helper_get_mut_from_boxed_term::<Self>( t, BOXTYPETAG_CLOSURE, RtErr::BoxedIsNotAClosure, ) } /// Given a closure, find new value for the code pointer and update the /// closure. Return: ...
code_fim
hard
{ "lang": "rust", "repo": "kvakvs/ErlangRT", "path": "/lib-erlangrt/src/term/boxed/closure.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(frozen.len(), fun_entry.nfrozen); println!( "{}new closure: {} frozen={} nfrozen={}", module(), fun_entry.mfa, frozen.len(), fun_entry.nfrozen ); this.write(Self::new(fun_entry.mfa, fun_entry.nfrozen)); assert_eq!(frozen.len(), fun_entry.nfroz...
code_fim
hard
{ "lang": "rust", "repo": "kvakvs/ErlangRT", "path": "/lib-erlangrt/src/term/boxed/closure.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kvakvs/ErlangRT path: /lib-erlangrt/src/term/boxed/closure.rs use crate::{ defs::{Arity, SizeBytes, Word, SizeWords}, emulator::{ code::pointer::{CodePtr, VersionedCodePtr}, code_srv::CodeServer, function::FunEntry, heap::{AllocInit, THeap}, mfa::ModFunArity, }, fail:...
code_fim
hard
{ "lang": "rust", "repo": "kvakvs/ErlangRT", "path": "/lib-erlangrt/src/term/boxed/closure.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] pub enum Category { Algorithms, ApiBindings, Asynchronous, Authentication, Caching, CommandLineInterface, CommandLineUtilities, Compression, C...
code_fim
hard
{ "lang": "rust", "repo": "H2CO3/rustbp_avocado", "path": "/src/entities.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Some(&self.id) } fn set_id(&mut self, id: Uid<Self>) { self.id = id; } } #[derive(Debug, Clone, Serialize, Deserialize, Doc)] #[index( name = "example_compound_embedded_index", unique = true, keys( login = "ascending", github_profile::email = "desc...
code_fim
hard
{ "lang": "rust", "repo": "H2CO3/rustbp_avocado", "path": "/src/entities.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: H2CO3/rustbp_avocado path: /src/entities.rs use std::collections::BTreeSet; use semver::Version; use chrono::prelude::*; use avocado::prelude::*; // TODO(H2CO3): `impl Doc` manually // TODO(H2CO3): then, `#[derive(Doc)]` instead #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Crate {...
code_fim
hard
{ "lang": "rust", "repo": "H2CO3/rustbp_avocado", "path": "/src/entities.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: believer/advent-of-code path: /rust/2020/src/day_22.rs use std::collections::{HashSet, VecDeque}; // Day 22 - Crab Combat #[aoc_generator(day22)] pub fn input_generator(input: &str) -> (VecDeque<u32>, VecDeque<u32>) { let players: VecDeque<VecDeque<u32>> = input .split("\n\n") ...
code_fim
hard
{ "lang": "rust", "repo": "believer/advent-of-code", "path": "/rust/2020/src/day_22.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> if player_1_card > player_2_card { player_1.push_back(player_1_card); player_1.push_back(player_2_card); } else { player_2.push_back(player_2_card); player_2.push_back(player_1_card); } if player_1.is_empty() || player_2.is_e...
code_fim
hard
{ "lang": "rust", "repo": "believer/advent-of-code", "path": "/rust/2020/src/day_22.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_particle_pos(&self, p_index: usize) -> &Vec<f64> { &self.particles[p_index].position } pub fn get_distance_between_particles( &self, p_i: usize, p_j: usize, ) -> f64 { let pos_i = &self.particles[p_i].position; let pos_j = &self.p...
code_fim
hard
{ "lang": "rust", "repo": "Schoyen/vmc", "path": "/src/particle.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Schoyen/vmc path: /src/particle.rs use rand::{prelude::thread_rng, Rng}; #[derive(Debug, Clone)] pub struct Particle { num_dimensions: usize, position: Vec<f64>, } impl Particle { pub fn new(num_dimensions: usize) -> Self { Particle { num_dimensions, ...
code_fim
hard
{ "lang": "rust", "repo": "Schoyen/vmc", "path": "/src/particle.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct Particles { num_dimensions: usize, particles: Vec<Particle>, } impl Particles { pub fn new(num_particles: usize, num_dimensions: usize) -> Self { Particles { num_dimensions, particles: vec![Particle::new(num_dimensions); num_particle...
code_fim
hard
{ "lang": "rust", "repo": "Schoyen/vmc", "path": "/src/particle.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stmobo/epiphyllum path: /kernel/src/asm/cpuid.rs use spin::Once; use core::arch::asm; static CPUID_INFO: Once<CpuIdInfo> = Once::new(); pub struct CpuIdInfo { basic_eax: u32, basic_ebx: u32, feature_flags: [u32; 4], } impl CpuIdInfo { pub fn get() -> &'static CpuIdInfo { ...
code_fim
hard
{ "lang": "rust", "repo": "stmobo/epiphyllum", "path": "/kernel/src/asm/cpuid.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> (self.feature_flags[reg_idx] & (1 << reg_bit)) != 0 } } pub fn get() -> &'static CpuIdInfo { CpuIdInfo::get() } pub fn check_feature(feature: FeatureFlags) -> bool { CpuIdInfo::get().check_feature(feature) } #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[repr(u32)] #[allow(non_camel...
code_fim
hard
{ "lang": "rust", "repo": "stmobo/epiphyllum", "path": "/kernel/src/asm/cpuid.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sidrashakeel19/Rust-Actix-Webapp path: /src/main.rs // Necessary imports here use actix_web::{App, HttpServer}; // imports for de/serializing objects use serde::{Deserialize}; // importing student module(s) mod students; #[actix_rt::main] async fn main() -> std::io::Result<()> { // Initi...
code_fim
hard
{ "lang": "rust", "repo": "sidrashakeel19/Rust-Actix-Webapp", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } // Function that will show the record with specified id fn find(id: i32) { } // Function that will update an existing record fn update(id: i32, student: Student) { } // Function that will delete an specified object fn delete(id: i32) { } } // ------------------...
code_fim
hard
{ "lang": "rust", "repo": "sidrashakeel19/Rust-Actix-Webapp", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for (grid_str, iter) in &memory { if (iter - prev_seen_iteration) == rem { println!("Part 2: {}", resource_value(grid_str)); break; } } break; } else { memory.insert(digest, i+1); } } }<|fim_prefix|>// repo: galenelias/AdventOfCode_2018 path: /src/Day18/mod.rs use std::...
code_fim
hard
{ "lang": "rust", "repo": "galenelias/AdventOfCode_2018", "path": "/src/Day18/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: galenelias/AdventOfCode_2018 path: /src/Day18/mod.rs use std::collections::HashMap; use itertools::Itertools; fn total(y: usize, x: usize, ch: char, grid: &Vec<Vec<char>>) -> usize { let y = y as i32; let x = x as i32; let mut result = 0; for dy in -1..=1 { for dx in -1..=1 { if y + dy...
code_fim
medium
{ "lang": "rust", "repo": "galenelias/AdventOfCode_2018", "path": "/src/Day18/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Store 'grid string' -> 'iteration #' mapping let mut memory : HashMap<String, u64> = HashMap::new(); for i in 0u64.. { let prev_grid = grid.clone(); for y in 0..grid.len() { for x in 0..grid[y].len() { let ch = prev_grid[y][x]; if ch == '.' && total(y, x, '|', &prev_grid) >= 3 { ...
code_fim
hard
{ "lang": "rust", "repo": "galenelias/AdventOfCode_2018", "path": "/src/Day18/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/hashbrown path: /benches/insert_unique_unchecked.rs //! Compare `insert` and `insert_unique_unchecked` operations performance. <|fim_suffix|>extern crate test; use hashbrown::HashMap; use test::Bencher; #[bench] fn insert(b: &mut Bencher) { let keys: Vec<String> = (0..1000).map(...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/hashbrown", "path": "/benches/insert_unique_unchecked.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[bench] fn insert_unique_unchecked(b: &mut Bencher) { let keys: Vec<String> = (0..1000).map(|i| format!("xxxx{}yyyy", i)).collect(); b.iter(|| { let mut m = HashMap::with_capacity(1000); for k in &keys { m.insert_unique_unchecked(k, k); } m }); }<|f...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/hashbrown", "path": "/benches/insert_unique_unchecked.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let keys: Vec<String> = (0..1000).map(|i| format!("xxxx{}yyyy", i)).collect(); b.iter(|| { let mut m = HashMap::with_capacity(1000); for k in &keys { m.insert(k, k); } m }); } #[bench] fn insert_unique_unchecked(b: &mut Bencher) { let keys: Vec<...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/hashbrown", "path": "/benches/insert_unique_unchecked.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qezz/polars path: /py-polars/src/lib.rs use pyo3::prelude::*; pub mod dataframe; pub mod error; pub mod series; <|fim_suffix|>#[pymodule] fn polars(_py: Python, m: &PyModule) -> PyResult<()> { m.add_class::<PySeries>()?; m.add_class::<PyDataFrame>()?; Ok(()) }<|fim_middle|>use crat...
code_fim
easy
{ "lang": "rust", "repo": "qezz/polars", "path": "/py-polars/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> m.add_class::<PySeries>()?; m.add_class::<PyDataFrame>()?; Ok(()) }<|fim_prefix|>// repo: qezz/polars path: /py-polars/src/lib.rs use pyo3::prelude::*; pub mod dataframe; pub mod error; pub mod series; use crate::{dataframe::PyDataFrame, series::PySeries}; <|fim_middle|>#[pymodule] fn pola...
code_fim
medium
{ "lang": "rust", "repo": "qezz/polars", "path": "/py-polars/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn play_index(&mut self, index: usize) -> String { self.is_playing = true; self.position.replace(index); self.running_order()[index].clone() } fn play_next(&mut self) -> Option<String> { self.next_index().map(|i| self.play_index(i)) } fn next_index(&se...
code_fim
hard
{ "lang": "rust", "repo": "forksbot/spot", "path": "/src/app/state/playback_state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> impl PlaybackState { fn current_position(&self) -> Option<usize> { self.position } fn song_ids(&self) -> Vec<&str> { self.songs().map(|s| &s.id[..]).collect() } } #[test] fn test_initial_state() { let state = PlaybackState::...
code_fim
hard
{ "lang": "rust", "repo": "forksbot/spot", "path": "/src/app/state/playback_state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: forksbot/spot path: /src/app/state/playback_state.rs nning_order(); let len = running_order.len(); running_order .iter() .position(|s| s == id) .filter(|&index| index + 1 < len) .map(|index| { self.swap(index, index ...
code_fim
hard
{ "lang": "rust", "repo": "forksbot/spot", "path": "/src/app/state/playback_state.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>t).contains(&c) { 1 } else { 0 }; for a_i in a { c += a_i; if (s..=t).contains(&c) { count += 1; } } let ans = count; println!("{}", ans); }<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc022/src/bin/a.rs use proconio::input...
code_fim
medium
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/abc022/src/bin/a.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc022/src/bin/a.rs use proconio::input; fn main() { input! { n: usize, s: i64, t: i64, w: i64, a: [i64; n - 1], }; let mut c = w; let mut count = if (s..=<|fim_suffix|>ns(&c) { ...
code_fim
medium
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/abc022/src/bin/a.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ns(&c) { count += 1; } } let ans = count; println!("{}", ans); }<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc022/src/bin/a.rs use proconio::input; fn main() { input! { n: usize, s: i64, t: i64,<|fim_middle|> ...
code_fim
medium
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/abc022/src/bin/a.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: regiontog/secret-service-rs path: /src/error.rs //Copyright 2016 secret-service-rs Developers // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your opt...
code_fim
hard
{ "lang": "rust", "repo": "regiontog/secret-service-rs", "path": "/src/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl error::Error for SsError { fn description(&self) -> &str { match *self { SsError::Crypto(_) => "crypto: Invalid Length or Padding", SsError::Dbus(ref err) => err.description(), SsError::Locked => "Object locked", SsError::NoResult => "Result...
code_fim
hard
{ "lang": "rust", "repo": "regiontog/secret-service-rs", "path": "/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Display for SsError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { // crypto error does not implement Display SsError::Crypto(_) => write!(f, "Crypto error: Invalid Length or Padding"), SsError::Dbus(ref err) => write!(f, "D...
code_fim
hard
{ "lang": "rust", "repo": "regiontog/secret-service-rs", "path": "/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn all_orders(values: &[i32]) -> Vec<Vec<i32>> { if values.len() == 2 { return vec![vec![values[0], values[1]], vec![values[1], values[0]]]; } let mut returns = Vec::new(); for value in 0..values.len() { let mut clone = Vec::from(values); clone.remove(value); ...
code_fim
hard
{ "lang": "rust", "repo": "SKyletoft/Advent-of-Code", "path": "/7/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { let opcode = format!("{:05}", array[*pos]); let param_one = *array.get(*pos + 1).unwrap_or(&0); let param_two = *array.get(*pos + 2).unwrap_or(&0); let param_three = *array.get(*pos + 3).unwrap_or(&0); let mode = [ { match &opc...
code_fim
hard
{ "lang": "rust", "repo": "SKyletoft/Advent-of-Code", "path": "/7/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SKyletoft/Advent-of-Code path: /7/src/main.rs fn main() { let input = include_str!("input.txt"); let array: Vec<i32> = input .split(',') .map(|number| number.parse::<i32>().unwrap()) .collect(); part_one(&array); } fn part_two(array: &Vec<i32>, io: &[i32]) ->...
code_fim
hard
{ "lang": "rust", "repo": "SKyletoft/Advent-of-Code", "path": "/7/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dflemstr/semantic-editor.old path: /src/update.rs use build; use hyper::Client; use hyper::header; use hyper::status; use md5; use std::env; use std::fs; use std::io; use std::path::Path; use std::os::unix::fs::PermissionsExt; pub fn download() { download_to(&env::current_exe().unwrap()...
code_fim
hard
{ "lang": "rust", "repo": "dflemstr/semantic-editor.old", "path": "/src/update.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("Update successful"); } else if res.status == status::StatusCode::NotModified { println!("No update available"); } else { println!("Got status {}", res.status); } } fn md5sum<R>(input: &mut R) -> String where R: io::Read { let mut context = md5::Context::n...
code_fim
hard
{ "lang": "rust", "repo": "dflemstr/semantic-editor.old", "path": "/src/update.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: risooonho/kludgine path: /src/shape/fill.rs use crate::color::Color; #[derive(Default, Clone, Debug)] pub struct Fil<|fim_suffix|> color, options: Default::default(), } } }<|fim_middle|>l { pub color: Color, pub options: lyon_tessellation::FillOptions, } ...
code_fim
medium
{ "lang": "rust", "repo": "risooonho/kludgine", "path": "/src/shape/fill.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> color, options: Default::default(), } } }<|fim_prefix|>// repo: risooonho/kludgine path: /src/shape/fill.rs use crate::color::Color; #[derive(Default, Clone, Debug)] pub struct Fil<|fim_middle|>l { pub color: Color, pub options: lyon_tessellation::FillOptions, } ...
code_fim
medium
{ "lang": "rust", "repo": "risooonho/kludgine", "path": "/src/shape/fill.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Avarel/packed_bit_stack path: /src/lib.rs pub struct PackedBitStack { vec: Vec<u8> } use std::mem::size_of; macro_rules! impl_ps { ($push_name: ident, $pop_name: ident, $type: ty) => { pub fn $push_name(&mut self, value: $type) { for &bits in &value.to_be_bytes() {...
code_fim
hard
{ "lang": "rust", "repo": "Avarel/packed_bit_stack", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub unsafe fn pop_bits<T>(&mut self) -> T { let z: usize = size_of::<T>(); let mut array = vec![0; z]; for i in 0..z { array[z - i - 1] = self.vec.pop().unwrap(); } std::ptr::read(array.as_ptr() as *const T) } }<|fim_prefix|>// repo: Avarel/pac...
code_fim
hard
{ "lang": "rust", "repo": "Avarel/packed_bit_stack", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zdimension/parm_extended path: /code_rs/test/src/parm/control.rs use crate::parm::mmio::{BREAKpin, RESETpin}; use core::hint::unreachable_unchecked; <|fim_suffix|>#[inline(always)] pub fn breakpoint() { BREAKpin.write(1); }<|fim_middle|>#[inline(always)] pub fn reset() -> ! { RESETpin.w...
code_fim
medium
{ "lang": "rust", "repo": "zdimension/parm_extended", "path": "/code_rs/test/src/parm/control.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }