-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Should the drop method take mutable self? #4514
Comments
Maybe I'm being dense, but why would you want to mutate |
That's a good question! The specific scenario I have in mind is for failure recovery of actors. Imagine you have some type that represents the actor state, and it contains a
As an actor, this port is your lifeline to the rest of the world. So the actor is sitting in its task processing events and one of them fails. Most actor systems have one or more recovery and restart strategies. Some of them may preserve the local state and resume processing at the next message, some may assume the state has been corrupted and resume processing messages from scratch. In Rust I have decided that implementing actor recovery is best done by shipping the
|
Thanks for the clear explanation! |
Related: #4330 (taking self by-value in finalize), which would also allow moving out of self |
I'd propose closing this as WONTFIX in favour of #4330 -- while that bug requires us to come up with an extra rule to prevent multiple destruction (eg. "only a destructuring move is allowed in dtor") it also means we don't have to fill destroyable objects with options and permit that many more invalid runtime states. @brson are you ok with that? |
@graydon yes |
Every time I write a destructor I think this looks wrong:
So far I've been able to avoid mutating self in destructors but I must assume there are cases where it's important.
The text was updated successfully, but these errors were encountered: