Skip to content

Commit

Permalink
syntax: Add ToTokens for Option<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
bgamari committed Jul 17, 2014
1 parent d3adccd commit eddc3cc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/libsyntax/ext/quote.rs
Expand Up @@ -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 {
Expand Down

0 comments on commit eddc3cc

Please sign in to comment.