Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern crate itertools;
- fn main(){
- let joined = join_slice(&vec!["one", "two", "three"]);
- println!("{}", joined);
- }
- //This works
- #[allow(dead_code)]
- pub fn join<'a, T>(values: Vec<T>) -> String where T: Into<&'a str>{
- use itertools::Itertools;
- values.into_iter()
- .map(Into::into)
- .join(",")
- }
- //But I want this
- #[allow(dead_code)]
- pub fn join_slice<'a, T>(values: &[T]) -> String where T: Into<&'a str>{
- use itertools::Itertools;
- values.into_iter()
- .map(Into::into)
- .join(",")
- }
Add Comment
Please, Sign In to add comment