commit | 1d510e53caa3d34444a6bbb9d18d0e73c4fd6390 | [log] [tgz] |
---|---|---|
author | Xin Li <delphij@google.com> | Thu Aug 27 20:24:07 2020 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Thu Aug 27 20:24:07 2020 +0000 |
tree | 8dda06cd32bb36663b6e07187b5a8e8d65660422 | |
parent | ee6921fd0b1c9f34b58d141e7665469189a9d9a5 [diff] | |
parent | d0e8812871b88b0341b01d78642f06c0e98f3055 [diff] |
[automerger skipped] Mark Android R (rvc-dev-plus-aosp-without-vendor@6692709) as merged am: b488c1f1fe -s ours am: 2d228464bf -s ours am: f8a82d676e -s ours am: d0e8812871 -s ours am skip reason: Change-Id Ie4a78bba0bd08e8d063466d366d0d1264f2322e7 with SHA-1 f0c0cb6761 is in history Original change: https://googleplex-android-review.googlesource.com/c/platform/external/rust/crates/pin-project/+/12469320 Change-Id: Ia5d597954284fcde8ecc5eedc22b51fb0e71a84f
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 projection types covering all the fields of struct or enum.
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 method(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 documentation for more details, and see examples directory for more examples and generated code.
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.