#[repr(transparent)]
pub struct PinBox<T> where
T: ?Sized, { /* fields omitted */ }
🔬 This is a nightly-only experimental API. (
pin
#49150)
A pinned, heap allocated reference.
🔬 This is a nightly-only experimental API. (
pin
#49150)
Allocate memory on the heap, move the data into it and pin it.
🔬 This is a nightly-only experimental API. (
pin
#49150)
Get a pinned reference to the data in this PinBox.
🔬 This is a nightly-only experimental API. (
pin
#49150)
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.
#![feature(pin)]
use std::boxed::PinBox;
let x = PinBox::new(5);
let ptr = PinBox::into_raw(x);
let x = unsafe { PinBox::from_raw(ptr) };Run
🔬 This is a nightly-only experimental API. (
pin
#49150)
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.
#![feature(pin)]
use std::boxed::PinBox;
let x = PinBox::new(5);
let ptr = PinBox::into_raw(x);Run
🔬 This is a nightly-only experimental API. (
pin
#49150)
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.
[−]
🔬 This is a nightly-only experimental API. (
pin
#49150)
Convert this PinBox into an unpinned Box.
This function is unsafe. Users must guarantee that the data is never
moved out of the box.
[+]
[−]
Mutably dereferences the value.
[+]
type Output = <F as Future>::Output
🔬 This is a nightly-only experimental API. (futures_api
#50547)
futures in libcore are unstable
The result of the Future
.
[−]
🔬 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
[+]
[−]
🔬 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.
[−]
🔬 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
[−]
🔬 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
[+]
[+]
[+]
[+]
[+]
[−]
Formats the value using the given formatter.
[+]
type Target = T
The resulting type after dereferencing.
[−]
[+]