Macro futures::unsafe_pinned[][src]

macro_rules! unsafe_pinned {
    ($f:tt: $t:ty) => { ... };
}

A pinned projection of a struct field.

To make using this macro safe, two things need to be ensured:

struct Foo<T> {
    field: T,
}

impl<T> Foo<T> {
    unsafe_pinned!(field: T);

    fn baz(mut self: PinMut<Self>) {
        let _: PinMut<T> = self.field(); // Pinned reference to the field
    }
}

impl<T: Unpin> Unpin for Foo<T> {}; // Conditional Unpin impl