Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[macro_use] extern crate quote;
- fn gen_zip_tuple(v: &[&str]) -> String {
- if v.len() >= 2 {
- let v0 = v[0];
- let v1 = v[1];
- v.iter().skip(2).fold(quote!{(#v0,#v1)}, |q, &v| {quote!{(#q, #v)}} )
- } else {
- let v0 = v[0];
- quote!{(#v0)}
- };
- }
- fn main() {
- let v = vec!["a","b","c"];
- println!("{}", gen_zip_tuple(&v).to_string());
- }
Add Comment
Please, Sign In to add comment