pin-project
pin-project copied to clipboard
A crate for safe and ergonomic pin-projection.
pin-project provides an appropriate Unpin implementation by default. Since overlapping implementations are prohibited, this ensures that users cannot add inappropriate Unpin implementations. However, currently, this guarantee can be broken by...
Suppose I have the following trait definition: ```rs trait Trait {} impl Trait for T {} ``` And I use it from another crate. Then this will not have overlapping...
Since rust 1.57 it is possible to put proc macro attributes after derive (see https://github.com/rust-lang/rust/issues/81119) so given proc macro crate like that: ```rust use proc_macro::TokenStream; use syn::{parse_macro_input, parse_quote, ItemStruct}; use...
It might be nice with a section mentioning the often overlooked standard library APIs such as `Option::as_pin_mut` (e.g., https://twitter.com/fasterthanlime/status/1377229099622662146, https://github.com/hyperium/tonic/pull/1377, https://github.com/tower-rs/tower/pull/316#discussion_r319770004), `Pin::as_mut` (e.g., https://github.com/taiki-e/pin-project/issues/345), `Pin::set` (e.g., https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/.60Pin.60.20used.20for.20encapsulation/near/300322988, https://github.com/tower-rs/tower/pull/323#discussion_r322239400), etc., and...
The following currently works: ```rust use pin_project::pin_project; use core::future::Future; #[pin_project] struct Pinned(#[pin] A, #[pin] B); ``` But this doesn't: ```rust use pin_project::pin_project; use core::future::Future; #[pin_project] struct Pinned { futures: (#[pin]...
I think pin-project could provide a safe method from `Pin` to `Option` which is a mix of `Option::take`, `Pin::set(..., None)` and `project_replace`. I imagine it could look something like this:...
Behavior on existing syntax is kept as is. The new syntax look like this: ```rust # use pin_project::pin_project #[pin_project(pub project = StructProj)] //force the project method and StructProj to be...
I would like, eventually as an option, to make the .project method and ProjectionRef struct public My use case is a user-defined callback, tacking as argument a Pin MyStruct have...
this seems like a big ask, and my solution introduces a lot of types, but it would help making pin projection and pin_replace much simpler in user code. here is...