text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let mut territory = Territory::new(); assert_eq!(territory.add_land(0, 0), 1); assert_eq!(territory.add_land(2, 0), 2); assert_eq!(territory.add_land(1, 0), 1); }<|fim_prefix|>// repo: lyuboraykov/rust-exercises path: /tests/integration_test.rs extern crate service_utils; <|fim_middle|>u...
code_fim
medium
{ "lang": "rust", "repo": "lyuboraykov/rust-exercises", "path": "/tests/integration_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let retransmit_receiver = Arc::new(Mutex::new(retransmit_receiver)); let t_retransmit = retransmitter( retransmit_sockets, bank_forks.clone(), leader_schedule_cache, cluster_info.clone(), retransmit_receiver, ); l...
code_fim
hard
{ "lang": "rust", "repo": "project-serum/solana", "path": "/core/src/retransmit_stage.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: project-serum/solana path: /core/src/retransmit_stage.rs uster_slots::ClusterSlots, cluster_slots_service::ClusterSlotsService, completed_data_sets_service::CompletedDataSetsSender, contact_info::ContactInfo, repair_service::DuplicateSlotsResetSender, repair_service::RepairIn...
code_fim
hard
{ "lang": "rust", "repo": "project-serum/solana", "path": "/core/src/retransmit_stage.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: azsn/compiler-practice path: /src/parser.rs use super::tokenizer::Token; use super::tokenizer::TokenType; use std::str; #[derive(Debug, Copy, Clone, PartialEq)] pub enum VarType { Int, Bool, } #[derive(Debug, Copy, Clone, PartialEq)] pub enum OpType { Plus, Minus, Multiply, Divide, Grea...
code_fim
hard
{ "lang": "rust", "repo": "azsn/compiler-practice", "path": "/src/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn parse_if(&mut self) -> IfNode { self.consume(TokenType::If); self.consume(TokenType::OParen); let condition = self.parse_expr(); self.consume(TokenType::CParen); let true_body = self.parse_block(); let mut false_body = None; if self.peek(TokenType::Else, 0) { self.consume(TokenType::...
code_fim
hard
{ "lang": "rust", "repo": "azsn/compiler-practice", "path": "/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dalnefre/oxide path: /tests/heap_allocation.rs #![no_std] #![no_main] #![feature(custom_test_frameworks)] #![test_runner(blog_os::test_runner)] #![reexport_test_harness_main = "test_main"] extern crate alloc; use alloc::{boxed::Box, vec::Vec}; use blog_os::{allocator::HEAP_SIZE, serial_print, ...
code_fim
medium
{ "lang": "rust", "repo": "dalnefre/oxide", "path": "/tests/heap_allocation.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test_case] fn many_boxes() { serial_print!("many_boxes... "); for i in 0..HEAP_SIZE { let x = Box::new(i); assert_eq!(*x, i); } serial_println!("[ok]"); } #[test_case] fn many_boxes_long_lived() { serial_print!("many_boxes_long_lived... "); let long_lived = Box::...
code_fim
hard
{ "lang": "rust", "repo": "dalnefre/oxide", "path": "/tests/heap_allocation.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: silvia-odwyer/photon path: /crate/src/lib.rs //! A high-performance image processing library, available for use both natively and on the web. //! //! #### Functions //! 96 functions are available, including: //! - **Transformations**: Resize, crop, and flip images. //! - **Image correction**: Hu...
code_fim
hard
{ "lang": "rust", "repo": "silvia-odwyer/photon", "path": "/crate/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> res_base64 } /// Convert the PhotonImage to raw bytes. Returns JPEG. pub fn get_bytes(&self) -> Vec<u8> { let mut img = helpers::dyn_image_from_raw(self); img = ImageRgba8(img.to_rgba8()); let mut buffer = vec![]; img.write_to(&mut buffer, image::ImageO...
code_fim
hard
{ "lang": "rust", "repo": "silvia-odwyer/photon", "path": "/crate/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let width = imgdata.width(); let height = imgdata.height(); let raw_pixels = to_raw_pixels(imgdata); PhotonImage { raw_pixels, width, height, } } } /// RGB color type. #[cfg_attr(feature = "enable_wasm", wasm_bindgen)] #[deri...
code_fim
hard
{ "lang": "rust", "repo": "silvia-odwyer/photon", "path": "/crate/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> handle_init_test( "unexpected state shutdownSent", AssociationState::ShutdownSent, true, ) .await; Ok(()) } #[tokio::test] async fn test_assoc_max_message_size_default() -> Result<(), Error> { let mut a = create_association_internal(Config { net_conn: ...
code_fim
hard
{ "lang": "rust", "repo": "u-03c9/sctp", "path": "/src/association/association_internal/association_internal_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: u-03c9/sctp path: /src/association/association_internal/association_internal_test.rs use super::*; use std::io; use std::net::SocketAddr; struct DumbConn; #[async_trait] impl Conn for DumbConn { async fn connect(&self, _addr: SocketAddr) -> io::Result<()> { Err(io::Error::new(io::E...
code_fim
hard
{ "lang": "rust", "repo": "u-03c9/sctp", "path": "/src/association/association_internal/association_internal_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let delayed_ack_triggered = a.delayed_ack_triggered; let immediate_ack_triggered = a.immediate_ack_triggered; assert_eq!( a.peer_last_tsn, prev_tsn + 3, "peerLastTSN should advance by 3 " ); assert!(delayed_ack_triggered, "delayed sack should be triggered"); ...
code_fim
hard
{ "lang": "rust", "repo": "u-03c9/sctp", "path": "/src/association/association_internal/association_internal_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( ::std::mem::size_of::<heif_writer>(), 16usize, concat!("Size of: ", stringify!(heif_writer)) ); assert_eq!( ::std::mem::align_of::<heif_writer>(), 8usize, concat!("Alignment of ", stringify!(heif_writer)) ); assert_eq!( ...
code_fim
hard
{ "lang": "rust", "repo": "FauxFaux/libheif-rs", "path": "/src/raw.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FauxFaux/libheif-rs path: /src/raw.rs rm_disparity: heif_depth_representation_type = 3; pub type heif_depth_representation_type = u32; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct heif_depth_representation_info { pub version: u8, pub has_z_near: u8, pub has_z_far: u8, ...
code_fim
hard
{ "lang": "rust", "repo": "FauxFaux/libheif-rs", "path": "/src/raw.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn mul_transform(&self, other: Self) -> Self { let translation = self.mul_vec3(other.translation); let rotation = self.rotation * other.rotation; let scale = self.scale * other.scale; Self { translation, rotation, scale, ...
code_fim
hard
{ "lang": "rust", "repo": "ChangeCaps/quartz", "path": "/quartz-engine/crates/core/src/transform.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ChangeCaps/quartz path: /quartz-engine/crates/core/src/transform.rs use quartz_render::prelude::*; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Transform { pub translation: Vec3, pub rotation: Quat, pub scale: Vec3, } im...
code_fim
hard
{ "lang": "rust", "repo": "ChangeCaps/quartz", "path": "/quartz-engine/crates/core/src/transform.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_random_generation() { let mut chain = MarkovChain::new(); let mut name_map = HashMap::new(); name_map.insert("sota".into(), Regex::new("sota").unwrap()); name_map.insert("denko".into(), Regex::new("denko").unwrap()); chain.append_message_dum...
code_fim
hard
{ "lang": "rust", "repo": "texbois/joebot", "path": "/joebot-markov-chain/src/generate.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: texbois/joebot path: /joebot-markov-chain/src/generate.rs use crate::{ChainEntry, MarkovChain, Selector, TextSource}; use indexmap::IndexSet; use rand::Rng; use std::collections::HashSet; const MAX_TRIES: usize = 100; pub trait ChainGenerate { fn generate<R: Rng>( &self, se...
code_fim
hard
{ "lang": "rust", "repo": "texbois/joebot", "path": "/joebot-markov-chain/src/generate.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Into::<BinaryArray>::into($values.to_vec()) }}; } #[macro_export] macro_rules! subview { ($name:expr, $path:expr, $values:expr) => {{ ($crate::field!($name, $path), $crate::array_ref!($values)) }}; ($name:expr, $ty:ty, $values:expr) => {{ use arrow::datatypes::Arro...
code_fim
hard
{ "lang": "rust", "repo": "kyle-mccarthy/alpine", "path": "/src/macros.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> $( let (field, array) = $crate::subview!($name, $ty, $values); fields.push(field); arrays.push(array); )* $crate::View::new(fields, arrays) }} } #[macro_export] macro_rules! array_ref { ($ty:ty, $v:expr) => {{ std::sync::Arc::ne...
code_fim
hard
{ "lang": "rust", "repo": "kyle-mccarthy/alpine", "path": "/src/macros.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kyle-mccarthy/alpine path: /src/macros.rs #[macro_export] macro_rules! as_array { ($arr:ident, $arr_type:ty) => {{ $arr.as_any() .downcast_ref::<$arr_type>() .ok_or(crate::Error::InvalidDowncast) }}; } #[macro_export] macro_rules! sel { ($s:expr) => {...
code_fim
hard
{ "lang": "rust", "repo": "kyle-mccarthy/alpine", "path": "/src/macros.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// /// Remove the first child of this `Node` and return the data that child contained. /// Returns a `Some`-value if this `Node` has a child to remove; returns a `None`-value /// otherwise. /// /// Children of the removed `Node` can either be dropped with `DropChildren` or orphane...
code_fim
hard
{ "lang": "rust", "repo": "MUDS7/slab-tree", "path": "/src/node/node_mut.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MUDS7/slab-tree path: /src/node/node_mut.rs rent().is_none()); /// ``` /// pub fn parent(&mut self) -> Option<NodeMut<T>> { self.get_self_as_node() .relatives .parent .map(move |id| NodeMut::new(id, self.tree)) } /// /// Return...
code_fim
hard
{ "lang": "rust", "repo": "MUDS7/slab-tree", "path": "/src/node/node_mut.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Exchange positions with the next sibling. /// /// Returns true if swapped with a next sibling, returns false if this was /// already the last sibling. /// /// ``` /// use slab_tree::tree::TreeBuilder; /// /// let mut tree = TreeBuilder::new().with_root(1).build(); ...
code_fim
hard
{ "lang": "rust", "repo": "MUDS7/slab-tree", "path": "/src/node/node_mut.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jstarry/proc-macro-workshop path: /seq/src/lib.rs extern crate proc_macro; use proc_macro::TokenStream; use proc_macro2::{Group, Ident, Literal, TokenTree}; use quote::quote; use std::iter::FromIterator; use syn::parse::{Parse, ParseStream, Result}; use syn::{braced, parse_macro_input, ExprBloc...
code_fim
hard
{ "lang": "rust", "repo": "jstarry/proc-macro-workshop", "path": "/seq/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let ident: Ident = input.parse()?; input.parse::<Token![in]>()?; let begin: LitInt = input.parse()?; input.parse::<Token![..]>()?; let end: LitInt = input.parse()?; let content; braced!(content in input); let mut tree: Vec<TokenTree> = vec![...
code_fim
hard
{ "lang": "rust", "repo": "jstarry/proc-macro-workshop", "path": "/seq/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let bodies = (seq.begin.value()..seq.end.value()).map(|iter| { let replaced = body .clone() .into_iter() .map(|tt| map_replace(tt, name.to_string().as_str(), Literal::u64_unsuffixed(iter))); quote! { #(#replaced)* } }); ...
code_fim
hard
{ "lang": "rust", "repo": "jstarry/proc-macro-workshop", "path": "/seq/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rainliu/rav1d path: /src/context.rs Pad 16 extra bytes to avoid reading overflow in SIMD optimization. const TX_PAD_END: usize = 16; const TX_PAD_2D: usize = ((MAX_TX_SIZE + TX_PAD_HOR) * (MAX_TX_SIZE + TX_PAD_VER) + TX_PAD_END); const TX_CLASSES: usize = 3; #[derive(Copy, Clone, PartialEq)...
code_fim
hard
{ "lang": "rust", "repo": "rainliu/rav1d", "path": "/src/context.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[rustfmt::skip] const SUBSIZE_LOOKUP: [[BlockSize; BlockSize::BLOCK_SIZES_ALL]; EXT_PARTITION_TYPES] = [ // PARTITION_NONE [ // 4X4 BLOCK_4X4, // 4X8, 8X4, 8X8 BLOCK_4X8, BLOCK_...
code_fim
hard
{ "lang": "rust", "repo": "rainliu/rav1d", "path": "/src/context.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rainliu/rav1d path: /src/context.rs nst SIG_COEF_CONTEXTS: usize = SIG_COEF_CONTEXTS_2D + SIG_COEF_CONTEXTS_1D; const COEFF_BASE_CONTEXTS: usize = SIG_COEF_CONTEXTS; pub const DC_SIGN_CONTEXTS: usize = 3; const BR_TMP_OFFSET: usize = 12; const BR_REF_CAT: usize = 4; pub const LEVEL_CONTEXTS...
code_fim
hard
{ "lang": "rust", "repo": "rainliu/rav1d", "path": "/src/context.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: forksarchive/matrix-rust-sdk path: /matrix_sdk_crypto/src/verification/requests.rs InnerRequest::Ready(r) => { DeviceIdOrAllDevices::DeviceId(r.state.other_device_id.to_owned()) } InnerRequest::Passive(_) => DeviceIdOrAllDevices::AllDevices, ...
code_fim
hard
{ "lang": "rust", "repo": "forksarchive/matrix-rust-sdk", "path": "/matrix_sdk_crypto/src/verification/requests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: forksarchive/matrix-rust-sdk path: /matrix_sdk_crypto/src/verification/requests.rs account: ReadOnlyAccount, private_cross_signing_identity: PrivateCrossSigningIdentity, store: Arc<dyn CryptoStore>, other_user: &UserId, ) -> Self { let flow_id = Uuid::new_...
code_fim
hard
{ "lang": "rust", "repo": "forksarchive/matrix-rust-sdk", "path": "/matrix_sdk_crypto/src/verification/requests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert!(bob_request.is_ready()); assert!(alice_request.is_ready()); } #[async_test] async fn test_requesting_until_sas() { let event_id = event_id!("$1234localhost"); let room_id = room_id!("!test:localhost"); let alice = ReadOnlyAccount::new(&alice_id...
code_fim
hard
{ "lang": "rust", "repo": "forksarchive/matrix-rust-sdk", "path": "/matrix_sdk_crypto/src/verification/requests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: karimElmougi/Simumo path: /simulator/extern/rts_logger/src/log_message_senders.rs use std::{ collections::HashMap, sync::{mpsc::Sender, Mutex}, }; /// Object send through the channels for logging pub type Loggable = Box<erased_serde::Serialize + Send>; pub enum LogMessage { Log(Logg...
code_fim
hard
{ "lang": "rust", "repo": "karimElmougi/Simumo", "path": "/simulator/extern/rts_logger/src/log_message_senders.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> pub fn drop_sender(&self, name : String) { self.0.lock().unwrap().remove(&name); } } /// this static collection is used to send the sender channels easily /// so the users don't have to do complex manipulation /// when creating a new LogSender /// lazy_static! { pub static ref LOG_ME...
code_fim
hard
{ "lang": "rust", "repo": "karimElmougi/Simumo", "path": "/simulator/extern/rts_logger/src/log_message_senders.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: klausklemens/rust-sudoku path: /src/container.rs #[derive(Copy, Clone)] pub enum FieldContent { Digit(u8), Hints([bool; 9]), None } <|fim_suffix|> pub fn unwrap(&self) -> u8 { let wrapper: Option<u8> = match *self { FieldContent::Digit(d) => Some(d), ...
code_fim
hard
{ "lang": "rust", "repo": "klausklemens/rust-sudoku", "path": "/src/container.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn is_none(&self) -> bool { !self.is_some() } pub fn unwrap(&self) -> u8 { let wrapper: Option<u8> = match *self { FieldContent::Digit(d) => Some(d), _ => None }; return wrapper.unwrap(); } }<|fim_prefix|>// repo: klausklemen...
code_fim
medium
{ "lang": "rust", "repo": "klausklemens/rust-sudoku", "path": "/src/container.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nrf-rs/nrf5340-pac path: /nrf5340-net-pac/src/spim0_ns/dcxcnt.rs #[doc = "Register `DCXCNT` reader"] pub struct R(crate::R<DCXCNT_SPEC>); impl core::ops::Deref for R { type Target = crate::R<DCXCNT_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } im...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf5340-pac", "path": "/nrf5340-net-pac/src/spim0_ns/dcxcnt.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|> W(writer) } } #[doc = "Field `DCXCNT` reader - This register specifies the number of command bytes preceding the data bytes. The PSEL.DCX line will be low during transmission of command bytes and high during transmission of data bytes. Value 0xF indicates that all bytes are command bytes."] pu...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf5340-pac", "path": "/nrf5340-net-pac/src/spim0_ns/dcxcnt.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_prefix|>// repo: windjm/rust-exercise path: /source/cat/src/main.rs fn main() { let filename = std::env::args().<|fim_suffix|>d file failed."); println!("{}", contents); }<|fim_middle|>nth(2).expect("No file given"); let contents = std::fs::read_to_string(filename).expect("Rea
code_fim
medium
{ "lang": "rust", "repo": "windjm/rust-exercise", "path": "/source/cat/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> = std::fs::read_to_string(filename).expect("Read file failed."); println!("{}", contents); }<|fim_prefix|>// repo: windjm/rust-exercise path: /source/cat/src/main.rs fn main() { let filename = std::env::args().<|fim_middle|>nth(2).expect("No file given"); let contents
code_fim
easy
{ "lang": "rust", "repo": "windjm/rust-exercise", "path": "/source/cat/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Patryk27/janet path: /libs/gitlab/src/endpoints/user.rs use crate::{GitLabClient, User, UserId}; use anyhow::*; impl GitLabClient { #[tracing::instrument(skip(self))] pub async fn user(&self, id: UserId) -> Result<User> { tracing::debug!("Sending request"); (try { ...
code_fim
hard
{ "lang": "rust", "repo": "Patryk27/janet", "path": "/libs/gitlab/src/endpoints/user.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> server.expect_user(&expected).await; let actual = client.user(UserId::new(250)).await.unwrap(); pa::assert_eq!(expected, actual); } } }<|fim_prefix|>// repo: Patryk27/janet path: /libs/gitlab/src/endpoints/user.rs use crate::{GitLabClient, User, UserId}; ...
code_fim
hard
{ "lang": "rust", "repo": "Patryk27/janet", "path": "/libs/gitlab/src/endpoints/user.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: museun/twitchchat path: /src/commands/clear.rs use super::{Channel, Encodable}; use std::io::{Result, Write}; /// Clear chat history for all users on `channel`. #[non_exhaustive] #[must_use = "commands must be encoded"] #[derive(Debug, Copy, Clone, PartialEq, Ord, PartialOrd, Eq, Hash)] #[cfg_a...
code_fim
hard
{ "lang": "rust", "repo": "museun/twitchchat", "path": "/src/commands/clear.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] #[cfg(feature = "serde")] fn clear_ensure_channel_serde() { test_serde(clear("museun"), "PRIVMSG #museun :/clear\r\n") } }<|fim_prefix|>// repo: museun/twitchchat path: /src/commands/clear.rs use super::{Channel, Encodable}; use std::io::{Result, Write}; /// Clear chat hi...
code_fim
hard
{ "lang": "rust", "repo": "museun/twitchchat", "path": "/src/commands/clear.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: michalisioak/aries-vcx path: /libvcx/src/aries/handlers/issuance/issuer/states/initial.rs use crate::aries::handlers::issuance::issuer::states::finished::FinishedState; use crate::aries::handlers::issuance::issuer::states::offer_sent::OfferSentState; use crate::aries::messages::a2a::MessageId; u...
code_fim
medium
{ "lang": "rust", "repo": "michalisioak/aries-vcx", "path": "/libvcx/src/aries/handlers/issuance/issuer/states/initial.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ChevyRay/grid path: /src/iterators.rs use crate::Grid; use math::{Int2, IntRectIter}; use std::marker::PhantomData; /// Immutable iterator over a region of a grid. pub struct GridIter<'a, T, G: Grid<T>> { pub(crate) grid: &'a G, pub(crate) iter: IntRectIter, pub(crate) _marker: Phan...
code_fim
hard
{ "lang": "rust", "repo": "ChevyRay/grid", "path": "/src/iterators.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while let Some(pos) = self.iter.next() { let val = unsafe { self.grid.get_unchecked_mut(pos) }; let ptr: *mut T = val; return unsafe { Some((pos, &mut *ptr)) }; } None } }<|fim_prefix|>// repo: ChevyRay/grid path: /src/iterators.rs use crate...
code_fim
hard
{ "lang": "rust", "repo": "ChevyRay/grid", "path": "/src/iterators.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Connicpu/directx-rs path: /wic/src/color_context/mod.rs use com_wrapper::ComWrapper; use winapi::um::wincodec<|fim_suffix|>sparent)] #[derive(ComWrapper)] #[com(debug)] pub struct ColorContext { ptr: ComPtr<IWICColorContext>, }<|fim_middle|>::IWICColorContext; use wio::com::ComPtr; #[repr(t...
code_fim
easy
{ "lang": "rust", "repo": "Connicpu/directx-rs", "path": "/wic/src/color_context/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ct ColorContext { ptr: ComPtr<IWICColorContext>, }<|fim_prefix|>// repo: Connicpu/directx-rs path: /wic/src/color_context/mod.rs use com_wrapper::ComWrapper; use winapi::um::wincodec::IWICColorContext; use wio::com::ComPtr; #[repr(tran<|fim_middle|>sparent)] #[derive(ComWrapper)] #[com(debug)] pub s...
code_fim
easy
{ "lang": "rust", "repo": "Connicpu/directx-rs", "path": "/wic/src/color_context/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // switch back drop(switch_guard); Ok(()) } #[cfg(test)] mod tests { use super::*; use users::{get_current_username, get_effective_uid}; fn wrap_switch_user(username: &str) -> Result<User> { switch_user(&OsString::from(username)).map(|(u, _g)| u) } #[test] ...
code_fim
hard
{ "lang": "rust", "repo": "coreos/ssh-key-dir", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coreos/ssh-key-dir path: /src/main.rs // Copyright 2020 CoreOS, Inc. // // 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/licenses/LICEN...
code_fim
hard
{ "lang": "rust", "repo": "coreos/ssh-key-dir", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: amiyamandal-dev/rust_summary path: /src/main.rs extern crate anyhow; use actix_web::middleware::Logger; use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder, Result}; use env_logger::Env; use rust_bert::bart::{ BartConfigResources, BartMergesResources, BartModelResources,...
code_fim
hard
{ "lang": "rust", "repo": "amiyamandal-dev/rust_summary", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(HttpResponse::Ok().json(OutputResponse { output_string: result, })) } #[derive(Serialize, Deserialize, Clone)] struct InputSummBatch { input_string: Vec<String>, min_length: i64, max_length: i64, num_beams: i64, } #[derive(Serialize, Deserialize)] struct OutputResponse...
code_fim
hard
{ "lang": "rust", "repo": "amiyamandal-dev/rust_summary", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut buffer = new_buffer(); let values: &[u32] = &[0, 1, 5, 9, 10, 11, 15, 99, 100, 101, 105, 999, 1000, 1001, 1005, 9999, 10000, 10001, 10005, 99999, 100000, 100001, 100005, 999999, 1000000, 1000001, 1000005, 9999999, 10000000, 10000001, 10000005, 99999999, 100000000, 100000001, 100000...
code_fim
hard
{ "lang": "rust", "repo": "10allday-kai/api-daemon", "path": "/third-party/lexical-core/src/itoa/api.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Proptest #[cfg(all(feature = "std", feature = "property_tests"))] proptest! { #[test] fn u8_proptest(i in u8::min_value()..u8::max_value()) { let mut buffer = new_buffer(); assert_eq!(i, u8::from_lexical(i.to_lexical(&mut buffer)).unwrap()) }...
code_fim
hard
{ "lang": "rust", "repo": "10allday-kai/api-daemon", "path": "/third-party/lexical-core/src/itoa/api.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 10allday-kai/api-daemon path: /third-party/lexical-core/src/itoa/api.rs 5, 9999, 10000, 10001, 10005]; for &i in values.iter() { assert_eq!(i, u16::from_lexical(i.to_lexical(&mut buffer)).unwrap()); } } #[test] fn u32_pow2_test() { let mut buffer ...
code_fim
hard
{ "lang": "rust", "repo": "10allday-kai/api-daemon", "path": "/third-party/lexical-core/src/itoa/api.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wahtak/rust-mandelbrot path: /src/mandelbrot.rs extern crate num; use num::complex::Complex64; pub trait Bounded { fn out_of_bound(&self, bound: f64) -> bool; } impl Bounded for Complex64 { fn out_of_bound(&self, bound: f64) -> bool { (self.re).abs() > bound || (self.im).abs()...
code_fim
hard
{ "lang": "rust", "repo": "wahtak/rust-mandelbrot", "path": "/src/mandelbrot.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let c = Complex64 { re: 0.1, im: 0.1 }; let iterations = measure_divergence(&*mandelbrot_function(c), 1.0, 10); assert!(iterations.is_none()); } #[test] fn mandelbrot_function_diverges_for_some_constant() { let c = Complex64 { re: 0.5, im: 0.5 }; let...
code_fim
hard
{ "lang": "rust", "repo": "wahtak/rust-mandelbrot", "path": "/src/mandelbrot.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } pub enum StateData { Amount(u256), } pub enum Seal { Hidden(Txid, u32, u32), Explicit(Txid, u32), } pub struct State { pub seal: Seal, pub data: StateData, } pub enum MetaRecord { String(String) } pub struct Sta...
code_fim
hard
{ "lang": "rust", "repo": "Kixunil/rust-lnpbp", "path": "/drafts/playgrounds.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kixunil/rust-lnpbp path: /drafts/playgrounds.rs pub mod serialize { pub mod commitment { pub struct Transition<const N: u32, const M: u16> { pub seals_root: MerkleRoot<SealHash, N>, pub state_root: MerkleRoot<StateHash, N>, pub meta_root: MerkleRo...
code_fim
hard
{ "lang": "rust", "repo": "Kixunil/rust-lnpbp", "path": "/drafts/playgrounds.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> pub struct State { pub seal: Seal, pub data: StateData, } pub enum MetaRecord { String(String) } pub struct StateSet(Set<State>); impl StateSet { pub fn from(states: Set<State>) -> Result<StateSet, Error> { unimplemented!() } pub fn create_...
code_fim
hard
{ "lang": "rust", "repo": "Kixunil/rust-lnpbp", "path": "/drafts/playgrounds.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let mut braces = match iter.next().unwrap() { #dummy::TokenTree::Group(group) => group.stream().into_iter(), _ => unimplemented!(), }; let variant = braces.next().unwrap(); // `Value` or `Nested` let varname = variant.to_strin...
code_fim
hard
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/third_party/rust_crates/vendor/proc-macro-hack/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> quote! { #[doc(hidden)] #vis use #from::#actual_name; #export_dispatch #export_call_site #attrs #macro_export macro_rules! #export_as { ($($proc_macro:tt)*) => ...
code_fim
hard
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/third_party/rust_crates/vendor/proc-macro-hack/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oshunter/fuchsia path: /third_party/rust_crates/vendor/proc-macro-hack/src/lib.rs //! As of Rust 1.30, the language supports user-defined function-like procedural //! macros. However these can only be invoked in item position, not in //! statements or expressions. //! //! This crate implements a...
code_fim
hard
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/third_party/rust_crates/vendor/proc-macro-hack/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn hello_saturn() { assert_eq!(hello_world(6), Some("Hello Saturn!")); } #[test] fn hello_uranus() { assert_eq!(hello_world(7), Some("Hello Uranus!")); } #[test] fn hello_neptune() { assert_eq!(hello_world(8), Some("Hello Neptune!")); } #[test] fn pluto_i...
code_fim
hard
{ "lang": "rust", "repo": "Densaugeo/hello_rusty_worlds", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Densaugeo/hello_rusty_worlds path: /src/lib.rs //! A hello world crate with automated testing, documentation, //! continuous integration, tested example code, implemented as a library //! with a command line tool. Supports Sol and all its planets, not just 'Hello (unspecified) world!' /// This ...
code_fim
hard
{ "lang": "rust", "repo": "Densaugeo/hello_rusty_worlds", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn hello_earth() { assert_eq!(hello_world(3), Some("Hello Earth!")); } #[test] fn hello_mars() { assert_eq!(hello_world(4), Some("Hello Mars!")); } #[test] fn hello_jupiter() { assert_eq!(hello_world(5), Some("Hello Jupiter!")); } #[test] fn hello_saturn(...
code_fim
hard
{ "lang": "rust", "repo": "Densaugeo/hello_rusty_worlds", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match Rc::get_mut(&mut self.allocator) { Some(alloc) => alloc.destroy(), None => panic!("Failed to destroy vk-mem allocator."), } } }<|fim_prefix|>// repo: MatchaChoco010/vulkan-ash-tutorial-rust-memo path: /techlabxe_vulkan_book_3/src/vk_wrapper_object/vk_mem_...
code_fim
medium
{ "lang": "rust", "repo": "MatchaChoco010/vulkan-ash-tutorial-rust-memo", "path": "/techlabxe_vulkan_book_3/src/vk_wrapper_object/vk_mem_allocator_object.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use parse_coordinates; use part_1; let data = r"1, 1 1, 6 8, 3 3, 4 5, 5 8, 9"; let coordinates = parse_coordinates(&data).unwrap(); assert_eq!(part_1(&coordinates), 17); // panic!("I just want to print"); } #[test] fn test_part_2() { us...
code_fim
hard
{ "lang": "rust", "repo": "vindvaki/advent-of-code-2018", "path": "/src/bin/day_06.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ((x_min, y_min), (rows, cols)) = extract_dimensions(coordinates); let mut state = Mat::new(rows, cols, NotSeen); for &(x0, y0) in coordinates { let x = x0 - x_min; let y = y0 - y_min; for u in 0..cols { for v in 0..rows { let d_xy = man...
code_fim
hard
{ "lang": "rust", "repo": "vindvaki/advent-of-code-2018", "path": "/src/bin/day_06.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vindvaki/advent-of-code-2018 path: /src/bin/day_06.rs extern crate aoc2018; #[macro_use] extern crate error_chain; use aoc2018::count_by_value; use aoc2018::Mat; use std::collections::HashMap; use std::io::Read; mod errors { error_chain!{} } use errors::*; pub fn main() { let mut da...
code_fim
hard
{ "lang": "rust", "repo": "vindvaki/advent-of-code-2018", "path": "/src/bin/day_06.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let get_value = add_value(); println!("{}", get_value); println!("{}", arg_value(1, 2)) }<|fim_prefix|>// repo: oksite/RUST-LEARN-PROJECT path: /src/function.rs fn add_value() -> isize { 5 } <|fim_middle|>fn arg_value(x: isize, y: isize) -> isize { x + y; } fn main() {
code_fim
medium
{ "lang": "rust", "repo": "oksite/RUST-LEARN-PROJECT", "path": "/src/function.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oksite/RUST-LEARN-PROJECT path: /src/function.rs fn add_value() -> isize { 5 } <|fim_suffix|> let get_value = add_value(); println!("{}", get_value); println!("{}", arg_value(1, 2)) }<|fim_middle|>fn arg_value(x: isize, y: isize) -> isize { x + y; } fn main() {
code_fim
medium
{ "lang": "rust", "repo": "oksite/RUST-LEARN-PROJECT", "path": "/src/function.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jannik4/openmls path: /src/ciphersuite/errors.rs //! # Crypto errors //! //! This file defines a set of errors thrown by crypto operations. use std::error::Error; #[derive(Debug)] pub(crate) enum HKDFError { InvalidLength, } #[derive(Debug)] pub(crate) enum CryptoError { CryptoLibrary...
code_fim
hard
{ "lang": "rust", "repo": "jannik4/openmls", "path": "/src/ciphersuite/errors.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Error for HKDFError { fn description(&self) -> &str { match self { Self::InvalidLength => "The HKDF output is empty.", } } } impl Error for CryptoError { fn description(&self) -> &str { match self { Self::CryptoLibraryError => "Unrecoverabl...
code_fim
hard
{ "lang": "rust", "repo": "jannik4/openmls", "path": "/src/ciphersuite/errors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Error for CryptoError { fn description(&self) -> &str { match self { Self::CryptoLibraryError => "Unrecoverable error in the crypto library.", } } }<|fim_prefix|>// repo: jannik4/openmls path: /src/ciphersuite/errors.rs //! # Crypto errors //! //! This file define...
code_fim
medium
{ "lang": "rust", "repo": "jannik4/openmls", "path": "/src/ciphersuite/errors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lisael/zero2prod path: /src/domain/subscriber_name.rs use unicode_segmentation::UnicodeSegmentation; #[derive(Debug)] pub struct SubscriberName(String); impl SubscriberName { pub fn parse(name: String) -> Result<Self, String> { let is_empty = name.trim().is_empty(); let too...
code_fim
hard
{ "lang": "rust", "repo": "lisael/zero2prod", "path": "/src/domain/subscriber_name.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for name in &['/', '(', ')', '"', '<', '>', '\\', '{', '}'] { let name = name.to_string(); assert_err!(SubscriberName::parse(name)); } } #[test] fn a_valid_name_is_parsed_successfully() { let name = "Ursula Le Guin".to_string(); assert_ok...
code_fim
hard
{ "lang": "rust", "repo": "lisael/zero2prod", "path": "/src/domain/subscriber_name.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IDragnev/myos path: /src/gdt/ist.rs use alloc::boxed::Box; use core::ops::{ Index, IndexMut, }; /// The size of the stacks in the IST in bytes pub const STACK_SIZE: usize = 4096; type InterruptStackPtr = Option<Box<InterruptStack>>; #[repr(transparent)] pub struct InterruptStackTable(...
code_fim
hard
{ "lang": "rust", "repo": "IDragnev/myos", "path": "/src/gdt/ist.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Index<usize> for InterruptStackTable { type Output = InterruptStackPtr; fn index(&self, index: usize) -> &Self::Output { &(self.0)[index] } } impl IndexMut<usize> for InterruptStackTable { fn index_mut(&mut self, index: usize) -> &mut Self::Output { &mut (self.0)[ind...
code_fim
medium
{ "lang": "rust", "repo": "IDragnev/myos", "path": "/src/gdt/ist.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &(self.0)[index] } } impl IndexMut<usize> for InterruptStackTable { fn index_mut(&mut self, index: usize) -> &mut Self::Output { &mut (self.0)[index] } }<|fim_prefix|>// repo: IDragnev/myos path: /src/gdt/ist.rs use alloc::boxed::Box; use core::ops::{ Index, IndexMut,...
code_fim
hard
{ "lang": "rust", "repo": "IDragnev/myos", "path": "/src/gdt/ist.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (_, version) = lookup_version(LookupVersion(msg.0), conn)?; let result = Dependency::belonging_to(&version) .inner_join(packages.inner_join(groups)) .select(( group_name_origin, package_name_origin, dependencies::all_columns(), )).lo...
code_fim
hard
{ "lang": "rust", "repo": "elba/website", "path": "/src/model/packages/action.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elba/website path: /src/model/packages/action.rs index: &Addr<Index>, storage: &Addr<Storage>, search: &Addr<Search>, ) -> Result<(), Error> { conn.build_transaction().serializable().run(|| { let user = lookup_user_by_token( LookupUserByToken { ...
code_fim
hard
{ "lang": "rust", "repo": "elba/website", "path": "/src/model/packages/action.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) }) } pub fn list_groups(_: ListGroups, conn: &Connection) -> Result<Vec<GroupName>, Error> { let group_names = { use crate::schema::groups::dsl::*; groups.select(group_name).load::<String>(conn)? }; let group_names: Vec<_> = group_names .into_iter(...
code_fim
hard
{ "lang": "rust", "repo": "elba/website", "path": "/src/model/packages/action.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stroberrysugar/home path: /src/commands/room/mod.rs mod add; pub mod create; mod forceadd; mod remove; mod rename; use serenity::{ client::Context, model::{ id::GuildId, interactions::{ApplicationCommandOptionType, Interaction}, }, }; pub async fn register(ctx: &Con...
code_fim
hard
{ "lang": "rust", "repo": "stroberrysugar/home", "path": "/src/commands/room/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> .description("The channel to add the user to") .kind(ApplicationCommandOptionType::Channel) .required(true) }) .create_sub_option(|o| { o.name("user") ...
code_fim
hard
{ "lang": "rust", "repo": "stroberrysugar/home", "path": "/src/commands/room/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yuyoyuppe/rust path: /src/libpanic_unwind/miri.rs #![allow(nonstandard_style)] use core::any::Any; use alloc::boxed::Box; pub fn payload() -> *mut u8 { core::ptr::null_mut() } pub unsafe fn panic(data: Box<dyn Any + Send>) -> ! { core::intrinsics::miri_start_panic(Box::into_raw(data))...
code_fim
hard
{ "lang": "rust", "repo": "yuyoyuppe/rust", "path": "/src/libpanic_unwind/miri.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg_attr(not(test), lang = "eh_catch_typeinfo")] static mut TYPE_DESCRIPTOR: _TypeDescriptor = _TypeDescriptor { pVFTable: core::ptr::null(), spare: core::ptr::null_mut(), name: TYPE_NAME, };<|fim_prefix|>// repo: yuyoyuppe/rust path: /src/libpanic_unwind/miri.rs #![allow(nonstandard_style)...
code_fim
hard
{ "lang": "rust", "repo": "yuyoyuppe/rust", "path": "/src/libpanic_unwind/miri.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> output.end()?; Ok(()) } fn process() -> Result<(), String> { let args: Vec<String> = args().skip(1).collect(); let usage_str = "usage: $action create|apply [...args]".to_string(); if args.is_empty() { return Err(usage_str); } let action = args[0].clone(); match action.as_ref() { "measure" => ...
code_fim
hard
{ "lang": "rust", "repo": "baitcenter/psd_lib", "path": "/src/bin_diff.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: baitcenter/psd_lib path: /src/bin_diff.rs //! psd_diff binary //! //! Creates or applies diff of psd file //! //! ``` //! usage: //! $: psd_diff measure|create|apply|combine [...args] //! //! $: psd_diff measure [--in-bytes] file_a.psd file_b.psd //! --in-bytes: output size in bytes instead ...
code_fim
hard
{ "lang": "rust", "repo": "baitcenter/psd_lib", "path": "/src/bin_diff.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[wasm_bindgen] pub fn encode(v: &JsValue) -> Vec<u8> { set_console_error_panic_hook(); bincode::serialize(&v.into_serde::<serde_json::Value>().unwrap().to_string()).unwrap() }<|fim_prefix|>// repo: juzi5201314/deno-bincode path: /src/lib.rs use wasm_bindgen::prelude::*; #[global_allocator] stat...
code_fim
hard
{ "lang": "rust", "repo": "juzi5201314/deno-bincode", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: juzi5201314/deno-bincode path: /src/lib.rs use wasm_bindgen::prelude::*; #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; <|fim_suffix|>#[wasm_bindgen] pub fn decode(data: Vec<u8>) -> JsValue { set_console_error_panic_hook(); JsValue::from_serde::<serd...
code_fim
medium
{ "lang": "rust", "repo": "juzi5201314/deno-bincode", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: imsnif/tui-rs path: /src/widgets/canvas/line.rs use super::Shape; use crate::style::Color; /// Shape to draw a line from (x1, y1) to (x2, y2) with the given color pub struct Line { pub x1: f64, pub y1: f64, pub x2: f64, pub y2: f64, pub color: Color, } pub struct LineIterat...
code_fim
medium
{ "lang": "rust", "repo": "imsnif/tui-rs", "path": "/src/widgets/canvas/line.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> IntoIterator for &'a Line { type Item = (f64, f64); type IntoIter = LineIterator; fn into_iter(self) -> Self::IntoIter { let dx = self.x1.max(self.x2) - self.x1.min(self.x2); let dy = self.y1.max(self.y2) - self.y1.min(self.y2); let dir_x = if self.x1 <= self....
code_fim
hard
{ "lang": "rust", "repo": "imsnif/tui-rs", "path": "/src/widgets/canvas/line.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BitcoinUnlimited/ElectrsCash path: /src/timeout.rs use crate::errors::*; use std::time::{Duration, Instant}; pub struct TimeoutTrigger { start: Instant, timeout: Duration, } <|fim_suffix|> let timeout = TimeoutTrigger::new(Duration::from_millis(50)); assert!(!timeout.che...
code_fim
hard
{ "lang": "rust", "repo": "BitcoinUnlimited/ElectrsCash", "path": "/src/timeout.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn check(&self) -> Result<()> { if self.start.elapsed() >= self.timeout { return Err(ErrorKind::RpcError(RpcErrorCode::Timeout, "Timeout".into()).into()); } Ok(()) } } #[cfg(test)] mod tests { use super::*; use std::thread::sleep; #[test] f...
code_fim
medium
{ "lang": "rust", "repo": "BitcoinUnlimited/ElectrsCash", "path": "/src/timeout.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let timeout = TimeoutTrigger::new(Duration::from_millis(50)); assert!(!timeout.check().is_err()); sleep(Duration::from_millis(50)); assert!(timeout.check().is_err()); } }<|fim_prefix|>// repo: BitcoinUnlimited/ElectrsCash path: /src/timeout.rs use crate::errors::*; use...
code_fim
hard
{ "lang": "rust", "repo": "BitcoinUnlimited/ElectrsCash", "path": "/src/timeout.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[doc(hidden)] impl From<Message> for tokio_tungstenite::tungstenite::Message { fn from(msg: Message) -> Self { use tokio_tungstenite::tungstenite::Message::*; match msg { Message::Text(data) => Text(data), Message::Binary(data) => Binary(data), Mes...
code_fim
hard
{ "lang": "rust", "repo": "happysalada/poem", "path": "/poem/src/web/websocket/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }