text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: seija-engine/seija-old path: /src/core/timing.rs use std::time::{Duration,Instant}; #[derive(Clone,Eq,PartialEq)] pub enum Stopwatch { Waiting, Started(Duration,Instant), Ended(Duration) } impl Default for Stopwatch { fn default() -> Stopwatch { Stopwatch::Waiting } ...
code_fim
hard
{ "lang": "rust", "repo": "seija-engine/seija-old", "path": "/src/core/timing.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 4rbor/tq path: /tests/common.rs // Testing utility functions pub fn get_fixture_path(fi<|fim_suffix|>t}/tests/fixtures/{file_name}", project_root = env!("CARGO_MANIFEST_DIR"), file_name = file_name ) }<|fim_middle|>le_name: &str) -> String { format!( "{project_roo
code_fim
easy
{ "lang": "rust", "repo": "4rbor/tq", "path": "/tests/common.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>("CARGO_MANIFEST_DIR"), file_name = file_name ) }<|fim_prefix|>// repo: 4rbor/tq path: /tests/common.rs // Testing utility functions pub fn get_fixture_path(file_name: &str) -> String { format!( "{project_roo<|fim_middle|>t}/tests/fixtures/{file_name}", project_root = env!
code_fim
easy
{ "lang": "rust", "repo": "4rbor/tq", "path": "/tests/common.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<E> Observer<E> for Arc<RwLock<dyn Observer<E>>> { fn on_notify(&self, event: &E) { self.read().unwrap().on_notify(event) } } impl<E> Observer<E> for Arc<RwLock<dyn MutObserver<E>>> { fn on_notify(&self, event: &E) { self.write().unwrap().on_notify(event) } }<|fim_pref...
code_fim
hard
{ "lang": "rust", "repo": "kan1-u/event-observer", "path": "/src/observer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<E> Observer<E> for Arc<dyn Observer<E>> { fn on_notify(&self, event: &E) { (**self).on_notify(event) } } impl<E> Observer<E> for Arc<Mutex<dyn Observer<E>>> { fn on_notify(&self, event: &E) { self.lock().unwrap().on_notify(event) } } impl<E> Observer<E> for Arc<Mutex...
code_fim
medium
{ "lang": "rust", "repo": "kan1-u/event-observer", "path": "/src/observer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kan1-u/event-observer path: /src/observer.rs use std::cell::RefCell; use std::rc::Rc; use std::sync::{Arc, Mutex, RwLock}; pub trait Observer<E> { fn on_notify(&self, event: &E); } pub trait MutObserver<E> { fn on_notify(&mut self, event: &E); } impl<E> Observer<E> for Rc<dyn Observer...
code_fim
medium
{ "lang": "rust", "repo": "kan1-u/event-observer", "path": "/src/observer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marvin-rs/robot-traits path: /src/lib.rs //! This crate defined a collection of robot related traits to allow //! interoperability between generic inputs and outputs. //! //! Many of the traits were originally borrowed from the python gpiozero //! library although I expect them to diverge over t...
code_fim
medium
{ "lang": "rust", "repo": "marvin-rs/robot-traits", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub trait Physical { type Position; fn get_position(&self) -> Self::Position; }<|fim_prefix|>// repo: marvin-rs/robot-traits path: /src/lib.rs //! This crate defined a collection of robot related traits to allow //! interoperability between generic inputs and outputs. //! //! Many of the traits w...
code_fim
medium
{ "lang": "rust", "repo": "marvin-rs/robot-traits", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn step(&mut self, input : &LEDInput) -> LEDOutput { let &LEDInput {button_pressed, usbstate} = input; let alarm = self.timer.step(); match self.led_state { LedState::Off => { if button_pressed == true { self.led_state = LedSt...
code_fim
hard
{ "lang": "rust", "repo": "apgoetz/led_clock", "path": "/app/src/led.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: apgoetz/led_clock path: /app/src/led.rs use crate::blocks; use usb_device::device::UsbDeviceState; use core::fmt::Debug; #[derive(Debug)] pub enum LedState {On,Off, Suspend} pub struct LEDInput { pub button_pressed : bool, pub usbstate : UsbDeviceState , } pub struct LEDOutput { ...
code_fim
hard
{ "lang": "rust", "repo": "apgoetz/led_clock", "path": "/app/src/led.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl LEDStateMachine { pub fn new () -> LEDStateMachine { let b = [ 0.00024136, 0.00048272, 0.00024136]; let a = [ 1. , -1.95557824, 0.95654368]; LEDStateMachine {ledfilter : blocks::BiQuad::new(0.0, b , ...
code_fim
hard
{ "lang": "rust", "repo": "apgoetz/led_clock", "path": "/app/src/led.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if ffi::opj_read_header(jp2_stream, jp2_codec, jp2_image) != 1 { ffi::opj_stream_destroy(jp2_stream); ffi::opj_destroy_codec(jp2_codec); //ffi::opj_image_destroy(jp2_image); //libc::free(jp2_image as *mut libc::c_void); return Err(Error::...
code_fim
hard
{ "lang": "rust", "repo": "jrmuizel/jpeg2000-rust", "path": "/src/decode.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jrmuizel/jpeg2000-rust path: /src/decode.rs use openjp2_sys as ffi; use std::os::raw::{c_char, c_void, c_int}; use std::ptr::{null, null_mut}; use std::mem; use libc; #[derive(Clone, Eq, PartialEq, Debug)] pub enum Codec { J2K, JP2, JPP, JPT, JPX, } impl Codec { fn to_i...
code_fim
hard
{ "lang": "rust", "repo": "jrmuizel/jpeg2000-rust", "path": "/src/decode.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Returns the log file path to use for the module. /// /// If the module has a custom path then that will be used instead. Otherwise /// the path is computed according to [log_file_path]. pub fn log_file_module(module: &ModuleDefinition) -> Result<PathBuf> { match &module.log_file_path { Som...
code_fim
hard
{ "lang": "rust", "repo": "weslien/cartel", "path": "/src/daemon/logs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: weslien/cartel path: /src/daemon/logs.rs use crate::daemon::module::{ModuleDefinition, ModuleKind}; use anyhow::{Context, Result}; use dirs::home_dir; use std::fs; use std::path::PathBuf; const PROJECT_DIR: &str = ".cartel"; const LOG_DIR: &str = "logs"; <|fim_suffix|>/// Returns the log file ...
code_fim
hard
{ "lang": "rust", "repo": "weslien/cartel", "path": "/src/daemon/logs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: amerelo/Gomoku path: /src/graphic/cursor.rs #[derive(PartialEq,)] pub enum Scene { Settings, Game, } #[derive(PartialEq,)] pub enum Controls { Mouse, KeyBoard, GameControls, } <|fim_suffix|>impl Cursor { pub fn new() -> Self { Cursor { press: false, up: false, down: false, ...
code_fim
hard
{ "lang": "rust", "repo": "amerelo/Gomoku", "path": "/src/graphic/cursor.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Cursor { pub fn new() -> Self { Cursor { press: false, up: false, down: false, place_piece: false, undo: false, hint: false, prev: false, ai1_level: 6, ai2_level: 6, cursor_pos: [0.0, 0.0], cursor_in_board: [0, 0], selected_scene: Scene::Settings, controll...
code_fim
hard
{ "lang": "rust", "repo": "amerelo/Gomoku", "path": "/src/graphic/cursor.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tyleo/graphflo path: /dep/backend/src/serialization/node_connector_descs.rs use serialization::NodeConnectorDesc; #[allow(non_camel_case_types)] #[derive(Clone, Debug, Deserialize, Eq, PartialEq, S<|fim_suffix|>nt(Vec<NodeConnectorDesc>), variable(NodeConnectorDesc), }<|fim_middle|>erialize...
code_fim
medium
{ "lang": "rust", "repo": "tyleo/graphflo", "path": "/dep/backend/src/serialization/node_connector_descs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>nt(Vec<NodeConnectorDesc>), variable(NodeConnectorDesc), }<|fim_prefix|>// repo: tyleo/graphflo path: /dep/backend/src/serialization/node_connector_descs.rs use serialization::NodeConnectorDesc; #[allow(non_camel_case<|fim_middle|>_types)] #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize...
code_fim
medium
{ "lang": "rust", "repo": "tyleo/graphflo", "path": "/dep/backend/src/serialization/node_connector_descs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fluxsocial/Shared-Perspective-Index path: /zomes/shared_perspective_index/src/lib.rs use chrono::{DateTime, Utc}; use hdk::prelude::*; mod inputs; mod utils; use inputs::*; use utils::err; //TODO // DNA needs spam protection since it is supposed to be public // Validation on the linking of so...
code_fim
hard
{ "lang": "rust", "repo": "fluxsocial/Shared-Perspective-Index", "path": "/zomes/shared_perspective_index/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[hdk_extern] pub fn index_shared_perspective(data: CreateSharedPerspective) -> ExternResult<SignedSharedPerspective> { let path = Path::from(data.key); path.ensure()?; create_entry(&data.shared_perspective)?; let expression_hash = hash_entry(&data.shared_perspective)?; create_link(pa...
code_fim
hard
{ "lang": "rust", "repo": "fluxsocial/Shared-Perspective-Index", "path": "/zomes/shared_perspective_index/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nordseele/hans_rust path: /src/eurorack/er301.rs pub use super::Command; pub use super::Arg; pub use super::Bufsize; pub use super::er301; // addresses pub const ADDRESSES: [usize; 3] = [0x31, 0x32, 0x33]; // commands pub enum Cmd { Tr, TrTog, TrPulse, TrTime, TrPol, ...
code_fim
hard
{ "lang": "rust", "repo": "nordseele/hans_rust", "path": "/src/eurorack/er301.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn cmd_from_string(cmd_name: &str) -> Option<Command>{ match cmd_name { "tr" | "trigger" => Some(TR), "tr_tog" => Some(TR_TOG), "tr_pulse" | "trp" | "tr_p" => Some(TR_PULSE), "tr_time" => Some(TR_TIME), "tr_pol...
code_fim
hard
{ "lang": "rust", "repo": "nordseele/hans_rust", "path": "/src/eurorack/er301.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hhawkens/advent_2018 path: /src/day_4/data.rs 00:08] falls asleep [1518-04-01 00:01] Guard #3371 begins shift [1518-06-29 00:33] falls asleep [1518-08-21 00:01] Guard #1213 begins shift [1518-08-21 23:51] Guard #1319 begins shift [1518-06-17 00:04] falls asleep [1518-05-22 00:54] falls asleep [...
code_fim
hard
{ "lang": "rust", "repo": "hhawkens/advent_2018", "path": "/src/day_4/data.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>akes up [1518-09-13 00:33] falls asleep [1518-09-28 00:31] wakes up [1518-06-07 00:00] Guard #3319 begins shift [1518-06-13 00:00] Guard #3347 begins shift [1518-05-09 00:48] wakes up [1518-05-10 00:32] wakes up [1518-10-23 00:03] Guard #103 begins shift [1518-10-13 00:17] falls asleep [1518-07-17 23:59] ...
code_fim
hard
{ "lang": "rust", "repo": "hhawkens/advent_2018", "path": "/src/day_4/data.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hhawkens/advent_2018 path: /src/day_4/data.rs 0:01] Guard #103 begins shift [1518-08-06 00:25] falls asleep [1518-10-24 00:15] falls asleep [1518-11-04 00:39] falls asleep [1518-03-27 00:11] falls asleep [1518-04-19 23:59] Guard #439 begins shift [1518-10-29 00:55] wakes up [1518-05-05 00:20] wa...
code_fim
hard
{ "lang": "rust", "repo": "hhawkens/advent_2018", "path": "/src/day_4/data.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> read() } fn fill_bytes(&mut self, buffer: &mut [u8]) { for c in buffer.chunks_mut(8) { let b = read().to_le_bytes(); c.copy_from_slice(&b[..c.len()]); } } fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> { ...
code_fim
hard
{ "lang": "rust", "repo": "Dentosal/rust_os", "path": "/src/random.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Dentosal/rust_os path: /src/random.rs use core::arch::asm; use core::sync::atomic::{AtomicU64, AtomicUsize, Ordering}; static ENTROPY_POOL: [AtomicU64; 512] = [const { AtomicU64::new(0) }; 512]; static READ_INDEX: AtomicUsize = AtomicUsize::new(0); static WRITE_INDEX: AtomicUsize = AtomicUsize:...
code_fim
hard
{ "lang": "rust", "repo": "Dentosal/rust_os", "path": "/src/random.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: human9/life path: /src/support/conrod_backend.rs lay`'s current framebuffer /// dimensions. pub fn new<F>(facade: &F) -> Result<Self, glium::texture::TextureCreationError> where F: glium::backend::Facade, { const SCALE_TOLERANCE: f32 = 0.1; const POSITION_TOLE...
code_fim
hard
{ "lang": "rust", "repo": "human9/life", "path": "/src/support/conrod_backend.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: human9/life path: /src/support/conrod_backend.rs * dpi_factor / half_win_h) as f32; let mut current_scizzor = glium::Rect { left: 0, width: screen_w, bottom: 0, height: screen_h, }; let rect_to_glium_rect = |rect: Rect| {...
code_fim
hard
{ "lang": "rust", "repo": "human9/life", "path": "/src/support/conrod_backend.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// The fragment shader used within the `glium::Program` for OpenGL. pub const FRAGMENT_SHADER_140: &'static str = " #version 140 uniform sampler2D tex; in vec2 v_tex_coords; in vec4 v_color; flat in uint v_mode; out vec4 f_color; void main() { // Text if (v_...
code_fim
hard
{ "lang": "rust", "repo": "human9/life", "path": "/src/support/conrod_backend.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: juhnowski/rust_tuples path: /src/main.rs fn main() { let tup: (i32, f64, bool) = (1,1.5,true); <|fim_suffix|>z); println!("tup.0={} tup.1={} and tup.2={}",a,b,c); }<|fim_middle|> let (x,y,z) = tup; let a = tup.0; let b = tup.1; let c = tup.2; println!("x={} y={} and z=...
code_fim
medium
{ "lang": "rust", "repo": "juhnowski/rust_tuples", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>z); println!("tup.0={} tup.1={} and tup.2={}",a,b,c); }<|fim_prefix|>// repo: juhnowski/rust_tuples path: /src/main.rs fn main() { let tup: (i32, f64, bool) = (1,1.5,true); <|fim_middle|> let (x,y,z) = tup; let a = tup.0; let b = tup.1; let c = tup.2; println!("x={} y={} and z=...
code_fim
medium
{ "lang": "rust", "repo": "juhnowski/rust_tuples", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Displayr/azure-sdk-for-rust path: /sdk/cosmos/src/requests/create_collection_builder.rs use crate::prelude::*; use crate::resources::collection::{IndexingPolicy, PartitionKey}; use crate::resources::ResourceType; use crate::responses::CreateCollectionResponse; use azure_core::prelude::*; use htt...
code_fim
hard
{ "lang": "rust", "repo": "Displayr/azure-sdk-for-rust", "path": "/sdk/cosmos/src/requests/create_collection_builder.rs", "mode": "psm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_suffix|> let body = azure_core::to_json(&collection)?; debug!("body == {:?}", body); let req = req.body(body)?; debug!("\nreq == {:?}", req); Ok(self .database_client .http_client() .execute_request_check_status(req, StatusCode::CREATED)...
code_fim
hard
{ "lang": "rust", "repo": "Displayr/azure-sdk-for-rust", "path": "/sdk/cosmos/src/requests/create_collection_builder.rs", "mode": "spm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_prefix|>// repo: semio-ai/vkfft-rs path: /src/app.rs use std::sync::Arc; use error::check_error; use vulkano::{buffer::BufferAccess, VulkanHandle, VulkanObject}; use crate::{ config::{Config, ConfigGuard}, error, }; use std::pin::Pin; use vk_sys as vk; use std::ptr::addr_of_mut; use derive_more::{Displa...
code_fim
hard
{ "lang": "rust", "repo": "semio-ai/vkfft-rs", "path": "/src/app.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(b) = &res.output_buffer { res.params.outputBuffer = transmute(b); } if let Some(k) = &res.kernel { res.params.kernel = transmute(k); } res } } pub fn builder() -> LaunchParamsBuilder { LaunchParamsBuilder::new() } } pub struct App...
code_fim
hard
{ "lang": "rust", "repo": "semio-ai/vkfft-rs", "path": "/src/app.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl App { pub fn new(config: Config) -> error::Result<Pin<Box<Self>>> { use vkfft_sys::*; let app: VkFFTApplication = unsafe { std::mem::zeroed() }; let sys_config = config.as_sys()?; let mut res = Box::pin(Self { app, config: sys_config, }); check_error(unsafe {...
code_fim
hard
{ "lang": "rust", "repo": "semio-ai/vkfft-rs", "path": "/src/app.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl<T> IntoStream<T> { /// Create a new `Stream` from the provided `BufStream`. pub fn new(buf: T) -> Self { IntoStream { buf } } /// Get a reference to the inner `BufStream`. pub fn get_ref(&self) -> &T { &self.buf } /// Get a mutable reference to the inner ...
code_fim
hard
{ "lang": "rust", "repo": "Aleru/tokio", "path": "/tokio-buf/src/util/stream.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Aleru/tokio path: /tokio-buf/src/util/stream.rs use crate::BufStream; use bytes::Buf; use futures::{Async, Poll, Stream}; /// Converts a `Stream` of `Buf` types into a `BufStream`. /// /// While `Stream` and `BufStream` are very similar, they are not identical. The /// `stream` function returns...
code_fim
hard
{ "lang": "rust", "repo": "Aleru/tokio", "path": "/tokio-buf/src/util/stream.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut left = Aggregate::new(); left.scale(2.0, 1.0, 2.0); left.rotate_z(90.0); left.translate([-2.0, 0.0, 0.0]); left.add_obj_of(plane, r); scene.root.add_group(left); let mut right = Aggregate::new(); right.scale(2.0, 1.0, 2.0); right.rotate_z(90.0); right.trans...
code_fim
hard
{ "lang": "rust", "repo": "nfrasser/lasgun", "path": "/src/examples/cornell.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nfrasser/lasgun path: /src/examples/cornell.rs use ::lasgun::{ scene::{Scene, Aggregate}, Material, output }; mod meshes; fn main() { output::render(&cornell(), [512, 512], "cornell.png"); } fn cornell() -> Scene { // Initialize a new empty scene with the given options let mut scene =...
code_fim
medium
{ "lang": "rust", "repo": "nfrasser/lasgun", "path": "/src/examples/cornell.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut back = Aggregate::new(); back.scale(2.0, 1.0, 2.0); back.rotate_x(90.0); back.translate([0.0, 0.0, -2.0]); back.add_obj_of(plane, white); scene.root.add_group(back); // Make and aggregate some spheres scene.root.add_sphere([1.0, -1.25, 0.0], 1.0, glass); scene....
code_fim
hard
{ "lang": "rust", "repo": "nfrasser/lasgun", "path": "/src/examples/cornell.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // "Used by SpinnerController" pub unknown6: u32, pub unknown7: u32, pub unknown8: u32, } impl<'r> SclyPropertyData for SpecialFunction<'r> { const OBJECT_TYPE: u8 = 0x3A; }<|fim_prefix|>// repo: YonicDev/randomprime path: /structs/src/scly_props/special_function.rs use auto_struct_m...
code_fim
medium
{ "lang": "rust", "repo": "YonicDev/randomprime", "path": "/structs/src/scly_props/special_function.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YonicDev/randomprime path: /structs/src/scly_props/special_function.rs use auto_struct_macros::auto_struct; use reader_writer::CStr; use reader_writer::typenum::*; use reader_writer::generic_array::GenericArray; use crate::SclyPropertyData; <|fim_suffix|> pub layer_change_room_id: u32, ...
code_fim
hard
{ "lang": "rust", "repo": "YonicDev/randomprime", "path": "/structs/src/scly_props/special_function.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub unknown4: u8, pub unknown5: f32, // "Used by SpinnerController" pub unknown6: u32, pub unknown7: u32, pub unknown8: u32, } impl<'r> SclyPropertyData for SpecialFunction<'r> { const OBJECT_TYPE: u8 = 0x3A; }<|fim_prefix|>// repo: YonicDev/randomprime path: /structs/src/sc...
code_fim
medium
{ "lang": "rust", "repo": "YonicDev/randomprime", "path": "/structs/src/scly_props/special_function.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let started = Instant::now(); set_message_handler(Box::new(Processor(0, 0, started))); }<|fim_prefix|>// repo: dunnock/grayarea path: /examples/throughput/src/bin/checksum.rs use grayarea::{set_message_handler, MessageHandler, Result}; use std::time::Instant; struct Processor(usize, ...
code_fim
hard
{ "lang": "rust", "repo": "dunnock/grayarea", "path": "/examples/throughput/src/bin/checksum.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dunnock/grayarea path: /examples/throughput/src/bin/checksum.rs use grayarea::{set_message_handler, MessageHandler, Result}; use std::time::Instant; struct Processor(usize, usize, Instant); impl MessageHandler for Processor { fn on_message(&mut self, message: &[u8]) -> Result<()> { <|fim_s...
code_fim
hard
{ "lang": "rust", "repo": "dunnock/grayarea", "path": "/examples/throughput/src/bin/checksum.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::VMOVDQA, operand1: Some(Direct(XMM7)), operand2: Some(Direct(XMM6)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[197, 249, 111, 254], OperandSize::Dword) } #[test] fn vmovd...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_vmovdqa.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/instr_vmovdqa.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_vmovdqa.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::VMOVDQA, operand1: Some(Direct(YMM7)), operand2: Some(Direct(YMM5)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[197, 253, 111, 253], OperandSize::Qword) } #[test] fn vmovd...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_vmovdqa.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kziemianek/tsp-solver path: /src/solver/mod.rs extern crate rand; use rand::rngs::ThreadRng; use rand::seq::SliceRandom; use rand::thread_rng; use rand::Rng; pub struct TspSolution { pub city_order: Vec<u32>, pub travel_distance: f32, } impl TspSolution { fn new(city_order: Vec<u3...
code_fim
hard
{ "lang": "rust", "repo": "kziemianek/tsp-solver", "path": "/src/solver/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn get_pairs_to_swap_test_3() { let first_idx: usize = 10; let second_idx: usize = 2; let expected_pairs = vec![ (2, 10), (3, 9), (4, 8), (5, 7), // todo: we can omit 6,6 pair as swapping them doesn't chang...
code_fim
hard
{ "lang": "rust", "repo": "kziemianek/tsp-solver", "path": "/src/solver/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Gunner-Bones/pointercrate path: /src/model/record/get.rs use super::Record; use crate::{error::PointercrateError, operation::Get, Result}; use diesel::{result::Error, PgConnection, RunQueryDsl}; <|fim_suffix|> match Record::by_id(id).first(connection) { Ok(record) => Ok(recor...
code_fim
hard
{ "lang": "rust", "repo": "Gunner-Bones/pointercrate", "path": "/src/model/record/get.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match Record::by_id(id).first(connection) { Ok(record) => Ok(record), Err(Error::NotFound) => Err(PointercrateError::ModelNotFound { model: "Record", identified_by: id.to_string(), }), Err(e...
code_fim
hard
{ "lang": "rust", "repo": "Gunner-Bones/pointercrate", "path": "/src/model/record/get.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xunilrj/sandbox path: /sources/rust/tomi/old/src/parser.rs } else { unsafe { std::str::from_utf8_unchecked(data) } }; Ok((input, s)) } #[inline(always)] #[allow(dead_code)] fn parse_string(input: &[u8], size: usize) -> nom::IResult<&[u8], &str> { let (input, data) = nom::...
code_fim
hard
{ "lang": "rust", "repo": "xunilrj/sandbox", "path": "/sources/rust/tomi/old/src/parser.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>struct DebugU32(u32); impl std::fmt::Debug for DebugU32 { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let bytes = self.0.to_le_bytes(); let asf32 = f32::from_le_bytes(bytes); f.write_fmt(format_args!("{} ({:X?}) (f32: {})", self.0, bytes, asf32)) } ...
code_fim
hard
{ "lang": "rust", "repo": "xunilrj/sandbox", "path": "/sources/rust/tomi/old/src/parser.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xunilrj/sandbox path: /sources/rust/tomi/old/src/parser.rs > { nom::number::complete::le_i32(input) } #[inline(always)] pub fn parse_le_u64(input: &[u8]) -> nom::IResult<&[u8], u64> { nom::number::complete::le_u64(input) } #[inline(always)] pub fn parse_le_f32(input: &[u8]) -> nom::IRe...
code_fim
hard
{ "lang": "rust", "repo": "xunilrj/sandbox", "path": "/sources/rust/tomi/old/src/parser.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: amao/Rust_Action_RPG_Tutorial path: /scripts/src/sword_hitbox.rs use crate::hitbox::*; use gdnative::api::*; use gdnative::prelude::*; <|fim_suffix|> #[export] fn get_hitbox_damage(&self, owner: &Area2D) -> i64 { self.hitbox.get_hitbox_damage(owner) } }<|fim_middle|>// SwordH...
code_fim
hard
{ "lang": "rust", "repo": "amao/Rust_Action_RPG_Tutorial", "path": "/scripts/src/sword_hitbox.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[export] fn get_hitbox_damage(&self, owner: &Area2D) -> i64 { self.hitbox.get_hitbox_damage(owner) } }<|fim_prefix|>// repo: amao/Rust_Action_RPG_Tutorial path: /scripts/src/sword_hitbox.rs use crate::hitbox::*; use gdnative::api::*; use gdnative::prelude::*; // SwordHitbox "class"....
code_fim
hard
{ "lang": "rust", "repo": "amao/Rust_Action_RPG_Tutorial", "path": "/scripts/src/sword_hitbox.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 15831944/async-gcode path: /src/parser/test/parse_trailing_comment.rs use super::{block_on, to_gcode_comment, GCode}; #[test] fn a_semicolon_is_followed_by_a_comment_until_the_end_of_the_line() { <|fim_suffix|> let input = format!("g32 ;{}\n", msg); let input = input.bytes(); let mut...
code_fim
hard
{ "lang": "rust", "repo": "15831944/async-gcode", "path": "/src/parser/test/parse_trailing_comment.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let input = format!("g32 ;{}\n", msg); let input = input.bytes(); let mut expected_output = vec![Ok(GCode::Word('g', (32.0).into()))]; expected_output.extend_from_slice(&to_gcode_comment(msg)); expected_output.push(Ok(GCode::Execute)); assert_eq!(block_on(input), expected_output); ...
code_fim
hard
{ "lang": "rust", "repo": "15831944/async-gcode", "path": "/src/parser/test/parse_trailing_comment.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: limonadev/metrics-system path: /db_managers/simple_movie_db_manager/src/movie_item.rs use std::collections::HashMap; use crate::schema::*; use db_manager::Item; #[derive(diesel::Queryable)] pub struct QueryableItem { pub id: i32, pub title: String, } #[derive(Insertable)] #[table_nam...
code_fim
hard
{ "lang": "rust", "repo": "limonadev/metrics-system", "path": "/db_managers/simple_movie_db_manager/src/movie_item.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.name.clone() } fn data(&self) -> HashMap<String, String> { HashMap::new() } }<|fim_prefix|>// repo: limonadev/metrics-system path: /db_managers/simple_movie_db_manager/src/movie_item.rs use std::collections::HashMap; use crate::schema::*; use db_manager::Item; #[derive...
code_fim
medium
{ "lang": "rust", "repo": "limonadev/metrics-system", "path": "/db_managers/simple_movie_db_manager/src/movie_item.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spyder-ide/pysyntect path: /src/base/theme.rs /// Class wrapper around [`syntect::highlighting::Theme`] and [`syntect::highlighting::ThemeSet`] // PyO3 imports use pyo3::prelude::*; use pyo3::exceptions::{PyKeyError}; use pyo3::class::PyMappingProtocol; // Syntect imports use syntect::highligh...
code_fim
hard
{ "lang": "rust", "repo": "spyder-ide/pysyntect", "path": "/src/base/theme.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Handle to a map of highlighting themes. #[pyclass(name="ThemeSet")] pub struct ThemeSetHandle { pub theme_set: ThemeSet, } #[pyproto] impl PyMappingProtocol for ThemeSetHandle { fn __getitem__(&self, key: String) -> PyResult<ThemeHandle> { let opt = self.theme_set.themes.get(&key).clo...
code_fim
hard
{ "lang": "rust", "repo": "spyder-ide/pysyntect", "path": "/src/base/theme.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: holtchesley/h2 path: /src/proto/peer.rs use codec::RecvError; use frame::{Headers, StreamId}; use std::fmt; /// Either a Client or a Server pub trait Peer { /// Message type sent into the transport type Send; /// Message type polled from the transport type Poll: fmt::Debug; <...
code_fim
hard
{ "lang": "rust", "repo": "holtchesley/h2", "path": "/src/proto/peer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn convert_poll_message(headers: Headers) -> Result<Self::Poll, RecvError>; fn is_local_init(id: StreamId) -> bool { assert!(!id.is_zero()); Self::is_server() == id.is_server_initiated() } }<|fim_prefix|>// repo: holtchesley/h2 path: /src/proto/peer.rs use codec::RecvError; u...
code_fim
medium
{ "lang": "rust", "repo": "holtchesley/h2", "path": "/src/proto/peer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn convert_send_message(id: StreamId, headers: Self::Send, end_of_stream: bool) -> Headers; fn convert_poll_message(headers: Headers) -> Result<Self::Poll, RecvError>; fn is_local_init(id: StreamId) -> bool { assert!(!id.is_zero()); Self::is_server() == id.is_server_initiate...
code_fim
medium
{ "lang": "rust", "repo": "holtchesley/h2", "path": "/src/proto/peer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yuteno/rust-RISC-V path: /src/cpu/mod.rs pub const REGISTERS_COUNT: usize = 32; pub mod cpu_main; pub mod execute; //pub mod exception; pub mod mode; <|fim_suffix|>#[derive(Debug, PartialEq, Eq, Copy, Clone)] pub enum Mode { User = 0b00, Supervisor = 0b01, Machine = 0b11, Debug,...
code_fim
medium
{ "lang": "rust", "repo": "yuteno/rust-RISC-V", "path": "/src/cpu/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(Debug, PartialEq, Eq, Copy, Clone)] pub enum Mode { User = 0b00, Supervisor = 0b01, Machine = 0b11, Debug, } pub struct Cpu { regs: [u64; REGISTERS_COUNT], pc: u64, mode: Mode, memory: Memory, state: State, }<|fim_prefix|>// repo: yuteno/rust-RISC-V path: /sr...
code_fim
medium
{ "lang": "rust", "repo": "yuteno/rust-RISC-V", "path": "/src/cpu/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub const CONTAINER_SCOPES: [(&str, &str, &str); 16] = [ ( "block", "meta.block.cfml punctuation.section.block.begin.cfml", "punctuation.section.block.end.cfml" ), ( "block", "meta.function.body.cfml punctuation.section.block.begin.cfml", "punctu...
code_fim
hard
{ "lang": "rust", "repo": "alejandrosuarez/cftokens", "path": "/src/scopes.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alejandrosuarez/cftokens path: /src/scopes.rs pub struct DelimitedScope<'a> { pub name: &'a str, pub start: &'a str, pub delimiter: &'a str, pub end: &'a str, } impl<'a> DelimitedScope<'a> { pub fn new( name: &'a str, start: &'a str, delimiter: &'a st...
code_fim
hard
{ "lang": "rust", "repo": "alejandrosuarez/cftokens", "path": "/src/scopes.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gabriel376/exercism path: /rust/matching-brackets/src/lib.rs pub fn brackets_are_balanced(string: &str) -> bool { let delimiters = "()[]{}"; let mut stack = Vec::new(); for char in string.chars() { <|fim_suffix|> _ => match stack.pop() { None => return...
code_fim
hard
{ "lang": "rust", "repo": "gabriel376/exercism", "path": "/rust/matching-brackets/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> true => (), false => return false, }, }, }, } } stack.is_empty() }<|fim_prefix|>// repo: gabriel376/exercism path: /rust/matching-brackets/src/lib.rs pub fn brackets_are_balanced(string: &str) -> bool { let deli...
code_fim
hard
{ "lang": "rust", "repo": "gabriel376/exercism", "path": "/rust/matching-brackets/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: galenelias/AdventOfCode_2020 path: /src/day8/mod.rs use itertools::Itertools; #[derive(Copy, Clone, Debug, PartialEq)] enum Op { Nop, Acc, Jmp, } #[derive(Copy, Clone, Debug)] struct Instruction { op: Op, arg: i32, } fn parse_instruction(line: &String) -> Instruction { let parts = line....
code_fim
hard
{ "lang": "rust", "repo": "galenelias/AdventOfCode_2020", "path": "/src/day8/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut run_instructions = vec![false; program.len()]; let mut pc = 0i32; let mut acc = 0i32; while (pc as usize) < program.len() { let instruction = program[pc as usize]; if run_instructions[pc as usize] { return RunResult { hung: true, acc }; } else { run_instructions[pc as ...
code_fim
hard
{ "lang": "rust", "repo": "galenelias/AdventOfCode_2020", "path": "/src/day8/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sebastiensavard/DiceTry path: /src/main.rs extern crate rand; use rand::distributions::{IndependentSample, Range}; fn dice_roll(sides: u8) -> u8 { <|fim_suffix|> fn main() { println!("Hello Sebastien!"); println!("your dice roll is:{}", dice_roll(20)); }<|fim_middle|>// return rand::ran...
code_fim
medium
{ "lang": "rust", "repo": "sebastiensavard/DiceTry", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn main() { println!("Hello Sebastien!"); println!("your dice roll is:{}", dice_roll(20)); }<|fim_prefix|>// repo: sebastiensavard/DiceTry path: /src/main.rs extern crate rand; use rand::distributions::{IndependentSample, Range}; <|fim_middle|>fn dice_roll(sides: u8) -> u8 { // return rand::ra...
code_fim
medium
{ "lang": "rust", "repo": "sebastiensavard/DiceTry", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: k-start/untitled_os path: /boot/src/main.rs use bootloader_locator::locate_bootloader; use std::env; use std::path::Path; use std::process::{Command, Stdio}; pub fn main() { let args: Vec<String> = env::args().collect(); let bootloader_manifest = locate_bootloader("bootloader").unwrap(...
code_fim
hard
{ "lang": "rust", "repo": "k-start/untitled_os", "path": "/boot/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut more_args = vec![ "-drive", "format=raw,file=fat32.img,bus=1", "-serial", "stdio", ]; qemu_args.append(&mut more_args); Command::new("qemu-system-x86_64") .args(qemu_args) .stdout(Stdio::inherit()) .stderr(Stdio::inherit()) ...
code_fim
hard
{ "lang": "rust", "repo": "k-start/untitled_os", "path": "/boot/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zatoichi-labs/substrate-api-client path: /primitives/src/extrinsic_params.rs use codec::{Decode, Encode}; use core::marker::PhantomData; use sp_core::H256; use sp_runtime::traits::Hash; use sp_runtime::{generic::Era, traits::BlakeTwo256}; use sp_std::prelude::*; /// Default SignedExtra. /// Sim...
code_fim
hard
{ "lang": "rust", "repo": "zatoichi-labs/substrate-api-client", "path": "/primitives/src/extrinsic_params.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl PlainTip { /// Create a new tip of the amount provided. pub fn new(amount: u128) -> Self { PlainTip { tip: amount } } } impl From<u128> for PlainTip { fn from(n: u128) -> Self { PlainTip::new(n) } } impl From<PlainTip> for u128 { fn from(tip: PlainTip) -> Sel...
code_fim
hard
{ "lang": "rust", "repo": "zatoichi-labs/substrate-api-client", "path": "/primitives/src/extrinsic_params.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aznhe21/waros path: /Kernel/memory/rust.rs use super::kcache; #[no_mangle] pub extern fn __rust_allocate(size: usize, align: usize) -> *mut u8 { kcache::manager().allocate(size, align) } #[no_mangle] pub extern fn __rust_deallocate(ptr: *mut u8, _old_size: usize, align: usize) { kcache...
code_fim
medium
{ "lang": "rust", "repo": "aznhe21/waros", "path": "/Kernel/memory/rust.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub extern fn __rust_usable_size(size: usize, align: usize) -> usize { kcache::manager().usable_size(size, align) }<|fim_prefix|>// repo: aznhe21/waros path: /Kernel/memory/rust.rs use super::kcache; #[no_mangle] pub extern fn __rust_allocate(size: usize, align: usize) -> *mut u8 { ...
code_fim
hard
{ "lang": "rust", "repo": "aznhe21/waros", "path": "/Kernel/memory/rust.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Divoolej/mapy-nageografiepl-be path: /web/src/config/initializers/mod.rs mod db_connection_pool; mod environment; mod logger; mod migrations; mod port; mod rollbar; <|fim_suffix|>pub fn run() -> Result<(String, DbPool), String> { environment::init(); logger::init()?; rollbar::init(); mi...
code_fim
easy
{ "lang": "rust", "repo": "Divoolej/mapy-nageografiepl-be", "path": "/web/src/config/initializers/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn run() -> Result<(String, DbPool), String> { environment::init(); logger::init()?; rollbar::init(); migrations::init()?; let db_pool = db_connection_pool::init()?; let port = port::init(); Ok((port, db_pool)) }<|fim_prefix|>// repo: Divoolej/mapy-nageografiepl-be path: /web/src/confi...
code_fim
easy
{ "lang": "rust", "repo": "Divoolej/mapy-nageografiepl-be", "path": "/web/src/config/initializers/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn whoami() -> anyhow::Result<()> { let username = util::get_username()?.context("(not logged in)")?; println!("{username}"); Ok(()) }<|fim_prefix|>// repo: wasmerio/wapm-cli path: /src/commands/whoami.rs use anyhow::Context; <|fim_middle|>use crate::util;
code_fim
easy
{ "lang": "rust", "repo": "wasmerio/wapm-cli", "path": "/src/commands/whoami.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wasmerio/wapm-cli path: /src/commands/whoami.rs use anyhow::Context; <|fim_suffix|>pub fn whoami() -> anyhow::Result<()> { let username = util::get_username()?.context("(not logged in)")?; println!("{username}"); Ok(()) }<|fim_middle|>use crate::util;
code_fim
easy
{ "lang": "rust", "repo": "wasmerio/wapm-cli", "path": "/src/commands/whoami.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(not(feature = "no_function"))] assert!(matches!( *engine .run_with_scope( &mut scope, " fn foo(a, b, c, d, e, f) { 42 } foo(0, 0, 0, 0, 0, 0); ...
code_fim
hard
{ "lang": "rust", "repo": "schungx/rhai", "path": "/tests/var_scope.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( engine .eval_with_scope::<INT>(&mut scope, "chameleon") .unwrap(), 1 ); assert!( matches!(*engine.eval_with_scope::<INT>(&mut scope, "DO_NOT_USE").unwrap_err(), EvalAltResult::ErrorVariableNotFound(n, ..) if n == "DO_NOT_USE")...
code_fim
hard
{ "lang": "rust", "repo": "schungx/rhai", "path": "/tests/var_scope.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: schungx/rhai path: /tests/var_scope.rs use rhai::{Dynamic, Engine, EvalAltResult, Module, ParseErrorType, Position, Scope, INT}; #[test] fn test_var_scope() { let engine = Engine::new(); let mut scope = Scope::new(); engine.run_with_scope(&mut scope, "let x = 4 + 5").unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "schungx/rhai", "path": "/tests/var_scope.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>t HOTPINK4 : (u8,u8,u8) = (139, 58, 98); pub const PINK1 : (u8,u8,u8) = (255, 181, 197); pub const PINK2 : (u8,u8,u8) = (238, 169, 184); pub const PINK3 : (u8,u8,u8) = (205, 145, 158); pub const PINK4 : (u8,u8,u8) = (139, 99, 108); pub const LIGHTPINK1 : (u8,u8,u8) = (255, 174, 185); pub const LIGHTPINK2 ...
code_fim
hard
{ "lang": "rust", "repo": "dns2utf8/rltk_rs", "path": "/src/color.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dns2utf8/rltk_rs path: /src/color.rs ub r : f32, pub g : f32, pub b : f32 } #[derive(PartialEq, Copy, Clone)] /// Represents an H/S/V triplet, in the range 0..1 (32-bit float) pub struct HSV { pub h : f32, pub s : f32, pub v : f32 } #[derive(Debug, PartialEq, Copy, Clone)]...
code_fim
hard
{ "lang": "rust", "repo": "dns2utf8/rltk_rs", "path": "/src/color.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dns2utf8/rltk_rs path: /src/color.rs 8,u8,u8) = (176, 48, 96); pub const WEB_MAROON : (u8,u8,u8) = (128, 0, 0); pub const WEBMAROON : (u8,u8,u8) = (128, 0, 0); pub const MEDIUM_VIOLET : (u8,u8,u8) = (199, 21, 133); pub const MEDIUMVIOLETRED : (u8,u8,u8) = (199, 21, 133); pub const VIOLET_RED : (...
code_fim
hard
{ "lang": "rust", "repo": "dns2utf8/rltk_rs", "path": "/src/color.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>async fn index() -> Index { Index {} }<|fim_prefix|>// repo: str4d/mostly-harmless path: /str4d.fly.dev/src/sssh.rs use askama::Template; use axum::{routing::get, Router}; pub(crate) fn build() -> Router { Router::new().route("/", get(index)) } <|fim_middle|>#[derive(Clone, Template)] #[templat...
code_fim
medium
{ "lang": "rust", "repo": "str4d/mostly-harmless", "path": "/str4d.fly.dev/src/sssh.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: str4d/mostly-harmless path: /str4d.fly.dev/src/sssh.rs use askama::Template; use axum::{routing::get, Router}; pub(crate) fn build() -> Router { Router::new().route("/", get(index)) } <|fim_suffix|>async fn index() -> Index { Index {} }<|fim_middle|>#[derive(Clone, Template)] #[templat...
code_fim
medium
{ "lang": "rust", "repo": "str4d/mostly-harmless", "path": "/str4d.fly.dev/src/sssh.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: denbeigh2000/rusty-interaction path: /src/types/interaction.rs // Return without any data. Use with caution pub fn none(mut self) -> Result<InteractionResponse, std::convert::Infallible> { self.r#type = InteractionResponseType::None; self.data = None; self.finish() ...
code_fim
hard
{ "lang": "rust", "repo": "denbeigh2000/rusty-interaction", "path": "/src/types/interaction.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>impl InteractionResponse { /// Creates a new InteractionResponse pub fn new( rtype: InteractionResponseType, data: Option<InteractionApplicationCommandCallbackData>, ) -> InteractionResponse { InteractionResponse { r#type: rtype, data, } ...
code_fim
hard
{ "lang": "rust", "repo": "denbeigh2000/rusty-interaction", "path": "/src/types/interaction.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> /// Respond to an Interaction /// /// This returns an [`InteractionResponseBuilder`] which you can use to build an [`InteractionResponse`] /// /// # Example /// ```ignore /// let response = ctx.respond() /// .content("Example message") /// ...
code_fim
hard
{ "lang": "rust", "repo": "denbeigh2000/rusty-interaction", "path": "/src/types/interaction.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }