text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> println!("<YASLC> Successful lexical analysis of file. Parsing."); let mut parser = Parser::new_with_tokens(tokens); parser.parse() }<|fim_prefix|>// repo: areteCocoa/yasl_compiler path: /src/lib.rs mod lexer; mod parser; use lexer::{LexerResult, LexerError}; use lexer::read_file; pub use ...
code_fim
hard
{ "lang": "rust", "repo": "areteCocoa/yasl_compiler", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if length % 2 == 0 { result = (list[length / 2] + list[(length / 2) - 1]) as f32 / 2.0; } else { result = list[length / 2] as f32; } result } fn mode(list: &Vec<i32>) -> i32 { let mut collection = HashMap::new(); for i in list.iter(){ let count = collec...
code_fim
hard
{ "lang": "rust", "repo": "kwj2104/rust_practice", "path": "/descript_stats/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kwj2104/rust_practice path: /descript_stats/src/main.rs use std::collections::HashMap; fn main() { let mut int_list = vec![4, 6, 23, 5, 4, 10]; println!("Mean: {}", mean(&int_list)); println!("Median: {}", median(&mut int_list)); println!("Mode: {}", mode(&int_list)); <|...
code_fim
medium
{ "lang": "rust", "repo": "kwj2104/rust_practice", "path": "/descript_stats/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ty()) { *counts.entry(word.to_string()).or_insert(0) += 1; } counts }<|fim_prefix|>// repo: silvadanilo/exercism path: /rust/word-count/src/lib.rs use std::collections::HashMap; pub fn word_count(string: &str) -> HashMap<String, u32> { <|fim_middle|> let mut counts: HashMap<Strin...
code_fim
medium
{ "lang": "rust", "repo": "silvadanilo/exercism", "path": "/rust/word-count/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>rcase() .split(|c: char| !c.is_alphanumeric()) .filter(|word| !word.is_empty()) { *counts.entry(word.to_string()).or_insert(0) += 1; } counts }<|fim_prefix|>// repo: silvadanilo/exercism path: /rust/word-count/src/lib.rs use std::collections::HashMap; pub fn word_cou...
code_fim
medium
{ "lang": "rust", "repo": "silvadanilo/exercism", "path": "/rust/word-count/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: silvadanilo/exercism path: /rust/word-count/src/lib.rs use std::collections::HashMap; pub fn word_count(string: &str) -> HashMap<String, u32> { <|fim_suffix|>ty()) { *counts.entry(word.to_string()).or_insert(0) += 1; } counts }<|fim_middle|> let mut counts: HashMap<Strin...
code_fim
medium
{ "lang": "rust", "repo": "silvadanilo/exercism", "path": "/rust/word-count/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mioalter/gentle-rust path: /byref.rs // Values can also be passed by reference. // A reference is created by & and dereferenced by *. // Passing by reference is important when we have a large object // and don't wish to copy it. fn by_ref(x: &i32) -> i32{ *x + 1 } <|fim_suffix|>fn main() { ...
code_fim
medium
{ "lang": "rust", "repo": "mioalter/gentle-rust", "path": "/byref.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let i = 10; let res1 = by_ref(&i); let res2 = by_ref(&41); println!("{} {}", res1,res2); // 11 42 let mut res = 0.0; modifies(&mut res); println!("res is {}", res); // res is 1 }<|fim_prefix|>// repo: mioalter/gentle-rust path: /byref.rs // Values can also be passed b...
code_fim
medium
{ "lang": "rust", "repo": "mioalter/gentle-rust", "path": "/byref.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: peppizza/songbird path: /utils/src/lib.rs use byteorder::{LittleEndian, WriteBytesExt}; use std::mem; pub fn make_sine(float_len: usize, stereo: bool) -> Vec<u8> { let sample_len = mem::size_of::<f32>(); let byte_len = float_len * sample_len; // set period to 100 samples == 480Hz s...
code_fim
hard
{ "lang": "rust", "repo": "peppizza/songbird", "path": "/utils/src/lib.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> let mut out = vec![0u8; byte_len]; let mut byte_slice = &mut out[..]; for i in 0..i16_len { let x_val = (i as f32) * 50.0 / std::f32::consts::PI; byte_slice .write_i16::<LittleEndian>((x_val.sin() * 10_000.0) as i16) .unwrap(); } if stereo { ...
code_fim
hard
{ "lang": "rust", "repo": "peppizza/songbird", "path": "/utils/src/lib.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: clinuxrulz/sodium-rust-demo path: /core/src/ecs/components/player_component.rs use ecs::Component; use ecs::IsComponent; #[derive(Copy, Clone)] pub struct PlayerComponent {} <|fim_suffix|> Component::of("PlayerComponent") } }<|fim_middle|>impl IsComponent for PlayerComponent { f...
code_fim
medium
{ "lang": "rust", "repo": "clinuxrulz/sodium-rust-demo", "path": "/core/src/ecs/components/player_component.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl IsComponent for PlayerComponent { fn component() -> Component<PlayerComponent> { Component::of("PlayerComponent") } }<|fim_prefix|>// repo: clinuxrulz/sodium-rust-demo path: /core/src/ecs/components/player_component.rs use ecs::Component; use ecs::IsComponent; <|fim_middle|>#[derive...
code_fim
easy
{ "lang": "rust", "repo": "clinuxrulz/sodium-rust-demo", "path": "/core/src/ecs/components/player_component.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ImageMeta { pub fn is_animation(&self) -> bool { self.animation_frames.is_some() } }<|fim_prefix|>// repo: anekos/image-meta path: /src/types.rs #[derive(Clone, Debug, Eq, PartialEq)] pub struct ImageMeta { pub animation_frames: Option<usize>, pub color: Color, pub dimens...
code_fim
medium
{ "lang": "rust", "repo": "anekos/image-meta", "path": "/src/types.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: anekos/image-meta path: /src/types.rs #[derive(Clone, Debug, Eq, PartialEq)] pub struct ImageMeta { pub animation_frames: Option<usize>, pub color: Color, pub dimensions: Dimensions, pub format: Format, } <|fim_suffix|>#[derive(Clone, Copy, Debug, Eq, PartialEq)] pub struct Colo...
code_fim
hard
{ "lang": "rust", "repo": "anekos/image-meta", "path": "/src/types.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>ice::Export => format!("{}/{}", BASE_URL, "export"), _ => unimplemented!() } } }<|fim_prefix|>// repo: modernlearner/mixpanel-rs path: /src/services.rs use BASE_URL; #[allow(dead_code)] pub enum Service { AnnotationsList, AnnotationsCreate, A<|fim_middle|>nnotationsUp...
code_fim
hard
{ "lang": "rust", "repo": "modernlearner/mixpanel-rs", "path": "/src/services.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: modernlearner/mixpanel-rs path: /src/services.rs use BASE_URL; #[allow(dead_code)] pub enum Service { AnnotationsList, AnnotationsCreate, A<|fim_suffix|>ice::Export => format!("{}/{}", BASE_URL, "export"), _ => unimplemented!() } } }<|fim_middle|>nnotationsUp...
code_fim
hard
{ "lang": "rust", "repo": "modernlearner/mixpanel-rs", "path": "/src/services.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self { memory: vec![0; MEMORY_SIZE as usize], } } } impl Memory { pub fn size(&self) -> u64 { MEMORY_BASE_ADDRESS + MEMORY_SIZE } pub fn load(&self, address: u64, size: Size) -> u64 { (0..size as usize).fold(0, |acc, i| { acc | (sel...
code_fim
medium
{ "lang": "rust", "repo": "konifar/five", "path": "/src/emulator/memory.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: konifar/five path: /src/emulator/memory.rs use crate::emulator::bus::Size; pub const MEMORY_SIZE: u64 = 1024 * 1024 * 1024; pub const MEMORY_BASE_ADDRESS: u64 = 0x8000_0000; <|fim_suffix|>impl Memory { pub fn size(&self) -> u64 { MEMORY_BASE_ADDRESS + MEMORY_SIZE } pub fn ...
code_fim
medium
{ "lang": "rust", "repo": "konifar/five", "path": "/src/emulator/memory.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(not(feature = "std"))] mod cs { pub use cortex_m::interrupt::CriticalSection; pub fn critical_section<F, R>(f: F) -> R where F: FnOnce(&CriticalSection) -> R, { cortex_m::interrupt::free(f) } }<|fim_prefix|>// repo: rukai/embassy path: /embassy/src/util/critical_...
code_fim
hard
{ "lang": "rust", "repo": "rukai/embassy", "path": "/embassy/src/util/critical_section.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rukai/embassy path: /embassy/src/util/critical_section.rs pub use cs::{critical_section, CriticalSection}; #[cfg(feature = "std")] mod cs { static INIT: std::sync::Once = std::sync::Once::new(); static mut BKL: Option<std::sync::Mutex<()>> = None; <|fim_suffix|>#[cfg(not(feature = "std...
code_fim
hard
{ "lang": "rust", "repo": "rukai/embassy", "path": "/embassy/src/util/critical_section.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonhoo/ureq path: /src/response.rs message.hello, "world"); /// # Ok(()) /// # } /// ``` /// /// Or, if you don't want to define a struct to read your JSON into, you can /// use the convenient `serde_json::Value` type to parse arbitrary or unknown /// JSON. /// ...
code_fim
hard
{ "lang": "rust", "repo": "jonhoo/ureq", "path": "/src/response.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // https://tools.ietf.org/html/rfc7230#appendix-B // HTTP-name = %x48.54.54.50 ; HTTP // HTTP-version = HTTP-name "/" DIGIT "." DIGIT let http_version = split[0]; if !http_version.starts_with("HTTP/") { return Err(BadStatus.msg("HTTP version did not start with HTTP/")); ...
code_fim
hard
{ "lang": "rust", "repo": "jonhoo/ureq", "path": "/src/response.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonhoo/ureq path: /src/response.rs ored. /// 2. If `Content-Length` is set, the returned reader is limited to this byte /// length regardless of how many bytes the server sends. /// 3. If no length header, the reader is until server stream end. /// /// Note: If you use `re...
code_fim
hard
{ "lang": "rust", "repo": "jonhoo/ureq", "path": "/src/response.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shaneutt/lumen path: /interpreter/src/native/mod.rs mod erlang; pub use erlang::make_erlang; <|fim_suffix|>mod logger; pub use logger::make_logger; mod lumen_intrinsics; pub use lumen_intrinsics::make_lumen_intrinsics;<|fim_middle|>mod lists; pub use lists::make_lists; mod maps; pub use maps:...
code_fim
medium
{ "lang": "rust", "repo": "shaneutt/lumen", "path": "/interpreter/src/native/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>mod lumen_intrinsics; pub use lumen_intrinsics::make_lumen_intrinsics;<|fim_prefix|>// repo: shaneutt/lumen path: /interpreter/src/native/mod.rs mod erlang; pub use erlang::make_erlang; mod lists; pub use lists::make_lists; mod maps; pub use maps::make_maps; <|fim_middle|>mod logger; pub use logger::m...
code_fim
easy
{ "lang": "rust", "repo": "shaneutt/lumen", "path": "/interpreter/src/native/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>mod logger; pub use logger::make_logger; mod lumen_intrinsics; pub use lumen_intrinsics::make_lumen_intrinsics;<|fim_prefix|>// repo: shaneutt/lumen path: /interpreter/src/native/mod.rs mod erlang; pub use erlang::make_erlang; <|fim_middle|>mod lists; pub use lists::make_lists; mod maps; pub use maps:...
code_fim
medium
{ "lang": "rust", "repo": "shaneutt/lumen", "path": "/interpreter/src/native/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> settings } impl fmt::Debug for Settings { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "remote_target is [{:?}] and firebase_dev is [{:?}]", self.remote_target, self.firebase_dev) } } impl Settings { pub fn new_local() -> Self { Self { ...
code_fim
hard
{ "lang": "rust", "repo": "NaomiLea/ji-cloud", "path": "/frontend/apps/crates/utils/src/settings.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NaomiLea/ji-cloud path: /frontend/apps/crates/utils/src/settings.rs use once_cell::sync::OnceCell; use std::fmt; use cfg_if::cfg_if; use config::RemoteTarget; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use shared::domain::auth::JWT_COOKIE_NAME; pub static SETTINGS:OnceCell<Settings...
code_fim
hard
{ "lang": "rust", "repo": "NaomiLea/ji-cloud", "path": "/frontend/apps/crates/utils/src/settings.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: starcoinorg/starcoin path: /vm/natives/src/helpers.rs // Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 <|fim_suffix|>pub fn make_module_natives( natives: impl IntoIterator<Item = (impl Into<String>, NativeFunction)>, ) -> impl Iterator<Item = (String, Nativ...
code_fim
easy
{ "lang": "rust", "repo": "starcoinorg/starcoin", "path": "/vm/natives/src/helpers.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn make_module_natives( natives: impl IntoIterator<Item = (impl Into<String>, NativeFunction)>, ) -> impl Iterator<Item = (String, NativeFunction)> { natives .into_iter() .map(|(func_name, func)| (func_name.into(), func)) }<|fim_prefix|>// repo: starcoinorg/starcoin path: /vm/...
code_fim
easy
{ "lang": "rust", "repo": "starcoinorg/starcoin", "path": "/vm/natives/src/helpers.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ynohat/learningrust path: /004-diningphilosophers/src/main.rs use std::thread; use std::sync::{Mutex, Arc}; struct Thinker { name: String, idx: usize, } impl Thinker { fn new(name: &str, idx: usize) -> Thinker { Thinker { name: name.to_string(), idx:...
code_fim
hard
{ "lang": "rust", "repo": "ynohat/learningrust", "path": "/004-diningphilosophers/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let thinkers = vec![ Thinker::new("Spinoza", 0), Thinker::new("Deleuze", 1), Thinker::new("Marx", 2), Thinker::new("Nietzsche", 3), Thinker::new("Foucault", 4), ]; let table = Arc::new(Table { forks: vec![ Mutex::new(()), ...
code_fim
hard
{ "lang": "rust", "repo": "ynohat/learningrust", "path": "/004-diningphilosophers/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nickelc/dbl-rs path: /src/error.rs use std::fmt; use reqwest::StatusCode; use url::ParseError; #[derive(Debug)] pub enum Error { Ratelimit { retry_after: u32 }, Reqwest(reqwest::Error), Url(ParseError), } <|fim_suffix|> match self { Error::Ratelimit { retry_afte...
code_fim
hard
{ "lang": "rust", "repo": "nickelc/dbl-rs", "path": "/src/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// updates the state of the game; executed every step fn update_game_state(state: &mut GameState) { // If we're not still on cooldown from the last auto-move if state.interface_state.next_auto_move <= Instant::now() { // try auto-moving another card to the foundations if let Some(n...
code_fim
hard
{ "lang": "rust", "repo": "FBemf/freecell", "path": "/src/main.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> // If we're not still on cooldown from the last auto-move if state.interface_state.next_auto_move <= Instant::now() { // try auto-moving another card to the foundations if let Some(new_state) = state.board.auto_move_to_foundations() { state.board = state ...
code_fim
hard
{ "lang": "rust", "repo": "FBemf/freecell", "path": "/src/main.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FBemf/freecell path: /src/main.rs use std::path::PathBuf; use std::thread::sleep; use std::time::{Duration, Instant}; use anyhow::{anyhow, Context, Result}; use clipboard::{ClipboardContext, ClipboardProvider}; use rand::prelude::*; use sdl2::mouse::MouseState; use sdl2::render::Canvas; use sdl...
code_fim
hard
{ "lang": "rust", "repo": "FBemf/freecell", "path": "/src/main.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> fn render( &mut self, data: &RenderData<VulkanoRendererRaw>, frame: &mut Frame<VulkanoRendererRaw>, render_target: &mut Renderer2DTarget<VulkanoRendererRaw, Self>, renderer: &mut Renderer<VulkanoRendererRaw>, ) { // Give the renderer an opportunity t...
code_fim
hard
{ "lang": "rust", "repo": "LaylBongers/damage-report", "path": "/libraries/rendering/calcium-rendering-2d-vulkano/src/renderer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LaylBongers/damage-report path: /libraries/rendering/calcium-rendering-2d-vulkano/src/renderer.rs use std::sync::{Arc}; use cgmath::{Vector2, Matrix4}; use vulkano::sync::{GpuFuture}; use vulkano::pipeline::viewport::{Viewport}; use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicSta...
code_fim
hard
{ "lang": "rust", "repo": "LaylBongers/damage-report", "path": "/libraries/rendering/calcium-rendering-2d-vulkano/src/renderer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Create pre-made mode buffers that can be re-used let mut mode_buffers = Vec::new(); for mode_id in 0..4 { let buffer = CpuAccessibleBuffer::from_data( renderer.raw().device().clone(), BufferUsage::uniform_buffer(), simple2d_fs::ty::Mod...
code_fim
hard
{ "lang": "rust", "repo": "LaylBongers/damage-report", "path": "/libraries/rendering/calcium-rendering-2d-vulkano/src/renderer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sharkdp/pastel path: /src/cli/commands/prelude.rs pub use crate::config::Config; pub use crate::error::{PastelError, Result}; pub use crate::output::Output; <|fim_suffix|>pub use super::io::*; pub use super::traits::*; pub use pastel::ansi::{AnsiColor, Brush, ToAnsiStyle}; pub use pastel::Colo...
code_fim
easy
{ "lang": "rust", "repo": "sharkdp/pastel", "path": "/src/cli/commands/prelude.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use pastel::ansi::{AnsiColor, Brush, ToAnsiStyle}; pub use pastel::Color;<|fim_prefix|>// repo: sharkdp/pastel path: /src/cli/commands/prelude.rs pub use crate::config::Config; pub use crate::error::{PastelError, Result}; pub use crate::output::Output; pub use clap::ArgMatches; <|fim_middle|>pub us...
code_fim
easy
{ "lang": "rust", "repo": "sharkdp/pastel", "path": "/src/cli/commands/prelude.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use super::io::*; pub use super::traits::*; pub use pastel::ansi::{AnsiColor, Brush, ToAnsiStyle}; pub use pastel::Color;<|fim_prefix|>// repo: sharkdp/pastel path: /src/cli/commands/prelude.rs pub use crate::config::Config; pub use crate::error::{PastelError, Result}; pub use crate::output::Output;...
code_fim
easy
{ "lang": "rust", "repo": "sharkdp/pastel", "path": "/src/cli/commands/prelude.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> d.static_attributes() .class("navbar_cart_value") .nodes() .render(&format!("${:.2}", state.cart_value())); }); }); } }<|fim_prefix|>// repo: aclueless/rustmart-examples path: /rustmart-spair/sr...
code_fim
hard
{ "lang": "rust", "repo": "aclueless/rustmart-examples", "path": "/rustmart-spair/src/renders/navbar.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aclueless/rustmart-examples path: /rustmart-spair/src/renders/navbar.rs use spair::prelude::*; pub struct Navbar; impl spair::Render<crate::App> for Navbar { fn render(self, nodes: spair::Nodes<crate::App>) { nodes.div(|d| { d.static_attributes() .class("...
code_fim
hard
{ "lang": "rust", "repo": "aclueless/rustmart-examples", "path": "/rustmart-spair/src/renders/navbar.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ecreeth/hhvm path: /hphp/hack/src/hhbc/label.rs // Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. use std::fmt; pub type Id = usize; #[derive(Debug, Clone, Part...
code_fim
hard
{ "lang": "rust", "repo": "ecreeth/hhvm", "path": "/hphp/hack/src/hhbc/label.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn option_map<F: FnOnce(Id) -> Option<Id>>(&self, f: F) -> Result<Option<Label>, Error> { match self { Label::Regular(id) => { if let Some(l) = f(*id) { return Ok(Some(Label::Regular(l))); } } Label::De...
code_fim
hard
{ "lang": "rust", "repo": "ecreeth/hhvm", "path": "/hphp/hack/src/hhbc/label.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spwilson2/headcrab path: /src/target/linux.rs use nix::{ sys::ptrace, sys::uio, sys::wait::waitpid, unistd::{execv, fork, ForkResult, Pid}, }; use std::{ ffi::CString, fs::File, io::{BufRead, BufReader}, mem, }; pub struct Target { pid: Pid, } impl Target { ...
code_fim
hard
{ "lang": "rust", "repo": "spwilson2/headcrab", "path": "/src/target/linux.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(usize::from_ne_bytes(read_buf)) } } /// Returns the start of a process's virtual memory address range. /// This can be useful for calculation of relative addresses in memory. pub fn get_addr_range(pid: Pid) -> Result<usize, Box<dyn std::error::Error>> { let file = File::open(format!("/...
code_fim
hard
{ "lang": "rust", "repo": "spwilson2/headcrab", "path": "/src/target/linux.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Returns the start of a process's virtual memory address range. /// This can be useful for calculation of relative addresses in memory. pub fn get_addr_range(pid: Pid) -> Result<usize, Box<dyn std::error::Error>> { let file = File::open(format!("/proc/{}/maps", pid))?; let mut bufread = BufRead...
code_fim
hard
{ "lang": "rust", "repo": "spwilson2/headcrab", "path": "/src/target/linux.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: szunami/broken-escalators path: /src/systems/escalator_absolute_velocity.rs use crate::systems::absolute_thing_velocity::velocity; use crate::{ components::{Atop, Escalator, Step, Velocity}, resources::RewindableClock, }; use amethyst::{ derive::SystemDesc, ecs::prelude::{Entitie...
code_fim
hard
{ "lang": "rust", "repo": "szunami/broken-escalators", "path": "/src/systems/escalator_absolute_velocity.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, (entities, clock, escalators, steps, atops, mut velocities): Self::SystemData, ) { if !clock.going_forwards() { return; } for (_escalator, escalator_entity, escalator_atop) in (&escalators, &entities, &atops).join() { ...
code_fim
hard
{ "lang": "rust", "repo": "szunami/broken-escalators", "path": "/src/systems/escalator_absolute_velocity.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rantingpirate/spinnrd path: /src/backend/mod.rs //! # backend //! The `backend` module is where the code for backends is stored, to make //! as simple as possible to add backends. use super::*; #[cfg(any(feature = "fsaccel", feature = "iioaccel"))] use accel::FilteredAccelerometer; #[cfg(fea...
code_fim
hard
{ "lang": "rust", "repo": "rantingpirate/spinnrd", "path": "/src/backend/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(not(feature = "fsaccel"))] /// Don't initiaze a non-compiled filesystem accelerometer fn init_fsaccel(_opts: HashMap<String, String>) -> BackendResult { return Err(BackendError::NotCompiled("fsaccel")); } #[cfg(feature = "fsaccel")] /// Initialize a filesystem accelerometer fn init_fsaccel(opts:...
code_fim
hard
{ "lang": "rust", "repo": "rantingpirate/spinnrd", "path": "/src/backend/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kirhgoff/dreamtime-server path: /src/user_repository.rs extern crate diesel; use diesel::prelude::*; use crate::models::{User, NewUser}; use crate::PgPool; pub struct UserRepository { pub connection: PgPool } impl UserRepository { // pub fn find_user(&self, email: &str) -> User { ...
code_fim
medium
{ "lang": "rust", "repo": "kirhgoff/dreamtime-server", "path": "/src/user_repository.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_users(&self) -> Vec<User> { use crate::schema::users::dsl::*; // TODO: how to select all limit xx users .load::<User>(&self.connection.get().unwrap()) .expect("Error loading users") } }<|fim_prefix|>// repo: kirhgoff/dreamtime-server pat...
code_fim
hard
{ "lang": "rust", "repo": "kirhgoff/dreamtime-server", "path": "/src/user_repository.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return vec![LIT, m.move_id(), GIP, COND, get_move_pos(m, inst_file)]; } fn get_move_pos(m: &Move, inst_file: &InstFile) -> i32 { return inst_file.get_move_location(m.move_id()); } fn get_end_inst(inst_file: &InstFile) -> Vec<i32> { return vec![JAS]; }<|fim_prefix|>// repo: BakaBBQ/lunautils path:...
code_fim
medium
{ "lang": "rust", "repo": "BakaBBQ/lunautils", "path": "/src/canceling_assemblier.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BakaBBQ/lunautils path: /src/canceling_assemblier.rs /* lit move_id gip cond move_pos lit move_id2 gip cond move_pos2 */ use std::collections::HashMap; use insts::{NOP,LIT,DEL,JMP,COND,JAS,GNP,GCP,ADD,SUB,MULT,DIV,TEX,GPX,GPY,GVX,GVY,SPX,SPY,SVX,SVY,SAX,SAY,GIP,END}; use inst_assemblier::Move; ...
code_fim
hard
{ "lang": "rust", "repo": "BakaBBQ/lunautils", "path": "/src/canceling_assemblier.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let context = match val { Ok(asset) => { let mut ctx = tera::Context::new(); ctx.insert("table", &asset); ctx.insert("not_empty", &true); ctx } Err(_) => { let mut ctx = tera::Context::new(); ctx.insert("no...
code_fim
hard
{ "lang": "rust", "repo": "karnaukhovlad/hyperledger_fabric", "path": "/src/handlers.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: karnaukhovlad/hyperledger_fabric path: /src/handlers.rs use crate::actor::{AssetId, CliActor, GetAll}; use actix::Addr; use actix_web::{error, Error, Result}; use actix_web::{web, HttpRequest, HttpResponse}; /// 404 handler pub async fn p404(tmpl: web::Data<tera::Tera>) -> Result<HttpResponse, ...
code_fim
medium
{ "lang": "rust", "repo": "karnaukhovlad/hyperledger_fabric", "path": "/src/handlers.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: scottschroeder/overwatch-3v3 path: /manager-gui/src/app.rs use crate::layout; use crate::support; use glium; use glium::glutin; use crate::image_util; use crate::image_util::ImageId; use overwatch::Hero; use std::collections::BTreeMap; use match_history::MatchDb; pub struct App { pub ui: ...
code_fim
hard
{ "lang": "rust", "repo": "scottschroeder/overwatch-3v3", "path": "/manager-gui/src/app.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let ids = layout::Ids::new(&mut ui.widget_id_generator()); App { ui: ui, display: window, ids: ids, images: image_map, renderer: renderer, assets: AppAssets { portraits }, } } }<|fim_prefix|>// repo: scott...
code_fim
hard
{ "lang": "rust", "repo": "scottschroeder/overwatch-3v3", "path": "/manager-gui/src/app.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let events = std::mem::replace(&mut *self.inner.lock().unwrap(), Vec::new()); let validator = Validator::new(&events, log); validator.validate(); events } }<|fim_prefix|>// repo: unneon/aetherchart path: /src/central.rs use crate::{chrome_dev_tools, events::Event, validate::Validator}; use once_...
code_fim
hard
{ "lang": "rust", "repo": "unneon/aetherchart", "path": "/src/central.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn save_to(&self, path: impl AsRef<Path>, log: &Logger) { let file = std::fs::File::create(path).unwrap(); let events = self.drain(log); let events = events.into_iter().map(chrome_dev_tools::Event::from).collect::<Vec<_>>(); serde_json::to_writer(file, &events).unwrap(); } fn drain(&self, ...
code_fim
hard
{ "lang": "rust", "repo": "unneon/aetherchart", "path": "/src/central.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: unneon/aetherchart path: /src/central.rs use crate::{chrome_dev_tools, events::Event, validate::Validator}; use once_cell::sync::Lazy; use slog::Logger; use std::{path::Path, sync::Mutex}; pub static CENTRAL: Central = Central { inner: Lazy::new(|| Mutex::new(Vec::new())) }; <|fim_suffix|>impl...
code_fim
medium
{ "lang": "rust", "repo": "unneon/aetherchart", "path": "/src/central.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: p0lunin/teloxide-core path: /src/types/non_telegram_types/non_strict_vec.rs use serde::de::DeserializeOwned; use serde_json::{from_value, Value}; /// Similar to `Vec<T>` but if it fails to deserialize element, it just saves /// `Err((value, err))` #[derive(Debug, serde::Deserialize)] #[serde(fr...
code_fim
hard
{ "lang": "rust", "repo": "p0lunin/teloxide-core", "path": "/src/types/non_telegram_types/non_strict_vec.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let x: NonStrictVec<Update> = serde_json::from_str( r#"[{ "update_id": 923808447, "message": { "message_id": 361678, "from": { "id": 218485655, "is_bot": false, "first_name": "вафель", "last_name": "🧇", ...
code_fim
hard
{ "lang": "rust", "repo": "p0lunin/teloxide-core", "path": "/src/types/non_telegram_types/non_strict_vec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TzuRen/SafeSearchSSE path: /game_generators/synthetic/src/main.rs Synth { specify_subgames: config.specify_subgames, num_subgames: config.num_subgames, main_game_size: config.main_game_size, subgame_size: config.subgame_size, ...
code_fim
hard
{ "lang": "rust", "repo": "TzuRen/SafeSearchSSE", "path": "/game_generators/synthetic/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(StructOpt, Debug)] #[structopt(name = "rps")] struct Opt { #[structopt(short = "o", long = "output_game_file")] output_game_file: PathBuf, #[structopt(short = "b", long = "output_blueprint_file")] output_blueprint_file: PathBuf, #[structopt(short = "M", long = "num_subgames"...
code_fim
hard
{ "lang": "rust", "repo": "TzuRen/SafeSearchSSE", "path": "/game_generators/synthetic/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Inject solution into sequence form matrix. let ann = &annotations.treeplex_annotations_pl1.sequence_annotations; for (sequence_id, a_) in ann.iter().enumerate() { match a_ { None=>continue, // Empty sequence Some(a)=> { // If there are no subg...
code_fim
hard
{ "lang": "rust", "repo": "TzuRen/SafeSearchSSE", "path": "/game_generators/synthetic/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/hippo-jvm-rust path: /src/class_parser/mod.rs pub mod attribute_info; pub mod constant_pool; pub mod descriptor; pub mod field_info; pub mod method_info; use crate::class_parser::attribute_info::{parse_attribute_info, AttributeInfo}; use crate::class_parser::constant_pool::{parse_const_...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/hippo-jvm-rust", "path": "/src/class_parser/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(( left, ClassFile::new( minor_version, major_version, constant_pool, access_flags, this_class, super_class, interfaces, fields, methods, attributes, ) ...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/hippo-jvm-rust", "path": "/src/class_parser/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ClassFile { pub fn new( minor_version: u16, major_version: u16, constant_pool: ConstPool, access_flags: u16, this_class: u16, super_class: u16, interfaces: Vec<u16>, fields: Vec<FieldInfo>, methods: Vec<MethodInfo>, a...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/hippo-jvm-rust", "path": "/src/class_parser/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JulianKnodt/raymarcher path: /src/light.rs use intersection::Intersection; use vector::vector::Vector; use vector::generate::generate; use vector::ray::Ray; use sdf::{SDF, find_intersection, intersects}; use std::f32; pub enum Light { Point(Vector, Vector, f32) // Position, color, intensity }...
code_fim
hard
{ "lang": "rust", "repo": "JulianKnodt/raymarcher", "path": "/src/light.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // the subtraction is important because then it would might intersect the sdf it originally // hit let ray = Ray::from(from, to).eps_shift(); let dist = (ray.position - to).sqr_magn().sqrt() - 0.001; objects.iter().find(|sdf| { match find_intersection(sdf, &ray) { None => false, ...
code_fim
hard
{ "lang": "rust", "repo": "JulianKnodt/raymarcher", "path": "/src/light.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> lights.iter().fold(i.surface.emitted(), |acc, light| { if visible(inter_pt, light.position(), objects) { let incoming_dir = (inter_pt - light.position()).normalized(); let bi = light.biradiance(&inter_pt); let (color, reflections) = i.surface.finite_sd(&i.incident_ray, &i.s...
code_fim
medium
{ "lang": "rust", "repo": "JulianKnodt/raymarcher", "path": "/src/light.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } } /// Wrapper around [Error] that implements [slog::KV] trait, but without backtraces pub struct SlogKVErrorWithoutBackTrace(pub Error); /// Enum used in [slog::Serializer] implementation when [SlogKVError] is used #[derive(Debug, Clone, Eq, PartialEq)] pub enum SlogKVErrorKey { ...
code_fim
hard
{ "lang": "rust", "repo": "facebookexperimental/rust-shed", "path": "/shed/failure_ext/src/slogkv.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn from_str(s: &str) -> Result<Self, Self::Err> { match s { "error" => Ok(Error), "root_cause" => Ok(RootCause), "backtrace" => Ok(Backtrace), "cause" => Ok(Cause), "error_debug" => Ok(ErrorDebug), _ => Err(()), } ...
code_fim
hard
{ "lang": "rust", "repo": "facebookexperimental/rust-shed", "path": "/shed/failure_ext/src/slogkv.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: facebookexperimental/rust-shed path: /shed/failure_ext/src/slogkv.rs /* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under both the MIT license found in the * LICENSE-MIT file in the root directory of this source tree and the Apache * License, Versio...
code_fim
hard
{ "lang": "rust", "repo": "facebookexperimental/rust-shed", "path": "/shed/failure_ext/src/slogkv.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drklee3/eilpx path: /src/error.rs use log::SetLoggerError; use std::error::Error as StdError; use std::fmt::{Display, Formatter, Result as FmtResult}; use std::result::Result as StdResult; use std::io::Error as IoError; use image::ImageError; /// Common result type used throughout the program. ...
code_fim
medium
{ "lang": "rust", "repo": "drklee3/eilpx", "path": "/src/error.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> match *self { Error::Io(ref inner) => inner.fmt(f), Error::SetLogger(ref inner) => inner.fmt(f), Error::Image(ref inner) => inner.fmt(f), } } } impl StdError for Error { fn description(&self) -> &str { match *self { Error::Io(ref inner) => inner.description(), ...
code_fim
hard
{ "lang": "rust", "repo": "drklee3/eilpx", "path": "/src/error.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> "a"], ["x", * "x"] ]. * * * 输入总是有效的。你可以假设除法运算中不会出现除数为0的情况,且不存在任何矛盾的结果。 * */ use std::collections::HashMap; // @lc code=start impl Solution { pub fn calc_equation( equations: Vec<Vec<String>>, values: Vec<f64>, queries: Vec<Vec<String>>, ) -> Vec<f64> { // Union Fin...
code_fim
hard
{ "lang": "rust", "repo": "Bert0324/leetcode-vscode", "path": "/399.除法求值.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>, * vector<pair<string, string>> queries(方程式,方程式结果,问题方程式), 其中 equations.size() * == values.size(),即方程式的长度与方程式结果长度相等(程式与结果一一对应),并且结果值均为正数。以上为方程式的描述。 * 返回vector<double>类型。 * * 基于上述例子,输入如下: * * * equations(方程式) = [ ["a", "b"], ["b", "c"] ], * values(方程式结果) = [2.0, 3.0], * queries(问题方程式) = [ ["a", "c"], ["b",...
code_fim
hard
{ "lang": "rust", "repo": "Bert0324/leetcode-vscode", "path": "/399.除法求值.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Bert0324/leetcode-vscode path: /399.除法求值.rs /* * @lc app=leetcode.cn id=399 lang=rust * * [399] 除法求值 * * https://leetcode-cn.com/problems/evaluate-division/description/ * * algorithms * Medium (52.90%) * Likes: 102 * Dislikes: 0 * Total Accepted: 5.2K * Total Submissions: 9.7K * Testcase E...
code_fim
hard
{ "lang": "rust", "repo": "Bert0324/leetcode-vscode", "path": "/399.除法求值.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> f.write_str(&serde_json::to_string_pretty(&self).map_err(|_| fmt::Error)?) } } #[derive(Debug, Serialize, Deserialize)] pub struct UserId(u32); #[derive(Debug, Serialize, Deserialize)] pub struct SmmoPlayerGuild { pub id: u32, pub name: String, }<|fim_prefix|>// repo: benluelo/smmo-a...
code_fim
medium
{ "lang": "rust", "repo": "benluelo/smmo-api", "path": "/src/models/smmo_player.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: benluelo/smmo-api path: /src/models/smmo_player.rs use std::fmt::{self, Display}; use crate::{ custom_serde::{bool_from_int, date_time_option::*}, models::SmmoModel, }; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct...
code_fim
medium
{ "lang": "rust", "repo": "benluelo/smmo-api", "path": "/src/models/smmo_player.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let row_groups = RowGroupIterator::try_new(batches.into_iter(), &schema, options, encodings).unwrap(); let mut file = File::create(path).unwrap(); let parquet_schema = row_groups.parquet_schema().clone(); write_file( &mut file, row_group...
code_fim
hard
{ "lang": "rust", "repo": "r-asou/databend", "path": "/query/src/tests/parquet.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: r-asou/databend path: /query/src/tests/parquet.rs // Copyright 2020 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/...
code_fim
hard
{ "lang": "rust", "repo": "r-asou/databend", "path": "/query/src/tests/parquet.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // double cnt, because edges are bidirected let (alice_edges_cnt, alice_common_edges_cnt) = alice.mst.iter().fold((0, 0), |cur, (_, edges)| { ( cur.0 + edges.len(), cur.1 + edges.iter().filter(|x| x...
code_fim
hard
{ "lang": "rust", "repo": "Cheshulko/Algorithms", "path": "/Leetcode/RemoveMaxNumberofEdgestoKeepGraphFullyTraversable.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Cheshulko/Algorithms path: /Leetcode/RemoveMaxNumberofEdgestoKeepGraphFullyTraversable.rs // https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable mod graph { use std::{ cmp::Reverse, collections::{BTreeMap, BinaryHeap}, }; pub str...
code_fim
hard
{ "lang": "rust", "repo": "Cheshulko/Algorithms", "path": "/Leetcode/RemoveMaxNumberofEdgestoKeepGraphFullyTraversable.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for (v, c) in &self.graph[&start] { prio.push(Reverse((*c, *v, start))); } while let Some(Reverse((dist, t, prev))) = prio.pop() { if self.mst.contains_key(&t) { continue; } self.add_e...
code_fim
hard
{ "lang": "rust", "repo": "Cheshulko/Algorithms", "path": "/Leetcode/RemoveMaxNumberofEdgestoKeepGraphFullyTraversable.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rustwasm/wasm-bindgen path: /crates/webidl/src/idl_type.rs record), NonAnyType::Int32Array(t) => t.to_idl_type(record), NonAnyType::Uint8Array(t) => t.to_idl_type(record), NonAnyType::Uint16Array(t) => t.to_idl_type(record), NonAnyType::Uint32Array...
code_fim
hard
{ "lang": "rust", "repo": "rustwasm/wasm-bindgen", "path": "/crates/webidl/src/idl_type.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>macro_rules! terms_to_idl_type { ($($t:tt => $r:tt)*) => ($( impl<'a> ToIdlType<'a> for term::$t { fn to_idl_type(&self, _record: &FirstPassRecord<'a>) -> IdlType<'a> { IdlType::$r } } )*); } // We default to arrays being mutable, but in cer...
code_fim
hard
{ "lang": "rust", "repo": "rustwasm/wasm-bindgen", "path": "/crates/webidl/src/idl_type.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> IdlType::ArrayBuffer => Ok(js_sys("ArrayBuffer")), IdlType::DataView => Ok(js_sys("DataView")), IdlType::Int8Array { immutable } => Ok(Some(array("i8", pos, *immutable))), IdlType::Uint8Array { immutable } => Ok(Some(array("u8", pos, *immutable))), ...
code_fim
hard
{ "lang": "rust", "repo": "rustwasm/wasm-bindgen", "path": "/crates/webidl/src/idl_type.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Moon { pos: Vec3 { x, y, z }, vel: Vec3::default(), } }) .collect() } fn main() { let mut moons = parse_moons(INPUT); for _ in 0..1000 { step(&mut moons); } println!("1. {}", total_energy(&moons)); let ...
code_fim
hard
{ "lang": "rust", "repo": "TyPR124/advent-of-code", "path": "/2019/src/bin/day12/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TyPR124/advent-of-code path: /2019/src/bin/day12/main.rs mod input; use input::INPUT; use std::cmp::Ordering; use std::str::FromStr; #[derive(Copy, Clone, Eq, PartialEq, Default, Debug, Hash)] struct Vec3 { x: isize, y: isize, z: isize, } impl Vec3 { fn abs_sum(self) -> usize {...
code_fim
hard
{ "lang": "rust", "repo": "TyPR124/advent-of-code", "path": "/2019/src/bin/day12/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Limegrass/llrs path: /llrs-site/src/app/app_navbar.rs use crate::{agents::manga::Response as MangaResponse, pages::ViewFormat, route::AppRoute}; use crate::{ agents::{ manga::{Action as MangaAction, MangaAgent}, user::{Action as UserAgentAction, Response as UserAgentResponse,...
code_fim
hard
{ "lang": "rust", "repo": "Limegrass/llrs", "path": "/llrs-site/src/app/app_navbar.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn get_menu_end_links(&self) -> Html { let waifusims_link = html! { <a class="navbar-item" href="https://waifusims.com/Manga"> {"Waifusims Reader"} </a> }; let discord_link = html! { <a class="navbar-item" href=env!("LLRS_DISC...
code_fim
hard
{ "lang": "rust", "repo": "Limegrass/llrs", "path": "/llrs-site/src/app/app_navbar.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: renchuqiao/chirpstack-api path: /rust/src/gen/as_pb/external/api/fuotaDeployment_grpc.rs // This file is generated. Do not edit // @generated // https://github.com/Manishearth/rust-clippy/issues/702 #![allow(unknown_lints)] #![allow(clippy::all)] #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(b...
code_fim
hard
{ "lang": "rust", "repo": "renchuqiao/chirpstack-api", "path": "/rust/src/gen/as_pb/external/api/fuotaDeployment_grpc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// server pub struct FUOTADeploymentServiceServer; impl FUOTADeploymentServiceServer { pub fn new_service_def<H : FUOTADeploymentService + 'static + Sync + Send + 'static>(handler: H) -> ::grpc::rt::ServerServiceDefinition { let handler_arc = ::std::sync::Arc::new(handler); ::grpc::...
code_fim
hard
{ "lang": "rust", "repo": "renchuqiao/chirpstack-api", "path": "/rust/src/gen/as_pb/external/api/fuotaDeployment_grpc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// client pub struct FUOTADeploymentServiceClient { grpc_client: ::std::sync::Arc<::grpc::Client>, method_CreateForDevice: ::std::sync::Arc<::grpc::rt::MethodDescriptor<super::fuotaDeployment::CreateFUOTADeploymentForDeviceRequest, super::fuotaDeployment::CreateFUOTADeploymentForDeviceResponse>>,...
code_fim
hard
{ "lang": "rust", "repo": "renchuqiao/chirpstack-api", "path": "/rust/src/gen/as_pb/external/api/fuotaDeployment_grpc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }