[−][src]Struct proc_macro2::Literal
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 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 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 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 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 f64_unsuffixed(f: f64) -> Literal[src]
pub fn f64_unsuffixed(f: f64) -> Literalpub fn f64_suffixed(f: f64) -> Literal[src]
pub fn f64_suffixed(f: f64) -> Literalpub fn f32_unsuffixed(f: f32) -> Literal[src]
pub fn f32_unsuffixed(f: 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(f: f32) -> Literal[src]
pub fn f32_suffixed(f: f32) -> Literalpub fn string(string: &str) -> Literal[src]
pub fn string(string: &str) -> Literalpub fn character(ch: char) -> Literal[src]
pub fn character(ch: char) -> Literalpub fn byte_string(s: &[u8]) -> Literal[src]
pub fn byte_string(s: &[u8]) -> Literalpub fn span(&self) -> Span[src]
pub fn span(&self) -> Spanpub fn set_span(&mut self, span: Span)[src]
pub fn set_span(&mut self, span: Span)Trait Implementations
impl 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 From<Literal> for TokenTree[src]
impl From<Literal> for TokenTreeimpl Display for Literal[src]
impl Display 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 Debug for Literal[src]
impl Debug for LiteralAuto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, type Owned = T
fn to_owned(&self) -> T[src]
fn to_owned(&self) -> TCreates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)[src]
fn clone_into(&self, target: &mut T)🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> ToString for T where
T: Display + ?Sized, [src]
impl<T> ToString for T where
T: Display + ?Sized, impl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T> From for T[src]
impl<T> From for Timpl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>try_from)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>try_from)Performs the conversion.
impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut TMutably borrows from an owned value. Read more
impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeId🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static
Gets the TypeId of self. Read more
impl<E> SpecializationError for E[src]
impl<E> SpecializationError for Efn not_found<S, T>(trait_name: &'static str, method_name: &'static str) -> E where
T: ?Sized, [src]
fn not_found<S, T>(trait_name: &'static str, method_name: &'static str) -> E where
T: ?Sized, 🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
Create an error for a missing method specialization. Defaults to panicking with type, trait & method names. S is the encoder/decoder state type, T is the type being encoded/decoded, and the arguments are the names of the trait and method that should've been overridden. Read more
impl<T> Erased for T[src]
impl<T> Erased for Timpl<T> Send for T where
T: ?Sized, [src]
impl<T> Send for T where
T: ?Sized, impl<T> Sync for T where
T: ?Sized, [src]
impl<T> Sync for T where
T: ?Sized, impl<T> Erased for T
impl<T> Erased for T