Skip to content

Instantly share code, notes, and snippets.

@lovasoa
Created July 2, 2015 22:40
Show Gist options
  • Select an option

  • Save lovasoa/b900e0c2c79b9c951663 to your computer and use it in GitHub Desktop.

Select an option

Save lovasoa/b900e0c2c79b9c951663 to your computer and use it in GitHub Desktop.
join vector of strings in rust
fn join<S:ToString> (l: Vec<S>, sep: &str) -> String{
l.iter().fold("".to_string(),
|a,b| if a.len()>0 {a+sep} else {a} + &b.to_string()
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment