syntax: Add ToTokens for Option<T>

This commit is contained in:
Ben Gamari 2014-07-16 22:16:55 -04:00
parent d3adccda4e
commit eddc3ccce8
1 changed files with 9 additions and 0 deletions

View File

@ -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 {