pub struct AssertSafe<T> { /* private fields */ }
Expand description
A type for pointers that cannot uphold the necessary guard invariants at the type level, but which can be assumed to behave properly by unsafe code.
Implementations§
Source§impl<T> AssertSafe<T>where
T: Deref,
impl<T> AssertSafe<T>where
T: Deref,
Sourcepub unsafe fn new_unchecked(inner: T) -> Self
pub unsafe fn new_unchecked(inner: T) -> Self
Wrap a general-purpose pointer into a wrapper that implements the Guarded
(and
potentially GuardedMut
) traits, provided that the pointer upholds this invariants anyway.
§Safety
For the guard invariants to be upheld, the pointer must:
- dereference into a stable location. This forbids types that implement
Deref
by borrowing data that they own without a heap-based container in between; - be owned. Any type that has a shorter lifetime than
'static
, may have its borrow cancelled at any time, with the original borrowed data accessible again.
Trait Implementations§
Source§impl<T: Debug> Debug for AssertSafe<T>
impl<T: Debug> Debug for AssertSafe<T>
Source§impl<T, U> Guarded for AssertSafe<T>
impl<T, U> Guarded for AssertSafe<T>
Source§type Target = U
type Target = U
The target pointee that this pointer may dereference into. There are no real restrictions
to what this type can be. However, the user must not assume that simply because a
&Target
reference is protected, that references indirectly derived (via Deref
and other traits)
would also be protected.Source§fn borrow_guarded(&self) -> &Self::Target
fn borrow_guarded(&self) -> &Self::Target
Borrow the pointee, into a fixed reference that can be sent directly and safely to e.g.
memory-sharing completion-based I/O interfaces. Read more
Source§impl<T, U> GuardedMut for AssertSafe<T>
impl<T, U> GuardedMut for AssertSafe<T>
Source§fn borrow_guarded_mut(&mut self) -> &mut Self::Target
fn borrow_guarded_mut(&mut self) -> &mut Self::Target
Borrow the pointee mutably, into a fixed reference that can be sent directly and safely to
e.g. memory-sharing completion-based I/O interfaces. Read more
Auto Trait Implementations§
impl<T> Freeze for AssertSafe<T>where
T: Freeze,
impl<T> RefUnwindSafe for AssertSafe<T>where
T: RefUnwindSafe,
impl<T> Send for AssertSafe<T>where
T: Send,
impl<T> Sync for AssertSafe<T>where
T: Sync,
impl<T> Unpin for AssertSafe<T>where
T: Unpin,
impl<T> UnwindSafe for AssertSafe<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more