pub enum LiteralValue<S: Span> {
Show 21 variants String(StringLiteral<S>), ByteString(ByteStringLiteral<S>), CString(CStringLiteral<S>), Character(CharacterLiteral<S>), ByteCharacter(ByteCharacterLiteral<S>), Int(IntLiteral<S>), Float(FloatLiteral<S>), I8(I8Literal<S>), I16(I16Literal<S>), I32(I32Literal<S>), I64(I64Literal<S>), I128(I128Literal<S>), Isize(IsizeLiteral<S>), U8(U8Literal<S>), U16(U16Literal<S>), U32(U32Literal<S>), U64(U64Literal<S>), U128(U128Literal<S>), Usize(UsizeLiteral<S>), F32(F32Literal<S>), F64(F64Literal<S>),
}
Available on crate feature literal-value only.
Expand description

A literal token. This is like Literal from proc-macro*, except that the value has already been parsed and is available at no cost. You can convert it to and from Literal with into.

Variants§

§

String(StringLiteral<S>)

String literal.

§

ByteString(ByteStringLiteral<S>)

Byte string literal.

§

CString(CStringLiteral<S>)

C string literal.

§

Character(CharacterLiteral<S>)

Character literal.

§

ByteCharacter(ByteCharacterLiteral<S>)

Byte character literal.

§

Int(IntLiteral<S>)

Unsuffixed integer literal.

§

Float(FloatLiteral<S>)

Unsuffixed floating point literal.

§

I8(I8Literal<S>)

i8 suffixed integer literal.

§

I16(I16Literal<S>)

i16 suffixed integer literal.

§

I32(I32Literal<S>)

i32 suffixed integer literal.

§

I64(I64Literal<S>)

i64 suffixed integer literal.

§

I128(I128Literal<S>)

i128 suffixed integer literal.

§

Isize(IsizeLiteral<S>)

isize suffixed integer literal.

§

U8(U8Literal<S>)

u8 suffixed integer literal.

§

U16(U16Literal<S>)

u16 suffixed integer literal.

§

U32(U32Literal<S>)

u32 suffixed integer literal.

§

U64(U64Literal<S>)

u64 suffixed integer literal.

§

U128(U128Literal<S>)

u128 suffixed integer literal.

§

Usize(UsizeLiteral<S>)

usize suffixed integer literal.

§

F32(F32Literal<S>)

f32 suffixed floating point literal.

§

F64(F64Literal<S>)

f64 suffixed floating point literal.

Trait Implementations§

source§

impl<S: Clone + Span> Clone for LiteralValue<S>

source§

fn clone(&self) -> LiteralValue<S>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<S: Debug + Span> Debug for LiteralValue<S>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<S: SpanExt> From<ByteCharacterLiteral<S>> for LiteralValue<S>

source§

