text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: ZePedroResende/advent2020 path: /src/3.rs use std::fs::File; use std::io::{BufRead, BufReader}; fn main() { let filename = "inputs/3.txt"; let file = File::open(filename).unwrap(); let reader = BufReader::new(file); <|fim_suffix|> if need_lines.chars().nth(index).unwrap() =...
code_fim
hard
{ "lang": "rust", "repo": "ZePedroResende/advent2020", "path": "/src/3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut need_lines = trimmed.to_owned(); if trimmed.len() < (index + 1) { let multiplicator = (index + 1 / trimmed.len()) as usize; for _i in 1..multiplicator { need_lines.push_str(trimmed); } } if need_lines.chars().nth(...
code_fim
medium
{ "lang": "rust", "repo": "ZePedroResende/advent2020", "path": "/src/3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ksindi/opr path: /pipeline/src/polygonize.rs use std::fs; use std::path::{Path, PathBuf}; use std::collections::HashSet; use sph::bubbler::DiffuseParticleType; use indicatif::{ProgressBar, ProgressStyle}; use nalgebra::Vector3; use rayon::prelude::*; use raytracer::{Camera, scene_config}; use r...
code_fim
hard
{ "lang": "rust", "repo": "ksindi/opr", "path": "/pipeline/src/polygonize.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if conf.display { Some(scene_config::MeshConfig { path: scene.solids[i].file(&Path::new(&scene.global_config.data_path)).to_str().unwrap().to_string(), scale: conf.scale(), rotation: v.euler_angle(), ...
code_fim
hard
{ "lang": "rust", "repo": "ksindi/opr", "path": "/pipeline/src/polygonize.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let radii: Vec<f32> = selected_bubbles.par_iter() .map(|&i| bubbles[i].1).collect(); Particles::new(positions, radii) .dump(path) .unwrap(); Some(BubbleConfig { path: path.to_str().unwrap().to_string(), material: conf.bu...
code_fim
hard
{ "lang": "rust", "repo": "ksindi/opr", "path": "/pipeline/src/polygonize.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Insertable, Debug)] #[table_name = "events"] pub struct DbEvent<'a> { pub id: &'a str, pub name: &'a str, pub description: &'a str, pub longitude: &'a f64, pub latitude: &'a f64, pub date_time: &'a NaiveDateTime, } ///Struct used for creation of new Event. #[derive(Debug,...
code_fim
hard
{ "lang": "rust", "repo": "majchrzamemil/rust-example", "path": "/src/models.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: majchrzamemil/rust-example path: /src/models.rs use crate::schema::{events, user_events, users}; use chrono::NaiveDateTime; use juniper::{GraphQLInputObject, GraphQLObject}; use serde::{Deserialize, Serialize}; #[derive(Identifiable, Debug, Serialize, Deserialize, Queryable, Associations)] pub ...
code_fim
hard
{ "lang": "rust", "repo": "majchrzamemil/rust-example", "path": "/src/models.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>///Struct representing Event model. #[derive(Identifiable, Debug, Queryable, GraphQLObject, Associations)] pub struct Event { pub id: String, pub name: String, pub description: Option<String>, pub longitude: f64, pub latitude: f64, pub date_time: NaiveDateTime, } ///User-Event con...
code_fim
hard
{ "lang": "rust", "repo": "majchrzamemil/rust-example", "path": "/src/models.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kulabun/notecli path: /src/cli/mod.rs pub use self::{ command::{Complet<|fim_suffix|>SubCommand}, }; mod command; mod cli;<|fim_middle|>ion, Create, Delete, Edit, List, Search, Show}, cli::{CommandLineInput,
code_fim
medium
{ "lang": "rust", "repo": "kulabun/notecli", "path": "/src/cli/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kulabun/notecli path: /src/cli/mod.rs pub use self::{ command::{Completion, Create, Delete, Edit, List, Searc<|fim_suffix|>SubCommand}, }; mod command; mod cli;<|fim_middle|>h, Show}, cli::{CommandLineInput,
code_fim
easy
{ "lang": "rust", "repo": "kulabun/notecli", "path": "/src/cli/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>h, Show}, cli::{CommandLineInput, SubCommand}, }; mod command; mod cli;<|fim_prefix|>// repo: kulabun/notecli path: /src/cli/mod.rs pub use self::{ command::{Complet<|fim_middle|>ion, Create, Delete, Edit, List, Searc
code_fim
easy
{ "lang": "rust", "repo": "kulabun/notecli", "path": "/src/cli/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: suspend0/aws-sdk-rust path: /sdk/textract/src/client.rs t_input::Builder, } impl<C, M, R> AnalyzeDocument<C, M, R> where C: aws_smithy_client::bounds::SmithyConnector, M: aws_smithy_client::bounds::SmithyMiddleware<C>, R: aws_smithy_client::retry::NewRequestPo...
code_fim
hard
{ "lang": "rust", "repo": "suspend0/aws-sdk-rust", "path": "/sdk/textract/src/client.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/instr_cmovnge.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; #[...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_cmovnge.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::CMOVNGE, operand1: Some(Direct(EBX)), operand2: Some(Direct(ESP)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[15, 76, 220], OperandSize::Qword) } #[test] fn cmovnge_12() {...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_cmovnge.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::CMOVNGE, operand1: Some(Direct(CX)), operand2: Some(Direct(CX)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[102, 15, 76, 201], OperandSize::Qword) } #[test] fn cmovnge_6()...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_cmovnge.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut map = HashMap::new(); let mut set = HashSet::new(); let top_left_col = (size - 2) / 3 + 1; for x in 0..size { for y in 0..size { let tup = (x, y); match tup { (k, l) if ((k == top_left_col) && (l == top...
code_fim
hard
{ "lang": "rust", "repo": "eddiechristian/othello", "path": "/othello/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eddiechristian/othello path: /othello/src/main.rs #![allow(unused_variables)] #![allow(dead_code)] use std::fmt; use std::collections::HashMap; use std::collections::HashSet; #[derive(Clone, Debug)] enum BoardSquareState { None, EMPTY(i32,i32), BLACK(i32,i32), WHITE(i32,i32)...
code_fim
hard
{ "lang": "rust", "repo": "eddiechristian/othello", "path": "/othello/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mikexxma/leaf path: /leaf/src/proxy/random/udp.rs use std::io; use async_trait::async_trait; use log::*; use rand::{rngs::StdRng, Rng, SeedableRng}; use crate::{app::SyncDnsClient, proxy::*, session::Session}; <|fim_suffix|> None } fn transport_type(&self) -> DatagramTransport...
code_fim
hard
{ "lang": "rust", "repo": "mikexxma/leaf", "path": "/leaf/src/proxy/random/udp.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn transport_type(&self) -> DatagramTransportType { DatagramTransportType::Undefined } async fn handle<'a>( &'a self, sess: &'a Session, _transport: Option<OutboundTransport<Self::UStream, Self::Datagram>>, ) -> io::Result<Self::Datagram> { let mut ...
code_fim
hard
{ "lang": "rust", "repo": "mikexxma/leaf", "path": "/leaf/src/proxy/random/udp.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> async fn handle<'a>( &'a self, sess: &'a Session, _transport: Option<OutboundTransport<Self::UStream, Self::Datagram>>, ) -> io::Result<Self::Datagram> { let mut rng = StdRng::from_entropy(); let i: usize = rng.gen_range(0..self.actors.len()); debug!...
code_fim
medium
{ "lang": "rust", "repo": "mikexxma/leaf", "path": "/leaf/src/proxy/random/udp.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shaneutt/kube-rs path: /kube-runtime/src/utils/backoff_reset_timer.rs use std::time::{Duration, Instant}; use backoff::{backoff::Backoff, Clock, SystemClock}; /// A [`Backoff`] wrapper that resets after a fixed duration has elapsed. pub struct ResetTimerBackoff<B, C = SystemClock> { backof...
code_fim
hard
{ "lang": "rust", "repo": "shaneutt/kube-rs", "path": "/kube-runtime/src/utils/backoff_reset_timer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Do not even bother trying to reset here, since `next_backoff` will take care of this when the timer expires. } } #[cfg(test)] mod tests { use backoff::{backoff::Backoff, Clock}; use tokio::time::advance; use super::ResetTimerBackoff; use crate::utils::stream_backoff::tests...
code_fim
hard
{ "lang": "rust", "repo": "shaneutt/kube-rs", "path": "/kube-runtime/src/utils/backoff_reset_timer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[tokio::test] async fn should_reset_when_timer_expires() { tokio::time::pause(); let mut backoff = ResetTimerBackoff::new_with_custom_clock( LinearBackoff::new(Duration::from_secs(2)), Duration::from_secs(60), TokioClock, ); asse...
code_fim
hard
{ "lang": "rust", "repo": "shaneutt/kube-rs", "path": "/kube-runtime/src/utils/backoff_reset_timer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gitter-badger/archiver path: /src/bin/stage-media.rs #[macro_use] extern crate log; use clap::{App, Arg}; use std::path::PathBuf; use archiver::cli; use archiver::config; use archiver::ctx::Ctx; use archiver::manual_file::ManualFile; use archiver::staging; use archiver::mountable::Mountable; ...
code_fim
hard
{ "lang": "rust", "repo": "gitter-badger/archiver", "path": "/src/bin/stage-media.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { archiver::cli::run(|| { let matches = cli_opts().get_matches(); let cfg = config::Config::from_file(matches.value_of("config").unwrap_or("archiver.toml")); let ctx = Ctx::create(cfg?)?; let dir = matches.value_of("PATH").expect("Couldn't get path"); ...
code_fim
hard
{ "lang": "rust", "repo": "gitter-badger/archiver", "path": "/src/bin/stage-media.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Concordium/wasm-tools path: /crates/wasm-encoder/src/aliases.rs use super::*; /// An encoder for the alias section. /// /// Note that this is part of the [module linking proposal][proposal] and is not /// currently part of stable WebAssembly. /// /// [proposal]: https://github.com/webassembly/m...
code_fim
hard
{ "lang": "rust", "repo": "Concordium/wasm-tools", "path": "/crates/wasm-encoder/src/aliases.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> /// Define an alias that references an outer module's module. pub fn outer_module(&mut self, depth: u32, module: u32) -> &mut Self { self.bytes.push(0x01); self.bytes.extend(encoders::u32(depth)); self.bytes.push(ItemKind::Module as u8); self.bytes.extend(encoders::...
code_fim
hard
{ "lang": "rust", "repo": "Concordium/wasm-tools", "path": "/crates/wasm-encoder/src/aliases.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stackcats/leetcode path: /algorithms/easy/detect_pattern_of_length_m_repeated_k_or_more_times.rs impl Solution { pub fn contains_pattern(arr: Vec<i32>, m: i32, k: i32) -> bool { let m = m as usize; for i in 0..arr.len() { let mut num_of_rep<|fim_suffix|> ...
code_fim
hard
{ "lang": "rust", "repo": "stackcats/leetcode", "path": "/algorithms/easy/detect_pattern_of_length_m_repeated_k_or_more_times.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> } if &arr[(j - m)..j] == &arr[j..(j + m)] { num_of_repeated += 1; if num_of_repeated >= k { return true; } } else { num_of_repeated = 1; } ...
code_fim
hard
{ "lang": "rust", "repo": "stackcats/leetcode", "path": "/algorithms/easy/detect_pattern_of_length_m_repeated_k_or_more_times.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn extended_id_new_out_of_range() { assert_eq!(ExtendedId::new(ExtendedId::MAX.as_raw() + 1), None); } #[test] fn extended_id_new_unchecked_out_of_range() { let id = ExtendedId::MAX.as_raw() + 1; assert_eq!(unsafe { ExtendedId::new_unchecked(id) }, Exte...
code_fim
hard
{ "lang": "rust", "repo": "rust-embedded/embedded-hal", "path": "/embedded-can/src/id.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-embedded/embedded-hal path: /embedded-can/src/id.rs //! CAN Identifiers. /// Standard 11-bit CAN Identifier (`0..=0x7FF`). #[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)] pub struct StandardId(u16); impl StandardId { /// CAN ID `0`, the highest priority. pub co...
code_fim
hard
{ "lang": "rust", "repo": "rust-embedded/embedded-hal", "path": "/embedded-can/src/id.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wieslander/aoc-2019 path: /src/bin/01-02.rs use aoc::get_input; fn get_mass(line: &str) -> i32 { line.parse().expect("NaN") } fn fuel_req(mass: i32) -> i32 { <|fim_suffix|> while fuel_mass > 0 { total_fuel_mass += fuel_mass; fuel_mass = fuel_mass / 3 - 2; } tota...
code_fim
medium
{ "lang": "rust", "repo": "wieslander/aoc-2019", "path": "/src/bin/01-02.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while fuel_mass > 0 { total_fuel_mass += fuel_mass; fuel_mass = fuel_mass / 3 - 2; } total_fuel_mass } fn main() { let input = get_input(); let masses = input.lines().map(get_mass); let total_fuel_req: i32 = masses.map(fuel_req).sum(); println!("{}", total_fue...
code_fim
medium
{ "lang": "rust", "repo": "wieslander/aoc-2019", "path": "/src/bin/01-02.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: u-03c9/sctp path: /src/chunk/mod.rs #[cfg(test)] mod chunk_test; pub(crate) mod chunk_abort; pub(crate) mod chunk_cookie_ack; pub(crate) mod chunk_cookie_echo; pub(crate) mod chunk_error; pub(crate) mod chunk_forward_tsn; pub(crate) mod chunk_header; pub(crate) mod chunk_heartbeat; pub(crate) m...
code_fim
medium
{ "lang": "rust", "repo": "u-03c9/sctp", "path": "/src/chunk/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn marshal(&self) -> Result<Bytes, Error> { let capacity = CHUNK_HEADER_SIZE + self.value_length(); let mut buf = BytesMut::with_capacity(capacity); self.marshal_to(&mut buf)?; Ok(buf.freeze()) } }<|fim_prefix|>// repo: u-03c9/sctp path: /src/chunk/mod.rs #[cfg(tes...
code_fim
medium
{ "lang": "rust", "repo": "u-03c9/sctp", "path": "/src/chunk/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn check(&self) -> Result<(), Error>; fn value_length(&self) -> usize; fn as_any(&self) -> &(dyn Any + Send + Sync); fn marshal(&self) -> Result<Bytes, Error> { let capacity = CHUNK_HEADER_SIZE + self.value_length(); let mut buf = BytesMut::with_capacity(capacity); ...
code_fim
hard
{ "lang": "rust", "repo": "u-03c9/sctp", "path": "/src/chunk/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> set::password_hash, set::login, logout::logout, login::login, meta::meta ] }<|fim_prefix|>// repo: kamirr/blogrs_backend path: /src/api/mod.rs pub mod manage_posts; pub mod logout; pub mod login; pub mod meta; pub mod set; <|fim_middle|>pub fn routes() -> Ve...
code_fim
hard
{ "lang": "rust", "repo": "kamirr/blogrs_backend", "path": "/src/api/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kamirr/blogrs_backend path: /src/api/mod.rs pub mod manage_posts; pub mod logout; pub mod login; pub mod meta; pub mod set; pub fn routes() -> Vec<rocket::Route> { routes![ manage_posts::get_json, manage_posts::get_html, manage_posts::update, manage_posts::de...
code_fim
easy
{ "lang": "rust", "repo": "kamirr/blogrs_backend", "path": "/src/api/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>" Sets the field bit"] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r" Clears the field bit"] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r" Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) ->...
code_fim
hard
{ "lang": "rust", "repo": "creationix/stm32f042x", "path": "/stm32f0x2/src/usb/cntr/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>.bit(false) } #[doc = r" Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { const MASK: bool = true; const OFFSET: u8 = 7; self.w.bits &= !((MASK as u32) << OFFSET); self.w.bits |= ((value & MASK) as u32) << OFFSET;...
code_fim
hard
{ "lang": "rust", "repo": "creationix/stm32f042x", "path": "/stm32f0x2/src/usb/cntr/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: creationix/stm32f042x path: /stm32f0x2/src/usb/cntr/mod.rs f) -> bool { self.bits } #[doc = r" Returns `true` if the bit is clear (0)"] #[inline(always)] pub fn bit_is_clear(&self) -> bool { !self.bit() } #[doc = r" Returns `true` if the bit is set (1)"] ...
code_fim
hard
{ "lang": "rust", "repo": "creationix/stm32f042x", "path": "/stm32f0x2/src/usb/cntr/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CryZe/raytracer path: /lib/src/raytracer.rs use prelude::*; use image::Image; use entity::camera::Camera; use scoped_threadpool::Pool; use num_cpus; use ray::Ray; use nalgebra as na; use rand; use rand::{ThreadRng, Rng}; use std::f32::consts::PI; use std::f32; pub struct SamplingConfig { ma...
code_fim
hard
{ "lang": "rust", "repo": "CryZe/raytracer", "path": "/lib/src/raytracer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if n_dot_l < 0.0 { direction = direction * -1.0; n_dot_l = na::dot(&collision.normal, &direction); } let new_ray = Ray::new(collision.position + collision.normal * 0.001, ...
code_fim
hard
{ "lang": "rust", "repo": "CryZe/raytracer", "path": "/lib/src/raytracer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> extern "C" { pub fn test_function(); }<|fim_prefix|>// repo: rust-lang/rust-bindgen path: /bindgen-tests/tests/expectations/tests/wasm-import-module.rs #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #<|fim_middle|>[link(wasm_import_module = "test-module")]
code_fim
easy
{ "lang": "rust", "repo": "rust-lang/rust-bindgen", "path": "/bindgen-tests/tests/expectations/tests/wasm-import-module.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust-bindgen path: /bindgen-tests/tests/expectations/tests/wasm-import-module.rs #![allow(dead_code, non_snake_case, non_ca<|fim_suffix|>[link(wasm_import_module = "test-module")] extern "C" { pub fn test_function(); }<|fim_middle|>mel_case_types, non_upper_case_globals)] #
code_fim
easy
{ "lang": "rust", "repo": "rust-lang/rust-bindgen", "path": "/bindgen-tests/tests/expectations/tests/wasm-import-module.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let ys = cmp::max(i as i32 - 1, 0); let yl = cmp::min(i as i32 + 2, y as i32); let xs = cmp::max(j as i32 - 1, 0); let xl = cmp::min(j as i32 + 2, x as i32); for ni in ys..yl { for nj in xs..xl { ...
code_fim
hard
{ "lang": "rust", "repo": "sipubot/WIKI", "path": "/Quiz/Leetcode.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sipubot/WIKI path: /Quiz/Leetcode.rs r.remove(n); i += 1; } i += 1; } } //https://leetcode.com/explore/learn/card/fun-with-arrays/521/introduction/3240/ pub fn sorted_squares(nums: Vec<i32>) -> Vec<i32> { let mut re = nums.iter...
code_fim
hard
{ "lang": "rust", "repo": "sipubot/WIKI", "path": "/Quiz/Leetcode.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sipubot/WIKI path: /Quiz/Leetcode.rs } if coins.len() == 0 { return 0; } let mut dp = vec![0; (amount + 1) as usize]; dp[0] = 1; for i in 0..(coins.len() as usize) { for j in coins[i]..amount+1 { let pos = j - coi...
code_fim
hard
{ "lang": "rust", "repo": "sipubot/WIKI", "path": "/Quiz/Leetcode.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ksqsf/toys path: /telegram/televery/src/main.rs extern crate bytes; extern crate clap; extern crate env_logger; extern crate failure; extern crate serde_yaml; extern crate tokio_core; extern crate tokio_io; #[macro_use] extern crate futures; #[macro_use] extern crate log; #[macro_use] extern cr...
code_fim
hard
{ "lang": "rust", "repo": "ksqsf/toys", "path": "/telegram/televery/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Config::from_file(matches.value_of("config").unwrap()).and_then(|cfg| start_server(cfg)) } fn start_server(cfg: Config) -> Result<(), Error> { let mut srv = Server::new(cfg.trusted_apps, cfg.trusted_users)?; srv.bind(cfg.bot_token, cfg.listen_address.parse()?)?; srv.run() } #[derive(Dese...
code_fim
hard
{ "lang": "rust", "repo": "ksqsf/toys", "path": "/telegram/televery/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if matches.occurrences_of("config") == 0 { warn!("--config not specified, 'config.yml' is used"); } Config::from_file(matches.value_of("config").unwrap()).and_then(|cfg| start_server(cfg)) } fn start_server(cfg: Config) -> Result<(), Error> { let mut srv = Server::new(cfg.trusted...
code_fim
hard
{ "lang": "rust", "repo": "ksqsf/toys", "path": "/telegram/televery/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>te::generic::Reg::read) this register and get [`adc2_or::R`](R). You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`adc2_or::W`](W). You can also [`modify`](crate::generic::Reg::modify) this...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp157/adc2/adc2_or.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32mp1/src/stm32mp157/adc2/adc2_or.rs #[doc = "Register `ADC2_OR` reader"] pub type R = crate::R<ADC2_OR_SPEC>; #[doc = "Register `ADC2_OR` writer"] pub type W = crate::W<ADC2_OR_SPEC>; #[doc = "Field `VDDCOREEN` reader - VDDCOREEN"] pub type VDDCOREEN_R = cr...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp157/adc2/adc2_or.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LDA111222/GraphScope path: /interactive_engine/src/executor/store/src/test/global_graph_test_fn.rs ertex, VI: Iterator<Item=V>, E: Edge, EI: Iterator<Item=E> { let mut out_result_list = global_graph.as_ref().get_out_vertex_ids(si, ...
code_fim
hard
{ "lang": "rust", "repo": "LDA111222/GraphScope", "path": "/interactive_engine/src/executor/store/src/test/global_graph_test_fn.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub fn test_get_in_edges<V, VI, E, EI>(global_graph: Arc<dyn GlobalGraphQuery<V=V, VI=VI, E=E, EI=EI>>, si: SnapshotId, src_ids: Vec<PartitionVertexIds>, edge_labels: &Vec<LabelId>, ...
code_fim
hard
{ "lang": "rust", "repo": "LDA111222/GraphScope", "path": "/interactive_engine/src/executor/store/src/test/global_graph_test_fn.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let update_type = UpdateType::DocumentsPartial { number: documents.len(), }; let result = apply_documents_partial_addition(writer, index, documents); (update_type, result, start.elapsed()) } UpdateData::DocumentsDeletion(doc...
code_fim
hard
{ "lang": "rust", "repo": "tpayet/MeiliSearch", "path": "/meilisearch-core/src/update/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tpayet/MeiliSearch path: /meilisearch-core/src/update/mod.rs mod clear_all; mod customs_update; mod documents_addition; mod documents_deletion; mod settings_update; mod helpers; pub use self::clear_all::{apply_clear_all, push_clear_all}; pub use self::customs_update::{apply_customs_update, push...
code_fim
hard
{ "lang": "rust", "repo": "tpayet/MeiliSearch", "path": "/meilisearch-core/src/update/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/rspb path: /src/highlighter.rs use lazy_static::lazy_static; use syntect::highlighting::ThemeSet; use syntect::parsing::SyntaxSet; #[derive(Debug)] pub struct Highlighter { ps: syntect::parsing::SyntaxSet, ts: syntect::highlighting::ThemeSet, } pub fn highlight_lines(co...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/rspb", "path": "/src/highlighter.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>t)?; Some(syntect::html::highlighted_html_for_string( &code.as_str(), &HIGHLIGHTER.ps, syntax, &HIGHLIGHTER.ts.themes["InspiredGitHub"], )) }<|fim_prefix|>// repo: isgasho/rspb path: /src/highlighter.rs use lazy_static::lazy_static; use syntect::highlightin...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/rspb", "path": "/src/highlighter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>lighter { ps: SyntaxSet::load_defaults_newlines(), ts: ThemeSet::load_defaults(), }; } let syntax = HIGHLIGHTER.ps.find_syntax_by_extension(ext)?; Some(syntect::html::highlighted_html_for_string( &code.as_str(), &HIGHLIGHTER.ps, ...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/rspb", "path": "/src/highlighter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Pctg-x8/infinitesweeper path: /build.rs fn main() { if cfg!(windows) { let mut cd = std::env::cu<|fim_suffix|>cargo:rustc-link-search=static={}", cd.display()); println!("cargo:rustc-link-search=static={}/Lib", env!("VK_SDK_PATH")); } }<|fim_middle|>rrent_dir().unwra...
code_fim
medium
{ "lang": "rust", "repo": "Pctg-x8/infinitesweeper", "path": "/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>cargo:rustc-link-search=static={}/Lib", env!("VK_SDK_PATH")); } }<|fim_prefix|>// repo: Pctg-x8/infinitesweeper path: /build.rs fn main() { if cfg!(windows) { let mut cd = std::env::current_dir().unwrap(); cd.push("spvlibs"); println!("<|fim_middle|>cargo:rustc-link-...
code_fim
medium
{ "lang": "rust", "repo": "Pctg-x8/infinitesweeper", "path": "/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leonbreedt/httpmock path: /tests/delay_tests.rs extern crate httpmock; use isahc::prelude::*; use isahc::{get, get_async, HttpClientBuilder}; use httpmock::Method::{GET, POST}; use httpmock::{Mock, MockServer, MockServerRequest, Regex}; use httpmock_macros::test_executors; use isahc::config::R...
code_fim
medium
{ "lang": "rust", "repo": "leonbreedt/httpmock", "path": "/tests/delay_tests.rs", "mode": "psm", "license": "LicenseRef-scancode-philippe-de-muyter", "source": "the-stack-v2" }
<|fim_suffix|> // Act: Send the HTTP request let response = get(mock_server.url("/delay")).unwrap(); // Assert assert_eq!(response.status(), 200); assert_eq!(search_mock.times_called(), 1); assert_eq!(start_time.elapsed().unwrap() > delay, true); }<|fim_prefix|>// repo: leonbreedt/httpmock path...
code_fim
medium
{ "lang": "rust", "repo": "leonbreedt/httpmock", "path": "/tests/delay_tests.rs", "mode": "spm", "license": "LicenseRef-scancode-philippe-de-muyter", "source": "the-stack-v2" }
<|fim_prefix|>// repo: algon-320/rusty-xv6 path: /user/init/src/main.rs #![no_std] #![no_main] #![feature(lang_items)] #![feature(global_asm)] <|fim_suffix|>#[lang = "eh_personality"] #[no_mangle] fn eh_personality() -> ! { loop {} }<|fim_middle|>global_asm! {r#" .code32 .global start start: jmp start "#} #[...
code_fim
medium
{ "lang": "rust", "repo": "algon-320/rusty-xv6", "path": "/user/init/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[lang = "eh_personality"] #[no_mangle] fn eh_personality() -> ! { loop {} }<|fim_prefix|>// repo: algon-320/rusty-xv6 path: /user/init/src/main.rs #![no_std] #![no_main] #![feature(lang_items)] #![feature(global_asm)] <|fim_middle|>global_asm! {r#" .code32 .global start start: jmp start "#} #[...
code_fim
medium
{ "lang": "rust", "repo": "algon-320/rusty-xv6", "path": "/user/init/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[panic_handler] #[no_mangle] fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } #[lang = "eh_personality"] #[no_mangle] fn eh_personality() -> ! { loop {} }<|fim_prefix|>// repo: algon-320/rusty-xv6 path: /user/init/src/main.rs #![no_std] #![no_main] #![feature(lang_items)] #![feature(gl...
code_fim
medium
{ "lang": "rust", "repo": "algon-320/rusty-xv6", "path": "/user/init/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/parking_lot_core/src/thread_parker/windows/keyed_event.rs / / Copyright 2016 Amanieu d ' Antras / / / / Licensed under the Apache License Version 2 . 0 < LICENSE - APACHE or / / http : / / apache . org / licenses / LICENSE - 2 . 0 > or the MIT ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/parking_lot_core/src/thread_parker/windows/keyed_event.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>l NtWaitForKeyedEvent / / otherwise that thread will stay stuck at NtReleaseKeyedEvent . if key . swap ( STATE_TIMED_OUT Ordering : : Relaxed ) = = STATE_UNPARKED { self . park ( key ) ; return true ; } false } # [ inline ] pub unsafe fn unpark_lock ( & ' static self key : & AtomicUsize ) - > UnparkHandle...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/parking_lot_core/src/thread_parker/windows/keyed_event.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>} impl<T: ToPointRange> Points for T where T::Point: PointRangeIteratorItem, { type Iter = PointRangeIterator<T::Point>; fn points(self) -> Self::Iter { PointRangeIterator::new(self.to_point_range()) } }<|fim_prefix|>// repo: yuushimizu/euclid-ext path: /src/points.rs use crate:...
code_fim
medium
{ "lang": "rust", "repo": "yuushimizu/euclid-ext", "path": "/src/points.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yuushimizu/euclid-ext path: /src/points.rs use crate::point_range_iterator::{PointRangeIterator, PointRangeIteratorItem}; use crate::to_point_range::ToPointRange; <|fim_suffix|>} impl<T: ToPointRange> Points for T where T::Point: PointRangeIteratorItem, { type Iter = PointRangeIterator...
code_fim
hard
{ "lang": "rust", "repo": "yuushimizu/euclid-ext", "path": "/src/points.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thetahq/Server path: /src/handlers.rs use std::str; use super::SETTINGS; use super::REDIS; use super::data_types; use super::utils; use jsonwebtoken::{encode, Header}; use chrono::prelude::Utc; use chrono::Duration; use std::net::SocketAddr; use sha3::{Digest, Sha3_256}; use redis::Co...
code_fim
hard
{ "lang": "rust", "repo": "thetahq/Server", "path": "/src/handlers.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let claims = data_types::Claims { uid: user_id[0].to_owned(), ip: socket.ip().to_string(), exp: date.format("%Y-%m-%d").to_string() }; let token = encode(&Header::default(), &claims, SETTINGS.secret.key.as_ref()); match token { Ok(tok)=> return Ok(...
code_fim
hard
{ "lang": "rust", "repo": "thetahq/Server", "path": "/src/handlers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Taneb/zombiesplit path: /src/model/run.rs //! Models relating to an in-progress run. use super::{ pace, split::{Comparison, Split}, time::Time, }; /// An in-progress run. pub struct Run { pub metadata: Metadata, /// The attempt number of this run. pub attempt: usize, ...
code_fim
hard
{ "lang": "rust", "repo": "Taneb/zombiesplit", "path": "/src/model/run.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Gets the paced time for the split at `split`. /// Said pace is made up of the split and run-so-far paces. #[must_use] pub fn paced_time_at(&self, split: usize) -> pace::Pair { pace::Pair { split: self.split_paced_time_at(split), run_so_far: self.run_pace...
code_fim
hard
{ "lang": "rust", "repo": "Taneb/zombiesplit", "path": "/src/model/run.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: innerr/tikv path: /tests/failpoints/cases/test_split_region.rs // Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0. use std::sync::atomic::AtomicBool; use std::sync::{mpsc, Arc, Mutex}; use std::time::Duration; use engine_traits::CF_WRITE; use kvproto::metapb::Region; use kvproto...
code_fim
hard
{ "lang": "rust", "repo": "innerr/tikv", "path": "/tests/failpoints/cases/test_split_region.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut region_c = pd_client.get_region(b"k0").unwrap(); let peer_c_3 = find_peer(&region_c, 3).cloned().unwrap(); pd_client.must_remove_peer(region_c.get_id(), peer_c_3); pd_client.must_add_peer(region_c.get_id(), new_peer(4, 5)); // [-∞, k2), [k2, +∞) // c a pd_cli...
code_fim
hard
{ "lang": "rust", "repo": "innerr/tikv", "path": "/tests/failpoints/cases/test_split_region.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: amnore/pinentry-keepassxc path: /src/logging.rs use std::fs::File; use std::io::Write; use std::sync::Mutex; use directories::BaseDirs; use lazy_static::lazy_static; use log::{Log, Metadata, Record}; lazy_static! { pub static ref LOGFILE: FileLogger = FileLogger::new(); } pub struct FileL...
code_fim
hard
{ "lang": "rust", "repo": "amnore/pinentry-keepassxc", "path": "/src/logging.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn init() { log::set_logger(&*LOGFILE).expect("could not set logger"); log::set_max_level(log::LevelFilter::Info); }<|fim_prefix|>// repo: amnore/pinentry-keepassxc path: /src/logging.rs use std::fs::File; use std::io::Write; use std::sync::Mutex; use directories::BaseDirs; use lazy_static::...
code_fim
hard
{ "lang": "rust", "repo": "amnore/pinentry-keepassxc", "path": "/src/logging.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Log for FileLogger { fn enabled(&self, _: &Metadata) -> bool { true } fn log(&self, rec: &Record) { writeln!(self.0.lock().unwrap(), "{} - {}", rec.level(), rec.args()) .expect("could not write log"); } fn flush(&self) { self.0.lock().unwrap()...
code_fim
medium
{ "lang": "rust", "repo": "amnore/pinentry-keepassxc", "path": "/src/logging.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kjunichi/libwebcamrs path: /src/lib.rs pub mod webcam; extern crate libc; use libc::c_char; use libc::c_int; use libc::c_uchar; use libc::c_void; use std::ffi::CStr; #[no_mangle] pub extern "C" fn named_window(title: *mut c_char) -> () { let slice = unsafe { CStr::from_ptr(title) }; w...
code_fim
hard
{ "lang": "rust", "repo": "kjunichi/libwebcamrs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>:ffi::cv_mat_cols(mat) } } #[no_mangle] pub extern "C" fn mat_data(mat: *const webcam::ffi::Cv2Mat) -> *mut c_uchar { unsafe { webcam::ffi::cv_mat_data(mat) } } #[no_mangle] pub extern "C" fn imencode( ext: *const c_char, img: *const webcam::ffi::Cv2Mat, params: *const c_int, ) -> *mut web...
code_fim
hard
{ "lang": "rust", "repo": "kjunichi/libwebcamrs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>" fn release_video_capture(capture: *mut webcam::ffi::CvVideoCapture) -> c_void { unsafe { webcam::ffi::cv_release_video_capture(capture) } } #[no_mangle] pub extern "C" fn create_mat() -> *mut webcam::ffi::Cv2Mat { unsafe { webcam::ffi::cv_create_mat() } } #[no_mangle] pub extern "C" fn imwrite(f...
code_fim
hard
{ "lang": "rust", "repo": "kjunichi/libwebcamrs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sria91-rlox/rlox-37 path: /src/vm.rs use crate::chunk::{read_u24, Chunk, OpCode}; use crate::compiler::Compiler; use crate::debug::{disassemble_instruction, print_value}; use crate::error::{self, Result}; use crate::value::Value; use snafu::{OptionExt, ResultExt}; use std::convert::TryInto; con...
code_fim
hard
{ "lang": "rust", "repo": "sria91-rlox/rlox-37", "path": "/src/vm.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { if cfg!(feature = "debug-trace-execution") { print!(" "); for slot in &self.stack { print!("[ "); print_value(slot); print!(" ]"); } println!(); ...
code_fim
hard
{ "lang": "rust", "repo": "sria91-rlox/rlox-37", "path": "/src/vm.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> macro_rules! binary_op { ($op:expr, $ty:tt, $err_msg:expr) => { let left = self.pop()?.$ty().context(error::TypeError { msg: $err_msg, line: self.chunk.lines.get(self.ip) as usize, })?; let right = ...
code_fim
hard
{ "lang": "rust", "repo": "sria91-rlox/rlox-37", "path": "/src/vm.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jcdavis/aoc2020 path: /day19/src/main.rs extern crate regex; use std::env; use std::fs; use std::collections::HashMap; use regex::Regex; use std::borrow::Borrow; use std::collections::hash_map::RandomState; trait Rule { fn to_regex(&self, rule_map: &HashMap<i32, Box<dyn Rule>>) -> String;...
code_fim
hard
{ "lang": "rust", "repo": "jcdavis/aoc2020", "path": "/day19/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> format!("({})+", rule_map[&42].to_regex(rule_map)) } } struct Rule11 {} impl Rule for Rule11 { // equal 42 31s // This is a massive hack because we can't really represent this in regex, and it blows up // when going 5 or deeper, thankfully 4 is sufficient fn to_regex(&self, r...
code_fim
hard
{ "lang": "rust", "repo": "jcdavis/aoc2020", "path": "/day19/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: OneSadCookie/walrus path: /examples/round-trip.rs // A small example which is primarily used to help benchmark walrus right now. <|fim_suffix|> env_logger::init(); let a = std::env::args().nth(1).unwrap(); let m = walrus::Module::from_file(&a).unwrap(); let wasm = m.emit_wasm().u...
code_fim
easy
{ "lang": "rust", "repo": "OneSadCookie/walrus", "path": "/examples/round-trip.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> env_logger::init(); let a = std::env::args().nth(1).unwrap(); let m = walrus::Module::from_file(&a).unwrap(); let wasm = m.emit_wasm().unwrap(); if let Some(destination) = std::env::args().nth(2) { std::fs::write(destination, wasm).unwrap(); } }<|fim_prefix|>// repo: OneSad...
code_fim
easy
{ "lang": "rust", "repo": "OneSadCookie/walrus", "path": "/examples/round-trip.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> StateEntityUtils::clear::<ControlSettingsEntity>(&mut data.world); } fn on_resume(&mut self, data: StateData<'_, GameData<'a, 'b>>) { data.world.insert(StateId::ControlSettings); } fn handle_event( &mut self, _data: StateData<'_, GameData<'_, '_>>, ...
code_fim
hard
{ "lang": "rust", "repo": "azriel91/autexousious", "path": "/crate/control_settings/src/control_settings_state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, _data: StateData<'_, GameData<'_, '_>>, event: AppEvent, ) -> Trans<GameData<'a, 'b>, AppEvent> { match event { AppEvent::Window(window_event) => { if is_key_down(&window_event, VirtualKeyCode::Escape) { debug!(...
code_fim
hard
{ "lang": "rust", "repo": "azriel91/autexousious", "path": "/crate/control_settings/src/control_settings_state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: azriel91/autexousious path: /crate/control_settings/src/control_settings_state.rs use amethyst::{ ecs::WorldExt, input::{is_key_down, VirtualKeyCode}, GameData, State, StateData, Trans, }; use application_event::AppEvent; use control_settings_model::{ControlSettingsEntity, ControlSet...
code_fim
hard
{ "lang": "rust", "repo": "azriel91/autexousious", "path": "/crate/control_settings/src/control_settings_state.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let time = LocalTime::now(); let (mut cbfmgr, tree, chain) = util::setup(network, best, DEFAULT_FILTER_CACHE_SIZE, time); let (watch, _) = gen::watchlist(birth, chain.iter()); cbfmgr.initialize(&tree); cbfmgr.peer_negotiated( Socket::new(remote), ...
code_fim
hard
{ "lang": "rust", "repo": "cloudhead/nakamoto", "path": "/p2p/src/fsm/cbfmgr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> FilterManager::new(Config::default(), rng, cache, upstream, clock) }; // Import the headers. { let msg = CFHeaders { filter_type: 0, stop_hash: BlockHash::from_hex( "00000000b3322c8c3ef7d2cf6da009a776e6a99...
code_fim
hard
{ "lang": "rust", "repo": "cloudhead/nakamoto", "path": "/p2p/src/fsm/cbfmgr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cloudhead/nakamoto path: /p2p/src/fsm/cbfmgr.rs ..Config::default() }; ( FilterManager::new(config, rng, cache, upstream, clock), tree, chain, ) } pub fn cfilters<'a>( blocks: impl...
code_fim
hard
{ "lang": "rust", "repo": "cloudhead/nakamoto", "path": "/p2p/src/fsm/cbfmgr.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qolop/bouncing_block path: /rust/src/board.rs use std::fmt; use time; use regex::Regex; use util; pub struct Board { width: i32, height: i32, been_drawn: bool, draw_count: i32, fps: i32, fps_time: time::Tm, str_board: Vec<Vec<String>> } impl Board { // A kin...
code_fim
hard
{ "lang": "rust", "repo": "qolop/bouncing_block", "path": "/rust/src/board.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(&board.str_board[2][0], "0"); assert_eq!(&board.str_board[2][1], "1"); } #[test] fn test_board_frame_upcode() { //panic!(); let tst_height = 3; let mut board = Board::new(4, tst_height); board.been_drawn = true; { // Check that the correct number of "up" ...
code_fim
hard
{ "lang": "rust", "repo": "qolop/bouncing_block", "path": "/rust/src/board.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> true } fn get_start(n: f64) -> i64 { let x: f64 = n.sqrt(); let mut start = x as i64; if start % 2 == 0 { start -= 1; } start }<|fim_prefix|>// repo: deathlyfrantic/project-euler path: /3.rs /* determine the largest prime factor of the number 600,851,475,143. * (a "pri...
code_fim
hard
{ "lang": "rust", "repo": "deathlyfrantic/project-euler", "path": "/3.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> while factor > 1 { if n % factor == 0 { return false } factor -= 2; } true } fn get_start(n: f64) -> i64 { let x: f64 = n.sqrt(); let mut start = x as i64; if start % 2 == 0 { start -= 1; } start }<|fim_prefix|>// repo: deat...
code_fim
medium
{ "lang": "rust", "repo": "deathlyfrantic/project-euler", "path": "/3.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }