about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2014-07-16 22:16:55 -0400
committerBen Gamari <bgamari.foss@gmail.com>2014-07-16 22:16:55 -0400
commiteddc3ccce8d50634f860cd1f79f2f242eed7be0f (patch)
tree3286f660b555c151ee7cc3d77e46451d27d56aa3 /src/libsyntax
parentd3adccda4e0a90e4163c261d6b9ab4de7cfd0ccb (diff)
downloadrust-eddc3ccce8d50634f860cd1f79f2f242eed7be0f.tar.gz
rust-eddc3ccce8d50634f860cd1f79f2f242eed7be0f.zip
syntax: Add ToTokens for Option<T>
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/quote.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs
index 696d62838ba..0eab9a90b95 100644
--- a/src/libsyntax/ext/quote.rs
+++ b/src/libsyntax/ext/quote.rs
@@ -67,6 +67,15 @@ pub mod rt {
         }
     }
 
+    impl<T: ToTokens> ToTokens for Option<T> {
+        fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> {
+            match self {
+                &Some(ref t) => t.to_tokens(cx),
+                &None => Vec::new(),
+            }
+        }
+    }
+
     /* Should be (when bugs in default methods are fixed):
 
     trait ToSource : ToTokens {