Created
January 2, 2017 08:37
-
-
Save byronmejia/c4a11bdbbd65e5c492bd3457f29663a6 to your computer and use it in GitHub Desktop.
Vector of ints to string separated by commas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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