From cbee8b7dde708164081fdb979e2b96740ba516a6 Mon Sep 17 00:00:00 2001 From: Nathan Ringo Date: Wed, 4 Sep 2024 02:19:32 -0500 Subject: Enables paging. --- crates/utils/src/lib.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'crates/utils/src') diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index 3649666..6e26317 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -1,7 +1,11 @@ //! Common utilities. #![no_std] -use core::{fmt, mem::size_of}; +use core::{ + fmt, + mem::size_of, + ops::{Deref, DerefMut}, +}; /// Creates an ad-hoc `Debug` instance. pub fn debug(f: impl Fn(&mut fmt::Formatter) -> fmt::Result) -> impl fmt::Debug { @@ -66,6 +70,25 @@ macro_rules! dbg { }; } +/// A wrapper type that promises that its contents are Send. +pub struct BelieveMeSend(pub T); + +impl Deref for BelieveMeSend { + type Target = T; + + fn deref(&self) -> &T { + &self.0 + } +} + +impl DerefMut for BelieveMeSend { + fn deref_mut(&mut self) -> &mut T { + &mut self.0 + } +} + +unsafe impl Send for BelieveMeSend {} + /// A trait for types that can be converted to from big-endian or little-endian byte slices. pub trait FromEndianBytes { /// Converts from a big-endian byte slice. -- cgit v1.2.3