-
-
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
Const projection from Pin<&Self>
#92
Comments
Pin always implements Deref, so you can access fields without projection (i.e, projection should not be necessary for your use-case). |
Ah, but the member of the struct are !Unpin themselves. And and would like to get pinned references to them. It should be safe if the containing struct is also in a pin. |
Just to be a bit more concrete, the use case is something like that:
Then, I'd put Container instance on the heap (typically in a |
Thanks for sharing about your use-case. It certainly seems like a use-case that requires pin-projection. However, as far as I know, most of the current use-cases of Pin API use |
The term "const" is very confusing here, that sounds like Sure, both make sense for projections, and both have their use-cases. Futures don't really need shared pinned references, but other cases like intrusive collections do. |
The standard suffix to identify self-by-shared-reference (if one is used) is Re other utilities: |
The I agree that |
Oh, you're right.
I agree with this. Adding this seems to make sense, so I will add |
By the way, maybe |
In my pet crate, i have to work a lot with Pin<&T> but without the mut (because it uses Cell internally, but nothing to do with futures). And i end up needing to do lots of projections.
Would it make sense for the macro to also have a
project_const(self: Pin<&'a Self>) -> FooProjectionConst<'a>
?(Actually, I feel like it should just be
project()
, and the current &mut Self should be renamedproject_mut
for consistency with all the other functions that overload const/mut)Is that something that make sense, or is using Pin<&Self> not a common pattern?
The text was updated successfully, but these errors were encountered: