Remove change I am faaairly certain I did NOT add :O

I'm guessing it's some issue after a rebase or something...
This commit is contained in:
jD91mZM2
2019-07-01 22:50:19 +00:00
committed by Jeremy Soller
parent 42f977e7da
commit effe02bd45
16 changed files with 881 additions and 181 deletions
+1
View File
@@ -1,2 +1,3 @@
#[macro_use]
pub mod int_like;
pub mod unique;
+33
View File
@@ -0,0 +1,33 @@
use core::{fmt, ptr::NonNull};
/// A small wrapper around NonNull<T> that is Send + Sync, which is
/// only correct if the pointer is never accessed from multiple
/// locations across threads. Which is always, if the pointer is
/// unique.
pub struct Unique<T>(NonNull<T>);
impl<T> Copy for Unique<T> {}
impl<T> Clone for Unique<T> {
fn clone(&self) -> Self {
*self
}
}
unsafe impl<T> Send for Unique<T> {}
unsafe impl<T> Sync for Unique<T> {}
impl<T> Unique<T> {
pub fn new(ptr: *mut T) -> Self {
Self(NonNull::new(ptr).unwrap())
}
pub unsafe fn new_unchecked(ptr: *mut T) -> Self {
Self(NonNull::new_unchecked(ptr))
}
pub fn as_ptr(&self) -> *mut T {
self.0.as_ptr()
}
}
impl<T> fmt::Debug for Unique<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self.0)
}
}