-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider allowing naming the projected type #124
Comments
At this time I don't have a strong opinion about whether this should be added, but I am a bit concerned that this can complicate the API. |
Given that Maybe something like this: #[pin_project(project = FooProj, project_ref = FooProjRef)]
struct Foo<T> {
#[pin]
x T: ,
}
impl<T> Foo<'_, T> {} (It should be mentioned in the documentation that a lifetime is added to the first position in generics.) |
211: Hide generated items from --document-private-items r=taiki-e a=taiki-e All of the generated items are private items, but it can be displayed in the document by using the `--document-private-items` flag. Naming will be allowed by #202, so it would probably be preferable to only display it in the document if the user did a naming. cc #124 #202 Related: #192 Co-authored-by: Taiki Endo <[email protected]>
One of the cases that current #[pin_project::pin_project(Replace)]
enum E<T, U> {
A(#[pin] T),
B(U),
C,
}
fn foo<T, U>(e: Pin<&mut E<T, Y>>) {
if let E::A(_a) = e.project() { // needs #[project]
// ..
} else if E::B(_b) = e.project_replace(E::C) { // needs #[project_replace]
//
}
} |
Oh, it seems I forgot to do this in #202. |
Currently, all ways for referring the projected type are provided by the
#[project]
attribute.Ideally, I would like to write using inherent associated types (rust-lang/rust#8995) or generic associated types (rust-lang/rust#44265) as follows, but neither has been implemented yet:
As implementing these features will take time (it seems that at least Chalk integration is necessary), we may allow naming as an alternative at this time.
I think there are two ways to provide these:
Provide way to refer to projected type #43 (comment)
Add use statements support to #[project] attribute #85 (comment)
pin-project/pin-project-internal/src/project.rs
Line 240 in 4803d04
Related: #43
The text was updated successfully, but these errors were encountered: