I think what I want is specialization in Rust. But I'm not sure if that's actually what I want. E.g. I want to be able to define some method. But then if certain conditions apply define a different, more efficient method with the same signature. That's... specialization right?
Oh yeah, the related static version would be: fn foo(arg: impl SomeTrait) {} What I'm talking about is: impl<T: Debug> Foo {} impl<T: Debug + Display> Foo {} Ths is not allowed because the implementations overlap. But with specialization one could be picked.
-
-
(I hope I'm doing an okay job explaining this -- just learned a bunch about this haha)
-
Ah so it’s having it choose the most narrow definition that matches?
- 7 more replies
New conversation -
-
-
A faster, rougher, solution in the type system would be allowing for negative bounds on all traits not just the auto-traits Debug + ! Display and Debug + Display do not overlap Personally, I'm of the opinion that we should implement CSS specificity rules.
- End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.