Local Default Bounds to assist Forget and other ?Trait.#3783
Local Default Bounds to assist Forget and other ?Trait.#3783Ddystopia wants to merge 12 commits intorust-lang:masterfrom
Forget and other ?Trait.#3783Conversation
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! |
Co-authored-by: Jack Rickard <jack.rickard@outlook.com>
#t-lang > The destruction guarantee and linear types formulation @ 💬 I have found this RFC to lack a good justification for breaking Rust language ergonomics in this way. |
|
I suspect solving the "default" problem is not sufficient. We also need a way to switch modes within a module, which an effect-like system may be better suited for. This might imply something like a modifier syntax: |
|
@tmandry I'm not sure about the motivation. Can you please explain why do we need a way to switch modes within a module? This RFC is not 100% ultra-generic solution, but more like an attempt to give a specific solution to the specific problem. Do you suggest it will allow better backwards compatibility? |
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
?Traitannotations while maintaining backward compatibility and enabling future language evolution.It is targeted at supporting migrations from default being
Traitto?Trait, whereTraitrepresents some assumption that is present everywhere but is not really exercised a lot, such asForget,size = strideetc. Features likeDynSized, as well asextern types, are out of the scope of this RFC, because it does not fit into this category.DynSizedis not retracting mostly unexercised assumptions in order to make it?DynSizedthe default.Primary use case is
Forgetmarker trait.Rendered
Pre-RFC thread