text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>fn main() { println!("part 1: {}", part_1(INPUT, WIDTH, HEIGHT)); println!("part 2:"); display(part_2(INPUT, WIDTH, HEIGHT)); } #[cfg(test)] mod test { use super::*; static TEST: &str = "0222112222120000"; #[test] fn test_part_2() { assert_eq!(part_2(TEST, 2, 2), vec!...
code_fim
hard
{ "lang": "rust", "repo": "fdumontmd/adventofcode", "path": "/2019/day-08/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut idx = 0; loop { let value = values[idx]; let digits = parse_digits(value); let raw_op_code = digits.get(0).expect("First digit is needed") + digits.get(1).unwrap_or(&0) * 10; let (p1_mode, p2_mode, p3_mode) = ( *digits.get(2).unwrap...
code_fim
hard
{ "lang": "rust", "repo": "pudgeball/advent-of-code", "path": "/src/aoc2019/day5/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match instruction_op_code { OpCode::Add { p1, p2, p3 } => { idx += 4; values[p3 as usize] = p1 + p2 } OpCode::Multiply { p1, p2, p3 } => { idx += 4; values[p3 as usize] = p1 * p2 } ...
code_fim
hard
{ "lang": "rust", "repo": "pudgeball/advent-of-code", "path": "/src/aoc2019/day5/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pudgeball/advent-of-code path: /src/aoc2019/day5/mod.rs use std::io; fn turn_vec_to_string(input: Vec<i64>) -> String { let mut returned = "".to_string(); for code in input { if returned.is_empty() { returned = format!("{}", code); } else { return...
code_fim
hard
{ "lang": "rust", "repo": "pudgeball/advent-of-code", "path": "/src/aoc2019/day5/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(&c) = iter.peek() { c == ch } else { false } }<|fim_prefix|>// repo: ghosthamlet/iota path: /src/iota/syntax/mod.rs use std::str::Chars; use std::iter::Peekable; <|fim_middle|>pub mod lexer; mod rust; mod python; pub mod langs { pub use super::rust::RustSyntax; pub ...
code_fim
medium
{ "lang": "rust", "repo": "ghosthamlet/iota", "path": "/src/iota/syntax/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn next_is(iter: &mut Peekable<Chars>, ch: char) -> bool { if let Some(&c) = iter.peek() { c == ch } else { false } }<|fim_prefix|>// repo: ghosthamlet/iota path: /src/iota/syntax/mod.rs use std::str::Chars; use std::iter::Peekable; <|fim_middle|>pub mod lexer; mod rust; mod python; pu...
code_fim
medium
{ "lang": "rust", "repo": "ghosthamlet/iota", "path": "/src/iota/syntax/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ghosthamlet/iota path: /src/iota/syntax/mod.rs use std::str::Chars; use std::iter::Peekable; pub mod lexer; mod rust; mod python; <|fim_suffix|> if let Some(&c) = iter.peek() { c == ch } else { false } }<|fim_middle|> pub mod langs { pub use super::rust::RustSyntax; pub ...
code_fim
medium
{ "lang": "rust", "repo": "ghosthamlet/iota", "path": "/src/iota/syntax/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: Stream> StreamExt for T { }<|fim_prefix|>// repo: carllerche/futures-ext path: /src/stream/mod.rs mod first; pub use self::first::First; use futures::stream::Stream; pub trait StreamExt: Stream { fn first(self) -> First<Self> where Self: Sized { <|fim_middle|> First::new(self) }...
code_fim
easy
{ "lang": "rust", "repo": "carllerche/futures-ext", "path": "/src/stream/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: carllerche/futures-ext path: /src/stream/mod.rs mod first; pub use self::first::First; use futures::stream::Stream; pub trait StreamExt: Stream { fn first(self) -> First<Self> where Self: Sized { <|fim_suffix|>impl<T: Stream> StreamExt for T { }<|fim_middle|> First::new(self) }...
code_fim
easy
{ "lang": "rust", "repo": "carllerche/futures-ext", "path": "/src/stream/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for c in stdin.keys() { // clear clear_entity(&mut stdout, &player); // input match c? { Key::Char('h') => player.x -= 1, Key::Char('j') => player.y += 1, Key::Char('k') => player.y -= 1, Key::Char('l') => player.x += 1, ...
code_fim
hard
{ "lang": "rust", "repo": "mfs/roguelikedev", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mfs/roguelikedev path: /src/main.rs extern crate failure; extern crate termion; mod entity; use failure::Error; use std::io::{stdin, stdout, Write}; use termion::event::Key; use termion::input::TermRead; use termion::raw::IntoRawMode; use termion::{clear, color, cursor, style}; use entity::En...
code_fim
hard
{ "lang": "rust", "repo": "mfs/roguelikedev", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nicolasazrak/renderer path: /src/collision.rs use crate::algebra::*; use crate::model::Model; pub struct BoundingBox { pmin: Vec3f, pmax: Vec3f, } impl BoundingBox { pub fn test(&self, from: &Vec3f, to: &Vec3f, direction: &Vec3f) -> (bool, Vec3f, f32) { if to.x > self.pmin.x && to.x < sel...
code_fim
hard
{ "lang": "rust", "repo": "nicolasazrak/renderer", "path": "/src/collision.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if intersection.x > self.pmin.x && intersection.x < self.pmax.x && intersection.z > self.pmin.z && intersection.z < self.pmax.z { if d < min_d { min_d = d; normal = vec3f(0., 1., 0.); collided = true; } } } } return (collided, normal, min_d); } else {...
code_fim
hard
{ "lang": "rust", "repo": "nicolasazrak/renderer", "path": "/src/collision.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("Hello Rust!"); }<|fim_prefix|>// repo: ryoherisson/rust-programming path: /src/rust-as-second-language/structual-programming/option-result/src/main.rs // ハッシュマップからの値の取得など「値があれば返すが見つからなければnil」という処理をするときに使われる enum Option<T> { None, Some(T), } // 計算が失敗するかもしれないときに使われる型 enum Result<T, E...
code_fim
easy
{ "lang": "rust", "repo": "ryoherisson/rust-programming", "path": "/src/rust-as-second-language/structual-programming/option-result/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ryoherisson/rust-programming path: /src/rust-as-second-language/structual-programming/option-result/src/main.rs // ハッシュマップからの値の取得など「値があれば返すが見つからなければnil」という処理をするときに使われる enum Option<T> { None, Some(T), } <|fim_suffix|> println!("Hello Rust!"); }<|fim_middle|>// 計算が失敗するかもしれないときに使われる型 en...
code_fim
medium
{ "lang": "rust", "repo": "ryoherisson/rust-programming", "path": "/src/rust-as-second-language/structual-programming/option-result/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { println!("Hello Rust!"); }<|fim_prefix|>// repo: ryoherisson/rust-programming path: /src/rust-as-second-language/structual-programming/option-result/src/main.rs // ハッシュマップからの値の取得など「値があれば返すが見つからなければnil」という処理をするときに使われる enum Option<T> { None, Some(T), } <|fim_middle|>// 計算が失敗するかもしれな...
code_fim
medium
{ "lang": "rust", "repo": "ryoherisson/rust-programming", "path": "/src/rust-as-second-language/structual-programming/option-result/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GaloisInc/mir-verifier path: /lib/libstd/sys/wasm/env.rs pub mod os { pub const FAMILY: &str = ""; pub const OS: &str = ""; pub const DLL_PREFIX: &str = ""; pub const DLL_SUFFIX: &str<|fim_suffix|>XE_SUFFIX: &str = ".wasm"; pub const EXE_EXTENSION: &str = "wasm"; }<|fim_middl...
code_fim
medium
{ "lang": "rust", "repo": "GaloisInc/mir-verifier", "path": "/lib/libstd/sys/wasm/env.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>XE_SUFFIX: &str = ".wasm"; pub const EXE_EXTENSION: &str = "wasm"; }<|fim_prefix|>// repo: GaloisInc/mir-verifier path: /lib/libstd/sys/wasm/env.rs pub mod os { pub const FAMILY: &str = ""; pub const OS: &str = ""; pub const DLL_PREFIX: &str = ""; pub const DLL_SUFFIX: &str<|fim_middl...
code_fim
medium
{ "lang": "rust", "repo": "GaloisInc/mir-verifier", "path": "/lib/libstd/sys/wasm/env.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> /// Submit a deposit to the `BeaconChain` and, if given a keypair, create a new /// `ValidatorHarness` instance for this validator. /// /// If a new `ValidatorHarness` was created, the validator should become fully operational as /// if the validator were created during `BeaconChainHar...
code_fim
hard
{ "lang": "rust", "repo": "mluluz/lighthouse", "path": "/beacon_node/beacon_chain/test_harness/src/beacon_chain_harness.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mluluz/lighthouse path: /beacon_node/beacon_chain/test_harness/src/beacon_chain_harness.rs use super::ValidatorHarness; use beacon_chain::{BeaconChain, BlockProcessingOutcome}; pub use beacon_chain::{BeaconChainError, CheckPoint}; use db::{ stores::{BeaconBlockStore, BeaconStateStore}, M...
code_fim
hard
{ "lang": "rust", "repo": "mluluz/lighthouse", "path": "/beacon_node/beacon_chain/test_harness/src/beacon_chain_harness.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KallDrexx/rustcaster path: /src/game/mod.rs use crate::game::map::{Map, SpawnType, CellType}; use crate::game::entities::Player; use std::time::Duration; use crate::core::vector::Vector; pub mod entities; pub mod map; pub struct GameState { pub map: Map, pub player: Player, pub map...
code_fim
hard
{ "lang": "rust", "repo": "KallDrexx/rustcaster", "path": "/src/game/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if inputs.toggle_test { self.test_mode = !self.test_mode; } if inputs.zoom_in { self.map_zoom_level += 1; } if inputs.zoom_out && self.map_zoom_level > 1 { self.map_zoom_level -= 1; } if inputs.toggle_map { ...
code_fim
hard
{ "lang": "rust", "repo": "KallDrexx/rustcaster", "path": "/src/game/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match (should_move, side) { (false, _) => (), (true, Side::Right) => {self.player.position.x = (col * self.map.units_per_cell - self.player.collision_size as u32 / 2) as f32;}, (true, Side::Left) => {self.player.position.x = ((col + 1) * self.map.units_per_cell ...
code_fim
hard
{ "lang": "rust", "repo": "KallDrexx/rustcaster", "path": "/src/game/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if a > m { m = a; } } } } return m; } } fn main() { assert_eq!(2.0, Solution::func(vec![ vec![0, 0], vec![0, 1], vec![1, 0], vec![0, 2], vec![2, 0],...
code_fim
hard
{ "lang": "rust", "repo": "karlmcguire/leet", "path": "/rust/812/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: karlmcguire/leet path: /rust/812/main.rs struct Solution {} impl Solution { pub fn func(points: Vec<Vec<i32>>) -> f64 { fn area(v: [f64; 6]) -> f64 { <|fim_suffix|> let mut m: f64 = 0.0; for i in 0..points.len() { for j in 0..points.len() { ...
code_fim
hard
{ "lang": "rust", "repo": "karlmcguire/leet", "path": "/rust/812/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..points.len() { for j in 0..points.len() { for k in 0..points.len() { let a: f64 = area([ points[i][0] as f64, points[i][1] as f64, points[j][0] as f64, points[j][1] as f64, ...
code_fim
hard
{ "lang": "rust", "repo": "karlmcguire/leet", "path": "/rust/812/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rome/tools path: /crates/rome_js_formatter/src/js/expressions/super_expression.rs use crate::prelude::*; use rome_formatter::write; use crate::parentheses::NeedsParentheses; use rome_js_syntax::JsSuperExpressionFields; use rome_js_syntax::{JsSuperExpression, JsSyntaxNode}; <|fim_suffix|>impl F...
code_fim
medium
{ "lang": "rust", "repo": "rome/tools", "path": "/crates/rome_js_formatter/src/js/expressions/super_expression.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> item.needs_parentheses() } } impl NeedsParentheses for JsSuperExpression { #[inline(always)] fn needs_parentheses(&self) -> bool { false } #[inline(always)] fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool { false } }<|fim_prefix|...
code_fim
hard
{ "lang": "rust", "repo": "rome/tools", "path": "/crates/rome_js_formatter/src/js/expressions/super_expression.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danielverkamp/crosvm path: /devices/src/pflash.rs // Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //! Programmable flash device that supports the minimum interface that OVMF //! requires. This is pu...
code_fim
hard
{ "lang": "rust", "repo": "danielverkamp/crosvm", "path": "/devices/src/pflash.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn write() { let f = empty_image(); let want = [0xdeu8]; let offset = 0x1000; let mut pflash = new(f); pflash.write(off(offset), &[COMMAND_WRITE_BYTE]); pflash.write(off(offset), &want); // Make sure the data reads back correctly ov...
code_fim
hard
{ "lang": "rust", "repo": "danielverkamp/crosvm", "path": "/devices/src/pflash.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> fn off(offset: u64) -> BusAccessInfo { BusAccessInfo { offset, address: 0, id: 0, } } #[test] fn read() { let mut f = empty_image(); let mut want = [0xde, 0xad, 0xbe, 0xef]; let offset = 0x1000; f.write_al...
code_fim
hard
{ "lang": "rust", "repo": "danielverkamp/crosvm", "path": "/devices/src/pflash.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BurntSushi/rust-analyzer path: /crates/ra_assists/src/handlers/add_missing_impl_members.rs use hir::HasSource; use ra_syntax::{ ast::{self, edit, make, AstNode, NameOwner}, SmolStr, }; use crate::{ ast_transform::{self, AstTransform, QualifyPaths, SubstituteTypeParams}, utils::{...
code_fim
hard
{ "lang": "rust", "repo": "BurntSushi/rust-analyzer", "path": "/crates/ra_assists/src/handlers/add_missing_impl_members.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_qualify_path_fn_trait_notation() { check_assist( add_missing_impl_members, " mod foo { pub trait Fn<Args> { type Output; } trait Foo { fn foo(&self, bar: dyn Fn(u32) -> i32); } } struct S; impl foo::Foo for S { <|> }", " mod foo {...
code_fim
hard
{ "lang": "rust", "repo": "BurntSushi/rust-analyzer", "path": "/crates/ra_assists/src/handlers/add_missing_impl_members.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> source_list_map; pub mod source_map; pub mod source_map_source; pub mod types; pub mod utils; mod wasm_api; pub use wasm_api::*;<|fim_prefix|>// repo: jevancc/rust-webpack-sources path: /src/lib.rs extern crate linked_hash_map; extern crate serde; extern crate source_map_mappings; extern crate vlq; #[m...
code_fim
medium
{ "lang": "rust", "repo": "jevancc/rust-webpack-sources", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jevancc/rust-webpack-sources path: /src/lib.rs extern crate linked_hash_map; extern crate serde; extern crate source_map_mappings; extern crate vlq; #[macro_use] extern crate l<|fim_suffix|> source_list_map; pub mod source_map; pub mod source_map_source; pub mod types; pub mod utils; mod wasm_a...
code_fim
hard
{ "lang": "rust", "repo": "jevancc/rust-webpack-sources", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JohnBSmith/moss path: /src/modules/graphics/font.rs #[allow(dead_code)] struct ImgData<'a> { w: u32, h: u32, max: u32, data: &'a [u8] } pub struct GlyphData { pub width: u32, pub height: u32, pub data: Vec<u8> } fn advance_space(p: &[u8], index: &mut usize) { let mut i = *...
code_fim
hard
{ "lang": "rust", "repo": "JohnBSmith/moss", "path": "/src/modules/graphics/font.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> cols: usize, rows: usize, w: usize, h: usize, shiftw: usize, shifth: usize ) -> Vec<u8> { let mut acc: Vec<u8> = Vec::new(); let data = img.data; let imgw = img.w as usize; for row in 0..rows { let hstart = row*shifth; for col in 0..cols { let wstart = col*s...
code_fim
hard
{ "lang": "rust", "repo": "JohnBSmith/moss", "path": "/src/modules/graphics/font.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|>fn pnm_as_data(p: &[u8], fmt: Fmt) -> ImgData { match fmt { Fmt::PGM => {if &p[0..2] != b"P5" {panic!("Error: not a PGM");}}, Fmt::PPM => {if &p[0..2] != b"P6" {panic!("Error: not a PPM");}} } let mut i = 2; advance_space(p, &mut i); if p[i] == b'#' { panic!("Er...
code_fim
hard
{ "lang": "rust", "repo": "JohnBSmith/moss", "path": "/src/modules/graphics/font.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> if self.auto_wrap_mode && self.next_print_wraps { self.do_move_cursor_to_col(0); let next_row = self.cursor_y + 1; if next_row == self.rows { self.scroll_up(1); } else { self.do_move_cursor_to_row(next_row); ...
code_fim
hard
{ "lang": "rust", "repo": "forkkit/vt-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: forkkit/vt-rs path: /src/lib.rs None, background: None, bold: false, italic: false, underline: false, strikethrough: false, blink: false, inverse: false } } } impl Cell { fn blank() -> Cell { ...
code_fim
hard
{ "lang": "rust", "repo": "forkkit/vt-rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // buffer switching fn switch_to_alternate_buffer(&mut self) { if let BufferType::Primary = self.active_buffer_type { self.active_buffer_type = BufferType::Alternate; std::mem::swap(&mut self.saved_ctx, &mut self.alternate_saved_ctx); std::mem::swap(&mu...
code_fim
hard
{ "lang": "rust", "repo": "forkkit/vt-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ifornia", 42); // Tupe field are accessed by index with . syntax println!("{} is from {} and is {}.", person.0, person.1, person.2); }<|fim_prefix|>// repo: dicroce/basic_rust path: /src/tuples.rs pub fn run() { // Tuples can be created simply by wrapping some l<|fim_middle|>iterals and/or...
code_fim
medium
{ "lang": "rust", "repo": "dicroce/basic_rust", "path": "/src/tuples.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dicroce/basic_rust path: /src/tuples.rs pub fn run() { // Tuples can be created simply by wrapping some l<|fim_suffix|>ifornia", 42); // Tupe field are accessed by index with . syntax println!("{} is from {} and is {}.", person.0, person.1, person.2); }<|fim_middle|>iterals and/or...
code_fim
medium
{ "lang": "rust", "repo": "dicroce/basic_rust", "path": "/src/tuples.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<N: Unary, T: 'static, P: Subst<Q, N>, Q> Subst<Q, N> for Recv<T, P> { type Substituted = Recv<T, P::Substituted>; } impl<N: Unary, T: 'static, P: Then<Q, N>, Q> Then<Q, N> for Recv<T, P> { type Combined = Recv<T, P::Combined>; } impl<N: Unary, T: 'static, P: Lift<N, Level>, Level: Unary> Li...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/dialectic", "path": "/dialectic/src/types/recv.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/dialectic path: /dialectic/src/types/recv.rs use super::sealed::IsSession; use crate::types::*; use std::{any::Any, marker::PhantomData}; /// Receive a message of type `T` using [`recv`](crate::Chan::recv), then continue with /// protocol `P`. #[derive(Debug, Clone, Copy, PartialEq, Eq,...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/dialectic", "path": "/dialectic/src/types/recv.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: betrusted-io/xous-core path: /services/gam/src/modal.rs r() } pub fn clear(&mut self) { self.0.0.clear(); } } #[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] pub struct CheckBoxPayload(pub [Option<ItemName>; MAX_ITEMS]); // returns a list of p...
code_fim
hard
{ "lang": "rust", "repo": "betrusted-io/xous-core", "path": "/services/gam/src/modal.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: betrusted-io/xous-core path: /services/gam/src/modal.rs > bool { false } /// navigation is one of '∴' | '←' | '→' | '↑' | '↓' fn key_action(&mut self, _key: char) -> Option<ValidatorErr> {None} fn set_action_opcode(&mut self, _op: u32) {} } #[derive(Debug, num_derive::FromPrimitive,...
code_fim
hard
{ "lang": "rust", "repo": "betrusted-io/xous-core", "path": "/services/gam/src/modal.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> log::trace!("posting bot tv: {:?}", bot_tv); modal.gam.bounds_compute_textview(&mut bot_tv).expect("couldn't simulate bot text size"); if let Some(bounds) = bot_tv.bounds_computed { total_height += bounds.br.y - bounds.tl.y; } else { log::error!("cou...
code_fim
hard
{ "lang": "rust", "repo": "betrusted-io/xous-core", "path": "/services/gam/src/modal.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // 通过 String 直接修改 sr.name.push_str(". yes"); // 通过 *mut 指针间接修改底层值 unsafe { (*sr.value2).push_str("!"); } // 最后底层的数据都是一样的 println!("sr: {:?} v1: {}, v2: {}", sr, unsafe {&*sr.value}, unsafe {&*sr.value2}); }<|fim_prefix|>// repo: zengzhiying/programming_languages path: ...
code_fim
hard
{ "lang": "rust", "repo": "zengzhiying/programming_languages", "path": "/rust/rust-basics/src/self_referential.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zengzhiying/programming_languages path: /rust/rust-basics/src/self_referential.rs // 所有权问题 // struct SelfRefer<'a> { // name: String, // value: &'a str, // } // 重新定义结构体 #[derive(Debug)] struct SelfRefer { name: String, // 如果不修改可以定义为 *const,需要修改则定义为 *mut value: *const String,...
code_fim
hard
{ "lang": "rust", "repo": "zengzhiying/programming_languages", "path": "/rust/rust-basics/src/self_referential.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } pub fn get_workload(&self) -> u32 { self.workload } pub fn increase_workload<'a>(&'a mut self) -> &'a u32 { self.workload += 1; &self.workload } pub fn decrease_workload<'a>(&'a mut self) -> &'a u32 { self.workload -= 1; &self.workload ...
code_fim
hard
{ "lang": "rust", "repo": "marius-cristian/load_balancer", "path": "/src/server/worker/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marius-cristian/load_balancer path: /src/server/worker/mod.rs use std::cmp::Ordering; use std::thread; use std::time::Duration; use tokio::sync::mpsc::{Sender}; use tokio::sync::mpsc; use tokio::task::JoinHandle; pub struct Worker { pub workload: u32, pub name: String, pub snd: Send...
code_fim
hard
{ "lang": "rust", "repo": "marius-cristian/load_balancer", "path": "/src/server/worker/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DanielMehlber/rust-diesel-actix-test path: /src/db.rs use diesel::{MysqlConnection, r2d2::{self, ConnectionManager, Pool}}; use crate::schema; use diesel::prelude::*; use crate::person::Person; <|fim_suffix|> return match r2d2::Pool::builder() .build(manager) { Ok(pool) ...
code_fim
hard
{ "lang": "rust", "repo": "DanielMehlber/rust-diesel-actix-test", "path": "/src/db.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return match r2d2::Pool::builder() .build(manager) { Ok(pool) => Ok(pool), Err(err) => Err(format!("error while creating connection pool: {}", err.to_string())) } } /** * search users by name and return a vector of matches */ pub fn search_users_in_database(k...
code_fim
hard
{ "lang": "rust", "repo": "DanielMehlber/rust-diesel-actix-test", "path": "/src/db.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/** * search users by name and return a vector of matches */ pub fn search_users_in_database(keyword: String, connection: &MysqlConnection) -> Result<Vec<Person>, diesel::result::Error> { // *::dsl contains helper types and bare functions not contained in prelude use schema::person::dsl::*; ...
code_fim
hard
{ "lang": "rust", "repo": "DanielMehlber/rust-diesel-actix-test", "path": "/src/db.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kbachti/algostru path: /src/collections/mod.rs pub mod multiplication; pub mod ordering; pub mod search; // geometric types enum Axis { X, Y } type Point = (isize, isize); type PointPair = (Point, Point); type Plane = Vec<Point>; fn f64_min(vals: &[f64]) -> f64 { vals.iter().fold(f64::INFI...
code_fim
hard
{ "lang": "rust", "repo": "kbachti/algostru", "path": "/src/collections/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_get_point_value_by_axis() { let point: Point = (0, 1); assert_eq!(get_point_value_by_axis(point, &Axis::X), point.0); assert_eq!(get_point_value_by_axis(point, &Axis::Y), point.1); } #[test] fn test_even_length_vec_range_midpoint() { let...
code_fim
hard
{ "lang": "rust", "repo": "kbachti/algostru", "path": "/src/collections/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RobbieMcKinstry/acheron path: /src/work_queue/termination.rs use crate::core::Condition; /// After an operator is applied /// to a Job, the job can terminal, or /// it can require additional p<|fim_suffix|>e, /// then a list of Pending Jobs. pub enum TerminationState { Sat(Vec<Condition>), ...
code_fim
hard
{ "lang": "rust", "repo": "RobbieMcKinstry/acheron", "path": "/src/work_queue/termination.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ying /// literals (or a unsigned Literal...). /// If it is unsat, the variant contains the /// "conflict set". If it doesn't terminate, /// then a list of Pending Jobs. pub enum TerminationState { Sat(Vec<Condition>), Unsat(Vec<Condition>), Unfinished, }<|fim_prefix|>// repo: RobbieMcKinstry/a...
code_fim
medium
{ "lang": "rust", "repo": "RobbieMcKinstry/acheron", "path": "/src/work_queue/termination.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: songokas/clipboard-sync path: /src/process.rs await { Ok(sent) if sent > 0 => { debug!("Sent bytes {}", sent); count += 1; } Ok(_) => (), Err(err) => { error!("...
code_fim
hard
{ "lang": "rust", "repo": "songokas/clipboard-sync", "path": "/src/process.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn handle_receive( clipboard: &mut Clipboard, raw_data: Vec<u8>, identity: &Identity, groups: &Groups, max_file_size: usize, app_dir: Option<&str>, ) -> Result<(String, String), ClipboardError> { let (mut message, group) = validate(Cursor::new(raw_data), groups, identity)?; ...
code_fim
hard
{ "lang": "rust", "repo": "songokas/clipboard-sync", "path": "/src/process.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: songokas/clipboard-sync path: /src/process.rs r!("{}", err); Err(err.to_string()) } } } async fn send_heartbeat( pool: &SocketPool, addr_pool: &SocketAddrPool, group: &Group, heartbeat_cache: &mut HashMap<String, Instant>, timeout: impl Fn(Duration) -...
code_fim
hard
{ "lang": "rust", "repo": "songokas/clipboard-sync", "path": "/src/process.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let csrf_token = "blah"; let mut data = Context::new(); data.add("logged_in", &true); data.add("csrf", &csrf_token); self.tera.render("game_create.html", data) } } impl Handler for NewGame { fn handle(&self, req: &mut Request) -> IronResult<Response> { ...
code_fim
hard
{ "lang": "rust", "repo": "coulson84/pusoy_dos_server", "path": "/project/src/controller/new_game.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coulson84/pusoy_dos_server path: /project/src/controller/new_game.rs use iron::prelude::*; use iron::{status}; use iron::middleware::Handler; use iron::mime::Mime; use tera::{Tera, Context, TeraResult}; <|fim_suffix|> info!("{:?}", req.extensions.get::<Session>()); let content_ty...
code_fim
hard
{ "lang": "rust", "repo": "coulson84/pusoy_dos_server", "path": "/project/src/controller/new_game.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> info!("{:?}", req.extensions.get::<Session>()); let content_type = "text/html".parse::<Mime>().unwrap(); Ok(Response::with((content_type, status::Ok, self.get_page().unwrap()))) } }<|fim_prefix|>// repo: coulson84/pusoy_dos_server path: /project/src/controller/new_game.rs us...
code_fim
hard
{ "lang": "rust", "repo": "coulson84/pusoy_dos_server", "path": "/project/src/controller/new_game.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Finds the next consecutive element currently in the tree /// /// # Arguments /// * self: the instance of VEBTree to operate on. /// * value: the value to find the successor of. /// /// # Returns /// * The successor of 'value' or None if not found pub fn findnext(&se...
code_fim
hard
{ "lang": "rust", "repo": "JMurph2015/rust-vebtrees", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JMurph2015/rust-vebtrees path: /src/lib.rs BTree>, max: Option<T>, min: Option<T> } impl VEBTree { /// Creates a new VEBTree with given max capacity. /// /// # Arguments /// * max_size: the maximum capacity with which to /// initialize the tree /// /// #...
code_fim
hard
{ "lang": "rust", "repo": "JMurph2015/rust-vebtrees", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JMurph2015/rust-vebtrees path: /src/lib.rs lements, equal to max if there is /// only one element #[derive(Clone,Debug, PartialEq, Eq)] pub struct VEBTree { children: Vec<VEBTree>, aux: Vec<VEBTree>, max: Option<T>, min: Option<T> } impl VEBTree { /// Creates a new VEBT...
code_fim
hard
{ "lang": "rust", "repo": "JMurph2015/rust-vebtrees", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let waker = noop_waker(); let cx = &mut Context::from_waker(&waker); match poll_read_buf(Pin::new(self), cx, buf) { Poll::Pending => Err(io::Error::from(io::ErrorKind::WouldBlock)), Poll::Ready(res) => res, } } fn try_write(&mut self, buf: ...
code_fim
hard
{ "lang": "rust", "repo": "yutiansut/actix-server-alt", "path": "/actix-http-alt/src/tls/openssl.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yutiansut/actix-server-alt path: /actix-http-alt/src/tls/openssl.rs use std::{ fmt::{self, Debug, Formatter}, future::Future, io, ops::{Deref, DerefMut}, pin::Pin, task::{Context, Poll}, }; use actix_server_alt::net::AsyncReadWrite; use actix_service_alt::{Service, Servi...
code_fim
hard
{ "lang": "rust", "repo": "yutiansut/actix-server-alt", "path": "/actix-http-alt/src/tls/openssl.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl From<ErrorStack> for OpensslError { fn from(e: ErrorStack) -> Self { Self::Stack(e) } } impl From<TlsError> for OpensslError { fn from(e: TlsError) -> Self { Self::Ssl(e) } } impl<S: AsyncRead + AsyncWrite + Unpin> AsyncRead for TlsStream<S> { #[inline] fn po...
code_fim
hard
{ "lang": "rust", "repo": "yutiansut/actix-server-alt", "path": "/actix-http-alt/src/tls/openssl.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gianlucamazza/proofmarshal path: /hoard/src/persist/mod.rs use std::mem; pub mod blob; pub use self::blob::*; <|fim_suffix|>#[cfg(test)] mod tests { #[test] fn test() { } }<|fim_middle|>pub trait Persist { type Error : std::error::Error; fn deref_blob<'a>(blob: Blob<'a, Sel...
code_fim
medium
{ "lang": "rust", "repo": "gianlucamazza/proofmarshal", "path": "/hoard/src/persist/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>} #[cfg(test)] mod tests { #[test] fn test() { } }<|fim_prefix|>// repo: gianlucamazza/proofmarshal path: /hoard/src/persist/mod.rs use std::mem; pub mod blob; pub use self::blob::*; <|fim_middle|>pub trait Persist { type Error : std::error::Error; fn deref_blob<'a>(blob: Blob<'a, ...
code_fim
medium
{ "lang": "rust", "repo": "gianlucamazza/proofmarshal", "path": "/hoard/src/persist/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn path_to_str(path: &ChildPath) -> String { let path_buf: PathBuf = path.path().into(); path_buf.as_os_str().to_owned().into_string().unwrap() } pub fn generate_keys(temp_dir: &TempDir) -> (PathBuf, PathBuf, PathBuf) { let openssl = Openssl::new().expect("no openssla installed."); let pr...
code_fim
hard
{ "lang": "rust", "repo": "stjordanis/jortestkit", "path": "/src/openssl/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let path_buf: PathBuf = path.path().into(); path_buf.as_os_str().to_owned().into_string().unwrap() } pub fn generate_keys(temp_dir: &TempDir) -> (PathBuf, PathBuf, PathBuf) { let openssl = Openssl::new().expect("no openssla installed."); let prv_key_file = temp_dir.child("prv.key"); l...
code_fim
hard
{ "lang": "rust", "repo": "stjordanis/jortestkit", "path": "/src/openssl/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stjordanis/jortestkit path: /src/openssl/mod.rs use crate::prelude::file_exists_and_not_empty; use assert_fs::{ assert::PathAssert, fixture::{ChildPath, PathChild}, TempDir, }; use std::path::PathBuf; use std::process::Command; use std::str::FromStr; type Error = std::io::Error; use ...
code_fim
hard
{ "lang": "rust", "repo": "stjordanis/jortestkit", "path": "/src/openssl/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Phantomical/mighty-server path: /server/src/handlers/say.rs use shrev::*; use specs::*; use types::*; use airmash_protocol::client::Say; use airmash_protocol::server::{ChatSay, ServerPacket}; use airmash_protocol::to_bytes; use websocket::OwnedMessage; pub struct SayHandler { reader: Option<R...
code_fim
hard
{ "lang": "rust", "repo": "Phantomical/mighty-server", "path": "/server/src/handlers/say.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>use dispatch::SystemInfo; use handlers::OnCloseHandler; impl SystemInfo for SayHandler { type Dependencies = OnCloseHandler; fn new() -> Self { Self::new() } fn name() -> &'static str { concat!(module_path!(), "::", line!()) } }<|fim_prefix|>// repo: Phantomical/mighty-server path: /server/sr...
code_fim
hard
{ "lang": "rust", "repo": "Phantomical/mighty-server", "path": "/server/src/handlers/say.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("Debug: {:?}", MinMax(1, 2)); println!("Display: {}", MinMax(1, 2)); }<|fim_prefix|>// repo: NatoliChris/rust-learn path: /rust-by-example/displays.rs /* * Implementing our own Display * > Equivalent to toString */ use std::fmt; #[derive(Debug)] struct Structure(i32); #[derive(Deb...
code_fim
medium
{ "lang": "rust", "repo": "NatoliChris/rust-learn", "path": "/rust-by-example/displays.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NatoliChris/rust-learn path: /rust-by-example/displays.rs /* * Implementing our own Display * > Equivalent to toString */ use std::fmt; #[derive(Debug)] struct Structure(i32); #[derive(Debug)] struct MinMax(i32, i32); //Now let's implement the display: impl fmt::Display for Structure { ...
code_fim
hard
{ "lang": "rust", "repo": "NatoliChris/rust-learn", "path": "/rust-by-example/displays.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> send(Message::ProgramChange(Channel::Ch1, 88)); send(Message::ProgramChange(Channel::Ch2, 23)); send(Message::ProgramChange(Channel::Ch3, 62)); if r > 127 { send(Message::NoteOn(Channel::Ch1, g / 2, 127)); send(Message::NoteOn(Channel::Ch2, b / 2, 12...
code_fim
hard
{ "lang": "rust", "repo": "astro/midicam", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: astro/midicam path: /src/main.rs extern crate opencv; extern crate midir; extern crate midi; use std::thread; use std::thread::sleep; use std::sync::{Arc, RwLock}; use std::time::Duration; use opencv::core as cv; use opencv::sys::types as cvtypes; use opencv::{imgproc, objdetect, highgui}; us...
code_fim
hard
{ "lang": "rust", "repo": "astro/midicam", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut cursor = shared_cursor.0.write().unwrap(); cursor.x = (cursor.x + 1) % SIZE; if cursor.x == 0 { cursor.y = (cursor.y + 1) % SIZE; } } } fn main() { let cursor = Shared::new(Cursor {x: 0, y: 0}); let cursor_ = cursor.clone(); let the_matrix = Shared::new(cv::Mat::fo...
code_fim
hard
{ "lang": "rust", "repo": "astro/midicam", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> rocket::ignite() .catch(errors![not_found]) .mount("/", routes![index, files]) } pub fn serve<P: AsRef<Path>>(serve_dir: P) -> ! { env::set_current_dir(serve_dir); rocket().launch(); process::exit(0); }<|fim_prefix|>// repo: jgbyrne/quilt path: /src/serve.rs use std::io; ...
code_fim
hard
{ "lang": "rust", "repo": "jgbyrne/quilt", "path": "/src/serve.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jgbyrne/quilt path: /src/serve.rs use std::io; use std::path::{Path, PathBuf}; use std::process; use std::env; #[macro_use] use rocket; use rocket::response::{Response, NamedFile, Responder}; use rocket::http::Status; use rocket::Request; #[get("/")] fn index() -> io::Result<NamedFile> { N...
code_fim
hard
{ "lang": "rust", "repo": "jgbyrne/quilt", "path": "/src/serve.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Responder<'static> for NotFoundResp { fn respond_to(self, req: &Request) -> Result<Response<'static>, Status> { match self { NotFoundResp::File(f) => f.respond_to(req), NotFoundResp::Text(t) => t.respond_to(req), } } } #[error(404)] fn not_found(req...
code_fim
medium
{ "lang": "rust", "repo": "jgbyrne/quilt", "path": "/src/serve.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: diggyk/ares path: /src/robot/process/neutral.rs use diesel::PgConnection; use rand::seq::SliceRandom; use rand::thread_rng; use super::ProcessResult; use super::*; use crate::grid::utils::traversal; use crate::robot::modules::collector::*; pub struct Neutral {} /// The "Neutral" process is wh...
code_fim
hard
{ "lang": "rust", "repo": "diggyk/ares", "path": "/src/robot/process/neutral.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if farthest.is_none() { farthest = Some((cell_coords, orientation, distance)); } else { if distance > farthest.unwrap().2 { farthest = Some((cell_coords, orientation, dis...
code_fim
hard
{ "lang": "rust", "repo": "diggyk/ares", "path": "/src/robot/process/neutral.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // check the edges in random order; if open, see if we know the cell beyond it for orientation in &search_order { if cell.unwrap().get_side(*orientation) != EdgeType::Wall { // we will test the coords adjacent to the known coords ...
code_fim
hard
{ "lang": "rust", "repo": "diggyk/ares", "path": "/src/robot/process/neutral.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aiifabbf/leetcode-memo path: /152.rust/src/main.rs /* .. default-role:: math 给个array,乘积最大的非空substring(要连续)的乘积是多少? 比如给 ``2, 3, -2, 4`` ,所有的substring是 :: [2] -> 2 [3] -> 2 [-2] -> -2 [4] -> 4 [2, 3] -> 6 [3, -2] -> -6 [-2, 4] -> -8 [2, 3, -2] -> -12 [3, -2, ...
code_fim
hard
{ "lang": "rust", "repo": "aiifabbf/leetcode-memo", "path": "/152.rust/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>struct Solution; impl Solution { pub fn max_product(nums: Vec<i32>) -> i32 { if nums.is_empty() { // 其实这个未定义 return 0; } let mut maximums = vec![0; nums.len()]; // maximums[i]是以第i个元素结尾的、积最大的substring的积 let mut minimums = vec![0; nums.len()]; //...
code_fim
hard
{ "lang": "rust", "repo": "aiifabbf/leetcode-memo", "path": "/152.rust/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: octo47/my-rust path: /hr/impl/beautiful.rs use std::io; fn main() { let mut buffer = String::new(); io::stdin().read_line(&mut buffer).unwrap(); let vec = buffer.split_whitespace() .map(|s| s.trim().parse::<i32>().unwrap()) .collect::<Vec<i32>>(); let k = vec[2];...
code_fim
medium
{ "lang": "rust", "repo": "octo47/my-rust", "path": "/hr/impl/beautiful.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let mut rval = 0 as i32; let mut orig = num; while orig > 0 { rval = rval * 10 + orig % 10; orig = orig / 10; }; rval }<|fim_prefix|>// repo: octo47/my-rust path: /hr/impl/beautiful.rs use std::io; fn main() { let mut buffer = String::new(); io::stdin().read...
code_fim
medium
{ "lang": "rust", "repo": "octo47/my-rust", "path": "/hr/impl/beautiful.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> pub fn push(&mut self, t: u32, ev: E) { self.min = self.min.min(t); self.items.push((t, ev)); } } // Only used to create the array x-x impl<E> Default for Bucket<E> { fn default() -> Self { Self::new() } }<|fim_prefix|>// repo: Yurihaia/xivc path: /src/sim/eventqu...
code_fim
hard
{ "lang": "rust", "repo": "Yurihaia/xivc", "path": "/src/sim/eventqueue.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Yurihaia/xivc path: /src/sim/eventqueue.rs use std::mem; // Event queue implemented as a radix heap. // The time key is a u32 to preserve space, and if time goes over 6 years you have a real problem // (and can just fork the project xd) #[derive(Clone, Debug)] pub struct EventQueue<E> { len...
code_fim
hard
{ "lang": "rust", "repo": "Yurihaia/xivc", "path": "/src/sim/eventqueue.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn place_ev(&mut self, time: u32, event: E) { self.buckets[32 - (time ^ self.time).leading_zeros() as usize].push(time, event); } pub fn pop(&mut self) -> Option<(u32, E)> { let index = self.buckets.iter().enumerate().find(|(_, v)| !v.items.is_empty()).map(|(i, _)| i)?; ...
code_fim
hard
{ "lang": "rust", "repo": "Yurihaia/xivc", "path": "/src/sim/eventqueue.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[macro_use] mod macros; mod auth; mod dsn; mod project_id; pub mod protocol; pub(crate) mod utils; pub use crate::auth::*; pub use crate::dsn::*; pub use crate::project_id::*; // Re-export external types and traits for convenience pub use debugid::*; pub use uuid::{Uuid, Variant as UuidVariant, Versio...
code_fim
hard
{ "lang": "rust", "repo": "getsentry/sentry-rust", "path": "/sentry-types/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>mod auth; mod dsn; mod project_id; pub mod protocol; pub(crate) mod utils; pub use crate::auth::*; pub use crate::dsn::*; pub use crate::project_id::*; // Re-export external types and traits for convenience pub use debugid::*; pub use uuid::{Uuid, Variant as UuidVariant, Version as UuidVersion};<|fim_pr...
code_fim
hard
{ "lang": "rust", "repo": "getsentry/sentry-rust", "path": "/sentry-types/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: getsentry/sentry-rust path: /sentry-types/src/lib.rs //! This crate provides common types for working with the Sentry protocol or the //! Sentry server. It's used by the Sentry Relay infrastructure as well as the //! rust Sentry client. //! //! Most of the types in this crate are serializable i...
code_fim
hard
{ "lang": "rust", "repo": "getsentry/sentry-rust", "path": "/sentry-types/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kofmatsugen/sprite_studio path: /src/resource/data.rs use crate::{resource::pack::Pack, traits::animation_file::AnimationFile}; use amethyst::{ assets::{Asset, Handle}, ecs::DenseVecStorage, }; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; <|fim_suffix|>//...
code_fim
hard
{ "lang": "rust", "repo": "kofmatsugen/sprite_studio", "path": "/src/resource/data.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }