text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: gz/rust-elfloader path: /src/arch/mod.rs use crate::{ElfLoaderErr, Machine}; pub mod aarch64; pub mod arm; pub mod riscv; pub mod x86; pub mod x86_64; #[cfg(test)] mod test; <|fim_suffix|>impl RelocationType { /// Match an architecture and value to a Relocation type pub fn from(machin...
code_fim
hard
{ "lang": "rust", "repo": "gz/rust-elfloader", "path": "/src/arch/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pected, /// that return value can be safely ignored. pub fn execute_script( environment: &mut Lua, filename: &str, ) -> Result<AnyLuaValue, DeucalionError> { use std::fs::File; use std::io::prelude::*; // Open the file let mut f = try!(File::open(filename)); // With the file op...
code_fim
hard
{ "lang": "rust", "repo": "team-code/deucalion", "path": "/deucalion-rs/src/scripting/basic.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: team-code/deucalion path: /deucalion-rs/src/scripting/basic.rs //! Basic operations on the Lua context, such as creation, destruction, etc use hlua::Lua; use hlua::AnyLuaValue; use error::DeucalionError; /// Do all required work to initialize a game's Lua context. /// The Lua object returned by...
code_fim
hard
{ "lang": "rust", "repo": "team-code/deucalion", "path": "/deucalion-rs/src/scripting/basic.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Alternate function mode (MODER=0b10). pub struct AlternateMode<Af: PinAf> { af: PhantomData<Af>, } impl<Af: PinAf> PinModeMap for AlternateMode<Af> {} impl<Af: PinAf> PinModeOrDontCare for AlternateMode<Af> {} // TODO: Analog mode /// Push/pull type (OTYPER=0). /// This is only applicabale for ...
code_fim
hard
{ "lang": "rust", "repo": "kaivol/drone-stm32f4-hal", "path": "/src/gpio/pin.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaivol/drone-stm32f4-hal path: /src/gpio/pin.rs use alloc::sync::Arc; use core::marker::PhantomData; use drone_cortexm::reg::prelude::*; use drone_stm32_map::periph::gpio::{ head::GpioHeadMap, pin::{GpioPinMap, GpioPinPeriph}, }; pub trait PinModeOrDontCare: Send + Sync + 'static {} pub...
code_fim
hard
{ "lang": "rust", "repo": "kaivol/drone-stm32f4-hal", "path": "/src/gpio/pin.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>af_token!(PinAf0, 0); af_token!(PinAf1, 1); af_token!(PinAf2, 2); af_token!(PinAf3, 3); af_token!(PinAf4, 4); af_token!(PinAf5, 5); af_token!(PinAf6, 6); af_token!(PinAf7, 7); af_token!(PinAf8, 8); af_token!(PinAf9, 9); af_token!(PinAf10, 10); af_token!(PinAf11, 11); af_token!(PinAf12, 12); af_token!(PinA...
code_fim
hard
{ "lang": "rust", "repo": "kaivol/drone-stm32f4-hal", "path": "/src/gpio/pin.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> W(writer) } } #[doc = "Field `adpll_sdm_dither_en_2444` reader - "] pub struct ADPLL_SDM_DITHER_EN_2444_R(crate::FieldReader<bool, bool>); impl ADPLL_SDM_DITHER_EN_2444_R { pub(crate) fn new(bits: bool) -> Self { ADPLL_SDM_DITHER_EN_2444_R(crate::FieldReader::new(bits)) } } imp...
code_fim
hard
{ "lang": "rust", "repo": "ehntoo/bl702-pac", "path": "/src/rf/lo_config_2444.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ehntoo/bl702-pac path: /src/rf/lo_config_2444.rs #[doc = "Register `lo_config_2444` reader"] pub struct R(crate::R<LO_CONFIG_2444_SPEC>); impl core::ops::Deref for R { type Target = crate::R<LO_CONFIG_2444_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 ...
code_fim
hard
{ "lang": "rust", "repo": "ehntoo/bl702-pac", "path": "/src/rf/lo_config_2444.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `adpll_sdm_dither_en_2444` writer - "] pub struct ADPLL_SDM_DITHER_EN_2444_W<'a> { w: &'a mut W, } impl<'a> ADPLL_SDM_DITHER_EN_2444_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) ...
code_fim
hard
{ "lang": "rust", "repo": "ehntoo/bl702-pac", "path": "/src/rf/lo_config_2444.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // part 2 reader.seek(SeekFrom::Start(0))?; let mut total2: i32 = 0; for line in reader.by_ref().lines() { let mut inner_total: i32 = 0; let thing = line?; let mut module_mass: i32 = thing.parse().unwrap(); loop { let fuel: i32 = module_mass / 3...
code_fim
hard
{ "lang": "rust", "repo": "SriRamanujam/adventofcode", "path": "/2019/src/day1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut total2: i32 = 0; for line in reader.by_ref().lines() { let mut inner_total: i32 = 0; let thing = line?; let mut module_mass: i32 = thing.parse().unwrap(); loop { let fuel: i32 = module_mass / 3 - 2; if fuel > 0 { inner...
code_fim
medium
{ "lang": "rust", "repo": "SriRamanujam/adventofcode", "path": "/2019/src/day1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SriRamanujam/adventofcode path: /2019/src/day1.rs use std::fs::File; use std::io::{self, prelude::*, BufReader, SeekFrom}; fn main() -> io::Result<()> { let path = std::env::args().nth(1).expect("need to pass input file"); <|fim_suffix|> // part 2 reader.seek(SeekFrom::Start(0))?; ...
code_fim
hard
{ "lang": "rust", "repo": "SriRamanujam/adventofcode", "path": "/2019/src/day1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let input = std::fs::read_to_string("../input.txt").unwrap(); let mut rules: HashMap<&str, Vec<(usize, &str)>> = HashMap::new(); for rule in input.split("\n").filter(|l| !l.is_empty()) { let mut parts: Vec<&str> = rule.trim_end_matches(".").split(" bags contain ").collect(); ...
code_fim
hard
{ "lang": "rust", "repo": "hamaluik/adventofcode2020", "path": "/day07/b/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hamaluik/adventofcode2020 path: /day07/b/src/main.rs use std::collections::HashMap; fn contained_bags(rules: &HashMap<&str, Vec<(usize, &str)>>, colour: &str) -> usize { rules .get(colour) .unwrap() .iter() .map(|(cnt, colour)| (cnt * contained_bags(rules, co...
code_fim
hard
{ "lang": "rust", "repo": "hamaluik/adventofcode2020", "path": "/day07/b/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let source = r#" def nested_ifs(): if n > 3: if n > 4: return "bigger than four" else: return "bigger than three" else: return "smaller than or equal to three" "#; let stmts = parse_suite(source, "<filename>")?; assert_eq!(get...
code_fim
hard
{ "lang": "rust", "repo": "astral-sh/ruff", "path": "/crates/ruff/src/rules/mccabe/rules/function_is_too_complex.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: astral-sh/ruff path: /crates/ruff/src/rules/mccabe/rules/function_is_too_complex.rs use ruff_python_ast::{self as ast, ExceptHandler, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::identifier::Identifier; /// ## ...
code_fim
hard
{ "lang": "rust", "repo": "astral-sh/ruff", "path": "/crates/ruff/src/rules/mccabe/rules/function_is_too_complex.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rileylyman/vulkano-renderer path: /src/main.rs #[macro_use] extern crate vulkano; extern crate vulkano_shaders; extern crate winit; extern crate vulkano_win; extern crate image; use std::cmp::{min, max}; use std::vec::Vec; use std::time::Instant; use std::sync::Arc; use std::error::Error; use w...
code_fim
hard
{ "lang": "rust", "repo": "rileylyman/vulkano-renderer", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let dimensions = images[0].dimensions(); let viewport = Viewport { origin: [0.0, 0.0], dimensions: [dimensions[0] as f32, dimensions[1] as f32], depth_range: 0.0..1.0 }; let depth_buffer = AttachmentImage::transient(device.clone(), dimensions, Format::D16Unorm) ...
code_fim
hard
{ "lang": "rust", "repo": "rileylyman/vulkano-renderer", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match future { Ok(future) => previous_frame_end = Box::new(future) as Box<_>, Err(FlushError::OutOfDate) => { recreate_swapchain = true; previous_frame_end = Box::new(sync::now(device.clone())) as Box<_>; } Err(err) =>...
code_fim
hard
{ "lang": "rust", "repo": "rileylyman/vulkano-renderer", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// PGC CPU Control Register pub mod CPU_CTRL { pub use super::MEGA_CTRL::PCR; } /// PGC CPU Power Up Sequence Control Register pub mod CPU_PUPSCR { pub use super::MEGA_PUPSCR::SW; pub use super::MEGA_PUPSCR::SW2ISO; } /// PGC CPU Pull Down Sequence Control Register pub mod CPU_PDNSCR { ...
code_fim
hard
{ "lang": "rust", "repo": "mitchmindtree/imxrt-rs", "path": "/imxrt-ral/src/imxrt102/imxrt1021/pgc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mitchmindtree/imxrt-rs path: /imxrt-ral/src/imxrt102/imxrt1021/pgc.rs #![allow(non_snake_case, non_upper_case_globals)] #![allow(non_camel_case_types)] //! PGC use crate::RWRegister; #[cfg(not(feature = "nosync"))] use core::marker::PhantomData; /// PGC Mega Control Register pub mod MEGA_CTRL ...
code_fim
hard
{ "lang": "rust", "repo": "mitchmindtree/imxrt-rs", "path": "/imxrt-ral/src/imxrt102/imxrt1021/pgc.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lineCode/tuix path: /examples/settings.rs use tuix::*; const STYLE: &str = r#" dropdown { border-radius: 3px; color: #ababab; border-width: 1px; border-color: #ababab; } dropdown>.header>.label { color: black; child-left: 10px; ...
code_fim
hard
{ "lang": "rust", "repo": "lineCode/tuix", "path": "/examples/settings.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let row = Row::new().build(state, audio_device, |builder| builder .set_child_top(Stretch(1.0)) .set_child_bottom(Stretch(1.0)) .set_width(Stretch(1.0)) .set_height(Pixels(30.0)) .set_top(Pixels(20.0)) ...
code_fim
hard
{ "lang": "rust", "repo": "lineCode/tuix", "path": "/examples/settings.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let minus = Button::new() .build(state, row, |builder| { builder .set_width(Pixels(20.0)) .set_height(Pixels(20.0)) .set_border_color(Color::rgb(100, 100, 100)) .set_border_width(Pixels(2.0)) .set_t...
code_fim
hard
{ "lang": "rust", "repo": "lineCode/tuix", "path": "/examples/settings.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let matches: Result<Vec<SearchResult>, _> = query .map(|row| SearchResult { site_id: row.get::<i32, _>("id") as i64, site_id_str: row.get::<i32, _>("id").to_string(), url: row.get("url"), filename: row.get("filename"), posted_at: row....
code_fim
hard
{ "lang": "rust", "repo": "Syfaro/fuzzysearch", "path": "/fuzzysearch-api/src/handlers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Syfaro/fuzzysearch path: /fuzzysearch-api/src/handlers.rs t; use hyper::StatusCode; use lazy_static::lazy_static; use prometheus::{register_histogram, register_int_counter, Histogram, IntCounter}; use std::convert::TryInto; use tracing::{span, warn}; use tracing_futures::Instrument; use warp::{R...
code_fim
hard
{ "lang": "rust", "repo": "Syfaro/fuzzysearch", "path": "/fuzzysearch-api/src/handlers.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Syfaro/fuzzysearch path: /fuzzysearch-api/src/handlers.rs ometheus::{register_histogram, register_int_counter, Histogram, IntCounter}; use std::convert::TryInto; use tracing::{span, warn}; use tracing_futures::Instrument; use warp::{Rejection, Reply}; use crate::models::image_query; use crate::...
code_fim
hard
{ "lang": "rust", "repo": "Syfaro/fuzzysearch", "path": "/fuzzysearch-api/src/handlers.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Config { pool_size: 10, helper_threads: 3, test_on_check_out: true, initialization_fail_fast: true, connection_timeout: Duration::seconds(30), } } } impl Config { /// Creates a new `Builder` which can be used to construct...
code_fim
hard
{ "lang": "rust", "repo": "markuskobler/r2d2", "path": "/src/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: markuskobler/r2d2 path: /src/config.rs //! Pool configuration. use std::default::Default; use time::Duration; /// A builder for `Config`. /// /// See the documentation of `Config` for more details about the default value /// and meaning of the configuration parameters. #[derive(Clone, Debug)] p...
code_fim
hard
{ "lang": "rust", "repo": "markuskobler/r2d2", "path": "/src/config.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Sets `connection_timeout`. /// /// # Panics /// /// Panics if `connection_timeout` is nonpositive. #[inline] pub fn connection_timeout(mut self, connection_timeout: Duration) -> Builder { assert!(connection_timeout > Duration::zero(), "connection_timeout must be pos...
code_fim
hard
{ "lang": "rust", "repo": "markuskobler/r2d2", "path": "/src/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> I: &mut [isize], V: &mut [isize], start: usize, len: usize, h: usize, ) -> Option<SplitParams> { if len < 16 { let mut k = start; while k < start + len { let mut j = 1; let mut x = V[usz(I[k] + h as isize)]; let mut i = 1; ...
code_fim
hard
{ "lang": "rust", "repo": "space-wizards/bsdiff-rs", "path": "/src/diff.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if start + len > kk { Some(SplitParams { start: kk, len: start + len - kk, }) } else { None } } } fn split(I: &mut [isize], V: &mut [isize], start: usize, len: usize, h: usize) { let mut ret = Some(SplitPa...
code_fim
hard
{ "lang": "rust", "repo": "space-wizards/bsdiff-rs", "path": "/src/diff.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: space-wizards/bsdiff-rs path: /src/diff.rs #![allow(non_snake_case)] /*- * Copyright 2003-2005 Colin Percival * Copyright 2012 Matthew Endsley * Modified 2017 Pieter-Jan Briers * All rights reserved * * Redistribution and use in source and binary forms, with or without * modification, are...
code_fim
hard
{ "lang": "rust", "repo": "space-wizards/bsdiff-rs", "path": "/src/diff.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] fn read_uint128(buf: &[u8], nbytes: usize) -> u128 { assert!(1 <= nbytes && nbytes <= 16 && nbytes <= buf.len()); let mut out = [0u8; 16]; let ptr_out = out.as_mut_ptr(); unsafe { copy_nonoverlapping( buf.as_ptr(), ptr_out.offse...
code_fim
hard
{ "lang": "rust", "repo": "Trietptm-on-Security/seer", "path": "/src/byteorder/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] fn read_uint(buf: &[u8], nbytes: usize) -> u64 { assert!(1 <= nbytes && nbytes <= 8 && nbytes <= buf.len()); let mut out = [0u8; 8]; let ptr_out = out.as_mut_ptr(); unsafe { copy_nonoverlapping(buf.as_ptr(), ptr_out, nbytes); (*(ptr...
code_fim
hard
{ "lang": "rust", "repo": "Trietptm-on-Security/seer", "path": "/src/byteorder/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Trietptm-on-Security/seer path: /src/byteorder/mod.rs /* horrible hack: we include the byteorder crate inline, so that we can use the 'i128' feature and publish to crates.io https://github.com/BurntSushi/byteorder/issues/89 */ use core::fmt::Debug; use core::hash::Hash; use core::mem::transmu...
code_fim
hard
{ "lang": "rust", "repo": "Trietptm-on-Security/seer", "path": "/src/byteorder/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ChorusOne/solana path: /sdk/program/src/nonce/state/mod.rs //! State for durable transaction nonces. mod current; pub use current::{Data, DurableNonce, State}; use { crate::hash::Hash, serde_derive::{Deserialize, Serialize}, }; #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clo...
code_fim
hard
{ "lang": "rust", "repo": "ChorusOne/solana", "path": "/sdk/program/src/nonce/state/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl From<Versions> for State { fn from(versions: Versions) -> Self { match versions { Versions::Legacy(state) => *state, Versions::Current(state) => *state, } } } #[cfg(test)] mod tests { use { super::*, crate::{fee_calculator::FeeCalcu...
code_fim
hard
{ "lang": "rust", "repo": "ChorusOne/solana", "path": "/sdk/program/src/nonce/state/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kkarad/templar path: /src/conf.rs extern crate toml; use serde::Deserialize; use std::fs::OpenOptions; use std::io::Write; use std::path::{Path, PathBuf}; use crate::release::Release; <|fim_suffix|>pub fn init(mut home_dir: PathBuf) -> Result<Conf, String> { home_dir.push(".templar.toml")...
code_fim
hard
{ "lang": "rust", "repo": "kkarad/templar", "path": "/src/conf.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn init(mut home_dir: PathBuf) -> Result<Conf, String> { home_dir.push(".templar.toml"); let conf_file: &Path = home_dir.as_path(); if let Ok(mut file) = OpenOptions::new().write(true).create_new(true).open(&conf_file) { let _ = file.write_all(default_conf().as_bytes()); } ...
code_fim
hard
{ "lang": "rust", "repo": "kkarad/templar", "path": "/src/conf.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Node::Expression(exp) = expr.unwrap() { return Some(Node::Statement(Statement::VariableDeclaration( VariableDeclaration { ident: Identifier { value: ident.literal, }, value: Box::new(exp), }, ...
code_fim
medium
{ "lang": "rust", "repo": "shinglyu/loop", "path": "/src/parser/statement/variable.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shinglyu/loop path: /src/parser/statement/variable.rs use crate::lexer::token::TokenType; use crate::parser::expression::identifier::Identifier; use crate::parser::expression::{Expression, Precedence}; use crate::parser::program::Node; use crate::parser::Parser; use super::Statement; #[derive(...
code_fim
medium
{ "lang": "rust", "repo": "shinglyu/loop", "path": "/src/parser/statement/variable.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: millicare/NFTYieldFarming-Substrate path: /contracts/media/src/errors.rs use scale::{Decode, Encode}; /// The Error type for this crate #[derive(Debug, Clone, PartialEq, Eq, Encode, Decode, err_derive::Error)] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] pub enum Error { /// T...
code_fim
hard
{ "lang": "rust", "repo": "millicare/NFTYieldFarming-Substrate", "path": "/contracts/media/src/errors.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>// The balance is insufficient #[error(display = "The balance is insufficient")] InsufficientBalance, /// An ERC-1620 error occurred #[error(display = "An Erc1620 error occurred: {}", _0)] Erc1620(#[source] erc1620::Error), /// An ERC-20 error occurred #[error(display = "An Erc...
code_fim
hard
{ "lang": "rust", "repo": "millicare/NFTYieldFarming-Substrate", "path": "/contracts/media/src/errors.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/prowl path: /src/actors/islands/island_component.rs use specs::{Component, VecStorage}; use specs_derive::Component; use crate::shared::Vector2; #[derive(Component, Debug)] #[storage(VecStorage)] pub struct Island{ // pub size: i32, //affect island size on map // pub arable: i...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/prowl", "path": "/src/actors/islands/island_component.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut coast_tile_positions = vec![]; for position in tile_positions { for x in -1..1 { for y in -1..1 { let position = Vector2::new(position.x + x, position.y + y); if !tile_positions.contains(&position) { ...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/prowl", "path": "/src/actors/islands/island_component.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn calculate_coastline(tile_positions: &Vec<Vector2>) -> Vec<Vector2> { let mut coast_tile_positions = vec![]; for position in tile_positions { for x in -1..1 { for y in -1..1 { let position = Vector2::new(position.x + x, position.y + y);...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/prowl", "path": "/src/actors/islands/island_component.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { let caught_up = if next_phase_is_even { self.parent.odd_end_epoch.load(Ordering::Relaxed) == start_value_at_flip } else { self.parent.even_end_epoch.load(Ordering::Relaxed) == start_value_at_flip }; if !caught_u...
code_fim
hard
{ "lang": "rust", "repo": "soro/rusty-hdrhistogram", "path": "/src/concurrent/writer_reader_phaser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: soro/rusty-hdrhistogram path: /src/concurrent/writer_reader_phaser.rs //! ReaderWriterPhaser implementation used in concurrent Histograms //! //! Writers acquire a write interface by invoking //! ```let wi = WriterReaderPhaser::write(phaser)``` //! and then call //! ```let section_guard = wi.beg...
code_fim
hard
{ "lang": "rust", "repo": "soro/rusty-hdrhistogram", "path": "/src/concurrent/writer_reader_phaser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: supercmmetry/jirachi path: /src/collision_resistant/mod.rs mod seed; use crate::collision_resistant::seed::Seed; use crate::schema::seeds::dsl::*; use diesel::prelude::*; use diesel::{PgConnection, RunQueryDsl, r2d2}; use dotenv; use std::env; use crate::Wishable; use diesel::r2d2::ConnectionMa...
code_fim
hard
{ "lang": "rust", "repo": "supercmmetry/jirachi", "path": "/src/collision_resistant/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> conn.transaction::<_, diesel::result::Error, _>(|| { let seed_index_option: Option<i32> = seeds.select(min(index)).first(&conn)?; if seed_index_option.is_none() { return Err(diesel::result::Error::RollbackTransaction); } let seed_in...
code_fim
hard
{ "lang": "rust", "repo": "supercmmetry/jirachi", "path": "/src/collision_resistant/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>test/AuroraUserGuide/USER_PerfInsights.html">Amazon Aurora User Guide</a>.</p> </li> <li> <p>To learn more about Performance Insights and Amazon RDS DB instances, go to the <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PerfInsights.html">Amazon RDS User Guide</a>.</p> </li> </ul></p...
code_fim
hard
{ "lang": "rust", "repo": "wg/rusoto", "path": "/rusoto/services/pi/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wg/rusoto path: /rusoto/services/pi/src/lib.rs // ================================================================= // // * WARNING * // // This file is generated! // // Changes made to this file will be overwritten. If changes are // required to th...
code_fim
hard
{ "lang": "rust", "repo": "wg/rusoto", "path": "/rusoto/services/pi/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Orca-bit/DataStructureAndAlgorithm path: /src/listlink/_23_merge_k_sorted_lists.rs use super::util::*; use std::collections::VecDeque; struct Solution; impl Solution { pub fn merge_k_lists(mut lists: Vec<ListLink>) -> ListLink { if lists.is_empty() { return None; ...
code_fim
hard
{ "lang": "rust", "repo": "Orca-bit/DataStructureAndAlgorithm", "path": "/src/listlink/_23_merge_k_sorted_lists.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let lists = vec![list!(1, 4, 5), list!(1, 3, 4), list!(2, 6)]; let res = list!(1, 1, 2, 3, 4, 4, 5, 6); assert_eq!(Solution::merge_k_lists(lists), res); }<|fim_prefix|>// repo: Orca-bit/DataStructureAndAlgorithm path: /src/listlink/_23_merge_k_sorted_lists.rs use super::util::*; use std::coll...
code_fim
hard
{ "lang": "rust", "repo": "Orca-bit/DataStructureAndAlgorithm", "path": "/src/listlink/_23_merge_k_sorted_lists.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ajguerrer/tobu-conversion path: /src/descriptor.rs #[derive(Debug)] pub struct MessageDescriptor { pub name: &'static str, pub fields: &'static [FieldDescriptor], } #[derive(Debug)] pub struct FieldDescriptor { pub ty: Type, pub label: Label, } #[derive(Debug)] pub enum Type { ...
code_fim
medium
{ "lang": "rust", "repo": "ajguerrer/tobu-conversion", "path": "/src/descriptor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct EnumDescriptor { pub values: &'static [i32], }<|fim_prefix|>// repo: ajguerrer/tobu-conversion path: /src/descriptor.rs #[derive(Debug)] pub struct MessageDescriptor { pub name: &'static str, pub fields: &'static [FieldDescriptor], } <|fim_middle|>#[derive(Debug)]...
code_fim
hard
{ "lang": "rust", "repo": "ajguerrer/tobu-conversion", "path": "/src/descriptor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..shapes { let mut x_bar: f64 = 0.0; let mut y_bar: f64 = 0.0; for j in 0..dots { let val_x = a[(i * dots * 2 + j * 2) as usize]; let val_y = a[(i * dots * 2 + j * 2 + 1) as usize]; x_bar += val_x; y_bar += val_y; ...
code_fim
hard
{ "lang": "rust", "repo": "wormtql/procrustes-analysis-wasm", "path": "/wasm/rust-wasm/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wormtql/procrustes-analysis-wasm path: /wasm/rust-wasm/src/lib.rs mod utils; use wasm_bindgen::prelude::*; // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global // allocator. #[cfg(feature = "wee_alloc")] #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::We...
code_fim
hard
{ "lang": "rust", "repo": "wormtql/procrustes-analysis-wasm", "path": "/wasm/rust-wasm/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn remove_translate(a: &mut Vec<f64>, shapes: i32, dots: i32) { for i in 0..shapes { let mut x_bar: f64 = 0.0; let mut y_bar: f64 = 0.0; for j in 0..dots { let val_x = a[(i * dots * 2 + j * 2) as usize]; let val_y = a[(i * dots * 2 + j * 2 + 1) as usize]...
code_fim
hard
{ "lang": "rust", "repo": "wormtql/procrustes-analysis-wasm", "path": "/wasm/rust-wasm/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[proc_macro_derive(SerdeDiff, attributes(serde_diff))] pub fn serde_diff_macro_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream { serde_diff::macro_derive(input) }<|fim_prefix|>// repo: aclysma/serde-diff path: /serde-diff-derive/src/lib.rs extern crate proc_macro; <|fim_middle|>mo...
code_fim
easy
{ "lang": "rust", "repo": "aclysma/serde-diff", "path": "/serde-diff-derive/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aclysma/serde-diff path: /serde-diff-derive/src/lib.rs extern crate proc_macro; <|fim_suffix|>#[proc_macro_derive(SerdeDiff, attributes(serde_diff))] pub fn serde_diff_macro_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream { serde_diff::macro_derive(input) }<|fim_middle|>mo...
code_fim
easy
{ "lang": "rust", "repo": "aclysma/serde-diff", "path": "/serde-diff-derive/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let five = Some(5); let six = plus_one(five); let none = plus_one(None); // ANCHOR_END: here }<|fim_prefix|>// repo: KaiserY/trpl-zh-cn path: /listings/ch06-enums-and-pattern-matching/listing-06-05/src/main.rs fn main() { // ANCHOR: here fn plus_one(x: Option<i32>) -> Option<i32> ...
code_fim
hard
{ "lang": "rust", "repo": "KaiserY/trpl-zh-cn", "path": "/listings/ch06-enums-and-pattern-matching/listing-06-05/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KaiserY/trpl-zh-cn path: /listings/ch06-enums-and-pattern-matching/listing-06-05/src/main.rs fn main() { // ANCHOR: here fn plus_one(x: Option<i32>) -> Option<i32> { <|fim_suffix|> let five = Some(5); let six = plus_one(five); let none = plus_one(None); // ANCHOR_END: here...
code_fim
hard
{ "lang": "rust", "repo": "KaiserY/trpl-zh-cn", "path": "/listings/ch06-enums-and-pattern-matching/listing-06-05/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fnimick/extensible-systems path: /5_kelly_nimick/graph_traversal/src/main.rs #![allow(unstable)] use std::io::{File, BufferedReader}; use graph::LabeledGraph; mod graph; static NO_PATH: &'static str = "No path found"; static WRONG_NODE_COUNT: &'static str = "You must provide a start and end no...
code_fim
hard
{ "lang": "rust", "repo": "fnimick/extensible-systems", "path": "/5_kelly_nimick/graph_traversal/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut g = LabeledGraph::new(); g.add_edge("a", "b"); g.add_edge("b", "c"); g.add_edge("c", "d"); g.add_edge("e", "d"); g.add_edge("f", "d"); let input = "a b\nb c\nc d\ne d\nf d"; let bytes = input.to_string().into_bytes(); let mut ...
code_fim
hard
{ "lang": "rust", "repo": "fnimick/extensible-systems", "path": "/5_kelly_nimick/graph_traversal/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let g = create_graph(); run_test("a b", "a b", &g); run_test("a d", "a b c d", &g); run_test("d a", NO_PATH, &g); } fn run_test(input: &str, output: &str, graph: &LabeledGraph) { let mut user_input = input.to_string(); user_input.push_str("\n"); ...
code_fim
hard
{ "lang": "rust", "repo": "fnimick/extensible-systems", "path": "/5_kelly_nimick/graph_traversal/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let name = ast.ident; //"Pancakes"字段 let gen = quote! { impl HelloMacro for #name { fn hello_macro(){ //stringify!接收一个Rust表达式,在编译时将其转换为字符串字面量 println!("Hello, Macro! My name is {}", stringify!(#name)); } } }; gen.into...
code_fim
hard
{ "lang": "rust", "repo": "DavidsIdylle/RustLearningCodes", "path": "/hello_macro/hello_macro_derive/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //stringify!接收一个Rust表达式,在编译时将其转换为字符串字面量 println!("Hello, Macro! My name is {}", stringify!(#name)); } } }; gen.into() //将quote!宏执行结果转换换位TokenStream类型 }<|fim_prefix|>// repo: DavidsIdylle/RustLearningCodes path: /hello_macro/hello_macro_derive/s...
code_fim
hard
{ "lang": "rust", "repo": "DavidsIdylle/RustLearningCodes", "path": "/hello_macro/hello_macro_derive/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DavidsIdylle/RustLearningCodes path: /hello_macro/hello_macro_derive/src/lib.rs extern crate proc_macro; use crate::proc_macro::TokenStream; use quote::quote; //将syn包产生的数据结构重新转换为Rust代码 use syn; //将Rust代码从字符串转换为可供进一步操作的数据结构体 <|fim_suffix|> //stringify!接收一个Rust表达式,在编译时将其转换为字符串字面量...
code_fim
hard
{ "lang": "rust", "repo": "DavidsIdylle/RustLearningCodes", "path": "/hello_macro/hello_macro_derive/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let channel_store = generate_random_channel_store(); let startup_info = channel_store.get_startup_info(); assert!(startup_info.is_ok()); assert!(startup_info.unwrap().is_none()); }<|fim_prefix|>// repo: ssyuan/stargate path: /sgstorage/tests/channel_store_test.rs // Copyright (c) The Star...
code_fim
medium
{ "lang": "rust", "repo": "ssyuan/stargate", "path": "/sgstorage/tests/channel_store_test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ssyuan/stargate path: /sgstorage/tests/channel_store_test.rs // Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 <|fim_suffix|>#[test] fn test_channel_store_startup() { let channel_store = generate_random_channel_store(); let startup_info = channel_sto...
code_fim
easy
{ "lang": "rust", "repo": "ssyuan/stargate", "path": "/sgstorage/tests/channel_store_test.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adam-mcdaniel/ramify path: /src/ast.rs Self::GreaterEqual(a, b) => { Self::GreaterEqual(a.resolve_tailcall(false), b.resolve_tailcall(false)) } Self::Less(a, b) => { Self::Less(a.resolve_tailcall(false), b.resolve_tail...
code_fim
hard
{ "lang": "rust", "repo": "adam-mcdaniel/ramify", "path": "/src/ast.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self::IfThenElse { condition, then_case, else_case, } => condition.is_recursive() || then_case.is_recursive() || else_case.is_recursive(), Self::CaseOf { value, cases, .. } => { for (_, _, case_body) in cas...
code_fim
hard
{ "lang": "rust", "repo": "adam-mcdaniel/ramify", "path": "/src/ast.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adam-mcdaniel/ramify path: /src/ast.rs Self::Negate(a) => Self::Negate(a.replace_constant(constant)), Self::Add(a, b) => { Self::Add(a.replace_constant(constant), b.replace_constant(constant)) } Self::Multiply(a, b) => { Se...
code_fim
hard
{ "lang": "rust", "repo": "adam-mcdaniel/ramify", "path": "/src/ast.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: saik0/rust-aoc-2020 path: /day01/src/lib.rs #![cfg_attr(feature = "unstable", feature(test))] const TARGET_YEAR: usize = 2020; const INPUT: &'static str = include_str!("../input"); trait Parser { fn parse(input: &str) -> Vec<usize>; } pub struct UnsortedParser; impl Parser for UnsortedPa...
code_fim
hard
{ "lang": "rust", "repo": "saik0/rust-aoc-2020", "path": "/day01/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let actual = parse_and_solve_part(INPUT, Part2, BruteForce); assert_eq!(actual, 303394260); } #[test] fn part_2_two_pointer_sample_01() { let actual = parse_and_solve_part(SAMPLE_01, Part2, TwoPointer); assert_eq!(actual, 241861950); } #[test] fn p...
code_fim
hard
{ "lang": "rust", "repo": "saik0/rust-aoc-2020", "path": "/day01/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub const fn as_str(&self) -> &str { // SAFETY: You can only construct a PackedString via a &str unsafe { ::std::str::from_utf8_unchecked(&self.buffer) } } } static_assertions::assert_eq_size!(PackedString, String);<|fim_prefix|>// repo: vipentti/compact_str path: /...
code_fim
hard
{ "lang": "rust", "repo": "vipentti/compact_str", "path": "/compact_str/src/repr/packed.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vipentti/compact_str path: /compact_str/src/repr/packed.rs use super::MAX_SIZE; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct PackedString { buffer: [u8; MAX_SIZE], } impl PackedString { #[inline] pub fn new(text: &str) -> Self { debug_assert_eq!(text.len(), MAX_SIZE)...
code_fim
hard
{ "lang": "rust", "repo": "vipentti/compact_str", "path": "/compact_str/src/repr/packed.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn program_build() { let src = "__kernel void test(__global int *i) { \ *i += 1; \ }"; let ctx = create_compute_context(); let prog = ctx.create_program_from_source(src); prog.build(ctx.device); } #[test] ...
code_fim
hard
{ "lang": "rust", "repo": "damapl/rust-opencl", "path": "/hl.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: damapl/rust-opencl path: /hl.rs clGetPlatformInfo(self.id, CL_PLATFORM_NAME, len as libc::size_t, p as *libc::c_void, ptr::to_mut_unsafe_ptr(&mut size)); }; name } } } pub ...
code_fim
hard
{ "lang": "rust", "repo": "damapl/rust-opencl", "path": "/hl.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: damapl/rust-opencl path: /hl.rs ndQueue(ctx.ctx, device.id, 0, ptr::to_unsafe_ptr(&errcode)); check(errcode, "Failed to create command queue!"); CommandQueue { cqueue: cqueue, device: device ...
code_fim
hard
{ "lang": "rust", "repo": "damapl/rust-opencl", "path": "/hl.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>assert_eq_size!(node; Node, NodeBytes, NodeWords, NodeDwords); #[repr(C)] pub union Node { pub dwords: NodeDwords, pub words: NodeWords, pub bytes: NodeBytes, } impl Clone for Node { fn clone(&self) -> Self { unsafe { Node { bytes: *&self.bytes } } } } // We use `inline(always)` because I was ex...
code_fim
hard
{ "lang": "rust", "repo": "yijie37/DaQiao", "path": "/bridge/parity-ethereum/ethash/src/shared.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yijie37/DaQiao path: /bridge/parity-ethereum/ethash/src/shared.rs // Copyright 2015-2019 Parity Technologies (UK) Ltd. // This file is part of Parity Ethereum. // Parity Ethereum is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as p...
code_fim
hard
{ "lang": "rust", "repo": "yijie37/DaQiao", "path": "/bridge/parity-ethereum/ethash/src/shared.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>static CHARS: &'static [u8] = b"0123456789abcdef"; pub fn to_hex(bytes: &[u8]) -> String { let mut v = Vec::with_capacity(bytes.len() * 2); for &byte in bytes.iter() { v.push(CHARS[(byte >> 4) as usize]); v.push(CHARS[(byte & 0xf) as usize]); } unsafe { String::from_utf8_unchecked(v) } } pub fn ...
code_fim
hard
{ "lang": "rust", "repo": "yijie37/DaQiao", "path": "/bridge/parity-ethereum/ethash/src/shared.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> irc.send_all(stream::iter(connect_sequence)) }) .and_then(|(irc, _)| { let (send, recv) = irc.split(); let welcome_received = recv.skip_while(|msg| { match msg.command() { Some(Welcome(_, _)) => Ok(false), ...
code_fim
hard
{ "lang": "rust", "repo": "Mr-Byte/tokio-irc-client", "path": "/examples/print_messages.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Mr-Byte/tokio-irc-client path: /examples/print_messages.rs extern crate futures; extern crate pircolate; extern crate tokio_core; extern crate tokio_irc_client; use std::net::ToSocketAddrs; use tokio_core::reactor::Core; use futures::future::Future; use futures::Stream; use futures::Sink; use f...
code_fim
hard
{ "lang": "rust", "repo": "Mr-Byte/tokio-irc-client", "path": "/examples/print_messages.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Instruction for Opcode0x7xkk { fn execute( &self, _memory: &mut Memory, register: &mut Register, _graphic: &mut Graphic, _keyboard_bus: &mpsc::Receiver<u8>, ) { register.v[self.vx] = register.v[self.vx].wrapping_add(self.byte); register....
code_fim
hard
{ "lang": "rust", "repo": "shorii/chip-8", "path": "/src/instructions/opcode_0x7xkk.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shorii/chip-8 path: /src/instructions/opcode_0x7xkk.rs use crate::emulator::{Graphic, Memory, Register}; use crate::instructions::Instruction; use std::sync::mpsc; /// ADD Vx = Vx + kk. /// Adds the value kk to the value of register Vx, the stores the result in Vx. pub struct Opcode0x7xkk { ...
code_fim
medium
{ "lang": "rust", "repo": "shorii/chip-8", "path": "/src/instructions/opcode_0x7xkk.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fukatani/rust-ant-book path: /lib/aho_corasick.rs #![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::io::Write; use std::ops::Bound::*; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e,...
code_fim
hard
{ "lang": "rust", "repo": "fukatani/rust-ant-book", "path": "/lib/aho_corasick.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn build(&mut self) { let mut q = VecDeque::new(); for i in 0..F { if let Some(x) = self.nodes[0].next[i] { q.push_back(x); } } while let Some(cur) = q.pop_front() { for next_ch in 0..F { if let Some(ne...
code_fim
hard
{ "lang": "rust", "repo": "fukatani/rust-ant-book", "path": "/lib/aho_corasick.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{}", i); } #[allow(dead_code)] fn sayi32_arr(arr: &Vec<i32>) { println!("{:?}", arr); } #[allow(dead_code)] pub fn bisect_left(arr: &Vec<i32>, target: i32) -> usize { let (mut lo, mut hi) = (0, arr.len() - 1); let mut mid; while lo < hi { mid = (lo + hi) >> 1; ...
code_fim
hard
{ "lang": "rust", "repo": "h4hany/leetcode", "path": "/python_solutions/1409.queries-on-a-permutation-with-key.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: h4hany/leetcode path: /python_solutions/1409.queries-on-a-permutation-with-key.rs /* * @lc app=leetcode id=1409 lang=rust * * [1409] Queries on a Permutation With Key * * https://leetcode.com/problems/queries-on-a-permutation-with-key/description/ * * algorithms * Medium (82.19%) * Tota...
code_fim
hard
{ "lang": "rust", "repo": "h4hany/leetcode", "path": "/python_solutions/1409.queries-on-a-permutation-with-key.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adhocmaster/cmps203 path: /HW4/while_small/src/ast/b_expression.rs use std::collections::HashMap; use std::rc::Rc; use super::expression::E; use super::expression::evalE; #[allow(dead_code)] <|fim_suffix|>pub fn evalB(e: B, s: &mut HashMap<Rc<String>, i32>) -> bool { let val = match e { ...
code_fim
medium
{ "lang": "rust", "repo": "adhocmaster/cmps203", "path": "/HW4/while_small/src/ast/b_expression.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} pub fn NotExp(b: B) -> B { NotB(Box::new(b)) } pub fn AndExp(b1: B, b2: B) -> B { AndB( Box::new(b1), Box::new(b2) ) } pub fn OrExp(b1: B, b2: B) -> B { OrB( Box::new(b1), Box::new(b2) ) }<|fim_prefix|>// repo: adhocmaster/cmps203 path: /HW4/while_small/src/ast/b_expression.rs use st...
code_fim
medium
{ "lang": "rust", "repo": "adhocmaster/cmps203", "path": "/HW4/while_small/src/ast/b_expression.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BrainiumLLC/objc-util path: /objc-macros/src/lib.rs extern crate proc_macro; mod extern_objc; mod framework; mod msg_wrappers; mod objc_attr; mod objc_selector; mod os_versions; use crate::{extern_objc::ExternObjc, framework::Framework}; use proc_macro::TokenStream; use std::{ collections:...
code_fim
hard
{ "lang": "rust", "repo": "BrainiumLLC/objc-util", "path": "/objc-macros/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #supports_func() } }, supports_func.span(), ); parsed.into() } struct SelectorFunc { sel_func: syn::Path, } impl Parse for SelectorFunc { fn parse(input: ParseStream) -> parse::Result<Self> { let mut sel_func: syn::Path = input.parse()?...
code_fim
hard
{ "lang": "rust", "repo": "BrainiumLLC/objc-util", "path": "/objc-macros/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: smmalis37/aoc2019 path: /src/days/day10.rs use crate::coord_system::unsigned::*; use crate::solver::Solver; use noisy_float::prelude::*; use std::collections::HashSet; use std::f32::consts::*; use std::f32::EPSILON; type F = f32; type R = R32; pub struct Day10 {} impl Solver<'_> for Day10 { ...
code_fim
hard
{ "lang": "rust", "repo": "smmalis37/aoc2019", "path": "/src/days/day10.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> if seen_angles.insert(angle) { visible_count[i] += 1; visible_count[j] += 1; } } } asteroid_coords .iter() .copied() .zip(visible_count.into_iter()) .max_by_key(|&(_, c)| c) .unwrap() } fn fin...
code_fim
hard
{ "lang": "rust", "repo": "smmalis37/aoc2019", "path": "/src/days/day10.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ChooChooShoe/rust-cardgame path: /src/server/ws_server.rs use crate::game::stage::NetRelay; use crate::game::Game; use crate::game::{GameSettings, Stage}; use crate::net::NetworkMode; use crate::server::{ServerConfig, ServerHandle}; use std::net::ToSocketAddrs; use std::sync::mpsc::channel; use ...
code_fim
hard
{ "lang": "rust", "repo": "ChooChooShoe/rust-cardgame", "path": "/src/server/ws_server.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }