-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
OnMove trait is much more general than Pin #2613
Comments
Please read previous discussions on |
@F001 Can you give a link? |
You can search in internals.rust-lang.org, for example: Pin related issues have been discussed for more than a year, I believe all the possibilities have been explored. Repeating deprecated ideas does not help. |
In this case I think the question is reasonable, yet extremely difficult to get a straight answer to just from searching past discussions, since there's so many more issues overlapping here than it might seem. So here's my high-level summary of why we went with Pin:
|
Also, there’s a lot of unsafe code out there that implements moves as a shallow byte copy. For example, call pushing to a |
We use
Pin
to support self referencing type.But what if we have a
OnMove
trait which define a methodfn on_move(&mut self)
. Then when we move an object,on_move
is called automatically.OnMove
trait is just likeDrop
trait, it's a part of the lifecycle of an object.To make the name
OnMove
andDrop
be the same pattern, we can name itMove
.Just an idea. If it's wrong, closed it.
The text was updated successfully, but these errors were encountered: