Struct proc_macro::Literal 1.29.0[−][src]
pub struct Literal { /* fields omitted */ }A literal string ("hello"), byte string (b"hello"),
character ('a'), byte character (b'a'), an integer or floating point number
with or without a suffix (1, 1u8, 2.3, 2.3f32).
Boolean literals like true and false do not belong here, they are Idents.
Methods
impl Literal[src]
impl Literalpub fn u8_suffixed(n: u8) -> Literal[src]
pub fn u8_suffixed(n: u8) -> LiteralCreates a new suffixed integer literal with the specified value.
This function will create an integer like 1u32 where the integer
value specified is the first part of the token and the integral is
also suffixed at the end.
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn u16_suffixed(n: u16) -> Literal[src]
pub fn u16_suffixed(n: u16) -> LiteralCreates a new suffixed integer literal with the specified value.
This function will create an integer like 1u32 where the integer
value specified is the first part of the token and the integral is
also suffixed at the end.
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn u32_suffixed(n: u32) -> Literal[src]
pub fn u32_suffixed(n: u32) -> LiteralCreates a new suffixed integer literal with the specified value.
This function will create an integer like 1u32 where the integer
value specified is the first part of the token and the integral is
also suffixed at the end.
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn u64_suffixed(n: u64) -> Literal[src]
pub fn u64_suffixed(n: u64) -> LiteralCreates a new suffixed integer literal with the specified value.
This function will create an integer like 1u32 where the integer
value specified is the first part of the token and the integral is
also suffixed at the end.
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn u128_suffixed(n: u128) -> Literal[src]
pub fn u128_suffixed(n: u128) -> LiteralCreates a new suffixed integer literal with the specified value.
This function will create an integer like 1u32 where the integer
value specified is the first part of the token and the integral is
also suffixed at the end.
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn usize_suffixed(n: usize) -> Literal[src]
pub fn usize_suffixed(n: usize) -> LiteralCreates a new suffixed integer literal with the specified value.
This function will create an integer like 1u32 where the integer
value specified is the first part of the token and the integral is
also suffixed at the end.
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn i8_suffixed(n: i8) -> Literal[src]
pub fn i8_suffixed(n: i8) -> LiteralCreates a new suffixed integer literal with the specified value.
This function will create an integer like 1u32 where the integer
value specified is the first part of the token and the integral is
also suffixed at the end.
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn i16_suffixed(n: i16) -> Literal[src]
pub fn i16_suffixed(n: i16) -> LiteralCreates a new suffixed integer literal with the specified value.
This function will create an integer like 1u32 where the integer
value specified is the first part of the token and the integral is
also suffixed at the end.
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn i32_suffixed(n: i32) -> Literal[src]
pub fn i32_suffixed(n: i32) -> LiteralCreates a new suffixed integer literal with the specified value.
This function will create an integer like 1u32 where the integer
value specified is the first part of the token and the integral is
also suffixed at the end.
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn i64_suffixed(n: i64) -> Literal[src]
pub fn i64_suffixed(n: i64) -> LiteralCreates a new suffixed integer literal with the specified value.
This function will create an integer like 1u32 where the integer
value specified is the first part of the token and the integral is
also suffixed at the end.
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn i128_suffixed(n: i128) -> Literal[src]
pub fn i128_suffixed(n: i128) -> LiteralCreates a new suffixed integer literal with the specified value.
This function will create an integer like 1u32 where the integer
value specified is the first part of the token and the integral is
also suffixed at the end.
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn isize_suffixed(n: isize) -> Literal[src]
pub fn isize_suffixed(n: isize) -> LiteralCreates a new suffixed integer literal with the specified value.
This function will create an integer like 1u32 where the integer
value specified is the first part of the token and the integral is
also suffixed at the end.
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn u8_unsuffixed(n: u8) -> Literal[src]
pub fn u8_unsuffixed(n: u8) -> LiteralCreates a new unsuffixed integer literal with the specified value.
This function will create an integer like 1 where the integer
value specified is the first part of the token. No suffix is
specified on this token, meaning that invocations like
Literal::i8_unsuffixed(1) are equivalent to
Literal::u32_unsuffixed(1).
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn u16_unsuffixed(n: u16) -> Literal[src]
pub fn u16_unsuffixed(n: u16) -> LiteralCreates a new unsuffixed integer literal with the specified value.
This function will create an integer like 1 where the integer
value specified is the first part of the token. No suffix is
specified on this token, meaning that invocations like
Literal::i8_unsuffixed(1) are equivalent to
Literal::u32_unsuffixed(1).
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn u32_unsuffixed(n: u32) -> Literal[src]
pub fn u32_unsuffixed(n: u32) -> LiteralCreates a new unsuffixed integer literal with the specified value.
This function will create an integer like 1 where the integer
value specified is the first part of the token. No suffix is
specified on this token, meaning that invocations like
Literal::i8_unsuffixed(1) are equivalent to
Literal::u32_unsuffixed(1).
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn u64_unsuffixed(n: u64) -> Literal[src]
pub fn u64_unsuffixed(n: u64) -> LiteralCreates a new unsuffixed integer literal with the specified value.
This function will create an integer like 1 where the integer
value specified is the first part of the token. No suffix is
specified on this token, meaning that invocations like
Literal::i8_unsuffixed(1) are equivalent to
Literal::u32_unsuffixed(1).
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn u128_unsuffixed(n: u128) -> Literal[src]
pub fn u128_unsuffixed(n: u128) -> LiteralCreates a new unsuffixed integer literal with the specified value.
This function will create an integer like 1 where the integer
value specified is the first part of the token. No suffix is
specified on this token, meaning that invocations like
Literal::i8_unsuffixed(1) are equivalent to
Literal::u32_unsuffixed(1).
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn usize_unsuffixed(n: usize) -> Literal[src]
pub fn usize_unsuffixed(n: usize) -> LiteralCreates a new unsuffixed integer literal with the specified value.
This function will create an integer like 1 where the integer
value specified is the first part of the token. No suffix is
specified on this token, meaning that invocations like
Literal::i8_unsuffixed(1) are equivalent to
Literal::u32_unsuffixed(1).
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn i8_unsuffixed(n: i8) -> Literal[src]
pub fn i8_unsuffixed(n: i8) -> LiteralCreates a new unsuffixed integer literal with the specified value.
This function will create an integer like 1 where the integer
value specified is the first part of the token. No suffix is
specified on this token, meaning that invocations like
Literal::i8_unsuffixed(1) are equivalent to
Literal::u32_unsuffixed(1).
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn i16_unsuffixed(n: i16) -> Literal[src]
pub fn i16_unsuffixed(n: i16) -> LiteralCreates a new unsuffixed integer literal with the specified value.
This function will create an integer like 1 where the integer
value specified is the first part of the token. No suffix is
specified on this token, meaning that invocations like
Literal::i8_unsuffixed(1) are equivalent to
Literal::u32_unsuffixed(1).
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn i32_unsuffixed(n: i32) -> Literal[src]
pub fn i32_unsuffixed(n: i32) -> LiteralCreates a new unsuffixed integer literal with the specified value.
This function will create an integer like 1 where the integer
value specified is the first part of the token. No suffix is
specified on this token, meaning that invocations like
Literal::i8_unsuffixed(1) are equivalent to
Literal::u32_unsuffixed(1).
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn i64_unsuffixed(n: i64) -> Literal[src]
pub fn i64_unsuffixed(n: i64) -> LiteralCreates a new unsuffixed integer literal with the specified value.
This function will create an integer like 1 where the integer
value specified is the first part of the token. No suffix is
specified on this token, meaning that invocations like
Literal::i8_unsuffixed(1) are equivalent to
Literal::u32_unsuffixed(1).
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn i128_unsuffixed(n: i128) -> Literal[src]
pub fn i128_unsuffixed(n: i128) -> LiteralCreates a new unsuffixed integer literal with the specified value.
This function will create an integer like 1 where the integer
value specified is the first part of the token. No suffix is
specified on this token, meaning that invocations like
Literal::i8_unsuffixed(1) are equivalent to
Literal::u32_unsuffixed(1).
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn isize_unsuffixed(n: isize) -> Literal[src]
pub fn isize_unsuffixed(n: isize) -> LiteralCreates a new unsuffixed integer literal with the specified value.
This function will create an integer like 1 where the integer
value specified is the first part of the token. No suffix is
specified on this token, meaning that invocations like
Literal::i8_unsuffixed(1) are equivalent to
Literal::u32_unsuffixed(1).
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Literals created through this method have the Span::call_site()
span by default, which can be configured with the set_span method
below.
pub fn f32_unsuffixed(n: f32) -> Literal[src]
pub fn f32_unsuffixed(n: f32) -> LiteralCreates a new unsuffixed floating-point literal.
This constructor is similar to those like Literal::i8_unsuffixed where
the float's value is emitted directly into the token but no suffix is
used, so it may be inferred to be a f64 later in the compiler.
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Panics
This function requires that the specified float is finite, for example if it is infinity or NaN this function will panic.
pub fn f32_suffixed(n: f32) -> Literal[src]
pub fn f32_suffixed(n: f32) -> LiteralCreates a new suffixed floating-point literal.
This consturctor will create a literal like 1.0f32 where the value
specified is the preceding part of the token and f32 is the suffix of
the token. This token will always be inferred to be an f32 in the
compiler.
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Panics
This function requires that the specified float is finite, for example if it is infinity or NaN this function will panic.
pub fn f64_unsuffixed(n: f64) -> Literal[src]
pub fn f64_unsuffixed(n: f64) -> LiteralCreates a new unsuffixed floating-point literal.
This constructor is similar to those like Literal::i8_unsuffixed where
the float's value is emitted directly into the token but no suffix is
used, so it may be inferred to be a f64 later in the compiler.
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Panics
This function requires that the specified float is finite, for example if it is infinity or NaN this function will panic.
pub fn f64_suffixed(n: f64) -> Literal[src]
pub fn f64_suffixed(n: f64) -> LiteralCreates a new suffixed floating-point literal.
This consturctor will create a literal like 1.0f64 where the value
specified is the preceding part of the token and f64 is the suffix of
the token. This token will always be inferred to be an f64 in the
compiler.
Literals created from negative numbers may not survive rountrips through
TokenStream or strings and may be broken into two tokens (- and positive literal).
Panics
This function requires that the specified float is finite, for example if it is infinity or NaN this function will panic.
pub fn string(string: &str) -> Literal[src]
pub fn string(string: &str) -> LiteralString literal.
pub fn character(ch: char) -> Literal[src]
pub fn character(ch: char) -> LiteralCharacter literal.
pub fn byte_string(bytes: &[u8]) -> Literal[src]
pub fn byte_string(bytes: &[u8]) -> LiteralByte string literal.
pub fn span(&self) -> Span[src]
pub fn span(&self) -> SpanReturns the span encompassing this literal.
pub fn set_span(&mut self, span: Span)[src]
pub fn set_span(&mut self, span: Span)Configures the span associated for this literal.
Trait Implementations
impl From<Literal> for TokenTree[src]
impl From<Literal> for TokenTreeimpl Clone for Literal[src]
impl Clone for Literalfn clone(&self) -> Literal[src]
fn clone(&self) -> LiteralReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Debug for Literal[src]
impl Debug for Literalfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl !Send for Literal[src]
impl !Send for Literalimpl !Sync for Literal[src]
impl !Sync for Literalimpl Display for Literal[src]
impl Display for LiteralPrints the literal as a string that should be losslessly convertible back into the same literal (except for possible rounding for floating point literals).