From 96072d6efc110e81ab6e0a70e2bf9a96a53268b6 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Wed, 16 Jul 2014 22:24:42 -0400 Subject: [PATCH] syntax: Generalize ToTokens impl for Vec It will now `flat_map` over the elements of a `Vec` if `T: ToTokens` --- src/libsyntax/ext/quote.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index eb1f25143cfce..21c5626d16d3f 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -54,9 +54,10 @@ pub mod rt { } } - impl ToTokens for Vec { - fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { - (*self).clone() + impl ToTokens for Vec { + fn to_tokens(&self, cx: &ExtCtxt) -> Vec { + let a = self.iter().flat_map(|t| t.to_tokens(cx).move_iter()); + FromIterator::from_iter(a) } }