pub(super) struct IntRange {
    range: RangeInclusive<u128>,
    bias: u128,
}
Expand description

An inclusive interval, used for precise integer exhaustiveness checking. IntRanges always store a contiguous range. This means that values are encoded such that 0 encodes the minimum value for the integer, regardless of the signedness. For example, the pattern -128..=127i8 is encoded as 0..=255. This makes comparisons and arithmetic on interval endpoints much more straightforward. See signed_bias for details.

IntRange is never used to encode an empty range or a “range” that wraps around the (offset) space: i.e., range.lo <= range.hi.

Fields§

§range: RangeInclusive<u128>§bias: u128

Keeps the bias used for encoding the range. It depends on the type of the range and possibly the pointer size of the current architecture. The algorithm ensures we never compare IntRanges with different types/architectures.

Implementations§

Only used for displaying the range properly.

Lint on likely incorrect range patterns (#63987)

See Constructor::is_covered_by

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Note: this is often not what we want: e.g. false is converted into the range 0..=0 and would be displayed as such. To render properly, convert to a pattern first.

Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. 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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 56 bytes