[−][src]Crate pin_project
A crate for safe and ergonomic pin-projection.
This crate provides the following attribute macros:
pin_project
- An attribute that creates a projection struct covering all the fields.pinned_drop
- An attribute for annotating a function that implementsDrop
.project
- An attribute to support pattern matching.
Examples
pin_project
attribute creates a projection struct covering all the fields.
use pin_project::pin_project; use std::pin::Pin; #[pin_project] struct Struct<T, U> { #[pin] pinned: T, unpinned: U, } impl<T, U> Struct<T, U> { fn foo(mut self: Pin<&mut Self>) { let this = self.project(); let _: Pin<&mut T> = this.pinned; // Pinned reference to the field let _: &mut U = this.unpinned; // Normal reference to the field } }
Code like this will be generated
There are examples and generated code of each feature in examples directory.
Traits
UnsafeUnpin | A trait used for custom implementations of |