commit | 13d0a3da53db825bae3f54491f7faf7f3819667a | [log] [tgz] |
---|---|---|
author | Haibo Huang <hhb@google.com> | Mon Jul 27 23:05:05 2020 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Mon Jul 27 23:05:05 2020 +0000 |
tree | 8dda06cd32bb36663b6e07187b5a8e8d65660422 | |
parent | 94f760e4ccbda8cbce697efe4612222b9b1866b5 [diff] | |
parent | cd74b54f7023c55d3fb14536808206d07dcece7a [diff] |
Upgrade rust/crates/pin-project to 0.4.23 am: c9e44565a7 am: 28d5e708ab am: f7aac199df am: cd74b54f70 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/pin-project/+/1372183 Change-Id: Ia6036c2daf3bffebccd7452f85ee8e789c5b835d
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.