Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created July 17, 2018 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/dcc27b2c4f9260c02490ddd2cfb2a34e to your computer and use it in GitHub Desktop.
Save rust-play/dcc27b2c4f9260c02490ddd2cfb2a34e to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
fn main() {
let some_string = convert(vec!["one", "two", "three"]);
println!("{}", some_string);
}
//Doesn't Work
pub fn convert<T>(values: Vec<T>) -> String where T: Into<String> {
values.iter()
.collect::<Vec<String>>()
.join(",")
}
/*
//Works
pub fn convert<T>(values: T) -> String where T: Into<String> {
values.into()
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment