/// Returns an AST string literal if the TokenStream is either a normal ('cooked') or
/// raw string literal.
Returns an AST string literal if the TokenStream is either a normal ('cooked') or
raw string literal.
Returns an AST string literal if the TokenStream is either a normal ( ' cooked ' ) or raw string literal .
pub fn maybe_str(&self) -> Option<ast::Lit> {
        if !(self.len() == 1) {
            return None;
        }
        match self[0] {
            TokenTree::Token(sp, Token::Literal(Lit::Str_(s), _)) => {
                let l = LitKind::Str(token::intern_and_get_ident(&parse::str_lit(&s.as_str())),
                                     ast::StrStyle::Cooked);
                Some(Spanned {
                    node: l,
                    span: sp,
                })
            }
            TokenTree::Token(sp, Token::Literal(Lit::StrRaw(s, n), _)) => {
                let l = LitKind::Str(token::intern_and_get_ident(&parse::raw_str_lit(&s.as_str())),
                                     ast::StrStyle::Raw(n));
                Some(Spanned {
                    node: l,
                    span: sp,
                })
            }
            _ => None,
        }
    }
pub fn maybe_str ( & self ) -> Option < ast :: Lit > { if ! ( self . len ( ) == 1 ) { return None ; } match self [ 0 ] { TokenTree :: Token ( sp , Token :: Literal ( Lit :: Str_ ( s ) , _ ) ) => { let l = LitKind :: Str ( token :: intern_and_get_ident ( & parse :: str_lit ( & s . as_str ( ) ) ) , ast :: StrStyle :: Cooked ) ; Some ( Spanned { node : l , span : sp , } ) } TokenTree :: Token ( sp , Token :: Literal ( Lit :: StrRaw ( s , n ) , _ ) ) => { let l = LitKind :: Str ( token :: intern_and_get_ident ( & parse :: raw_str_lit ( & s . as_str ( ) ) ) , ast :: StrStyle :: Raw ( n ) ) ; Some ( Spanned { node : l , span : sp , } ) } _ => None , } }
Returns an AST string literal if the TokenStream is either a normal ('cooked') or
raw string literal.
Returns an AST string literal if the TokenStream is either a normal ( ' cooked ' ) or raw string literal .
&self