Struct alloc::boxed::PinBox [−][src]
#[repr(transparent)]pub struct PinBox<T: ?Sized> { /* fields omitted */ }
A pinned, heap allocated reference.
Methods
impl<T> PinBox<T>
[src]
impl<T> PinBox<T>
impl<T: ?Sized> PinBox<T>
[src]
impl<T: ?Sized> PinBox<T>
pub fn as_pin_mut<'a>(&'a mut self) -> PinMut<'a, T>
[src]
pub fn as_pin_mut<'a>(&'a mut self) -> PinMut<'a, T>
Get a pinned reference to the data in this PinBox.
pub unsafe fn from_raw(raw: *mut T) -> Self
[src]
pub unsafe fn from_raw(raw: *mut T) -> Self
Constructs a PinBox
from a raw pointer.
After calling this function, the raw pointer is owned by the
resulting PinBox
. Specifically, the PinBox
destructor will call
the destructor of T
and free the allocated memory. Since the
way PinBox
allocates and releases memory is unspecified, the
only valid pointer to pass to this function is the one taken
from another PinBox
via the PinBox::into_raw
function.
This function is unsafe because improper use may lead to memory problems. For example, a double-free may occur if the function is called twice on the same raw pointer.
Examples
#![feature(pin)] use std::boxed::PinBox; let x = PinBox::new(5); let ptr = PinBox::into_raw(x); let x = unsafe { PinBox::from_raw(ptr) };
pub fn into_raw(b: PinBox<T>) -> *mut T
[src]
pub fn into_raw(b: PinBox<T>) -> *mut T
Consumes the PinBox
, returning the wrapped raw pointer.
After calling this function, the caller is responsible for the
memory previously managed by the PinBox
. In particular, the
caller should properly destroy T
and release the memory. The
proper way to do so is to convert the raw pointer back into a
PinBox
with the PinBox::from_raw
function.
Note: this is an associated function, which means that you have
to call it as PinBox::into_raw(b)
instead of b.into_raw()
. This
is so that there is no conflict with a method on the inner type.
Examples
#![feature(pin)] use std::boxed::PinBox; let x = PinBox::new(5); let ptr = PinBox::into_raw(x);
pub unsafe fn get_mut<'a>(this: &'a mut PinBox<T>) -> &'a mut T
[src]
pub unsafe fn get_mut<'a>(this: &'a mut PinBox<T>) -> &'a mut T
Get a mutable reference to the data inside this PinBox.
This function is unsafe. Users must guarantee that the data is never moved out of this reference.
ⓘImportant traits for Box<I>pub unsafe fn unpin(this: PinBox<T>) -> Box<T>
[src]
pub unsafe fn unpin(this: PinBox<T>) -> Box<T>
Convert this PinBox into an unpinned Box.
This function is unsafe. Users must guarantee that the data is never moved out of the box.
Trait Implementations
impl<T: ?Sized> From<Box<T>> for PinBox<T>
[src]
impl<T: ?Sized> From<Box<T>> for PinBox<T>
impl<T: Unpin + ?Sized> From<PinBox<T>> for Box<T>
[src]
impl<T: Unpin + ?Sized> From<PinBox<T>> for Box<T>
impl<T: ?Sized> Deref for PinBox<T>
[src]
impl<T: ?Sized> Deref for PinBox<T>
type Target = T
The resulting type after dereferencing.
fn deref(&self) -> &T
[src]
fn deref(&self) -> &T
Dereferences the value.
impl<T: Unpin + ?Sized> DerefMut for PinBox<T>
[src]
impl<T: Unpin + ?Sized> DerefMut for PinBox<T>
impl<T: Display + ?Sized> Display for PinBox<T>
[src]
impl<T: Display + ?Sized> Display for PinBox<T>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: Debug + ?Sized> Debug for PinBox<T>
[src]
impl<T: Debug + ?Sized> Debug for PinBox<T>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: ?Sized> Pointer for PinBox<T>
[src]
impl<T: ?Sized> Pointer for PinBox<T>
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<PinBox<U>> for PinBox<T>
[src]
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<PinBox<U>> for PinBox<T>
impl<T: ?Sized> Unpin for PinBox<T>
[src]
impl<T: ?Sized> Unpin for PinBox<T>
impl<'a, F: ?Sized + Future> Future for PinBox<F>
[src]
impl<'a, F: ?Sized + Future> Future for PinBox<F>
type Output = F::Output
🔬 This is a nightly-only experimental API. (futures_api
#50547)
futures in libcore are unstable
The result of the Future
.
fn poll(self: PinMut<Self>, cx: &mut Context) -> Poll<Self::Output>
[src]
fn poll(self: PinMut<Self>, cx: &mut Context) -> Poll<Self::Output>
🔬 This is a nightly-only experimental API. (futures_api
#50547)
futures in libcore are unstable
Attempt to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more
impl<F: Future<Output = ()> + Send + 'static> UnsafeTask for PinBox<F>
[src]
impl<F: Future<Output = ()> + Send + 'static> UnsafeTask for PinBox<F>
fn into_raw(self) -> *mut ()
[src]
fn into_raw(self) -> *mut ()
🔬 This is a nightly-only experimental API. (futures_api
#50547)
futures in libcore are unstable
Convert a owned instance into a (conceptually owned) void pointer.
unsafe fn poll(task: *mut (), cx: &mut Context) -> Poll<()>
[src]
unsafe fn poll(task: *mut (), cx: &mut Context) -> Poll<()>
🔬 This is a nightly-only experimental API. (futures_api
#50547)
futures in libcore are unstable
Poll the task represented by the given void pointer. Read more
unsafe fn drop(task: *mut ())
[src]
unsafe fn drop(task: *mut ())
🔬 This is a nightly-only experimental API. (futures_api
#50547)
futures in libcore are unstable
Drops the task represented by the given void pointer. Read more
impl<F: Future<Output = ()> + Send + 'static> From<PinBox<F>> for TaskObj
[src]
impl<F: Future<Output = ()> + Send + 'static> From<PinBox<F>> for TaskObj