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

Parses the input as an integer literal. Returns an error if the input is invalid or represents a different kind of literal.

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.

The base of this integer literal.

The main part containing the digits and potentially _. Do not try to parse this directly as that would ignore the base!

The type suffix, if specified.

Makes a copy of the underlying buffer and returns the owned version of Self.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.