summaryrefslogtreecommitdiff
path: root/crates/utils
diff options
context:
space:
mode:
authorNathan Ringo <nathan@remexre.com>2024-09-04 02:19:32 -0500
committerNathan Ringo <nathan@remexre.com>2024-09-04 02:19:32 -0500
commitcbee8b7dde708164081fdb979e2b96740ba516a6 (patch)
treef18bcf8da431d85fb09c4f3884de85a739edc860 /crates/utils
parentc27e5ca6bf2b4040abd628ef59f8a3bc9326749c (diff)
Enables paging.
Diffstat (limited to 'crates/utils')
-rw-r--r--crates/utils/src/lib.rs25
1 files changed, 24 insertions, 1 deletions
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<T>(pub T);
+
+impl<T> Deref for BelieveMeSend<T> {
+ type Target = T;
+
+ fn deref(&self) -> &T {
+ &self.0
+ }
+}
+
+impl<T> DerefMut for BelieveMeSend<T> {
+ fn deref_mut(&mut self) -> &mut T {
+ &mut self.0
+ }
+}
+
+unsafe impl<T> Send for BelieveMeSend<T> {}
+
/// 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.