pub struct Range<'id, I: Idx = u32, Emptiness = Unknown> { /* private fields */ }
Expand description
A branded range.
Range<'id>
only indexes the container instantiated with the exact same
lifetime for the parameter 'id
created by the scope
function.
The range may carry a proof of non-emptiness (Emptiness
),
which enables further operations.
Implementations§
Source§impl<'id, I: Idx, Emptiness> Range<'id, I, Emptiness>
impl<'id, I: Idx, Emptiness> Range<'id, I, Emptiness>
Sourcepub fn nonempty(&self) -> Option<Range<'id, I, NonEmpty>>
pub fn nonempty(&self) -> Option<Range<'id, I, NonEmpty>>
Try to create a proof that the range is nonempty.
Sourcepub fn start(&self) -> Index<'id, I, Emptiness>
pub fn start(&self) -> Index<'id, I, Emptiness>
The starting index. (Accessible if the range is NonEmpty
.)
Sourcepub fn split_at<E>(
&self,
index: Index<'id, I, E>,
) -> Option<(Range<'id, I>, Range<'id, I>)>
pub fn split_at<E>( &self, index: Index<'id, I, E>, ) -> Option<(Range<'id, I>, Range<'id, I>)>
Split around the middle index
if it is in this range.
Sourcepub fn contains_in<Array: TrustedContainer>(
&self,
index: I,
container: &Container<'id, Array>,
) -> Option<Index<'id, I, NonEmpty>>
pub fn contains_in<Array: TrustedContainer>( &self, index: I, container: &Container<'id, Array>, ) -> Option<Index<'id, I, NonEmpty>>
If the index is a valid absolute index within this range.
Sourcepub fn contains<P>(
&self,
index: Index<'id, I, P>,
) -> Option<Index<'id, I, NonEmpty>>
pub fn contains<P>( &self, index: Index<'id, I, P>, ) -> Option<Index<'id, I, NonEmpty>>
If the index is within this range. Provides a nonempty proof.
Sourcepub fn join<Q>(
&self,
other: Range<'id, I, Q>,
) -> Option<Range<'id, I, <(Emptiness, Q) as ProofAdd>::Sum>>where
(Emptiness, Q): ProofAdd,
pub fn join<Q>(
&self,
other: Range<'id, I, Q>,
) -> Option<Range<'id, I, <(Emptiness, Q) as ProofAdd>::Sum>>where
(Emptiness, Q): ProofAdd,
Join together two adjacent ranges. (They must be exactly touching, non-overlapping, and in order.)
Sourcepub fn join_cover<Q>(
&self,
other: Range<'id, I, Q>,
) -> Range<'id, I, <(Emptiness, Q) as ProofAdd>::Sum>where
(Emptiness, Q): ProofAdd,
pub fn join_cover<Q>(
&self,
other: Range<'id, I, Q>,
) -> Range<'id, I, <(Emptiness, Q) as ProofAdd>::Sum>where
(Emptiness, Q): ProofAdd,
Extend the range to cover all of other
, including any space between.
Source§impl<'id, I: Idx> Range<'id, I, NonEmpty>
impl<'id, I: Idx> Range<'id, I, NonEmpty>
Sourcepub fn advance_in<Array: TrustedContainer>(
&mut self,
container: &Container<'id, Array>,
) -> bool
pub fn advance_in<Array: TrustedContainer>( &mut self, container: &Container<'id, Array>, ) -> bool
Increase the range’s start, if the result is still a non-empty range.
true
if stepped successfully, false
if the range would be empty.
Trait Implementations§
Source§impl<'id, I: Idx, Emptiness> From<Range<Index<'id, I, Emptiness>>> for Range<'id, I, Unknown>
§Note
In order to use this impl, you’ll likely need to erase the emptiness proof
from the indices to create the range. This doesn’t lose any Range
proof.
impl<'id, I: Idx, Emptiness> From<Range<Index<'id, I, Emptiness>>> for Range<'id, I, Unknown>
§Note
In order to use this impl, you’ll likely need to erase the emptiness proof
from the indices to create the range. This doesn’t lose any Range
proof.