pub struct IntRange {
pub lo: MaybeInfiniteInt,
pub hi: MaybeInfiniteInt,
}
Expand description
An exclusive interval, used for precise integer exhaustiveness checking. IntRange
s always
store a contiguous range.
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§
§lo: MaybeInfiniteInt
§hi: MaybeInfiniteInt
Implementations§
source§impl IntRange
impl IntRange
sourcepub fn is_singleton(&self) -> bool
pub fn is_singleton(&self) -> bool
Best effort; will not know that e.g. 255u8..
is a singleton.
sourcepub fn from_singleton(x: MaybeInfiniteInt) -> IntRange
pub fn from_singleton(x: MaybeInfiniteInt) -> IntRange
Construct a singleton range.
x
must be a Finite(_)
value.
sourcepub fn from_range(
lo: MaybeInfiniteInt,
hi: MaybeInfiniteInt,
end: RangeEnd,
) -> IntRange
pub fn from_range( lo: MaybeInfiniteInt, hi: MaybeInfiniteInt, end: RangeEnd, ) -> IntRange
Construct a range with these boundaries.
lo
must not be PosInfinity
. hi
must not be NegInfinity
.
fn is_subrange(&self, other: &Self) -> bool
fn intersection(&self, other: &Self) -> Option<Self>
sourcefn split(
&self,
column_ranges: impl Iterator<Item = IntRange>,
) -> impl Iterator<Item = (Presence, IntRange)>
fn split( &self, column_ranges: impl Iterator<Item = IntRange>, ) -> impl Iterator<Item = (Presence, IntRange)>
Partition a range of integers into disjoint subranges. This does constructor splitting for integer ranges as explained at the top of the file.
This returns an output that covers self
. The output is split so that the only
intersections between an output range and a column range are inclusions. No output range
straddles the boundary of one of the inputs.
Additionally, we track for each output range whether it is covered by one of the column ranges or not.
The following input:
(--------------------------) // `self`
(------) (----------) (-)
(------) (--------)
is first intersected with self
:
(--------------------------) // `self`
(----) (----------) (-)
(------) (--------)
and then iterated over as follows:
(-(--)-(-)-(------)-)--(-)-
where each sequence of dashes is an output range, and dashes outside parentheses are marked
as Presence::Missing
.
§isize
/usize
Whereas a wildcard of type i32
stands for the range i32::MIN..=i32::MAX
, a usize
wildcard stands for 0..PosInfinity
and a isize
wildcard stands for
NegInfinity..PosInfinity
. In other words, as far as IntRange
is concerned, there are
values before isize::MIN
and after usize::MAX
/isize::MAX
.
This is to avoid e.g. 0..(u32::MAX as usize)
from being exhaustive on one architecture and
not others. This was decided in https://github.com/rust-lang/rfcs/pull/2591.
These infinities affect splitting subtly: it is possible to get NegInfinity..0
and
usize::MAX+1..PosInfinity
in the output. Diagnostics must be careful to handle these
fictitious ranges sensibly.
Trait Implementations§
source§impl Debug for IntRange
impl Debug for IntRange
Note: this will render signed ranges incorrectly. To render properly, convert to a pattern first.
impl Copy for IntRange
impl Eq for IntRange
impl StructuralPartialEq for IntRange
Auto Trait Implementations§
impl DynSend for IntRange
impl DynSync for IntRange
impl Freeze for IntRange
impl RefUnwindSafe for IntRange
impl Send for IntRange
impl Sync for IntRange
impl Unpin for IntRange
impl UnwindSafe for IntRange
Blanket Implementations§
source§impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut T
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'tcx mut [T]
source§impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut T
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'tcx mut [T]
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<P> IntoQueryParam<P> for P
impl<P> IntoQueryParam<P> for P
fn into_query_param(self) -> P
source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
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: 64 bytes