pub enum Lit {
Int(LitInt),
Float(LitFloat),
Str(LitStr),
ByteStr(LitByteStr),
CStr(LitCStr),
Char(LitChar),
Byte(LitByte),
Bool(LitBool),
Verbatim(LitVerbatim),
}Variants§
Int(LitInt)
Float(LitFloat)
Str(LitStr)
ByteStr(LitByteStr)
CStr(LitCStr)
Char(LitChar)
Byte(LitByte)
Bool(LitBool)
Verbatim(LitVerbatim)
Implementations§
Source§impl Lit
impl Lit
pub fn f32_suffixed(value: f32) -> Self
pub fn f32_unsuffixed(value: f32) -> Self
pub fn f64_suffixed(value: f64) -> Self
pub fn f64_unsuffixed(value: f64) -> Self
Source§impl Lit
impl Lit
pub fn u8_suffixed(value: u8) -> Self
pub fn u8_unsuffixed(value: u8) -> Self
pub fn u16_suffixed(value: u16) -> Self
pub fn u16_unsuffixed(value: u16) -> Self
pub fn u32_suffixed(value: u32) -> Self
pub fn u32_unsuffixed(value: u32) -> Self
pub fn u64_suffixed(value: u64) -> Self
pub fn u64_unsuffixed(value: u64) -> Self
pub fn usize_suffixed(value: usize) -> Self
pub fn usize_unsuffixed(value: usize) -> Self
pub fn i8_suffixed(value: i8) -> Self
pub fn i8_unsuffixed(value: i8) -> Self
pub fn i16_suffixed(value: i16) -> Self
pub fn i16_unsuffixed(value: i16) -> Self
pub fn i32_suffixed(value: i32) -> Self
pub fn i32_unsuffixed(value: i32) -> Self
pub fn i64_suffixed(value: i64) -> Self
pub fn i64_unsuffixed(value: i64) -> Self
pub fn isize_suffixed(value: isize) -> Self
pub fn isize_unsuffixed(value: isize) -> Self
Source§impl Lit
impl Lit
pub fn string(value: &str) -> Self
pub fn char(value: char) -> Self
Sourcepub fn from_repr(repr: &str, span: Span) -> Self
pub fn from_repr(repr: &str, span: Span) -> Self
Classify and decode an arbitrary literal repr into the matching variant. Used by
the proc-macro bridges, which only have the source text. Falls back to
LitVerbatim for anything that doesn’t lex as a known literal.
pub fn is_int(&self) -> bool
pub fn is_float(&self) -> bool
pub fn is_str(&self) -> bool
pub fn is_c_str(&self) -> bool
pub fn is_bool(&self) -> bool
pub fn is_char(&self) -> bool
pub fn is_byte(&self) -> bool
pub fn is_byte_str(&self) -> bool
pub fn is_verbatim(&self) -> bool
pub fn as_str(&self) -> Option<&LitStr>
pub fn as_c_str(&self) -> Option<&LitCStr>
pub fn as_bool(&self) -> Option<&LitBool>
pub fn as_int(&self) -> Option<&LitInt>
pub fn as_float(&self) -> Option<&LitFloat>
pub fn as_char(&self) -> Option<&LitChar>
pub fn as_byte(&self) -> Option<&LitByte>
pub fn as_byte_str(&self) -> Option<&LitByteStr>
pub fn to_token_tree(&self) -> TokenTree
pub fn into_token_tree(self) -> TokenTree
pub fn repr(&self) -> &str
pub fn span(&self) -> Span
pub fn set_span(&mut self, span: Span)
Trait Implementations§
impl Eq for Lit
Source§impl From<LitByteStr> for Lit
impl From<LitByteStr> for Lit
Source§fn from(value: LitByteStr) -> Self
fn from(value: LitByteStr) -> Self
Converts to this type from the input type.
Source§impl From<LitVerbatim> for Lit
impl From<LitVerbatim> for Lit
Source§fn from(value: LitVerbatim) -> Self
fn from(value: LitVerbatim) -> Self
Converts to this type from the input type.
impl StructuralPartialEq for Lit
Auto Trait Implementations§
impl !Send for Lit
impl !Sync for Lit
impl Freeze for Lit
impl RefUnwindSafe for Lit
impl Unpin for Lit
impl UnsafeUnpin for Lit
impl UnwindSafe for Lit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more