[][src]Struct indexing::Container

#[repr(transparent)]
pub struct Container<'id, Array: TrustedContainer + ?Sized> { /* fields omitted */ }

A branded container, that allows access only to indices and ranges with the exact same brand in the 'id parameter.

The elements in the underlying data structure are accessible partly through special purpose methods, and through indexing/slicing.

The container can be indexed with self[i] where i is a trusted, dereferenceable index or range. Indexing like this uses no runtime checking at all, as it is statically guaranteed correct.

Methods

impl<'id, Array: TrustedContainer + ?Sized, '_> Container<'id, &'_ Array>[src]

pub fn project(&self) -> &Container<'id, Array>[src]

impl<'id, Array: TrustedContainer + ?Sized> Container<'id, Array>[src]

pub fn untrusted(&self) -> &Array[src]

This container without the branding.

Note

The returned lifetime of &Array is not 'id! It's completely valid to drop the container during the scope, in which case this reference would become invalid. If you need a longer lifetime, consider using scope_ref such that the reference is guaranteed to live for the entire scope.

pub fn unit_len(&self) -> usize[src]

The length of the container in base item units.

pub fn start<I: Idx>(&self) -> Index<'id, I, Unknown>[src]

The zero index without a proof of contents.

pub fn end<I: Idx>(&self) -> Index<'id, I, Unknown>[src]

The index one past the end of this container.

pub fn empty_range<I: Idx>(&self) -> Range<'id, I, Unknown>[src]

The empty range 0..0.

pub fn range<I: Idx>(&self) -> Range<'id, I, Unknown>[src]

The full range of the container.

pub fn vet<I: Idx>(&self, idx: I) -> Result<Index<'id, I, NonEmpty>, IndexError>[src]

Vet an absolute index.

pub fn vet_range<I: Idx>(
    &self,
    r: Range<I>
) -> Result<Range<'id, I, Unknown>, IndexError>
[src]

Vet an absolute range.

pub fn split_at<I: Idx, P>(
    &self,
    idx: Index<'id, I, P>
) -> (Range<'id, I, Unknown>, Range<'id, I, P>)
[src]

Split the container in two at the given index, such that the second range contains the index.

pub fn split_after<I: Idx>(
    &self,
    idx: Index<'id, I, NonEmpty>
) -> (Range<'id, I, NonEmpty>, Range<'id, I, Unknown>)
[src]

Split the container in two after the given index, such that the first range contains the index.

pub fn split_around<I: Idx, P>(
    &self,
    r: Range<'id, I, P>
) -> (Range<'id, I, Unknown>, Range<'id, I, Unknown>)
[src]

Split around the range r creating ranges 0..r.start and r.end...

The input r and return values (s, t) cover teh whole container in the order s, r, t.

pub fn before<I: Idx, P>(&self, idx: Index<'id, I, P>) -> Range<'id, I, Unknown>[src]

Return the range before but not including the index.

pub fn after<I: Idx>(
    &self,
    idx: Index<'id, I, NonEmpty>
) -> Range<'id, I, Unknown>
[src]

Return the range after but not including the index.

pub fn advance<I: Idx>(
    &self,
    idx: Index<'id, I, NonEmpty>
) -> Option<Index<'id, I, NonEmpty>>
[src]

Advance an index to the next item in the container, if there is one.

pub fn advance_by<I: Idx, P>(
    &self,
    idx: Index<'id, I, P>,
    offset: usize
) -> Result<Index<'id, I, NonEmpty>, IndexError>
[src]

Advance an index by a given base unit offset, if the index at said offset is a valid item index.

pub fn decrease_by<I: Idx, P>(
    &self,
    idx: Index<'id, I, P>,
    offset: usize
) -> Result<Index<'id, I, NonEmpty>, IndexError>
[src]

Decrease an index by a given base unit offset, if the index at said offset is a valid item index.

impl<'id, Array: TrustedContainer + ?Sized> Container<'id, Box<Array>>[src]

pub fn project(&self) -> &Container<'id, Array>[src]

This is supported on feature="std" only.

impl<'id, T> Container<'id, Vec<T>>[src]

pub fn project(&self) -> &Container<'id, [T]>[src]

This is supported on feature="std" only.

impl<'id> Container<'id, String>[src]

pub fn project(&self) -> &Container<'id, str>[src]

This is supported on feature="std" only.

Trait Implementations

impl<'id, Array: TrustedContainer + Copy> Copy for Container<'id, Array>[src]

impl<'id, Array: TrustedContainer + Clone> Clone for Container<'id, Array>[src]

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

Performs copy-assignment from source. Read more

impl<'id, Array: TrustedContainer + Debug + ?Sized> Debug for Container<'id, Array>[src]

impl<'id, Array: TrustedContainer + ?Sized, I: Idx> Index<Index<'id, I, NonEmpty>> for Container<'id, Array>[src]

type Output = Array::Item

The returned type after indexing.

impl<'id, Array: TrustedContainer + ?Sized, I: Idx, P> Index<Range<'id, I, P>> for Container<'id, Array>[src]

type Output = Array::Slice

The returned type after indexing.

impl<'id, Array: TrustedContainer + ?Sized, I: Idx, P> Index<RangeFrom<Index<'id, I, P>>> for Container<'id, Array>[src]

type Output = Array::Slice

The returned type after indexing.

impl<'id, Array: TrustedContainer + ?Sized, I: Idx, P> Index<RangeTo<Index<'id, I, P>>> for Container<'id, Array>[src]

type Output = Array::Slice

The returned type after indexing.

impl<'id, Array: TrustedContainer + ?Sized> Index<RangeFull> for Container<'id, Array>[src]

type Output = Array::Slice

The returned type after indexing.

Auto Trait Implementations

impl<'id, Array: ?Sized> Send for Container<'id, Array> where
    Array: Send

impl<'id, Array: ?Sized> Sync for Container<'id, Array> where
    Array: Sync

Blanket Implementations

impl<'_, T, Array> TrustedItem<&'_ Array> for T where
    Array: TrustedContainer<Item = T> + ?Sized,
    T: TrustedItem<Array> + ?Sized
[src]

type Unit = <T as TrustedItem<Array>>::Unit

impl<T> TrustedItem<[T]> for T[src]

type Unit = T

impl<T, Array> TrustedItem<Box<Array>> for T where
    Array: TrustedContainer<Item = T> + ?Sized,
    T: TrustedItem<Array> + ?Sized
[src]

type Unit = <T as TrustedItem<Array>>::Unit

impl<T> TrustedItem<Vec<T>> for T where
    T: TrustedItem<[T]>, 
[src]

type Unit = <T as TrustedItem<[T]>>::Unit

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.