Guest User

Untitled

a guest
Jul 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. extern crate itertools;
  2.  
  3.  
  4. fn main(){
  5. let joined = join_slice(&vec!["one", "two", "three"]);
  6. println!("{}", joined);
  7. }
  8.  
  9. //This works
  10. #[allow(dead_code)]
  11. pub fn join<'a, T>(values: Vec<T>) -> String where T: Into<&'a str>{
  12. use itertools::Itertools;
  13. values.into_iter()
  14. .map(Into::into)
  15. .join(",")
  16. }
  17.  
  18. //But I want this
  19. #[allow(dead_code)]
  20. pub fn join_slice<'a, T>(values: &[T]) -> String where T: Into<&'a str>{
  21. use itertools::Itertools;
  22. values.into_iter()
  23. .map(Into::into)
  24. .join(",")
  25. }
Add Comment
Please, Sign In to add comment