Struct indexing::Range [] [src]

pub struct Range<'id, Proof = Unknown> {
    // some fields omitted
}

A branded range.

Range<'id> only indexes the container instantiated with the exact same particular lifetime for the parameter 'id at its inception from the indices() constructor.

The Range may carry a proof of nonemptiness (type parameter Proof), which enables further methods.

Methods

impl<'id, P> Range<'id, P>
[src]

fn len(&self) -> usize

Return the length of the range.

fn is_empty(&self) -> bool

Return true if the range is empty.

fn nonempty(&self) -> Result<Range<'id, NonEmpty>, IndexingError>

Try to create a proof that the Range is nonempty; return a Result where the Ok branch carries a non-empty Range.

fn start(&self) -> usize

Return the start index.

fn end(&self) -> usize

Return the end index.

fn split_in_half(&self) -> (Range<'id>, Range<'id, P>)

Split the range in half, with the upper middle index landing in the latter half. Proof of length P transfers to the latter half.

fn split_at(&self, index: usize) -> (Range<'id>, Range<'id>, bool)

Split to length index; if past the end, return false and clamp to the end

index is a relative index.

fn contains(&self, abs_index: usize) -> Option<Index<'id>>

abs_index is an absolute index

fn subdivide(&self, n: usize) -> Subdivide<'id>

Return an iterator that divides the range in n parts, in as even length chunks as possible.

fn join<Q>(&self, other: Range<'id, Q>) -> Result<Range<'id, (P, Q)::Sum>, IndexingError> where (P, Q): ProofAdd

Join together two adjacent ranges (they must be exactly touching, and in left to right order).

fn join_cover<Q>(&self, other: Range<'id, Q>) -> Range<'id, (P, Q)::Sum> where (P, Q): ProofAdd

Extend the range to the end of other, including any space in between

fn join_cover_both<Q>(&self, other: Range<'id, Q>) -> Range<'id, (P, Q)::Sum> where (P, Q): ProofAdd

Extend the range to start and end of other, including any space in between

fn as_range(&self) -> Range<usize>

fn frontiers(&self) -> (Range<'id>, Range<'id>)

Return two empty ranges, at the front and the back of the range respectively

fn forward_by(&self, index: &mut Index<'id>, offset: usize) -> bool

Increment index, if doing so would still be before the end of the range

Return true if the index was incremented.

fn forward_range_by<Q>(&self, r: Range<'id, Q>, offset: usize) -> Range<'id>

Increment r, clamping to the end of self.

fn no_proof(&self) -> Range<'id>

impl<'id> Range<'id, NonEmpty>
[src]

fn first(&self) -> Index<'id>

fn lower_middle(&self) -> Index<'id>

Return the middle index, rounding down.

Produces mid where mid = start + (len - 1)/ 2.

fn upper_middle(&self) -> Index<'id>

Return the middle index, rounding up.

Produces mid where mid = start + len / 2.

fn last(&self) -> Index<'id>

fn tail(&self) -> Range<'id>

fn init(&self) -> Range<'id>

fn advance_(&self) -> Result<Range<'id, NonEmpty>, IndexingError>

fn advance(&mut self) -> bool

Increase the range's start, if the result is still a non-empty range.

Return true if stepped successfully, false if the range would be empty.

fn advance_by(&mut self, offset: usize) -> bool

Increase the range's start, if the result is still a non-empty range.

Return true if stepped successfully, false if the range would be empty.

fn advance_back(&mut self) -> bool

Decrease the range's end, if the result is still a non-empty range.

Return true if stepped successfully, false if the range would be empty.

Trait Implementations

impl<'id, P> Copy for Range<'id, P>
[src]

impl<'id, P> Clone for Range<'id, P>
[src]

fn clone(&self) -> Self

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl<'id, P, Q> PartialEq<Range<'id, Q>> for Range<'id, P>
[src]

fn eq(&self, other: &Range<'id, Q>) -> bool

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

fn ne(&self, other: &Rhs) -> bool
1.0.0

This method tests for !=.

impl<'id, P> Eq for Range<'id, P>
[src]

impl<'id, P> Debug for Range<'id, P>
[src]

fn fmt(&self, f: &mut Formatter) -> Result

Formats the value using the given formatter.

impl<'id> IntoCheckedRange<'id> for Range<'id>
[src]

fn into(self) -> Result<Range<'id, NonEmpty>, IndexingError>

impl<'id> IntoCheckedRange<'id> for Range<'id, NonEmpty>
[src]

fn into(self) -> Result<Range<'id, NonEmpty>, IndexingError>

impl<'id, P> IntoIterator for Range<'id, P>
[src]

type Item = Index<'id>

The type of the elements being iterated over.

type IntoIter = RangeIter<'id>

Which kind of iterator are we turning this into?

fn into_iter(self) -> RangeIter<'id>

Creates an iterator from a value. Read more