commit | c74636f6b4a77d0103e9971d984407bff8ddc5f0 | [log] [tgz] |
---|---|---|
author | Chih-Hung Hsieh <chh@google.com> | Mon May 18 18:45:33 2020 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Mon May 18 18:45:33 2020 +0000 |
tree | c0d427205c0f0002d86155721cc4f8de67c4fbe5 | |
parent | 2e1ed433d835e9f8409237243b8c03b0be6a1310 [diff] | |
parent | 0d926734e2aa57fe7349adf1bd4e2499403998ec [diff] |
Import 'pin-project' package version 0.4.16 am: 6f3e9271b1 am: 0d926734e2 Change-Id: I0504abb58778bbeb24f2677e3d8d993852a23f86
A crate for safe and ergonomic pin-projection.
Add this to your Cargo.toml
:
[dependencies] pin-project = "0.4"
The current pin-project requires Rust 1.34 or later.
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(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
See API documentation for more details.
Also, there are examples and generated code of each feature in examples directory.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.