text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>features! { // Vulkan 1.0 {robust_buffer_access => vulkan_1_0.features.robust_buffer_access}, {full_draw_index_uint32 => vulkan_1_0.features.full_draw_index_uint32}, {image_cube_array => vulkan_1_0.features.image_cube_array}, {independent_blend => vulkan_1_0.features.independent_blend}...
code_fim
hard
{ "lang": "rust", "repo": "i509VCB/vulkano", "path": "/vulkano/src/device/features.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Manishearth/compiletest-rs path: /test-project/tests/run-pass/vec-slice-drop.rs // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 ...
code_fim
medium
{ "lang": "rust", "repo": "Manishearth/compiletest-rs", "path": "/test-project/tests/run-pass/vec-slice-drop.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn foo(x: &Cell<isize>) -> foo { foo { x: x } } pub fn main() { let x = &Cell::new(0); { let l = &[foo(x)]; assert_eq!(l[0].x.get(), 0); } assert_eq!(x.get(), 1); }<|fim_prefix|>// repo: Manishearth/compiletest-rs path: /test-project/tests/run-pass/vec-sli...
code_fim
medium
{ "lang": "rust", "repo": "Manishearth/compiletest-rs", "path": "/test-project/tests/run-pass/vec-slice-drop.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>: PhantomData , } } ; ( "address" ) => { $ crate :: atom :: tests :: TestAtom { unsafe_data : 0x700000002u64 , phantom : :: std :: marker :: PhantomData , } } ; ( "head" ) => { $ crate :: atom :: tests :: TestAtom { unsafe_data : 0x800000002u64 , phantom : :: std :: marker :: PhantomData , } } ; ( "b" ) =...
code_fim
hard
{ "lang": "rust", "repo": "yochidros/example_scraper", "path": "/rls/debug/build/string_cache-5ecfd9baa3bfedab/out/test_atom.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yochidros/example_scraper path: /rls/debug/build/string_cache-5ecfd9baa3bfedab/out/test_atom.rs pub type TestAtom = :: string_cache :: Atom < TestAtomStaticSet > ; pub struct TestAtomStaticSet ; impl :: string_cache :: StaticAtomSet for TestAtomStaticSet { fn get ( ) -> & 'static :: string_cache...
code_fim
hard
{ "lang": "rust", "repo": "yochidros/example_scraper", "path": "/rls/debug/build/string_cache-5ecfd9baa3bfedab/out/test_atom.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ChristophWurst/gotham-middleware-tokio path: /src/lib.rs extern crate gotham; #[macro_use] extern crate gotham_derive; extern crate tokio_core; use std::io; use std::panic::AssertUnwindSafe; use gotham::handler::HandlerFuture; use gotham::middleware::{Middleware, NewMiddleware}; use gotham::st...
code_fim
hard
{ "lang": "rust", "repo": "ChristophWurst/gotham-middleware-tokio", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> chain(state) } } impl NewMiddleware for TokioMiddleware { type Instance = TokioMiddleware; fn new_middleware(&self) -> io::Result<Self::Instance> { Ok(TokioMiddleware { handle: AssertUnwindSafe(self.handle.clone()), }) } } #[derive(StateData)] pub str...
code_fim
hard
{ "lang": "rust", "repo": "ChristophWurst/gotham-middleware-tokio", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: belltoy/rust-rtmp path: /src/messages/types/acknowledgement.rs use std::io::Cursor; use byteorder::{BigEndian, WriteBytesExt, ReadBytesExt}; use bytes::Bytes; use ::messages::{MessageDeserializationError, MessageSerializationError}; use ::messages::{RtmpMessage}; pub fn serialize(sequence_numb...
code_fim
hard
{ "lang": "rust", "repo": "belltoy/rust-rtmp", "path": "/src/messages/types/acknowledgement.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(RtmpMessage::Acknowledgement { sequence_number: cursor.read_u32::<BigEndian>()? }) } #[cfg(test)] mod tests { use super::{serialize, deserialize}; use std::io::Cursor; use byteorder::{BigEndian, WriteBytesExt}; use bytes::Bytes; use ::messages::{RtmpMessage}; ...
code_fim
hard
{ "lang": "rust", "repo": "belltoy/rust-rtmp", "path": "/src/messages/types/acknowledgement.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(&cursor.into_inner()[..], &result[..]); } #[test] fn can_deserialize_message() { let number = 532; let mut cursor = Cursor::new(Vec::new()); cursor.write_u32::<BigEndian>(number).unwrap(); let bytes = Bytes::from(cursor.into_inner()); ...
code_fim
hard
{ "lang": "rust", "repo": "belltoy/rust-rtmp", "path": "/src/messages/types/acknowledgement.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: patrickelectric/rest-settings-service path: /src/settings.rs use std::collections::HashMap; use std::fs::File; use std::io::prelude::*; use std::path::{Path, PathBuf}; use chrono; use hex; use serde::{Deserialize, Serialize}; use serde_json::json; use sha1::{Digest, Sha1}; use toml; #[derive(S...
code_fim
hard
{ "lang": "rust", "repo": "patrickelectric/rest-settings-service", "path": "/src/settings.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("Test safe.."); save(); println!("Test load.."); load(); } fn save() { let mut settings_manager = SettingsManager::new(Some(create_path())); settings_manager.settings = serde_json::Map::new(); println!("Check settings path: {}", se...
code_fim
hard
{ "lang": "rust", "repo": "patrickelectric/rest-settings-service", "path": "/src/settings.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // By default, we only create the default settings file if it does not exist yet if !default_file_name.exists() { let mut default_file = File::create(default_file_name).unwrap_or_else(|error| { panic!("Failed to create default file: {:#?}", error...
code_fim
hard
{ "lang": "rust", "repo": "patrickelectric/rest-settings-service", "path": "/src/settings.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lucab/lockfile-rs path: /src/lib.rs //! This crate provides a lockfile struct that marks a location in the filesystem as locked. //! //! A lock is conceptually created when the file is created, and released when it is deleted. //! //! If the file is already present, the `create` function will fa...
code_fim
hard
{ "lang": "rust", "repo": "lucab/lockfile-rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(unix)] pub trait LockfileUnixExt { fn create_at(dirfd: RawFd, path: impl AsRef<Path>) -> Result<Lockfile, io::Error>; } #[cfg(unix)] impl LockfileUnixExt for Lockfile { fn create_at(dirfd: RawFd, path: impl AsRef<Path>) -> Result<Lockfile, io::Error> { let dir = unsafe { openat::Dir...
code_fim
hard
{ "lang": "rust", "repo": "lucab/lockfile-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let klass = class.as_mut(); klass.edited = Some(cell_renderer_text_edited::<T>); } } unsafe extern "C" fn cell_renderer_text_edited<T: CellRendererTextImpl>( ptr: *mut ffi::GtkCellRendererText, path: *const libc::c_char, new_text: *const libc::c_char, ) { let instance ...
code_fim
hard
{ "lang": "rust", "repo": "zecakeh/gtk4-rs", "path": "/gtk4/src/subclass/cell_renderer_text.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>unsafe impl<T: CellRendererTextImpl> IsSubclassable<T> for CellRendererText { fn class_init(class: &mut ::glib::Class<Self>) { Self::parent_class_init::<T>(class); let klass = class.as_mut(); klass.edited = Some(cell_renderer_text_edited::<T>); } } unsafe extern "C" fn ce...
code_fim
hard
{ "lang": "rust", "repo": "zecakeh/gtk4-rs", "path": "/gtk4/src/subclass/cell_renderer_text.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zecakeh/gtk4-rs path: /gtk4/src/subclass/cell_renderer_text.rs // Take a look at the license at the top of the repository in the LICENSE file. // rustdoc-stripper-ignore-next //! Traits intended for subclassing [`CellRendererText`](crate::CellRendererText). use crate::subclass::prelude::*; use...
code_fim
medium
{ "lang": "rust", "repo": "zecakeh/gtk4-rs", "path": "/gtk4/src/subclass/cell_renderer_text.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // A thread listening for exit signal from master to end the whole slave process pub fn exit_signal(&self) { let listener = match TcpListener::bind(format!("0.0.0.0:{}", self.port + 10,)) { Ok(s) => { log::debug!( "created end signal server i...
code_fim
hard
{ "lang": "rust", "repo": "return02/native_spark", "path": "/src/executor.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: return02/native_spark path: /src/executor.rs use crate::serialized_data_capnp::serialized_data; use crate::task::TaskOption; use capnp::serialize_packed; use log::info; use std::net::TcpListener; use std::thread; use std::time::Instant; use threadpool::ThreadPool; pub struct Executor { port...
code_fim
hard
{ "lang": "rust", "repo": "return02/native_spark", "path": "/src/executor.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub struct Ray { pub origin: Point, pub direction: Vector3D, } impl Ray { pub fn prime_ray_on_sensor(x: u32, y: u32, scene: &Scene) -> Ray { // Geometry correction for sensor origin coordinate // linear scale to -1. ~ 1. let fov_adjus...
code_fim
hard
{ "lang": "rust", "repo": "posutsai/ray_tracer", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: posutsai/ray_tracer path: /src/lib.rs extern crate image; pub mod utils { use image::{Pixel, GenericImage}; #[derive(Clone)] pub struct Vector3D { pub x: f64, pub y: f64, pub z: f64, } impl Vector3D { fn a2b_vec(a: &Point, b: &Point) -> Vector...
code_fim
hard
{ "lang": "rust", "repo": "posutsai/ray_tracer", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> log::info!("Checking for listen socket from systemd or systemfd"); let mut listenfd = ListenFd::from_env(); server = if let Ok(Some(l)) = listenfd.take_tcp_listener(0) { log::info!("Got one! Using system listener: {:#?}", &l); server.listen(l) } else { let bindip: &...
code_fim
hard
{ "lang": "rust", "repo": "ludumipsum/turbobunny-example", "path": "/src/service_base.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ludumipsum/turbobunny-example path: /src/service_base.rs use clap::{AppSettings, Arg}; use listenfd::ListenFd; const DEFAULT_PORT: i64 = 8080; #[macro_export] macro_rules! gen_service_metadata_functions { () => ( fn get_name(&self) -> &str { env!("CARGO_PKG_NAME") } fn get_...
code_fim
hard
{ "lang": "rust", "repo": "ludumipsum/turbobunny-example", "path": "/src/service_base.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut cur_link = self.pop_node(); while let Link::More(mut boxed_node) = cur_link { cur_link = mem::replace(&mut boxed_node.next, Link::Empty); } } } #[cfg(test)] mod test { use super::*; #[test] fn push_and_pop() { struct Test { n...
code_fim
hard
{ "lang": "rust", "repo": "keithnoguchi/books-rs", "path": "/list/src/first.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: keithnoguchi/books-rs path: /list/src/first.rs // SPDX-License-Identifier: GPL-2.0 use std::mem; pub struct List { head: Link, } enum Link { Empty, More(Box<Node>), } struct Node { elem: i32, next: Link, } impl List { #[allow(dead_code)] pub fn new() -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "keithnoguchi/books-rs", "path": "/list/src/first.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> struct Test { name: &'static str, data: Vec<i32>, want: Vec<Option<i32>>, } let tests = [ Test { name: "single pop from the empty stack", data: vec![], want: vec![None], }, ...
code_fim
hard
{ "lang": "rust", "repo": "keithnoguchi/books-rs", "path": "/list/src/first.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dtcristo/exercism path: /rust/luhn-from/src/lib.rs pub struct Luhn { input: String, } impl Luhn { pub fn is_valid(&self) -> bool { let mut sum = 0u64; let mut digit_count = 0u64; let mut double = false; for ch in self.input.chars().rev() { mat...
code_fim
hard
{ "lang": "rust", "repo": "dtcristo/exercism", "path": "/rust/luhn-from/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>turn false; } } } } (digit_count > 1) && (sum % 10 == 0) } } impl<T: ToString> From<T> for Luhn { fn from(to_stringable: T) -> Luhn { Luhn { input: to_stringable.to_string() } } }<|fim_prefix|>// repo: dtcristo/exercism ...
code_fim
hard
{ "lang": "rust", "repo": "dtcristo/exercism", "path": "/rust/luhn-from/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match variant { IERW_A::_0 => false, IERW_A::_1 => true, } } } #[doc = "Reader of field `IERW`"] pub type IERW_R = crate::R<bool, IERW_A>; impl IERW_R { #[doc = r"Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> IERW_A { ...
code_fim
hard
{ "lang": "rust", "repo": "thorhs/mk66f18", "path": "/src/rtc/war.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thorhs/mk66f18 path: /src/rtc/war.rs lf, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3); self.w } } #[doc = "Control Register Write\n\nValue on reset: 1"] #[derive(Clone, Copy, Debug, PartialEq)] pub enum CRW_A { #[...
code_fim
hard
{ "lang": "rust", "repo": "thorhs/mk66f18", "path": "/src/rtc/war.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/async-await/non-trivial-drop.rs // revisions: no_drop_tracking drop_tracking drop_tracking_mir // [drop_tracking] compile-flags: -Zdrop-tracking // [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // build-pass // edition:2018 <|fim_suffix|>} #[derive(Defau...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/async-await/non-trivial-drop.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Default)] struct NonCopy2; impl Drop for NonCopy2 { fn drop(&mut self) {} } #[derive(Default)] struct Config { nickname: NonCopy, b: NonCopy2, }<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/async-await/non-trivial-drop.rs // revisions: no_drop_tracking drop_tracking drop_tra...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/async-await/non-trivial-drop.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: realbigsean/lighthouse path: /common/task_executor/src/lib.rs mod metrics; use futures::channel::mpsc::Sender; use futures::prelude::*; use slog::{crit, debug, o, trace}; use std::sync::Weak; use tokio::runtime::Runtime; /// Provides a reason when Lighthouse is shut down. #[derive(Copy, Clone,...
code_fim
hard
{ "lang": "rust", "repo": "realbigsean/lighthouse", "path": "/common/task_executor/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Spawn a blocking task on a dedicated tokio thread pool wrapped in an exit future. /// This function generates prometheus metrics on number of tasks and task duration. pub fn spawn_blocking<F>(&self, task: F, name: &'static str) where F: FnOnce() + Send + 'static, { ...
code_fim
hard
{ "lang": "rust", "repo": "realbigsean/lighthouse", "path": "/common/task_executor/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wolovim/trin path: /src/main.rs #[macro_use] extern crate lazy_static; use std::env; mod cli; use cli::TrinConfig; mod jsonrpc; use jsonrpc::launch_trin; fn main() { let trin_config = TrinConfig::new(); <|fim_suffix|> launch_trin(trin_config, infura_project_id); }<|fim_middle|> let ...
code_fim
hard
{ "lang": "rust", "repo": "wolovim/trin", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> launch_trin(trin_config, infura_project_id); }<|fim_prefix|>// repo: wolovim/trin path: /src/main.rs #[macro_use] extern crate lazy_static; use std::env; mod cli; use cli::TrinConfig; mod jsonrpc; use jsonrpc::launch_trin; fn main() { <|fim_middle|> let trin_config = TrinConfig::new(); let ...
code_fim
hard
{ "lang": "rust", "repo": "wolovim/trin", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: carsonmyers/aglet path: /aglet-regex/src/tokenize/mod.rs pub mod error; mod pretty; mod state; pub mod token; pub mod tokenizer; pub use error::{Error, ErrorKind, Result}; pub use token::{Token, TokenKind}; pub use tokenizer::Tokenizer; #[cfg(test)] pub(crate) fn assert_tokens(mut tr: Tokenize...
code_fim
hard
{ "lang": "rust", "repo": "carsonmyers/aglet", "path": "/aglet-regex/src/tokenize/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] pub(crate) use assert_next_err; #[cfg(test)] pub(crate) use assert_next_none; #[cfg(test)] pub(crate) use assert_next_tok;<|fim_prefix|>// repo: carsonmyers/aglet path: /aglet-regex/src/tokenize/mod.rs pub mod error; mod pretty; mod state; pub mod token; pub mod tokenizer; pub use error::{E...
code_fim
hard
{ "lang": "rust", "repo": "carsonmyers/aglet", "path": "/aglet-regex/src/tokenize/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] macro_rules! assert_next_err { ( $tokenizer:expr , $kind:pat ) => { assert!(matches!( $tokenizer.next(), Some(Err(Error { kind: $kind, .. })) )); }; } #[cfg(test)] macro_rules! assert_next_none { ( $tokenizer:expr ) => { assert!(mat...
code_fim
hard
{ "lang": "rust", "repo": "carsonmyers/aglet", "path": "/aglet-regex/src/tokenize/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>h computing software, which allows you to focus on analyzing results and solving problems. AWS Batch reduces operational complexities, saves time, and reduces costs, which makes it easy for developers, scientists, and engineers to run their batch jobs in the AWS Cloud.</p> //! //! If you're using the serv...
code_fim
hard
{ "lang": "rust", "repo": "MaterializeInc/rusoto", "path": "/rusoto/services/batch/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MaterializeInc/rusoto path: /rusoto/services/batch/src/lib.rs // ================================================================= // // * WARNING * // // This file is generated! // // Changes made to this file will be overwritten. If changes are // ...
code_fim
hard
{ "lang": "rust", "repo": "MaterializeInc/rusoto", "path": "/rusoto/services/batch/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> context: &mut common::SpdmContext, r: &mut Reader, ) -> Option<SpdmMeasurementsResponsePayload> { let number_of_measurement = u8::read(r)?; // param1 let slot_id = u8::read(r)?; // param2 let measurement_record = SpdmMeasurementRecordStructure::spdm_read(context...
code_fim
hard
{ "lang": "rust", "repo": "andrewjstone/rust-spdm", "path": "/spdmlib/src/cmds/measurement.rs", "mode": "spm", "license": "BSD-2-Clause-Patent", "source": "the-stack-v2" }
<|fim_suffix|> value.spdm_encode(&mut context, &mut writer); let mut reader = Reader::init(u8_slice); assert_eq!(48, reader.left()); let get_measurements = SpdmGetMeasurementsRequestPayload::spdm_read(&mut context, &mut reader).unwrap(); assert_eq!( get_mea...
code_fim
hard
{ "lang": "rust", "repo": "andrewjstone/rust-spdm", "path": "/spdmlib/src/cmds/measurement.rs", "mode": "spm", "license": "BSD-2-Clause-Patent", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andrewjstone/rust-spdm path: /spdmlib/src/cmds/measurement.rs // Copyright (c) 2020 Intel Corporation // // SPDX-License-Identifier: BSD-2-Clause-Patent use crate::common; use crate::msgs::SpdmCodec; use crate::msgs::{ SpdmMeasurementRecordStructure, SpdmNonceStruct, SpdmOpaqueStruct, SpdmS...
code_fim
hard
{ "lang": "rust", "repo": "andrewjstone/rust-spdm", "path": "/spdmlib/src/cmds/measurement.rs", "mode": "psm", "license": "BSD-2-Clause-Patent", "source": "the-stack-v2" }
<|fim_suffix|> match &op.action { OpType::MarkBegin(_, data) if op.id == self.id => { if !op.succ.is_empty() { return QueryResult::Finish; } self.found = true; self.mark_name = data.name.clone(); // re...
code_fim
hard
{ "lang": "rust", "repo": "automerge/automerge", "path": "/rust/automerge/src/query/seek_mark.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: automerge/automerge path: /rust/automerge/src/query/seek_mark.rs use crate::marks::Mark; use crate::op_tree::OpSetMetadata; use crate::query::{ListState, OpTreeNode, QueryResult, TreeQuery}; use crate::types::{ListEncoding, Op, OpId, OpType}; use std::cmp::Ordering; use std::collections::HashMap...
code_fim
hard
{ "lang": "rust", "repo": "automerge/automerge", "path": "/rust/automerge/src/query/seek_mark.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jsperafico/rust_project_invaders path: /src/main.rs use std::{error::Error, sync::mpsc, thread, time::{Duration, Instant}}; use rust_project_invaders::{frame::{self, Drawable, new_frame}, invaders::Invaders, player::Player, render}; use rusty_audio::Audio; use std::io; use std::io::Stdout; use c...
code_fim
hard
{ "lang": "rust", "repo": "jsperafico/rust_project_invaders", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // player.draw(&mut curr_frame); // invaders.draw(&mut curr_frame); let drawables: Vec<&dyn Drawable> = vec![&player, &invaders]; for drawable in drawables { drawable.draw(&mut curr_frame); } let _ = render_sender.send(curr_frame); threa...
code_fim
hard
{ "lang": "rust", "repo": "jsperafico/rust_project_invaders", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/settings/storage/src/device_storage.rs m.next().await.unwrap() { Ok(StoreAccessorRequest::SetValue { key, val, control_handle: _ }) => { assert_eq!(key, STORE_KEY); if let Value::Stringval(string_value) = val { ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/settings/storage/src/device_storage.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let written_value = VALUE2; let mut executor = TestExecutor::new_with_fake_time().expect("Failed to create executor"); let (stash_proxy, mut stash_stream) = fidl::endpoints::create_proxy_and_stream::<StoreAccessorMarker>().unwrap(); let storage = DeviceStorage...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/settings/storage/src/device_storage.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> format!("{}_{}", SETTINGS_PREFIX, input_string) } #[cfg(test)] mod tests { use super::*; use crate::stash_logger::StashInspectLoggerHandle; use assert_matches::assert_matches; use fidl_fuchsia_stash::{ FlushError, StoreAccessorMarker, StoreAccessorRequest, StoreAccessorRequest...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/settings/storage/src/device_storage.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> parser.parse(tokens) } /// Parse the given [`proc-macro2::TokenStream`] into a [`Node`] tree /// /// [`proc-macro2::TokenStream`]: https://docs.rs/proc-macro2/latest/proc_macro2/struct.TokenStream.html /// [`Node`]: struct.Node.html pub fn parse2(tokens: proc_macro2::TokenStream) -> Result<Vec<Node>>...
code_fim
hard
{ "lang": "rust", "repo": "forkkit/syn-rsx", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: forkkit/syn-rsx path: /src/lib.rs //! [`syn`]-powered parser for JSX-like [`TokenStream`]s, aka RSX. The parsed result is a //! nested [`Node`] structure, similar to the browser DOM, where node name and //! value are syn expressions to support building proc macros. //! //! ```rust //! use quote:...
code_fim
hard
{ "lang": "rust", "repo": "forkkit/syn-rsx", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mod node; mod parser; pub mod punctuation { //! Custom syn punctuations use syn::custom_punctuation; custom_punctuation!(Dash, -); } pub use node::{Node, NodeName, NodeType}; pub use parser::{Parser, ParserConfig}; /// Parse the given [`proc-macro::TokenStream`] into a [`Node`] tree /// //...
code_fim
hard
{ "lang": "rust", "repo": "forkkit/syn-rsx", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let to = self.transition(from, c); if to < self.nodes.len() && self.nodes[to].check == from { Some(to) } else { None } } fn transition(&self, from: NodeIdx, c: u8) -> NodeIdx { add_offset(self.nodes[from].base, c) } } #[cfg(test...
code_fim
hard
{ "lang": "rust", "repo": "yuichiro-s/rust-double-array-trie", "path": "/src/static_trie.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yuichiro-s/rust-double-array-trie path: /src/static_trie.rs extern crate failure; extern crate bincode; use bincode::{deserialize_from, serialize}; use serde::de::{DeserializeOwned}; use serde::ser::Serialize; extern crate snap; use std::fs::File; use std::io::{BufWriter, BufReader, Write}; ...
code_fim
hard
{ "lang": "rust", "repo": "yuichiro-s/rust-double-array-trie", "path": "/src/static_trie.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let entries = map.iter().map(|(k, &v)| (k.clone(), v)).collect::<Vec<_>>(); let trie = Trie::new(&entries); (trie, map) } #[test] fn test_100k() { let (trie, map) = generate_trie(100000); for (k, &v) in map.iter() { assert_eq!(trie.get(k), ...
code_fim
hard
{ "lang": "rust", "repo": "yuichiro-s/rust-double-array-trie", "path": "/src/static_trie.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0357_count_numbers_with_unique_digits/mod.rs pub mod mathematical; pub mod precomputed; pub trait Solution { fn count_numbers_with_unique_digits(n: i32) -> i32; <|fim_suffix|> pub fn run<S: Solution>() { let test_cases = [ (0, 1), ...
code_fim
medium
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_0357_count_numbers_with_unique_digits/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn run<S: Solution>() { let test_cases = [ (0, 1), (1, 10), (2, 91), (3, 739), (4, 5275), (5, 32491), (6, 168_571), (7, 712_891), (8, 2_345_851), ]; for (n, expected...
code_fim
medium
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_0357_count_numbers_with_unique_digits/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kettle11/kcolor path: /kcolor/src/tests.rs use crate::white_points::*; use crate::*; fn approx_equal_f64(a: f64, b: f64) -> bool { (a - b).abs() < 0.00001 } fn approx_equal(a: (f64, f64, f64, f64), b: (f64, f64, f64, f64)) -> bool { approx_equal_f64(a.0, b.0) && approx_equal_f6...
code_fim
hard
{ "lang": "rust", "repo": "kettle11/kcolor", "path": "/kcolor/src/tests.rs", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|>/// Tests chromatic adaptation /// Chromatic adaptation finds XYZ values that are perceptually /// similar to different XYZ values under another white point. #[test] fn chromatic_adaptation() { let chromatic_adaptation = ChromaticAdaptation::new(D65_WHITE_POINT_2DEGREES, D50_WHITE_POINT_2DEGRE...
code_fim
hard
{ "lang": "rust", "repo": "kettle11/kcolor", "path": "/kcolor/src/tests.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { if context.game == std::ptr::null_mut() { panic!("GameScreen is null"); } else { extend_lifetime(R(&mut (*context.game))).0 } } } pub fn set_screen<T: screen::Screen>(screen: T) where T: Sized+'static { let context = get_context(); context.screen = Some(Box::new(...
code_fim
hard
{ "lang": "rust", "repo": "tzizi/opensrme", "path": "/src/sr2/src/globals.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tzizi/opensrme path: /src/sr2/src/globals.rs use super::*; use opensrme_common::*; use std::collections::HashMap; pub struct Context { pub running: bool, pub archive: Box<Archive>, pub platform: Box<Platform>, pub realtime: Time, pub time: Time, pub delta: Time, pub data: DataCont...
code_fim
hard
{ "lang": "rust", "repo": "tzizi/opensrme", "path": "/src/sr2/src/globals.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> context.screen = Some(Box::new(screen)); context.game = std::ptr::null_mut(); } pub fn set_game(screen: screen::GameScreen) { let context = get_context(); let mut our_box = Box::new(screen); context.game = &mut (*our_box) as *mut screen::GameScreen; context.screen = Some(our_box); }<|fim_pre...
code_fim
hard
{ "lang": "rust", "repo": "tzizi/opensrme", "path": "/src/sr2/src/globals.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// The `OptimizerPassState` implementation. impl OptimizerPassState { /// Tests if reading `n` more characters is possible. fn can_advance(&self, n: usize) -> bool { self.pos + n < self.size } /// Peeks at the 'n'-th instruction relative to `self.pos`. fn peek_at(&self, optim...
code_fim
hard
{ "lang": "rust", "repo": "SplittyDev/neoqo", "path": "/src/optimizer/optimizer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut incs = 0; let mut decs = 0; let fst = state.peek_at(self, 0).unwrap(); while state.can_advance(0) { let current = state.peek_at(self, 0); match current { Some(val) => { match val.opcode { ...
code_fim
hard
{ "lang": "rust", "repo": "SplittyDev/neoqo", "path": "/src/optimizer/optimizer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SplittyDev/neoqo path: /src/optimizer/optimizer.rs use vm::instruction::Instruction; use vm::opcodes::Opcode; use optimizer::OPTIMIZED_VALUE; /// The `OptimizerPass` type. #[derive(Copy, Clone)] pub enum OptimizerPass { /// Clear-loop optimization pass. /// /// Creates a single `Opc...
code_fim
hard
{ "lang": "rust", "repo": "SplittyDev/neoqo", "path": "/src/optimizer/optimizer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ivfranco/notes path: /network/application/web-proxy/src/cache.rs //! In-memory cache of HTTP response bodies.\ //! WIP, not yet integrated into the proxy server. use crate::GMTDateTime; use std::collections::HashMap; /// An entry in the HTTP cache. pub struct CacheEntry { /// Last-Modified...
code_fim
hard
{ "lang": "rust", "repo": "ivfranco/notes", "path": "/network/application/web-proxy/src/cache.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> /// Retrieve or invalidate an cache entry based on the Last-Modified: header from server. pub fn get_or_invalidate( &mut self, host: &str, path: &str, last_modified: &GMTDateTime, ) -> Option<&CacheEntry> { let key = construct_key(host, path); le...
code_fim
hard
{ "lang": "rust", "repo": "ivfranco/notes", "path": "/network/application/web-proxy/src/cache.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> todo!() // self.expr.eval() } }<|fim_prefix|>// repo: oberblastmeister/monkey path: /crates/monkey-lang/src/evaluating/eval/stmt_expr.rs pub use crate::{ast, Eval, EvalResult, Value}; <|fim_middle|>impl Eval for ast::StmtExpr { fn eval(self) -> EvalResult<Value> {
code_fim
medium
{ "lang": "rust", "repo": "oberblastmeister/monkey", "path": "/crates/monkey-lang/src/evaluating/eval/stmt_expr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oberblastmeister/monkey path: /crates/monkey-lang/src/evaluating/eval/stmt_expr.rs pub use crate::{ast, Eval, EvalResult, Value}; <|fim_suffix|> todo!() // self.expr.eval() } }<|fim_middle|>impl Eval for ast::StmtExpr { fn eval(self) -> EvalResult<Value> {
code_fim
medium
{ "lang": "rust", "repo": "oberblastmeister/monkey", "path": "/crates/monkey-lang/src/evaluating/eval/stmt_expr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doytsujin/dns-message-parser path: /src/decode/rr/rfc_7553.rs use super::Header; use crate::decode::Decoder; use crate::rr::URI; use crate::DecodeResult; use std::str::from_utf8; impl<'a, 'b: 'a> Decoder<'a, 'b> { pub<|fim_suffix|>header.domain_name, ttl: header.ttl, ...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/dns-message-parser", "path": "/src/decode/rr/rfc_7553.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>header.domain_name, ttl: header.ttl, class, priority, weight, uri, }; Ok(uri) } }<|fim_prefix|>// repo: doytsujin/dns-message-parser path: /src/decode/rr/rfc_7553.rs use super::Header; use crate::decode::Decoder; use crate::r...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/dns-message-parser", "path": "/src/decode/rr/rfc_7553.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>// pub mod r101; #[cfg(feature = "release-1-2")] pub mod r102; // pub mod r103; // pub mod r104; // pub mod r105; // pub mod r106; // pub mod r107; // pub mod r108; // pub mod r109; // pub mod r110; // pub mod r111; // pub mod r112;<|fim_prefix|>// repo: Niedzwiedzw/minecraftrs path: /mc/worldgen/src/gen...
code_fim
easy
{ "lang": "rust", "repo": "Niedzwiedzw/minecraftrs", "path": "/mc/worldgen/src/gen/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Niedzwiedzw/minecraftrs path: /mc/worldgen/src/gen/mod.rs //! //! Naming convention for generators modules: //! //! `"gen" + <major_version> + <minor_version>` with `minor_version` being padded to 2 digits. //! <|fim_suffix|>// pub mod r101; #[cfg(feature = "release-1-2")] pub mod r102; // pub ...
code_fim
easy
{ "lang": "rust", "repo": "Niedzwiedzw/minecraftrs", "path": "/mc/worldgen/src/gen/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialicons/social/icon_fireplace.rs pub struct IconFireplace { props: crate::Props, } impl yew::Component for IconFireplace { type Properties = crate::Props; type Message = (); fn create(props: Self::Properties, _: yew::prelude::Compo...
code_fim
medium
{ "lang": "rust", "repo": "andoriyu/material-design-icons-rs", "path": "/src/materialicons/social/icon_fireplace.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> loop { let mut index; unsafe { index = PROGRAM_PTR; } let op_code = program[index as usize] % 100; let a_mode: i64 = ((program[index as usize]) / 100) % 10; let b_mode: i64 = ((program[index as usize]) / 1000) % 10; let c_mode: i64 =...
code_fim
hard
{ "lang": "rust", "repo": "FredTheDino/AoC2019", "path": "/src/day13.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let at = program[index as usize]; if addr { if mode == 0 { at } else if mode == 2 { unsafe { BASE_PTR + at } } else { panic!("Invalid address mode?"); } } else { if mode == 0 { p...
code_fim
hard
{ "lang": "rust", "repo": "FredTheDino/AoC2019", "path": "/src/day13.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FredTheDino/AoC2019 path: /src/day13.rs use std::collections::HashMap; use std::cmp::min; use std::cmp::max; pub fn first(input : &String) { let mut memory: Vec<i64> = input.split(",") .map(|s| s.parse().unwrap()) .collect();...
code_fim
hard
{ "lang": "rust", "repo": "FredTheDino/AoC2019", "path": "/src/day13.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if name == "FRAMEBUFFER_VIRT" { virt = usize::from_str_radix(value, 16).unwrap_or(0); } if name == "FRAMEBUFFER_WIDTH" { width = usize::from_str_radix(value, 16).unwrap_or(0); } if name == "FRAMEBUFFER_HEIGHT" { height = usize::...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/kernel", "path": "/src/devices/graphical_debug/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: redox-os/kernel path: /src/devices/graphical_debug/mod.rs use core::str; use spin::Mutex; pub use self::debug::DebugDisplay; use self::display::Display; pub mod debug; pub mod display; pub static FONT: &[u8] = include_bytes!("../../../res/unifont.font"); pub static DEBUG_DISPLAY: Mutex<Optio...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/kernel", "path": "/src/devices/graphical_debug/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> { let display = Display::new(width, height, stride, virt as *mut u32); let debug_display = DebugDisplay::new(display); *DEBUG_DISPLAY.lock() = Some(debug_display); } } pub fn init_heap() { if let Some(debug_display) = &mut *DEBUG_DISPLAY.lock() { debug_display....
code_fim
hard
{ "lang": "rust", "repo": "redox-os/kernel", "path": "/src/devices/graphical_debug/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut api = tide::new(); api.at("/").get(price_history_handler); Ok(api) } fn session_middleware() -> tide::sessions::SessionMiddleware<tide::sessions::MemoryStore> { tide::sessions::SessionMiddleware::new( tide::sessions::MemoryStore::new(), session::generate_secret().a...
code_fim
hard
{ "lang": "rust", "repo": "mankinskin/binance-bot", "path": "/server/src/tide_server.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn session_middleware() -> tide::sessions::SessionMiddleware<tide::sessions::MemoryStore> { tide::sessions::SessionMiddleware::new( tide::sessions::MemoryStore::new(), session::generate_secret().as_bytes() ) .with_cookie_name("session") .with_session_ttl(Some(std::time::Dur...
code_fim
hard
{ "lang": "rust", "repo": "mankinskin/binance-bot", "path": "/server/src/tide_server.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mankinskin/binance-bot path: /server/src/tide_server.rs use crate::{ *, binance::{ PriceHistoryRequest, Binance, }, }; use tide_tracing::{ TraceMiddleware, }; use async_std::net::SocketAddr; use tide_rustls::TlsListener; #[allow(unused)] use tracing::{ debug, ...
code_fim
hard
{ "lang": "rust", "repo": "mankinskin/binance-bot", "path": "/server/src/tide_server.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Display for DbError { fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { write!(f, "{}", self.message()) } } impl Debug for DbError { fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { write!(f, "{}", self.message()) } }<|fim_prefix|>// repo: paoloposso/rust-mongo-p...
code_fim
medium
{ "lang": "rust", "repo": "paoloposso/rust-mongo-poc", "path": "/src/domain/infrastructure/account_repository.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Error for DbError {} impl Display for DbError { fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { write!(f, "{}", self.message()) } } impl Debug for DbError { fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { write!(f, "{}", self.message()) } }<|fim_prefix|>// re...
code_fim
medium
{ "lang": "rust", "repo": "paoloposso/rust-mongo-poc", "path": "/src/domain/infrastructure/account_repository.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paoloposso/rust-mongo-poc path: /src/domain/infrastructure/account_repository.rs use std::{error::Error, fmt::{Debug, Display, Formatter, Result as FmtResult}}; use crate::domain::Account; use async_trait::async_trait; <|fim_suffix|> write!(f, "{}", self.message()) } } impl Debug f...
code_fim
hard
{ "lang": "rust", "repo": "paoloposso/rust-mongo-poc", "path": "/src/domain/infrastructure/account_repository.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>struct PlayerState; struct Event; struct MapConnection { conn: rusqlite::Connection, players: std::collections::HashMap<EntityUUID, PlayerState>, blocks: std::collections::HashMap<BlockPostion, (dynamic_types::BlockDynamicValue, u8)>, entities: std::collections::HashMap<EntityUUID, (Enit...
code_fim
hard
{ "lang": "rust", "repo": "Xtricman/block_game_server", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl MapConnection { fn new(file_name: &str) -> Self { MapConnection { conn: rusqlite::Connection::open(file_name).expect("Open Fail!"), players: std::collections::HashMap::new(), blocks: std::collections::HashMap::new(), entities: std::collectio...
code_fim
hard
{ "lang": "rust", "repo": "Xtricman/block_game_server", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Xtricman/block_game_server path: /src/main.rs #![feature(const_fn)] #![feature(const_if_match)] #![feature(specialization)] #![feature(trace_macros)] mod dynamic_types; fn main() { println!("{:?}", dynamic_types::filter_ids_by_tag(dynamic_types::Tag::CanBeBurn)); println!("{:?}", dynam...
code_fim
medium
{ "lang": "rust", "repo": "Xtricman/block_game_server", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: charlieyqin/optimal-image path: /src/optimal_image/dataclients/jpeg.rs extern crate dssim; extern crate image; extern crate imgref; extern crate lodepng; extern crate rgb; use dataclients::{ImageDataResult, Loader, MemoryLoader}; use image::*; use rgb::RGBA; use std::path::Path; pub struct Jpe...
code_fim
hard
{ "lang": "rust", "repo": "charlieyqin/optimal-image", "path": "/src/optimal_image/dataclients/jpeg.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let image = image::load_from_memory(&buffer)?; let (width, height) = image.dimensions(); let buffer = image .to_rgba() .pixels() .map(|pixel| { let [r, g, b, a] = pixel.to_rgba().data; let rgba: RGBA<f32>; ...
code_fim
hard
{ "lang": "rust", "repo": "charlieyqin/optimal-image", "path": "/src/optimal_image/dataclients/jpeg.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl MemoryLoader for Jpeg { fn load_from_memory(&self, buffer: &Vec<u8>) -> ImageDataResult<ImageError> { let image = image::load_from_memory(&buffer)?; let (width, height) = image.dimensions(); let buffer = image .to_rgba() .pixels() .map(|...
code_fim
hard
{ "lang": "rust", "repo": "charlieyqin/optimal-image", "path": "/src/optimal_image/dataclients/jpeg.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>t) { physics_world.step(context); }<|fim_prefix|>// repo: ElnuDev/pong path: /src/systems/physics.rs use ggez::*; use crate::physics_world::*; pub fn system_physics(physics_worl<|fim_middle|>d: &mut PhysicsWorld, context: &Contex
code_fim
easy
{ "lang": "rust", "repo": "ElnuDev/pong", "path": "/src/systems/physics.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>d: &mut PhysicsWorld, context: &Context) { physics_world.step(context); }<|fim_prefix|>// repo: ElnuDev/pong path: /src/systems/physics.rs use ggez::*; use crate::physics_world:<|fim_middle|>:*; pub fn system_physics(physics_worl
code_fim
easy
{ "lang": "rust", "repo": "ElnuDev/pong", "path": "/src/systems/physics.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ElnuDev/pong path: /src/systems/physics.rs use ggez::*; use crate::physics_world:<|fim_suffix|>t) { physics_world.step(context); }<|fim_middle|>:*; pub fn system_physics(physics_world: &mut PhysicsWorld, context: &Contex
code_fim
medium
{ "lang": "rust", "repo": "ElnuDev/pong", "path": "/src/systems/physics.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(dead_code)] pub struct Empty;<|fim_prefix|>// repo: CrueLu/lunatic path: /uptown_funk/tests/common.rs use uptown_funk::{memory::Memory, Executor}; <|fim_middle|>#[derive(Clone)] pub struct SimpleExcutor { pub memory: Memory, } impl Executor for SimpleExcutor { fn memory(&self) -> Memory...
code_fim
medium
{ "lang": "rust", "repo": "CrueLu/lunatic", "path": "/uptown_funk/tests/common.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CrueLu/lunatic path: /uptown_funk/tests/common.rs use uptown_funk::{memory::Memory, Executor}; <|fim_suffix|> self.memory.clone() } } #[allow(dead_code)] pub struct Empty;<|fim_middle|>#[derive(Clone)] pub struct SimpleExcutor { pub memory: Memory, } impl Executor for SimpleExc...
code_fim
medium
{ "lang": "rust", "repo": "CrueLu/lunatic", "path": "/uptown_funk/tests/common.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }