pub struct AliasedBox<T> { /* private fields */ }embedded_runtime only.Expand description
An owned heap allocation, like Box, but without Box’s unique-aliasing guarantee.
Moving a Box asserts that it is the only pointer to its contents (noalias),
invalidating raw pointers previously derived from them (e.g. under Stacked Borrows).
AliasedBox stores only a raw pointer, so it may be freely moved — such as into the
holder struct built by embedded_flow! — while InputStreams
and sink closures hold NonNull pointers into its contents.
The contents are never moved and never exposed as &mut (only Deref), so their
address is stable from construction until drop; this is what makes
as_pin sound.
Implementations§
Source§impl<T> AliasedBox<T>
impl<T> AliasedBox<T>
Sourcepub fn as_pin(&self) -> Pin<&T>
pub fn as_pin(&self) -> Pin<&T>
Returns the contents as a pinned reference.
This is safe because the contents are heap-allocated, never moved, and never
exposed mutably, so they remain at the same address until self is dropped
(at which point their destructor runs, upholding the Pin drop guarantee).
Trait Implementations§
Source§impl<T: Debug> Debug for AliasedBox<T>
impl<T: Debug> Debug for AliasedBox<T>
Source§impl<T> Deref for AliasedBox<T>
impl<T> Deref for AliasedBox<T>
Source§impl<T> Drop for AliasedBox<T>
impl<T> Drop for AliasedBox<T>
Auto Trait Implementations§
impl<T> !Send for AliasedBox<T>
impl<T> !Sync for AliasedBox<T>
impl<T> Freeze for AliasedBox<T>
impl<T> RefUnwindSafe for AliasedBox<T>where
T: RefUnwindSafe,
impl<T> Unpin for AliasedBox<T>where
T: Unpin,
impl<T> UnsafeUnpin for AliasedBox<T>
impl<T> UnwindSafe for AliasedBox<T>where
T: RefUnwindSafe + 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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more