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
Several methods on the str type take a generic "predicate" on characters:
split and friends
trim_chars and friends
find and friends
The CharEq trait makes character predicates convenient by providing instances for char, various char -> bool function types, and slices of characters.
Vector slices should provide a similar interface. Right now, some of the relevant slice methods operate on individual items, while others take bool-producing functions.
Unfortunately, this is blocked on trait reform (#5527).
The text was updated successfully, but these errors were encountered:
It's unclear to me if this is possible to implement to get exactly the same sort of API as str, since there element type is very generic, and so impls overlap, e.g.:
Yes, this is a pretty old issue and filed before the final overlapping rules became clear. (I think it might have been workable before unboxed closures, and could perhaps be made to work with negative bounds, but @Kimundi's approach is nicer in any case).
Several methods on the
str
type take a generic "predicate" on characters:split
and friendstrim_chars
and friendsfind
and friendsThe
CharEq
trait makes character predicates convenient by providing instances forchar
, variouschar -> bool
function types, and slices of characters.Vector slices should provide a similar interface. Right now, some of the relevant slice methods operate on individual items, while others take
bool
-producing functions.Unfortunately, this is blocked on trait reform (#5527).
The text was updated successfully, but these errors were encountered: