You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In particular, making Iterator::position generic over a Predicate trait would help replacing [T]::position_elem, which was deprecated in #26914, without the verbosity of .position(|i| i == &x)
This should sync method names with &str and their pattern API if possible IMO, and futher API inspiration from there as well. The substring search algorithm we use does in theory work on all "orderable alphabets".
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 () -> T being ByNeed<Self> and ByNeed<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 #[fundamental], adding explicit "low-priority" impls to specialization, or introducing negative bounds.
(To be clear, the reason the example fails to compile is that in principle you could have &T: Fn(&T) -> bool, in which case both impls would apply; specialization as proposed doesn't help because neither impl is strictly more general. But since the relevant types/traits here are marked #[fundamental], some negative reasoning is already permitted, and if we took full advantage might be enough to work around this limitation.)
Activity
bluss commentedon Aug 4, 2015
This should sync method names with
&strand their pattern API if possible IMO, and futher API inspiration from there as well. The substring search algorithm we use does in theory work on all "orderable alphabets".Gankra commentedon Aug 4, 2015
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
() -> TbeingByNeed<Self>andByNeed<T>aturon commentedon Aug 4, 2015
Yeah, for example, the following fails to compile:
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
#[fundamental], adding explicit "low-priority" impls to specialization, or introducing negative bounds.aturon commentedon Aug 4, 2015
(To be clear, the reason the example fails to compile is that in principle you could have
&T: Fn(&T) -> bool, in which case both impls would apply; specialization as proposed doesn't help because neither impl is strictly more general. But since the relevant types/traits here are marked#[fundamental], some negative reasoning is already permitted, and if we took full advantage might be enough to work around this limitation.)alexcrichton commentedon Feb 18, 2016
Lots of time has passed since these were originally designed, so they would likely basically require another RFC to be added today, so closing.