Struct litrs::IntegerLit [−][src]
#[non_exhaustive]pub struct IntegerLit<B: Buffer> { /* fields omitted */ }
Expand description
An integer literal, e.g. 27, 0x7F, 0b101010u8 or 5_000_000i64.
An integer literal consists of an optional base prefix (0b, 0o, 0x),
the main part (digits and underscores), and an optional type suffix
(e.g. u64 or i8). See the reference for more information.
Note that integer literals are always positive: the grammar does not contain
the minus sign at all. The minus sign is just the unary negate operator,
not part of the literal. Which is interesting for cases like - 128i8:
here, the literal itself would overflow the specified type (i8 cannot
represent 128). That’s why in rustc, the literal overflow check is
performed as a lint after parsing, not during the lexing stage. Similarly,
IntegerLit::parse does not perform an overflow check.
Implementations
impl<B: Buffer> IntegerLit<B>[src]
impl<B: Buffer> IntegerLit<B>[src]pub fn parse(input: B) -> Result<Self, Error>[src]
pub fn parse(input: B) -> Result<Self, Error>[src]Parses the input as an integer literal. Returns an error if the input is invalid or represents a different kind of literal.
pub fn value<N: FromIntegerLiteral>(&self) -> Option<N>[src]
pub fn value<N: FromIntegerLiteral>(&self) -> Option<N>[src]Performs the actual string to int conversion to obtain the integer
value. The optional type suffix of the literal is ignored by this
method. This means N does not need to match the type suffix!
Returns None if the literal overflows N.
pub fn base(&self) -> IntegerBase[src]
pub fn base(&self) -> IntegerBase[src]The base of this integer literal.
pub fn raw_main_part(&self) -> &str[src]
pub fn raw_main_part(&self) -> &str[src]The main part containing the digits and potentially _. Do not try to
parse this directly as that would ignore the base!
pub fn type_suffix(&self) -> Option<IntegerType>[src]
pub fn type_suffix(&self) -> Option<IntegerType>[src]The type suffix, if specified.
impl IntegerLit<&str>[src]
impl IntegerLit<&str>[src]pub fn to_owned(&self) -> IntegerLit<String>[src]
pub fn to_owned(&self) -> IntegerLit<String>[src]Makes a copy of the underlying buffer and returns the owned version of
Self.
Trait Implementations
impl<B: Clone + Buffer> Clone for IntegerLit<B>[src]
impl<B: Clone + Buffer> Clone for IntegerLit<B>[src]fn clone(&self) -> IntegerLit<B>[src]
fn clone(&self) -> IntegerLit<B>[src]Returns 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)1.0.0[src]Performs copy-assignment from source. Read more
impl<B: Debug + Buffer> Debug for IntegerLit<B>[src]
impl<B: Debug + Buffer> Debug for IntegerLit<B>[src]impl<B: Buffer> Display for IntegerLit<B>[src]
impl<B: Buffer> Display for IntegerLit<B>[src]impl<B: PartialEq + Buffer> PartialEq<IntegerLit<B>> for IntegerLit<B>[src]
impl<B: PartialEq + Buffer> PartialEq<IntegerLit<B>> for IntegerLit<B>[src]fn eq(&self, other: &IntegerLit<B>) -> bool[src]
fn eq(&self, other: &IntegerLit<B>) -> bool[src]This method tests for self and other values to be equal, and is used
by ==. Read more
fn ne(&self, other: &IntegerLit<B>) -> bool[src]
fn ne(&self, other: &IntegerLit<B>) -> bool[src]This method tests for !=.
impl<B: Copy + Buffer> Copy for IntegerLit<B>[src]
impl<B: Eq + Buffer> Eq for IntegerLit<B>[src]
impl<B: Buffer> StructuralEq for IntegerLit<B>[src]
impl<B: Buffer> StructuralPartialEq for IntegerLit<B>[src]
Auto Trait Implementations
impl<B> RefUnwindSafe for IntegerLit<B> where
B: RefUnwindSafe,
B: RefUnwindSafe,
impl<B> Send for IntegerLit<B> where
B: Send,
B: Send,
impl<B> Sync for IntegerLit<B> where
B: Sync,
B: Sync,
impl<B> Unpin for IntegerLit<B> where
B: Unpin,
B: Unpin,
impl<B> UnwindSafe for IntegerLit<B> where
B: UnwindSafe,
B: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut T[src]
pub fn borrow_mut(&mut self) -> &mut T[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, [src]type Owned = T
type Owned = TThe resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn to_owned(&self) -> T[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)[src]
pub fn clone_into(&self, target: &mut T)[src]🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more