pub enum Literal<B: Buffer> {
Bool(BoolLit),
Integer(IntegerLit<B>),
Float(FloatLit<B>),
Char(CharLit<B>),
String(StringLit<B>),
Byte(ByteLit<B>),
ByteString(ByteStringLit<B>),
}
Expand description
A literal. This is the main type of this library.
This type is generic over the underlying buffer B
, which can be &str
or
String
. There are two useful type aliases: OwnedLiteral
and
SharedLiteral
.
To create this type, you have to either call Literal::parse
with an
input string or use the From<_>
impls of this type. The impls are only
available of the corresponding crate features are enabled (they are enabled
by default).
Variants§
Bool(BoolLit)
Integer(IntegerLit<B>)
Float(FloatLit<B>)
Char(CharLit<B>)
String(StringLit<B>)
Byte(ByteLit<B>)
ByteString(ByteStringLit<B>)
Implementations§
Source§impl<B: Buffer> Literal<B>
impl<B: Buffer> Literal<B>
Sourcepub fn parse(input: B) -> Result<Self, ParseError>
pub fn parse(input: B) -> Result<Self, ParseError>
Parses the given input as a Rust literal.
Source§impl Literal<&str>
impl Literal<&str>
Sourcepub fn into_owned(self) -> OwnedLiteral
pub fn into_owned(self) -> OwnedLiteral
Makes a copy of the underlying buffer and returns the owned version of
Self
.
Trait Implementations§
Source§impl<B: Buffer> From<ByteStringLit<B>> for Literal<B>
impl<B: Buffer> From<ByteStringLit<B>> for Literal<B>
Source§fn from(src: ByteStringLit<B>) -> Self
fn from(src: ByteStringLit<B>) -> Self
Converts to this type from the input type.
Source§impl<B: Buffer> From<IntegerLit<B>> for Literal<B>
impl<B: Buffer> From<IntegerLit<B>> for Literal<B>
Source§fn from(src: IntegerLit<B>) -> Self
fn from(src: IntegerLit<B>) -> Self
Converts to this type from the input type.
impl<B: Eq + Buffer> Eq for Literal<B>
impl<B: Buffer> StructuralPartialEq for Literal<B>
Auto Trait Implementations§
impl<B> Freeze for Literal<B>where
B: Freeze,
impl<B> RefUnwindSafe for Literal<B>where
B: RefUnwindSafe,
impl<B> Send for Literal<B>where
B: Send,
impl<B> Sync for Literal<B>where
B: Sync,
impl<B> Unpin for Literal<B>where
B: Unpin,
impl<B> UnwindSafe for Literal<B>where
B: UnwindSafe,
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