[−][src]Struct indexing::Container
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]
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]
&self,
r: Range<I>
) -> Result<Range<'id, I, Unknown>, IndexError>
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]
&self,
idx: Index<'id, I, P>
) -> (Range<'id, I, Unknown>, Range<'id, I, P>)
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]
&self,
idx: Index<'id, I, NonEmpty>
) -> (Range<'id, I, NonEmpty>, Range<'id, I, Unknown>)
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]
&self,
r: Range<'id, I, P>
) -> (Range<'id, I, Unknown>, Range<'id, I, Unknown>)
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]
&self,
idx: Index<'id, I, NonEmpty>
) -> Range<'id, I, Unknown>
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]
&self,
idx: Index<'id, I, NonEmpty>
) -> Option<Index<'id, I, NonEmpty>>
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]
&self,
idx: Index<'id, I, P>,
offset: usize
) -> Result<Index<'id, I, NonEmpty>, IndexError>
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]
&self,
idx: Index<'id, I, P>,
offset: usize
) -> Result<Index<'id, I, NonEmpty>, IndexError>
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]
impl<'id, T> Container<'id, Vec<T>>
[src]
impl<'id> Container<'id, String>
[src]
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(&self) -> Self
[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.
fn index(&self, index: Index<'id, I, NonEmpty>) -> &Self::Output
[src]
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.
fn index(&self, r: Range<'id, I, P>) -> &Self::Output
[src]
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.
fn index(&self, r: RangeFrom<Index<'id, I, P>>) -> &Self::Output
[src]
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.
fn index(&self, r: RangeTo<Index<'id, I, P>>) -> &Self::Output
[src]
impl<'id, Array: TrustedContainer + ?Sized> Index<RangeFull> for Container<'id, Array>
[src]
Auto Trait Implementations
impl<'id, Array: ?Sized> Send for Container<'id, Array> where
Array: Send,
Array: Send,
impl<'id, Array: ?Sized> Sync for Container<'id, Array> where
Array: Sync,
Array: Sync,
Blanket Implementations
impl<'_, T, Array> TrustedItem<&'_ Array> for T where
Array: TrustedContainer<Item = T> + ?Sized,
T: TrustedItem<Array> + ?Sized,
[src]
Array: TrustedContainer<Item = T> + ?Sized,
T: TrustedItem<Array> + ?Sized,
type Unit = <T as TrustedItem<Array>>::Unit
fn vet<I>(
I,
&Container<'id, &Array>
) -> Result<Index<'id, I, Unknown>, IndexError> where
I: Idx,
[src]
I,
&Container<'id, &Array>
) -> Result<Index<'id, I, Unknown>, IndexError> where
I: Idx,
fn after<I>(
Index<'id, I, NonEmpty>,
&Container<'id, &Array>
) -> Index<'id, I, Unknown> where
I: Idx,
[src]
Index<'id, I, NonEmpty>,
&Container<'id, &Array>
) -> Index<'id, I, Unknown> where
I: Idx,
fn advance<I>(
Index<'id, I, NonEmpty>,
&Container<'id, &Array>
) -> Option<Index<'id, I, NonEmpty>> where
I: Idx,
[src]
Index<'id, I, NonEmpty>,
&Container<'id, &Array>
) -> Option<Index<'id, I, NonEmpty>> where
I: Idx,
impl<T> TrustedItem<[T]> for T
[src]
type Unit = T
fn vet<I>(I, &Container<'id, [T]>) -> Result<Index<'id, I, Unknown>, IndexError> where
I: Idx,
[src]
I: Idx,
fn after<I>(
Index<'id, I, NonEmpty>,
&Container<'id, [T]>
) -> Index<'id, I, Unknown> where
I: Idx,
[src]
Index<'id, I, NonEmpty>,
&Container<'id, [T]>
) -> Index<'id, I, Unknown> where
I: Idx,
fn advance<I>(
Index<'id, I, NonEmpty>,
&Container<'id, [T]>
) -> Option<Index<'id, I, NonEmpty>> where
I: Idx,
[src]
Index<'id, I, NonEmpty>,
&Container<'id, [T]>
) -> Option<Index<'id, I, NonEmpty>> where
I: Idx,
impl<T, Array> TrustedItem<Box<Array>> for T where
Array: TrustedContainer<Item = T> + ?Sized,
T: TrustedItem<Array> + ?Sized,
[src]
Array: TrustedContainer<Item = T> + ?Sized,
T: TrustedItem<Array> + ?Sized,
type Unit = <T as TrustedItem<Array>>::Unit
fn vet<I>(
I,
&Container<'id, Box<Array>>
) -> Result<Index<'id, I, Unknown>, IndexError> where
I: Idx,
[src]
I,
&Container<'id, Box<Array>>
) -> Result<Index<'id, I, Unknown>, IndexError> where
I: Idx,
fn after<I>(
Index<'id, I, NonEmpty>,
&Container<'id, Box<Array>>
) -> Index<'id, I, Unknown> where
I: Idx,
[src]
Index<'id, I, NonEmpty>,
&Container<'id, Box<Array>>
) -> Index<'id, I, Unknown> where
I: Idx,
fn advance<I>(
Index<'id, I, NonEmpty>,
&Container<'id, Box<Array>>
) -> Option<Index<'id, I, NonEmpty>> where
I: Idx,
[src]
Index<'id, I, NonEmpty>,
&Container<'id, Box<Array>>
) -> Option<Index<'id, I, NonEmpty>> where
I: Idx,
impl<T> TrustedItem<Vec<T>> for T where
T: TrustedItem<[T]>,
[src]
T: TrustedItem<[T]>,
type Unit = <T as TrustedItem<[T]>>::Unit
fn vet<I>(
I,
&Container<'id, Vec<T>>
) -> Result<Index<'id, I, Unknown>, IndexError> where
I: Idx,
[src]
I,
&Container<'id, Vec<T>>
) -> Result<Index<'id, I, Unknown>, IndexError> where
I: Idx,
fn after<I>(
Index<'id, I, NonEmpty>,
&Container<'id, Vec<T>>
) -> Index<'id, I, Unknown> where
I: Idx,
[src]
Index<'id, I, NonEmpty>,
&Container<'id, Vec<T>>
) -> Index<'id, I, Unknown> where
I: Idx,
fn advance<I>(
Index<'id, I, NonEmpty>,
&Container<'id, Vec<T>>
) -> Option<Index<'id, I, NonEmpty>> where
I: Idx,
[src]
Index<'id, I, NonEmpty>,
&Container<'id, Vec<T>>
) -> Option<Index<'id, I, NonEmpty>> where
I: Idx,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,