Closed
Description
Wanting to limit your splits to a certain number suddenly requires the pattern to implement DoubleEndedSearcher
, so the following code fragment using strings as splits fails:
fn main() {
let v1: Vec<_> = "test::thing::test".split("::").collect();
let v2: Vec<_> = "test::thing::test".splitn(1, "::").collect();
}
With:
<anon>:3:54: 3:63 error: type `core::str::SplitN<'_, &str>` does not implement any method in scope named `collect`
<anon>:3 let v2: Vec<_> = "test:thing:test".splitn(1, ":").collect();
^~~~~~~~~
I would expect both of them to have pretty much the same requirements as for the pattern argument.
Metadata
Metadata
Assignees
Labels
No labels