-
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
Add ByNeed
and Predicate
traits
#27517
Comments
This should sync method names with |
To my knowledge ByNeed and Predicate were totally busted and are unimplementable because of mumble mumble something something overlapping implementation stuff. In particular this RFC was merged while closures were known to be Boxed which somehow avoided conflicts. Now unboxed closures exist so everything falls apart. Not even specialization is supposed to be able to fix this. This is all vague out-of-cache memory though, @aturon should be able to recall the precise details if pressed. Something about |
Yeah, for example, the following fails to compile: trait Foo<T> {}
impl<T, U> Foo<U> for T where T: Fn(&U) -> bool {}
impl<'a, T> Foo<T> for &'a T {} and as @gankro mentioned I was hoping specialization would solve it, but doing so requires some crazypants rules. Still, there are other ways to address this, possibly including getting the compiler to reason more about |
(To be clear, the reason the example fails to compile is that in principle you could have |
Lots of time has passed since these were originally designed, so they would likely basically require another RFC to be added today, so closing. |
#18424 "Implement collections reform" was closed with one part left not implemented yet:
In particular, making
Iterator::position
generic over aPredicate
trait would help replacing[T]::position_elem
, which was deprecated in #26914, without the verbosity of.position(|i| i == &x)
CC @alexcrichton, @aturon
The text was updated successfully, but these errors were encountered: