-
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
Forget
marker trait
#3782
base: master
Are you sure you want to change the base?
Forget
marker trait
#3782
Conversation
This definitely seems to be a reasonably motivated RFC, although it's going to definitely be something I'll have to read through a lot more closely to fully comment on it. A few first impressions:
Again, I do want to go through this a bit more closely before fully commenting on it, but I think that you definitely need to go back and make the primary motivation for this crystal clear: because of Generally, the only way to deal with this is to make these calls unsafe and tell people to pinky-promise they run the future to completion, but it would be nice to be able to have a safe way to do this instead. |
@clarfonthey We do use verbs as trait name when the only purpose of the trait is to support that verb, think of |
This is definitely a much desired feature that would enable new safe design patterns in Rust. Having a gradual migration path with I appreciate all the links to the prior art. |
# Guide-level explanation | ||
[guide-level-explanation]: #guide-level-explanation | ||
|
||
The core goal of `Forget` trait, as proposed in that RFC, is to bring back the "Proxy Guard" idiom for non-static types, with `async` being the primary motivation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand correctly that all !Forget
types need to have a lifetime bound to have any effect? Does it ever make sense to have a !Forget
type that has no lifetime? (like an integer)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s correct. Non-Forget
types must be dropped before their lifetime ends
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the perspective of use cases and definitions, it really makes little sense to have !Forget
and 'static
together. But I am not opposed too, it may have some other benefits which I am not aware of / or implementational / migrational benefits.
# Unresolved questions | ||
[unresolved-questions]: #unresolved-questions | ||
|
||
- [ ] Maybe the name `Forget` is misleading, as its core is around the `unsafe` guarantee of borrowed resources and the destructor. `IndirectPin`? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not mix it with Pin
. Pin
is an advanced concept needed only for certain niches, so for many users it may not clarify the meaning, but rather connect it to something they're unfamiliar with. There are also proposals for integrating Pin
more into Rust's syntax, so the Pin
itself may become even less visible in the future.
I assume that Forget
may appear more often in the API surface. It may eventually be easier to teach Pin
in terms of !Forget
than the other way.
Add a
Forget
marker trait indicating whether it is safe to skip the destructor before the value of a type exits the scope and basic utilities to work with!Forget
types. Introduce a seamless migration route for the standard library and ecosystem.Rendered
Pre-RFC thread