text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>fn cli_get_value(app: &App, args: &[&str]) -> XcliResult { let mut kad = handler(app); if args.len() != 1 { return Err(XcliError::MismatchArgument(1, args.len())); } let key = args.get(0).cloned().unwrap(); task::block_on(async { let value = kad.get_value(Vec::from(k...
code_fim
hard
{ "lang": "rust", "repo": "lstarby/libp2p-rs", "path": "/protocols/kad/src/cli.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let keys = provider.ssh_keys().unwrap(); assert_ne!(keys, vec![]); assert_eq!(keys.len(), 1); assert_eq!(keys[0].options, None); assert_eq!(keys[0].comment, Some("test-comment".to_string())); server.reset(); provider.ssh_keys().unwrap_err(); } #[test] fn basic_attributes() {...
code_fim
hard
{ "lang": "rust", "repo": "coreos/afterburn", "path": "/src/providers/exoscale/mock_tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coreos/afterburn path: /src/providers/exoscale/mock_tests.rs use crate::providers::exoscale; use crate::providers::MetadataProvider; use mockito; #[test] fn basic_hostname() { let ep = "/1.0/meta-data/local-hostname"; let hostname = "test-hostname"; let mut server = mockito::Server...
code_fim
hard
{ "lang": "rust", "repo": "coreos/afterburn", "path": "/src/providers/exoscale/mock_tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn run(&self, graph: &JsGraph, length: &Function, sources: &Array) -> JsDrawing { let sources = sources .iter() .map(|item| node_index(item.as_f64().unwrap() as usize)) .collect::<Vec<_>>(); let mut length_map = HashMap::new(); for e in g...
code_fim
hard
{ "lang": "rust", "repo": "likr/egraph-rs", "path": "/crates/wasm/src/layout/mds.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[wasm_bindgen(js_class = "PivotMds")] impl JsPivotMds { #[wasm_bindgen(constructor)] pub fn new() -> JsPivotMds { JsPivotMds { pivot_mds: PivotMds::new(), } } pub fn run(&self, graph: &JsGraph, length: &Function, sources: &Array) -> JsDrawing { let sou...
code_fim
hard
{ "lang": "rust", "repo": "likr/egraph-rs", "path": "/crates/wasm/src/layout/mds.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: likr/egraph-rs path: /crates/wasm/src/layout/mds.rs use crate::{drawing::JsDrawing, graph::JsGraph}; use js_sys::{Array, Function}; use petgraph::{graph::node_index, visit::EdgeRef}; use petgraph_layout_mds::{ClassicalMds, PivotMds}; use std::collections::HashMap; use wasm_bindgen::prelude::*; ...
code_fim
hard
{ "lang": "rust", "repo": "likr/egraph-rs", "path": "/crates/wasm/src/layout/mds.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fredfortier/bitmex-rs path: /src/model/instrument.rs use super::GeneralRequest; use chrono::{DateTime, Utc}; use serde_derive::Deserialize; pub type GetInstrumentRequest = GeneralRequest; impl Default for GetInstrumentRequest { fn default() -> Self { GetInstrumentRequest { ...
code_fim
hard
{ "lang": "rust", "repo": "fredfortier/bitmex-rs", "path": "/src/model/instrument.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone, Debug, Deserialize)] pub struct GetInstrumentActiveIntervalsResponse { pub intervals: Vec<String>, pub symbols: Vec<String>, } pub type GetInstrumentCompositeIndexRequest = GetInstrumentRequest; #[derive(Clone, Debug, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Ge...
code_fim
hard
{ "lang": "rust", "repo": "fredfortier/bitmex-rs", "path": "/src/model/instrument.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> write!(sql, " ON ").unwrap(); if let Some(table) = &create.table { table.prepare(sql, '"'); } self.prepare_index_type(&create.index_type, sql); self.prepare_index_columns(&create.index.columns, sql); } fn prepare_index_drop_statement(&self, dr...
code_fim
hard
{ "lang": "rust", "repo": "laashub-soa/sea-query", "path": "/src/backend/postgres/index.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: laashub-soa/sea-query path: /src/backend/postgres/index.rs use super::*; impl IndexBuilder for PostgresQueryBuilder { fn prepare_table_index_expression(&self, create: &IndexCreateStatement, sql: &mut SqlWriter) { self.prepare_index_prefix(create, sql); write!(sql, "KEY ").un...
code_fim
hard
{ "lang": "rust", "repo": "laashub-soa/sea-query", "path": "/src/backend/postgres/index.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sunfishcode/object path: /crates/examples/src/readobj/pe.rs index + 1); if let Some(name) = symbols.and_then(|symbols| section.name(symbols.strings()).print_err(p)) { p.field_inline_string("Name", name); } else { ...
code_fim
hard
{ "lang": "rust", "repo": "sunfishcode/object", "path": "/crates/examples/src/readobj/pe.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>MD64_INDIR_BR_REX, IMAGE_REL_AMD64_INDIR_CALL, IMAGE_REL_AMD64_INDIR_BR_SWITCHTABLE_FIRST, IMAGE_REL_AMD64_INDIR_BR_SWITCHTABLE_LAST, ); static FLAGS_IMAGE_REL_IA64: &[Flag<u16>] = &flags!( IMAGE_REL_IA64_ABSOLUTE, IMAGE_REL_IA64_IMM14, IMAGE_REL_IA64_IMM22, IMAGE_REL_IA64_IMM6...
code_fim
hard
{ "lang": "rust", "repo": "sunfishcode/object", "path": "/crates/examples/src/readobj/pe.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sunfishcode/object path: /crates/examples/src/readobj/pe.rs '_>, data: &[u8]) { writeln!(p.w(), "Format: PE 64-bit").unwrap(); print_pe::<ImageNtHeaders64>(p, data); } fn print_pe<Pe: ImageNtHeaders>(p: &mut Printer<'_>, data: &[u8]) { if let Some(dos_header) = ImageDosHeader::parse...
code_fim
hard
{ "lang": "rust", "repo": "sunfishcode/object", "path": "/crates/examples/src/readobj/pe.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub type SimulationTime = f64; pub type PickQuantity = i32; pub type ItemPicks<'a> = HashMap<&'a str, PickQuantity>;<|fim_prefix|>// repo: michael-groble/warehouse-simulator-rust path: /src/lib.rs use std::collections::HashMap; pub mod line_member; pub use self::line_member::LineMember; <|fim_middle|>p...
code_fim
medium
{ "lang": "rust", "repo": "michael-groble/warehouse-simulator-rust", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: michael-groble/warehouse-simulator-rust path: /src/lib.rs use std::collections::HashMap; pub mod line_member; pub use self::line_member::LineMember; <|fim_suffix|>pub mod checker; pub use self::checker::Checker; pub mod line; pub use self::line::Line; pub type SimulationTime = f64; pub type ...
code_fim
easy
{ "lang": "rust", "repo": "michael-groble/warehouse-simulator-rust", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Nyashiki/minishogilib path: /src/bitboard.rs use bitintr::Pext; use bitintr::Popcnt; use once_cell::sync::Lazy; use position::*; use types::*; pub type Bitboard = u32; pub const ONE_BB: Bitboard = 0b11111_11111_11111_11111_11111; /// 近接の利きを保持するbitboard /// ADJACENT_ATTACK[square][piece]として参照...
code_fim
hard
{ "lang": "rust", "repo": "Nyashiki/minishogilib", "path": "/src/bitboard.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..SQUARE_NB { let top: usize = i % 5; for player_bb in 0..32 { let mut position: Position = Position::empty_board(); for j in 0..5 { if player_bb & (1 << j) != 0 { position.board[top + 5 * j] = Piece::B_PAWN; ...
code_fim
hard
{ "lang": "rust", "repo": "Nyashiki/minishogilib", "path": "/src/bitboard.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // これ以上上に行けない if i / 5 == 0 && (*move_dir == Direction::NE || *move_dir == Direction::NW) { continue; } // これ以上右に行けない if i % 5 == 4 && (*move_dir == Direction::NE || *move_dir == Direction:...
code_fim
hard
{ "lang": "rust", "repo": "Nyashiki/minishogilib", "path": "/src/bitboard.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>orkaround; see [this comment] for details. /// /// [this comment]: https://github.com/rust-lang/rust/issues/34511#issuecomment-373423999 pub trait Captures<'a> { } impl<'a, T: ?Sized> Captures<'a> for T { }<|fim_prefix|>// repo: unnsa/rust path: /src/librustc/util/captures.rs // Copyright 2012-2014 The ...
code_fim
hard
{ "lang": "rust", "repo": "unnsa/rust", "path": "/src/librustc/util/captures.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: unnsa/rust path: /src/librustc/util/captures.rs // Copyright 2012-2014 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": "unnsa/rust", "path": "/src/librustc/util/captures.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn read_cpu_exp(&mut self, pinout: mos::Pinout) -> mos::Pinout { // open bus pinout } fn read_cpu_wram(&mut self, mut pinout: mos::Pinout) -> mos::Pinout { if self.ram_enable { let internal_address = self.context.wram_addr_mapper.translate_address(pinout.ad...
code_fim
hard
{ "lang": "rust", "repo": "w1n5t0n99/rustnes", "path": "/nes/src/mappers/mapper1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: w1n5t0n99/rustnes path: /nes/src/mappers/mapper1.rs use ::nes_rom::ines; use super::*; use super::ppu; pub enum PrgBankMode { Switch32K, FixFirst, FixLast, } pub enum ChrBankMode { Switch8K, Switch4K, } pub struct Mapper1 { pub context: Context, pub prg_bank_mode:...
code_fim
hard
{ "lang": "rust", "repo": "w1n5t0n99/rustnes", "path": "/nes/src/mappers/mapper1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self, source: PublicKey, root_hash: BlockHash, file_hash: BlockHash, collated_data_hash: BlockHash, callback: ValidatorBlockCandidateCallback, ) { log::info!(target: "validator", "SessionListener::on_get_approved_candidate, {}", self.info_round(...
code_fim
hard
{ "lang": "rust", "repo": "funnyzone/ton-labs-node", "path": "/src/validator/validator_session_listener.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: funnyzone/ton-labs-node path: /src/validator/validator_session_listener.rs use std::{fmt, time::{*, SystemTime, SystemTimeError}, sync::*}; use tokio::{time::timeout, runtime::Runtime}; use validator_session::*; use crate::validator::validator_group::{ValidatorGroup, ValidatorGroupStatus}; use ...
code_fim
hard
{ "lang": "rust", "repo": "funnyzone/ton-labs-node", "path": "/src/validator/validator_session_listener.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn process_validation_queue( queue: Arc<Receiver<ValidationAction>>, g: Arc<ValidatorGroup>, rt: Arc<Runtime> ) { let mut cur_round = 0; let mut last_action = SystemTime::now(); 'queue_loop: while g.clone().get_status().await != ValidatorGroupStatus::Stopped ...
code_fim
hard
{ "lang": "rust", "repo": "funnyzone/ton-labs-node", "path": "/src/validator/validator_session_listener.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if self.len() != other.len() { std::f64::NAN } else { let mut distance : f64 = 0.0; for i in 0..self.len() { distance += (self[i] - other[i]).abs(); } distance } } fn manhattan_distance_weighted(&s...
code_fim
hard
{ "lang": "rust", "repo": "LukasJaeger307/distancers", "path": "/src/distances.rs", "mode": "spm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LukasJaeger307/distancers path: /src/distances.rs /* * (c) 2020, Lukas Jäger * * This program is free software. It comes without any warranty, to * the extent permitted by applicable law. You can redistribute it * and/or modify it under the terms of the Do What The Fuck You Want * To Publ...
code_fim
hard
{ "lang": "rust", "repo": "LukasJaeger307/distancers", "path": "/src/distances.rs", "mode": "psm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_prefix|>// repo: regular-pv/rchc path: /src/bin/rchc.rs #[macro_use] extern crate log; extern crate stderrlog; #[macro_use] extern crate clap; extern crate utf8_decode; extern crate source_span; extern crate smt2; extern crate rchc; extern crate automatic_relations as automatic; use std::io::Read; use std::rc::...
code_fim
hard
{ "lang": "rust", "repo": "regular-pv/rchc", "path": "/src/bin/rchc.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if matches.is_present("benchmark") { env.enable_benchmark() } load_asset(&mut env, "builtin", include_bytes!("builtin.smt2")); // Choose the input. let stdin = std::io::stdin(); match matches.value_of("INPUT") { Some(filename) => { info!("reading file: `{}'.", filename); match std::fs::F...
code_fim
hard
{ "lang": "rust", "repo": "regular-pv/rchc", "path": "/src/bin/rchc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn load_asset(env: &mut rchc::Environment, name: &str, data: &[u8]) { let start = Position::default(); let decoder = Decoder::new(data.iter().cloned()); let buffer = SourceBuffer::new(decoder, start, DEFAULT_METRICS); process_buffer(env, name, buffer, start, &DEFAULT_METRICS) } /// Process a given SM...
code_fim
hard
{ "lang": "rust", "repo": "regular-pv/rchc", "path": "/src/bin/rchc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aguss787/doraemon path: /src/config.rs use std::fs; use serde::Deserialize; #[derive(Deserialize, Clone)] pub struct Config { pub database: DatabaseConfig, pub auth: AuthConfig, pub url: UrlConfig, pub gmail: GmailConfig, } <|fim_suffix|>#[derive(Deserialize, Clone)] pub struc...
code_fim
hard
{ "lang": "rust", "repo": "aguss787/doraemon", "path": "/src/config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Deserialize, Clone)] pub struct UrlConfig { pub client_secret: String, } pub fn get_config() -> Config { let config = fs::read("var/config.toml").expect("Error in reading config file"); toml::from_slice(&config).expect("Error in parsing config") }<|fim_prefix|>// repo: aguss787/dorae...
code_fim
hard
{ "lang": "rust", "repo": "aguss787/doraemon", "path": "/src/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { dbg!(std::mem::transmute::<MyEnum, [u32;8]>(MyEnum::A(123))) }; unsafe { dbg!(std::mem::transmute::<MyEnum, [u32;8]>(MyEnum::B("hello".to_string()))) }; unsafe { dbg!(std::mem::transmute::<MyEnum, [u32;8]>(MyEnum::C(123, 5, 6, 7))) }; unsafe { ...
code_fim
medium
{ "lang": "rust", "repo": "carrotflakes/fnum", "path": "/examples/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: carrotflakes/fnum path: /examples/main.rs use fnum::Fnum; #[derive(Fnum)] enum MyEnum { A(u64), B(String), C(u64, u32, u32, u32), D { hello: u32, world: String, }, E } <|fim_suffix|> unsafe { dbg!(std::mem::transmute::<MyEnum, [u32;8]>(MyEnum:...
code_fim
medium
{ "lang": "rust", "repo": "carrotflakes/fnum", "path": "/examples/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use self::common::{version, Database, DatabaseRef}; pub use self::compile::{compile, Builder, Mode}; pub use self::errors::{CompileError, Error}; pub use self::pattern::{Flags, Pattern, Patterns}; pub use self::runtime::{ Capture, Error as MatchError, ErrorEventHandler, MatchEventHandler, Matching...
code_fim
medium
{ "lang": "rust", "repo": "eliaslevy/rust-hyperscan", "path": "/hyperscan/src/chimera/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eliaslevy/rust-hyperscan path: /hyperscan/src/chimera/mod.rs //! Chimera is a software regular expression matching engine that is a hybrid of Hyperscan and PCRE. //! //! The design goals of Chimera are to fully support PCRE syntax as well as to //! take advantage of the high performance nature o...
code_fim
hard
{ "lang": "rust", "repo": "eliaslevy/rust-hyperscan", "path": "/hyperscan/src/chimera/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn is_seat(seat: &char) -> bool { match seat { '.' => return false, 'L' => return false, '#' => return true, _ => return false } } fn get_blank(seat_max: usize, row_max: usize) -> Vec<Vec<char>> { let mut tmp: Vec<Vec<char>> = vec!(); for _ in 0..row_max { ...
code_fim
hard
{ "lang": "rust", "repo": "Hariador/Advent2020", "path": "/day11/day11.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //SE Diagonal let range = cmp::min((seat_max-1 - seat), (row_max -1 - row)); for i in 1..=range { match seats[row+i][seat+i] { '#' => { if diag { print!("SE,") } count += 1; break; ...
code_fim
hard
{ "lang": "rust", "repo": "Hariador/Advent2020", "path": "/day11/day11.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hariador/Advent2020 path: /day11/day11.rs use std::io; use std::fs::File; use std::env; use std::io::prelude::*; use std::io::Error; use std::io::BufRead; use std::cmp; fn main() -> Result<(),io::Error> { let filename = env::args().nth(1).expect("Enter filename"); let (mut seats, seat_...
code_fim
hard
{ "lang": "rust", "repo": "Hariador/Advent2020", "path": "/day11/day11.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod fvm; mod nand; pub use fvm::{Filesystem, FilesystemAttributes, FvmBuilder, FvmType}; pub use nand::NandFvmBuilder;<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/lib/assembly/fvm/src/lib.rs // Copyright 2021 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD...
code_fim
medium
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/assembly/fvm/src/lib.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>//! Library for constructing the FVM. mod fvm; mod nand; pub use fvm::{Filesystem, FilesystemAttributes, FvmBuilder, FvmType}; pub use nand::NandFvmBuilder;<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/lib/assembly/fvm/src/lib.rs // Copyright 2021 The Fuchsia Authors. All rights reserved. // Use o...
code_fim
easy
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/assembly/fvm/src/lib.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/lib/assembly/fvm/src/lib.rs // Copyright 2021 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. #![deny(missing_docs)] //! Library for constructing the FVM. <|fim_suffix...
code_fim
easy
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/assembly/fvm/src/lib.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> for i in 32..48 { idt[i].set_handler_fn(handle_int_other); } idt }; } pub fn init_idt() { IDT.load(); } extern "x86-interrupt" fn handle_breakpoint(stack_frame: &mut ExceptionStackFrame) { debug!("EXCEPTION: Breakpoint\n{:#?}", stack_frame); } extern "x8...
code_fim
hard
{ "lang": "rust", "repo": "tmandry/alloy", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tmandry/alloy path: /src/main.rs #![feature(panic_implementation)] #![feature(abi_x86_interrupt)] #![no_std] #![cfg_attr(not(test), no_main)] #![cfg_attr(test, allow(dead_code, unused_macros, unused_imports))] #[macro_use] extern crate alloy; #[macro_use] extern crate lazy_static; extern crate...
code_fim
hard
{ "lang": "rust", "repo": "tmandry/alloy", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { idt.double_fault.set_handler_fn(handle_double_fault) .set_stack_index(alloy::gdt::DOUBLE_FAULT_IST_INDEX); } for i in 32..48 { idt[i].set_handler_fn(handle_int_other); } idt }; } pub fn init_idt() {...
code_fim
hard
{ "lang": "rust", "repo": "tmandry/alloy", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ndler>() .with_handler::<SayHandler>() .with::<PongHandler>() .with_handler::<ScoreBoardTimerHandler>() .with::<PingTimerHandler>() .with::<SignalHandler>() .with_handler::<WhisperHandler>() .with::<ChatEventHandler>() .with_handler::<TeamChatHandler>() }<|fim_prefix|>// repo: airmash-refu...
code_fim
medium
{ "lang": "rust", "repo": "airmash-refugees/airmash-server-eu", "path": "/server/src/systems/handlers/packet/register.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: airmash-refugees/airmash-server-eu path: /server/src/systems/handlers/packet/register.rs use dispatch::Builder; use super::*; pub fn register<'a, 'b>(builder: Builder<'a, 'b>) -> Builder<'a, 'b> { builder // Add handlers here .with::<OnOpenHandler>() .with_handler::<OnCloseHandler>() ...
code_fim
medium
{ "lang": "rust", "repo": "airmash-refugees/airmash-server-eu", "path": "/server/src/systems/handlers/packet/register.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>r>() .with::<SignalHandler>() .with_handler::<WhisperHandler>() .with::<ChatEventHandler>() .with_handler::<TeamChatHandler>() }<|fim_prefix|>// repo: airmash-refugees/airmash-server-eu path: /server/src/systems/handlers/packet/register.rs use dispatch::Builder; use super::*; pub fn register<'a...
code_fim
medium
{ "lang": "rust", "repo": "airmash-refugees/airmash-server-eu", "path": "/server/src/systems/handlers/packet/register.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ShaneEverittM/jsrs_derive path: /src/object_derive.rs use proc_macro::TokenStream; use quote::quote; use syn::parse::{Parse, ParseBuffer}; use syn::punctuated::Punctuated; use syn::{parenthesized, Error, Field, Ident, Result}; use syn::{parse_macro_input, Attribute, DeriveInput}; pub(crate) fn ...
code_fim
hard
{ "lang": "rust", "repo": "ShaneEverittM/jsrs_derive", "path": "/src/object_derive.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn get(&self, name: &str) -> Option<crate::runtime::Value> { self.#properties_ident.get(name).cloned() } fn get_mut(&mut self, name: &str) -> Option<&mut crate::runtime::Value> { self.#properties_ident.get_mut(name) } ...
code_fim
hard
{ "lang": "rust", "repo": "ShaneEverittM/jsrs_derive", "path": "/src/object_derive.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chansuke/basalt path: /src/assembler/mod.rs pub mod assembler_errors; pub mod instruction_parsers; pub mod label_parsers; pub mod opcode; pub mod opcode_parsers; pub mod operand_parsers; pub mod program_parsers; pub mod register_parsers; pub mod symbols; use nom::types::CompleteStr; use crate:...
code_fim
hard
{ "lang": "rust", "repo": "chansuke/basalt", "path": "/src/assembler/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if self.phase != AssemblerPhase::First { return; } match i.get_label_name() { Some(s) => { match i.get_label_name() { Some(name) => { self.symbols.set_symbol_offset(&name, self.ro_offset); ...
code_fim
hard
{ "lang": "rust", "repo": "chansuke/basalt", "path": "/src/assembler/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Erk-/spotrust path: /src/playlist.rs extern crate reqwest; use model::*; use construct_headers_token; pub fn playlist_get_tracks(client: &reqwest::Client, t: SpotifyToken, id: SpotifyURI) -> SpotifyPagingTracks { let uri_parts: Vec<&str> = id.uri_raw.split(':').collect(); let url = ...
code_fim
medium
{ "lang": "rust", "repo": "Erk-/spotrust", "path": "/src/playlist.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> let res = client .get(url.as_str()) .headers(construct_headers_token(t.clone())) .send(); let mut resp = match res { Ok(resp) => resp, Err(why) => panic!("Err: {}", why), }; let jres: SpotifyPagingTracks = resp.json().unwrap(); jres }<|fim_p...
code_fim
medium
{ "lang": "rust", "repo": "Erk-/spotrust", "path": "/src/playlist.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>pub fn parenthesis_close(source: SourceSlice) -> Lexeme { Lexeme::ParenthesisClose(ParenthesisCloseLexeme::new(source)) } pub fn bracket_open(source: SourceSlice) -> Lexeme { Lexeme::BracketOpen(BracketOpenLexeme::new(source)) } pub fn bracket_close(source: SourceSlice) -> Lexeme { Lexeme::B...
code_fim
hard
{ "lang": "rust", "repo": "mangolang/compiler", "path": "/src/lexeme/collect/short.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mangolang/compiler path: /src/lexeme/collect/short.rs use ::std::str::FromStr; use ::ustr::ustr; use crate::common::error::{ErrMsg, MsgResult}; use crate::io::slice::SourceSlice; use crate::ir::codeparts::eqfloat::f64eq; use crate::ir::codeparts::Keyword; use crate::lexeme::brackets::{BracketC...
code_fim
hard
{ "lang": "rust", "repo": "mangolang/compiler", "path": "/src/lexeme/collect/short.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn literal_int(nr: i64, source: SourceSlice) -> Lexeme { Lexeme::Literal(LiteralLexeme::Int(nr, source)) } pub fn literal_real(nr: impl Into<f64eq>, source: SourceSlice) -> Lexeme { Lexeme::Literal(LiteralLexeme::Real(nr.into(), source)) } pub fn literal_bool(b: bool, source: SourceSlice) ->...
code_fim
hard
{ "lang": "rust", "repo": "mangolang/compiler", "path": "/src/lexeme/collect/short.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cronokirby/ludus path: /src/controller.rs #[derive(Default)] pub struct ButtonState { pub a: bool, pub b: bool, pub select: bool, pub start: bool, pub up: bool, pub down: bool, pub left: bool, pub right: bool, } <|fim_suffix|>impl Controller { pub fn new() ->...
code_fim
hard
{ "lang": "rust", "repo": "cronokirby/ludus", "path": "/src/controller.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Controller { pub fn new() -> Self { Controller::default() } pub fn set_buttons(&mut self, buttons: ButtonState) { self.buttons = [ buttons.a, buttons.b, buttons.select, buttons.start, buttons.up, butt...
code_fim
hard
{ "lang": "rust", "repo": "cronokirby/ludus", "path": "/src/controller.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wangchao0502/rust-leetcode path: /src/p493_reverse_pairs.rs #![allow(dead_code)] // use mods pub struct Solution {} // problem description // Given an array nums, we call (i, j) an important reverse pair if i < j and nums[i] > 2*nums[j]. // You need to return the number of important reverse p...
code_fim
hard
{ "lang": "rust", "repo": "wangchao0502/rust-leetcode", "path": "/src/p493_reverse_pairs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while p1 <= mid || p2 <= right { if p1 > mid { sorted[p] = nums[p2]; p2 += 1; } else if p2 > right { sorted[p] = nums[p1]; p1 += 1; } else { if nu...
code_fim
hard
{ "lang": "rust", "repo": "wangchao0502/rust-leetcode", "path": "/src/p493_reverse_pairs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhuxianbin0/garnet path: /bin/net-cli/src/main.rs // Copyright 2018 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. #![deny(warnings)] extern crate failure; extern crate fidl; extern crate fidl_fu...
code_fim
hard
{ "lang": "rust", "repo": "zhuxianbin0/garnet", "path": "/bin/net-cli/src/main.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>fn main() -> Result<(), Error> { let opt = Opt::from_args(); let mut exec = async::Executor::new().context("error creating event loop")?; let stack = connect_to_service::<StackMarker>().context("failed to connect to netstack")?; match opt { Opt::If(cmd) => exec.run_singlethreaded(...
code_fim
hard
{ "lang": "rust", "repo": "zhuxianbin0/garnet", "path": "/bin/net-cli/src/main.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arn-the-long-beard/arangors path: /src/error.rs use std::fmt; use serde::Deserialize; use thiserror::Error; use crate::connection::Permission; #[derive(Error, Debug)] pub enum ClientError { #[error("Insufficient permission ({permission:?}) to operate: {operation}")] InsufficientPermis...
code_fim
hard
{ "lang": "rust", "repo": "arn-the-long-beard/arangors", "path": "/src/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn error_num(&self) -> u16 { self.error_num } pub fn message(&self) -> &str { &self.message } }<|fim_prefix|>// repo: arn-the-long-beard/arangors path: /src/error.rs use std::fmt; use serde::Deserialize; use thiserror::Error; use crate::connection::Permission; #[de...
code_fim
medium
{ "lang": "rust", "repo": "arn-the-long-beard/arangors", "path": "/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>MIN_SAMPLE_VALUE: u16 = 340; pub const S_MAX_SAMPLE_VALUE: u16 = 341; pub const TRANSFER_RANGE: u16 = 342; pub const JPEG_PROC: u16 = 512; pub const JPEG_INTERCHANGE_FORMAT: u16 = 513; pub const JPEG_INTERCHANGE_FORMAT_LNGTH: u16 = 514; pub const JPEG_RESTART_INTERVAL: u16 = 515; pub const JPEG_LOSSLESS_P...
code_fim
hard
{ "lang": "rust", "repo": "Masterchef365/tiffy", "path": "/src/baseline/tags.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Masterchef365/tiffy path: /src/baseline/tags.rs pub const NEW_SUBFILE_TYPE: u16 = 254; pub const SUBFILE_TYPE: u16 = 255; pub const IMAGE_WIDTH: u16 = 256; pub const IMAGE_LENGTH: u16 = 257; pub const BITS_PER_SAMPLE: u16 = 258; pub const COMPRESSION: u16 = 259; pub const PHOTOMETRIC_INTERPRETAT...
code_fim
hard
{ "lang": "rust", "repo": "Masterchef365/tiffy", "path": "/src/baseline/tags.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match stream.write(input_buffer.as_bytes()) { Err(e) => { println!("Error writing at stream socket: {}", e); input_buffer.clear(); continue; } _ => {} } input_buffer.clear(); let bytes_rece...
code_fim
medium
{ "lang": "rust", "repo": "renorram/tcp_bike_station", "path": "/src/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: renorram/tcp_bike_station path: /src/client.rs use std::net::{TcpStream, SocketAddrV4}; use crate::server::{DEFAULT_SERVER_PORT, DEFAULT_LOCAL_ADDRESS}; use std::io::{Write, Read}; use std::str::FromStr; use std::process::exit; pub(crate) fn run_client(server_addr: Option<String>) -> std::io::R...
code_fim
hard
{ "lang": "rust", "repo": "renorram/tcp_bike_station", "path": "/src/client.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let map_entity = commands.spawn().id(); commands.entity(map_entity).insert_bundle( LdtkMapBundle { ldtk_map: handle, map: Map::new(0u16, map_entity), transform: Transform::from_xyz( -(0.5 * 1920.0), 706.0 - (1080.0 / 2.0)...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/super-corgo", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/super-corgo path: /src/main.rs { // if let Ok(( // entity, // tile, // )) = // tiles.get(*ent...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/super-corgo", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/super-corgo path: /src/main.rs ndle(collider) .insert_bundle(SpriteBundle { material: materials.add(Color::RED.into()), sprite: Sprite::new(Vec2::new(50000.0, 5.0)), ..Default::default() }) .insert(ColliderPositionSync::Discrete...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/super-corgo", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sklirg/sbanken_does_nynab path: /src/sbanken/helpers.rs use crate::helpers::http::{ base64_encode_uname_pw, generate_auth_header, generate_header_value, AuthenticationType, }; use crate::sbanken::config::get_config; use reqwest::header; pub fn build_authorization_http_client() -> reqwest::b...
code_fim
hard
{ "lang": "rust", "repo": "sklirg/sbanken_does_nynab", "path": "/src/sbanken/helpers.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn build_api_client(credentials: String) -> reqwest::blocking::Client { debug!("Building HTTP Client for authorized API requests"); let config = get_config(); let auth_header = generate_auth_header(credentials, AuthenticationType::Bearer); let customer_id_header = generate_header_val...
code_fim
hard
{ "lang": "rust", "repo": "sklirg/sbanken_does_nynab", "path": "/src/sbanken/helpers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mkurnikov/move-language-server path: /crates/integration_tests/tests/test_executor.rs use move_executor::compile_and_execute_script; use shared::errors::ExecCompilerError; use integration_tests::{ existing_file_abspath, get_modules_path, get_script_path, get_stdlib_path, }; use utils::{io, ...
code_fim
hard
{ "lang": "rust", "repo": "mkurnikov/move-language-server", "path": "/crates/integration_tests/tests/test_executor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let module_source_text = r" address wallet1me0cdn52672y7feddy7tgcj6j4dkzq2su745vh { module M { resource struct T { value: u8 } public fun get_t(v: u8) { move_to_sender<T>(T { value: v }) } } } "; let script_text = r" script { fun main() { ...
code_fim
hard
{ "lang": "rust", "repo": "mkurnikov/move-language-server", "path": "/crates/integration_tests/tests/test_executor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> where Chain: FnOnce(State) -> Box<HandlerFuture>, { state.put(Configuration { name: name(), version: version(), }); Box::new(chain(state)) } } #[cfg(test)] mod tests { use super::*; use gotham::pipeline::new_pipeline; use g...
code_fim
medium
{ "lang": "rust", "repo": "NikolaLohinski/rust-gcp-k8s-micro-server", "path": "/src/middlewares/configuration.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NikolaLohinski/rust-gcp-k8s-micro-server path: /src/middlewares/configuration.rs use gotham::handler::HandlerFuture; use gotham::state::State; use config::config::{name, version}; #[derive(StateData)] pub struct Configuration { pub name: String, pub version: String, } #[derive(Clone, ...
code_fim
hard
{ "lang": "rust", "repo": "NikolaLohinski/rust-gcp-k8s-micro-server", "path": "/src/middlewares/configuration.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Box::new(chain(state)) } } #[cfg(test)] mod tests { use super::*; use gotham::pipeline::new_pipeline; use gotham::pipeline::single::single_pipeline; use gotham::router::builder::*; use gotham::state::FromState; use gotham::test::TestServer; use hamcrest::prelude::...
code_fim
hard
{ "lang": "rust", "repo": "NikolaLohinski/rust-gcp-k8s-micro-server", "path": "/src/middlewares/configuration.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dbcfd/rust-rdkafka path: /src/util.rs //! Utility functions use crate::rdsys; use std::ffi::CStr; use std::os::raw::c_char; use std::os::raw::c_void; use std::ptr; use std::slice; use std::time::{Duration, SystemTime, UNIX_EPOCH}; /// Return a tuple representing the version of `librdkafka` in ...
code_fim
hard
{ "lang": "rust", "repo": "dbcfd/rust-rdkafka", "path": "/src/util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn ptr(&self) -> *mut Self::Target; fn is_null(&self) -> bool { self.ptr().is_null() } } /// Converts a container into a C array. pub(crate) trait AsCArray<T: WrappedCPointer> { fn as_c_array(&self) -> *mut *mut T::Target; } impl<T: WrappedCPointer> AsCArray<T> for Vec<T> { ...
code_fim
hard
{ "lang": "rust", "repo": "dbcfd/rust-rdkafka", "path": "/src/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unimplemented!() } /* End of support for GiST Index */ #[pg_operator(immutable, parallel_safe)] #[opname(?#)] pub fn intersects(t1: vectime, t2: vectime) -> bool { t1.partial_cmp(&t2).is_none() } #[pg_operator(immutable, parallel_safe)] #[opname(~=)] pub fn same(t1: vectime, t2: vectime) -> bo...
code_fim
hard
{ "lang": "rust", "repo": "Horusiath/pgrdt", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> unimplemented!() } /* End of support for GiST Index */ #[pg_operator(immutable, parallel_safe)] #[opname(?#)] pub fn intersects(t1: vectime, t2: vectime) -> bool { t1.partial_cmp(&t2).is_none() } #[pg_operator(immutable, parallel_safe)] #[opname(~=)] pub fn same(t1: vectime, t2: vectime) -> boo...
code_fim
hard
{ "lang": "rust", "repo": "Horusiath/pgrdt", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Horusiath/pgrdt path: /src/lib.rs #![feature(btree_retain)] #![allow(non_camel_case_types)] use std::collections::BTreeMap; use serde::{Serialize, Deserialize}; use std::cmp::Ordering; use pgx::*; use pgx::pg_sys::{GISTENTRY, StrategyNumber, Oid, GistEntryVector, Datum, GIST_SPLITVEC}; use std:...
code_fim
hard
{ "lang": "rust", "repo": "Horusiath/pgrdt", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nbigaouette/python-poetry-rust-wheel path: /dfrs/src/lib.rs #[derive(Debug)] #[repr(C)] pub struct Point { pub x: i32, pub y: i32, } #[no_mangle] fn modify_point(mut p: Point) { let old_x = p.x; println!("From Rust: p: {:?}", p); p.x = (p.y + 1) * 2; p.y = (old_x - 5) * ...
code_fim
easy
{ "lang": "rust", "repo": "nbigaouette/python-poetry-rust-wheel", "path": "/dfrs/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let p = Point {x: 1, y: 2}; modify_point(p); } }<|fim_prefix|>// repo: nbigaouette/python-poetry-rust-wheel path: /dfrs/src/lib.rs #[derive(Debug)] #[repr(C)] pub struct Point { pub x: i32, pub y: i32, } #[no_mangle] fn modify_point(mut p: Point) { let old_x = p.x; pr...
code_fim
easy
{ "lang": "rust", "repo": "nbigaouette/python-poetry-rust-wheel", "path": "/dfrs/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: boa-dev/boa path: /boa_engine/src/builtins/set/set_iterator.rs //! This module implements the `SetIterator` object. //! //! More information: //! - [ECMAScript reference][spec] //! //! [spec]: https://tc39.es/ecma262/#sec-set-iterator-objects use super::ordered_set::SetLock; use crate::{ b...
code_fim
hard
{ "lang": "rust", "repo": "boa-dev/boa", "path": "/boa_engine/src/builtins/set/set_iterator.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if set_iterator.iterated_set.is_undefined() { return Ok(create_iter_result_object( JsValue::undefined(), true, context, )); } let entries = m.as_object().map(JsObject::borrow); ...
code_fim
hard
{ "lang": "rust", "repo": "boa-dev/boa", "path": "/boa_engine/src/builtins/set/set_iterator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: toninhoPinto/fighting-game path: /src/rendering/renderer.rs use std::{collections::HashMap, string::String}; use sdl2::{rect::{Point, Rect}, render::TextureQuery}; use sdl2::render::WindowCanvas; use sdl2::{pixels::Color, render::Texture}; use crate::{asset_management::asset_holders::{EntityAs...
code_fim
hard
{ "lang": "rust", "repo": "toninhoPinto/fighting-game", "path": "/src/rendering/renderer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let spritesheet = level_assets.level_tiles.get(&level.level_map.tilesets[0].name).unwrap(); let src_rect = level.rect_from_index(tile.texture_id, layer_id); canvas.copy(spritesheet, src_rect, dst_rect).unwrap(); } ...
code_fim
hard
{ "lang": "rust", "repo": "toninhoPinto/fighting-game", "path": "/src/rendering/renderer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WorryingWonton/rust-bat path: /src/stringMatch.rs #[allow(non_snake_case)] fn stringMatch(s1: String, s2: String) -> i32 { let mut i = 0; let s1_len = s1.len(); let s2_len = s2.len(); let mut count = 0; while i < s1_len && i < s2_len { if i + 1 < s1_len && i + 1 < s2_...
code_fim
medium
{ "lang": "rust", "repo": "WorryingWonton/rust-bat", "path": "/src/stringMatch.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let tests = vec![ ("xxcaazz","xxbaaz"), ("abc","abc"), ("abc","axc"), ("hello","he"), ("he","hello"), ("h","hello"), ("","hello"), ("aabbccdd","abbbxd"), ("aaxxaaxx","iaxxai"), ("iaxxai","aaxxaaxx")]; for i in tests { ...
code_fim
medium
{ "lang": "rust", "repo": "WorryingWonton/rust-bat", "path": "/src/stringMatch.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nbigaouette/advent_of_code_2017 path: /day03/src/lib.rs //! # Day 3: Spiral Memory //! //! ## Part One //! //! You come across an experimental new kind of memory stored on an infinite two-dimensional grid. //! //! Each square on the grid is allocated in a spiral pattern starting at a location ma...
code_fim
hard
{ "lang": "rust", "repo": "nbigaouette/advent_of_code_2017", "path": "/day03/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(expected, to_check); } #[test] fn part_2_test_coordinates() { assert_eq!(MemoryLocation::new(1).coordinates(), (0, 0)); assert_eq!(MemoryLocation::new(2).coordinates(), (1, 0)); assert_eq!(Memo...
code_fim
hard
{ "lang": "rust", "repo": "nbigaouette/advent_of_code_2017", "path": "/day03/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Err(e) = insertion_thread.join() { error!("Error joining on inserter thread: {:?}", e); } info!( "Library index update took {} seconds", start.elapsed().as_millis() as f32 / 1000.0 ); Ok(()) } }<|fim_prefix|>// repo: chengjingfeng/polaris path: /src/app/index/update/mod.rs us...
code_fim
hard
{ "lang": "rust", "repo": "chengjingfeng/polaris", "path": "/src/app/index/update/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chengjingfeng/polaris path: /src/app/index/update/mod.rs use anyhow::*; use log::{error, info}; use std::time; mod cleaner; mod collector; mod inserter; mod traverser; use super::*; use cleaner::Cleaner; use collector::Collector; use inserter::Inserter; use traverser::Traverser; <|fim_suffix|...
code_fim
medium
{ "lang": "rust", "repo": "chengjingfeng/polaris", "path": "/src/app/index/update/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Err(e) = collector_thread.join() { error!("Error joining on collector thread: {:?}", e); } if let Err(e) = insertion_thread.join() { error!("Error joining on inserter thread: {:?}", e); } info!( "Library index update took {} seconds", start.elapsed().as_millis() as f32 / 100...
code_fim
hard
{ "lang": "rust", "repo": "chengjingfeng/polaris", "path": "/src/app/index/update/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dwango/fibers-rs path: /src/net/udp.rs // Copyright (c) 2016 DWANGO Co., Ltd. All Rights Reserved. // See the LICENSE file at the top-level directory of this distribution. use futures::{Async, Future, Poll}; use mio::net::UdpSocket as MioUdpSocket; use std::fmt; use std::io; use std::net::Socke...
code_fim
hard
{ "lang": "rust", "repo": "dwango/fibers-rs", "path": "/src/net/udp.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Calls `f` with the reference to the inner socket. pub fn with_inner<F, T>(&self, f: F) -> T where F: FnOnce(&MioUdpSocket) -> T, { f(&*self.handle.inner()) } } impl fmt::Debug for UdpSocket { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(...
code_fim
hard
{ "lang": "rust", "repo": "dwango/fibers-rs", "path": "/src/net/udp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (width, height) = window.get_inner_size().unwrap(); let aspect = (width as f32 * window.hidpi_factor()) / (height as f32 * window.hidpi_factor()); self.perspective = cgmath::perspective(cgmath::deg(self.fov), aspect, self.near, self.far); pr...
code_fim
hard
{ "lang": "rust", "repo": "Aceeri/overseer-build", "path": "/src/camera.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }