diff options
| author | Ben Gamari <bgamari.foss@gmail.com> | 2014-07-16 22:16:55 -0400 |
|---|---|---|
| committer | Ben Gamari <bgamari.foss@gmail.com> | 2014-07-16 22:16:55 -0400 |
| commit | eddc3ccce8d50634f860cd1f79f2f242eed7be0f (patch) | |
| tree | 3286f660b555c151ee7cc3d77e46451d27d56aa3 /src/libsyntax/ext | |
| parent | d3adccda4e0a90e4163c261d6b9ab4de7cfd0ccb (diff) | |
| download | rust-eddc3ccce8d50634f860cd1f79f2f242eed7be0f.tar.gz rust-eddc3ccce8d50634f860cd1f79f2f242eed7be0f.zip | |
syntax: Add ToTokens for Option<T>
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 9 |
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 { |
