-
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
Local Default Bounds to assist Forget
and other ?Trait
.
#3783
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: kennytm <kennytm@gmail.com>
Another drawback is that (similar to
One situation where it could cause friction is when dependencies do not support #![default_trait_bounds(?Forget)]
fn frobnicate(x: impl ToString) {
other_crate::frobnicate(x); // error: `Forget` bound not satisfied
} That said, I like this proposal and think that the benefits outweigh the drawbacks. Thank you! |
[`DynSized`]: https://github.com/rust-lang/rfcs/pull/2984 | ||
[`extern types`]: https://github.com/rust-lang/rfcs/pull/1861 | ||
|
||
The syntax is to be bikeshedded, initially, it might be with a crate-level attributes. |
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.
What’s the advantage of starting with this being a crate-level attribute rather than a module-level attribute?
This RFC proposes a mechanism for crates to define default bounds on generics. By specifying these defaults at the crate level we can reduce the need for verbose and repetitive
?Trait
annotations while maintaining backward compatibility and enabling future language evolution.It is targeted at supporting migrations from default being
Trait
to?Trait
, whereTrait
represents some assumption that is present everywhere but is not really exercised a lot, such asForget
,size = stride
etc. Features likeDynSized
, as well asextern types
, are out of the scope of this RFC, because it does not fit into this category.DynSized
is not retracting mostly unexercised assumptions in order to make it?DynSized
the default.Primary use case is
Forget
marker trait.Rendered
Pre-RFC thread