fn from(value: ByteCharacterLiteral<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<ByteStringLiteral<S>> for LiteralValue<S>

source§

fn from(value: ByteStringLiteral<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<CStringLiteral<S>> for LiteralValue<S>

source§

fn from(value: CStringLiteral<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<CharacterLiteral<S>> for LiteralValue<S>

source§

fn from(value: CharacterLiteral<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<F32Literal<S>> for LiteralValue<S>

source§

fn from(value: F32Literal<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<F64Literal<S>> for LiteralValue<S>

source§

fn from(value: F64Literal<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<FloatLiteral<S>> for LiteralValue<S>

source§

fn from(value: FloatLiteral<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<I128Literal<S>> for LiteralValue<S>

source§

fn from(value: I128Literal<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<I16Literal<S>> for LiteralValue<S>

source§

fn from(value: I16Literal<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<I32Literal<S>> for LiteralValue<S>

source§

fn from(value: I32Literal<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<I64Literal<S>> for LiteralValue<S>

source§

fn from(value: I64Literal<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<I8Literal<S>> for LiteralValue<S>

source§

fn from(value: I8Literal<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<IntLiteral<S>> for LiteralValue<S>

source§

fn from(value: IntLiteral<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<IsizeLiteral<S>> for LiteralValue<S>

source§

fn from(value: IsizeLiteral<S>) -> Self

Converts to this type from the input type.
source§

impl From<Literal> for LiteralValue<Span>

Available on crate feature proc-macro2 only.
source§

fn from(value: Literal) -> Self

Converts to this type from the input type.
source§

impl From<Literal> for LiteralValue<Span>

Available on crate feature proc-macro only.
source§

fn from(value: Literal) -> Self

Converts to this type from the input type.
source§

impl From<LiteralValue<Span>> for Literal

Available on crate feature proc-macro only.
source§

fn from(value: LiteralValue<Span>) -> Self

Converts to this type from the input type.
source§

impl From<LiteralValue<Span>> for Literal

Available on crate feature proc-macro2 only.
source§

fn from(value: LiteralValue<Span>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<StringLiteral<S>> for LiteralValue<S>

source§

fn from(value: StringLiteral<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<U128Literal<S>> for LiteralValue<S>

source§

fn from(value: U128Literal<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<U16Literal<S>> for LiteralValue<S>

source§

fn from(value: U16Literal<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<U32Literal<S>> for LiteralValue<S>

source§

fn from(value: U32Literal<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<U64Literal<S>> for LiteralValue<S>

source§

fn from(value: U64Literal<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<U8Literal<S>> for LiteralValue<S>

source§

fn from(value: U8Literal<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> From<UsizeLiteral<S>> for LiteralValue<S>

source§

fn from(value: UsizeLiteral<S>) -> Self

Converts to this type from the input type.
source§

impl<S: SpanExt> FromStr for LiteralValue<S>

§

type Err = Error<S>

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl<T: TokenTreeExt> IntoTokens<T> for LiteralValue<T::Span>

source§

fn into_tokens(self) -> impl Iterator<Item = T>

Convert this object into an iterator of tokens representing the object.
source§

impl<T: TokenTreeExt> Parse<T> for LiteralValue<T::Span>

source§

fn parse(buf: &mut &TokenBuf<T>) -> Result<Self, Error<T::Span>>

Parse a value from a TokenBuf. Read more
source§

fn parse_all(buf: &mut &TokenBuf<T>) -> Result<Self, Error<T::Span>>

Parse a value from a TokenBuf buffer, but return an error if there’s any tokens left in the buffer after parsing. Read more
source§

impl<T: TokenStreamExt> ToTokenStream<T> for LiteralValue<T::Span>

source§

fn extend_token_stream(&self, token_stream: &mut T)

Extend the given TokenStream with a representation of this object.
source§

fn into_token_stream(self) -> T
where Self: Sized,

Make a new TokenStream with a representation of this object.
source§

fn to_token_stream(&self) -> T

Make a new TokenStream with a representation of this object.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for ByteCharacterLiteral<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for ByteStringLiteral<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for CStringLiteral<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for CharacterLiteral<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for F32Literal<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for F64Literal<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for FloatLiteral<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for I128Literal<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for I16Literal<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for I32Literal<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for I64Literal<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for I8Literal<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for IntLiteral<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for IsizeLiteral<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for StringLiteral<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for U128Literal<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for U16Literal<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for U32Literal<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for U64Literal<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for U8Literal<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<S: SpanExt> TryFrom<LiteralValue<S>> for UsizeLiteral<S>

§

type Error = Error<S>

The type returned in the event of a conversion error.
source§

fn try_from(value: LiteralValue<S>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<S> Freeze for LiteralValue<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for LiteralValue<S>
where S: RefUnwindSafe,

§

impl<S> Send for LiteralValue<S>
where S: Send,

§

impl<S> Sync for LiteralValue<S>
where S: Sync,

§

impl<S> Unpin for LiteralValue<S>
where S: Unpin,

§

impl<S> UnwindSafe for LiteralValue<S>
where S: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, X> DefaultParser<T> for X
where T: TokenTreeExt, X: Parse<T>,

§

type Parser = DefaultParserImpl<T, X>

The parser that will be created.
source§

fn parser() -> Self::Parser

Create a new parser.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, X> ToTokenBuffer<T> for X
where T: TokenTree, X: IntoTokens<T> + Clone,

source§

fn extend_token_buffer(&self, token_buffer: &mut TokenBuffer<T>)

Extend the given TokenBuffer with tokens representing this object.
source§

fn to_token_buffer(&self) -> TokenBuffer<T>

Make a new TokenBuffer with tokens representing this object.
source§

impl<T, X> ToTokens<T> for X
where T: TokenTree, X: IntoTokens<T> + Clone,

source§

fn to_tokens(&self) -> impl Iterator<Item = T>

Get an iterator of tokens representing this object.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.