Macro unsafe_pinned
macro_rules! unsafe_pinned {
($f:tt: $t:ty) => { ... };
}
A pinned projection of a struct field.
Safety
To make using this macro safe, three things need to be ensured:
- If the struct implements
Drop, thedropmethod is not allowed to move the value of the field. - If the struct wants to implement
Unpin, it has to do so conditionally: The struct can only implementUnpinif the field's type isUnpin. - The struct must not be
#[repr(packed)].
Example
use unsafe_pinned;
use Unpin;
use Pin;
// Conditional Unpin impl
Note: borrowing the field multiple times requires using .as_mut() to
avoid consuming the Pin.