pub fn to_lit_token(&self) -> (token::Lit, Option<Symbol>) {
        match *self {
            LitKind::Str(string, ast::StrStyle::Cooked) => {
                let escaped = string.as_str().escape_default().to_string();
                (token::Lit::Str_(Symbol::intern(&escaped)), None)
            }
            LitKind::Str(string, ast::StrStyle::Raw(n)) => {
                (token::Lit::StrRaw(string, n), None)
            }
            LitKind::ByteStr(ref bytes) => {
                let string = bytes.iter().cloned().flat_map(ascii::escape_default)
                    .map(Into::<char>::into).collect::<String>();
                (token::Lit::ByteStr(Symbol::intern(&string)), None)
            }
            LitKind::Byte(byte) => {
                let string: String = ascii::escape_default(byte).map(Into::<char>::into).collect();
                (token::Lit::Byte(Symbol::intern(&string)), None)
            }
            LitKind::Char(ch) => {
                let string: String = ch.escape_default().map(Into::<char>::into).collect();
                (token::Lit::Char(Symbol::intern(&string)), None)
            }
            LitKind::Int(n, ty) => {
                let suffix = match ty {
                    ast::LitIntType::Unsigned(ty) => Some(Symbol::intern(ty.ty_to_string())),
                    ast::LitIntType::Signed(ty) => Some(Symbol::intern(ty.ty_to_string())),
                    ast::LitIntType::Unsuffixed => None,
                };
                (token::Lit::Integer(Symbol::intern(&n.to_string())), suffix)
            }
            LitKind::Float(symbol, ty) => {
                (token::Lit::Float(symbol), Some(Symbol::intern(ty.ty_to_string())))
            }
            LitKind::FloatUnsuffixed(symbol) => (token::Lit::Float(symbol), None),
            LitKind::Bool(value) => {
                let kw = if value { kw::True } else { kw::False };
                (token::Lit::Bool(kw), None)
            }
            LitKind::Err(val) => (token::Lit::Err(val), None),
        }
    }
/// Attempts to recover a token from semantic literal.
/// This function is used when the original token doesn't exist (e.g. the literal is created
/// by an AST-based macro) or unavailable (e.g. from HIR pretty-printing).
Attempts to recover a token from semantic literal.
This function is used when the original token doesn't exist  or unavailable .
Attempts to recover a token from semantic literal . This function is used when the original token doesn ' t exist or unavailable .
pub fn to_lit_token(&self) -> (token::Lit, Option<Symbol>) {
        match *self {
            LitKind::Str(string, ast::StrStyle::Cooked) => {
                let escaped = string.as_str().escape_default().to_string();
                (token::Lit::Str_(Symbol::intern(&escaped)), None)
            }
            LitKind::Str(string, ast::StrStyle::Raw(n)) => {
                (token::Lit::StrRaw(string, n), None)
            }
            LitKind::ByteStr(ref bytes) => {
                let string = bytes.iter().cloned().flat_map(ascii::escape_default)
                    .map(Into::<char>::into).collect::<String>();
                (token::Lit::ByteStr(Symbol::intern(&string)), None)
            }
            LitKind::Byte(byte) => {
                let string: String = ascii::escape_default(byte).map(Into::<char>::into).collect();
                (token::Lit::Byte(Symbol::intern(&string)), None)
            }
            LitKind::Char(ch) => {
                let string: String = ch.escape_default().map(Into::<char>::into).collect();
                (token::Lit::Char(Symbol::intern(&string)), None)
            }
            LitKind::Int(n, ty) => {
                let suffix = match ty {
                    ast::LitIntType::Unsigned(ty) => Some(Symbol::intern(ty.ty_to_string())),
                    ast::LitIntType::Signed(ty) => Some(Symbol::intern(ty.ty_to_string())),
                    ast::LitIntType::Unsuffixed => None,
                };
                (token::Lit::Integer(Symbol::intern(&n.to_string())), suffix)
            }
            LitKind::Float(symbol, ty) => {
                (token::Lit::Float(symbol), Some(Symbol::intern(ty.ty_to_string())))
            }
            LitKind::FloatUnsuffixed(symbol) => (token::Lit::Float(symbol), None),
            LitKind::Bool(value) => {
                let kw = if value { kw::True } else { kw::False };
                (token::Lit::Bool(kw), None)
            }
            LitKind::Err(val) => (token::Lit::Err(val), None),
        }
    }
pub fn to_lit_token ( & self ) -> ( token :: Lit , Option < Symbol > ) { match * self { LitKind :: Str ( string , ast :: StrStyle :: Cooked ) => { let escaped = string . as_str ( ) . escape_default ( ) . to_string ( ) ; ( token :: Lit :: Str_ ( Symbol :: intern ( & escaped ) ) , None ) } LitKind :: Str ( string , ast :: StrStyle :: Raw ( n ) ) => { ( token :: Lit :: StrRaw ( string , n ) , None ) } LitKind :: ByteStr ( ref bytes ) => { let string = bytes . iter ( ) . cloned ( ) . flat_map ( ascii :: escape_default ) . map ( Into :: < char > :: into ) . collect :: < String > ( ) ; ( token :: Lit :: ByteStr ( Symbol :: intern ( & string ) ) , None ) } LitKind :: Byte ( byte ) => { let string : String = ascii :: escape_default ( byte ) . map ( Into :: < char > :: into ) . collect ( ) ; ( token :: Lit :: Byte ( Symbol :: intern ( & string ) ) , None ) } LitKind :: Char ( ch ) => { let string : String = ch . escape_default ( ) . map ( Into :: < char > :: into ) . collect ( ) ; ( token :: Lit :: Char ( Symbol :: intern ( & string ) ) , None ) } LitKind :: Int ( n , ty ) => { let suffix = match ty { ast :: LitIntType :: Unsigned ( ty ) => Some ( Symbol :: intern ( ty . ty_to_string ( ) ) ) , ast :: LitIntType :: Signed ( ty ) => Some ( Symbol :: intern ( ty . ty_to_string ( ) ) ) , ast :: LitIntType :: Unsuffixed => None , } ; ( token :: Lit :: Integer ( Symbol :: intern ( & n . to_string ( ) ) ) , suffix ) } LitKind :: Float ( symbol , ty ) => { ( token :: Lit :: Float ( symbol ) , Some ( Symbol :: intern ( ty . ty_to_string ( ) ) ) ) } LitKind :: FloatUnsuffixed ( symbol ) => ( token :: Lit :: Float ( symbol ) , None ) , LitKind :: Bool ( value ) => { let kw = if value { kw :: True } else { kw :: False } ; ( token :: Lit :: Bool ( kw ) , None ) } LitKind :: Err ( val ) => ( token :: Lit :: Err ( val ) , None ) , } }
Attempts to recover a token from semantic literal.
Attempts to recover a token from semantic literal .
&self
&self