Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created July 17, 2018 20:39
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/5868a6998d301395a7a4eec3b747663f to your computer and use it in GitHub Desktop.
Save rust-play/5868a6998d301395a7a4eec3b747663f 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>,
{
let strings: Vec<String> = values.into_iter().map(Into::into).collect();
strings.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