Skip to content

Instantly share code, notes, and snippets.

@byronmejia
Created January 2, 2017 08:37
Show Gist options
  • Save byronmejia/c4a11bdbbd65e5c492bd3457f29663a6 to your computer and use it in GitHub Desktop.
Save byronmejia/c4a11bdbbd65e5c492bd3457f29663a6 to your computer and use it in GitHub Desktop.
Vector of ints to string separated by commas
pub fn vec_u64(original: &Vec<u64>) -> String {
let mut list = original.clone();
let next = list.pop();
match next {
Some(next) => {
vec_u64_next(list, format!("{next}", next=next))
},
_ => {
"".to_string()
}
}
}
fn vec_u64_next(mut list: Vec<u64>, builder: String) -> String {
let next = list.pop();
match next {
Some(next) => {
vec_u64_next(list, format!("{builder},{next}", builder=builder, next=next))
},
_ => {
builder
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment