Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #59 from brandonedens/string-totoken
Browse files Browse the repository at this point in the history
Add ToToken implementation for String.
  • Loading branch information
dtolnay authored Sep 23, 2016
2 parents 8d25874 + d07a779 commit a177942
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions quasi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ impl ToTokens for str {
}
}

impl ToTokens for String {
fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> {
let lit
= ast::LitKind::Str(
token::intern_and_get_ident(self), ast::StrStyle::Cooked);
dummy_spanned(lit).to_tokens(cx)
}
}

impl ToTokens for () {
fn to_tokens(&self, _cx: &ExtCtxt) -> Vec<TokenTree> {
vec![TokenTree::Delimited(DUMMY_SP, Rc::new(tokenstream::Delimited {
Expand Down

0 comments on commit a177942

Please sign in to comment.