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
{{ message }}
Repository navigation
Implement SliceConcatExt for any iterable of string slices, not just Slice and Vec #1137
Currently, these work (they both return "foo foo foo", as you'd expect):
["foo";3].connect(" ")vec!["foo";3].connect(" ")
But these do not:
// type `collections::linked_list::LinkedList<&str>` does not implement any method in scope named `connect`LinkedList::from_iter(repeat("foo").take(3)).connect(" ")// type `core::iter::Take<core::iter::Repeat<&str>>` does not implement any method in scope named `connect`
repeat("foo").take(3).connect(" ")
I think coherence should allow it. Note that the slice versions iterate twice, to calculate the needed allocation exactly before concat. The iterator version can't do that, so it will be less efficient that way.
Note that the slice versions iterate twice, to calculate the needed allocation exactly before concat. The iterator version can't do that, so it will be less efficient that way.
This got me thinking: if the ability to iterate twice is sufficient, could the methods be bounded on Self: Clone? This should preserve the efficiency while relaxing the requirements.
Activity
bluss commentedon May 30, 2015
I think coherence should allow it. Note that the slice versions iterate twice, to calculate the needed allocation exactly before concat. The iterator version can't do that, so it will be less efficient that way.
gkoz commentedon May 31, 2015
This got me thinking: if the ability to iterate twice is sufficient, could the methods be bounded on
Self: Clone? This should preserve the efficiency while relaxing the requirements.A quick and dirty POC.
Centril commentedon Oct 7, 2018
Triage: no movement.