diff options
author | Corey Farwell <coreyf@rwell.org> | 2015-09-28 19:45:01 -0400 |
---|---|---|
committer | Corey Farwell <coreyf@rwell.org> | 2015-09-28 19:45:01 -0400 |
commit | 2857e547be606cbed1e5db060d254116223b7723 (patch) | |
tree | 049774206314c174c7bd8c458dbc32a059a0c7af | |
parent | 8547d132f9a6f5499c437572ea5648c6baf2f621 (diff) | |
download | servo-2857e547be606cbed1e5db060d254116223b7723.tar.gz servo-2857e547be606cbed1e5db060d254116223b7723.zip |
Make util::str::str_join operate on Iterators
-rw-r--r-- | components/util/str.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/components/util/str.rs b/components/util/str.rs index 606933d7033..c3af9a26bbc 100644 --- a/components/util/str.rs +++ b/components/util/str.rs @@ -326,8 +326,10 @@ pub unsafe fn c_str_to_string(s: *const c_char) -> String { from_utf8(CStr::from_ptr(s).to_bytes()).unwrap().to_owned() } -pub fn str_join<T: AsRef<str>>(strs: &[T], join: &str) -> String { - strs.iter().fold(String::new(), |mut acc, s| { +pub fn str_join<I, T>(strs: I, join: &str) -> String + where I: IntoIterator<Item=T>, T: AsRef<str>, +{ + strs.into_iter().fold(String::new(), |mut acc, s| { if !acc.is_empty() { acc.push_str(join); } acc.push_str(s.as_ref()); acc |