pub struct IndexVec<I, T>where
I: Idx,{
vector: IndexVec<I, T>,
}Expand description
Contiguous indexed vector.
Fields§
§vector: IndexVec<I, T>Implementations§
Source§impl<I, T> IndexVec<I, T>where
I: Idx,
impl<I, T> IndexVec<I, T>where
I: Idx,
pub fn new() -> Self
pub fn with_capacity(capacity: usize) -> Self
pub fn from_vec(v: Vec<T>) -> Self
pub fn from_array<const N: usize>(v: [T; N]) -> Self
Sourcepub fn remove(&mut self, _: I) -> Option<T>
pub fn remove(&mut self, _: I) -> Option<T>
Shadow the index_vec::IndexVec method because it silently shifts ids.
pub fn push_with(&mut self, f: impl FnOnce(I) -> T) -> I
pub fn extend_from_slice(&mut self, other: &Self)where
T: Clone,
Sourcepub fn insert_and_shift_ids(&mut self, id: I, x: T)
pub fn insert_and_shift_ids(&mut self, id: I, x: T)
Insert a value at that index, shifting all the values with equal or larger indices.
Sourcepub fn map<U>(self, f: impl FnMut(T) -> U) -> IndexVec<I, U>
pub fn map<U>(self, f: impl FnMut(T) -> U) -> IndexVec<I, U>
Map each entry to a new one, keeping the same ids.
Sourcepub fn map_ref<'a, U>(&'a self, f: impl FnMut(&'a T) -> U) -> IndexVec<I, U>
pub fn map_ref<'a, U>(&'a self, f: impl FnMut(&'a T) -> U) -> IndexVec<I, U>
Map each entry to a new one, keeping the same ids.
Sourcepub fn map_ref_mut<'a, U>(
&'a mut self,
f: impl FnMut(&'a mut T) -> U,
) -> IndexVec<I, U>
pub fn map_ref_mut<'a, U>( &'a mut self, f: impl FnMut(&'a mut T) -> U, ) -> IndexVec<I, U>
Map each entry to a new one, keeping the same ids.
Sourcepub fn map_ref_indexed<'a, U>(
&'a self,
f: impl FnMut(I, &'a T) -> U,
) -> IndexVec<I, U>
pub fn map_ref_indexed<'a, U>( &'a self, f: impl FnMut(I, &'a T) -> U, ) -> IndexVec<I, U>
Map each entry to a new one, keeping the same ids.
pub fn iter_indexed(&self) -> impl Iterator<Item = (I, &T)>
pub fn iter_mut_indexed(&mut self) -> impl Iterator<Item = (I, &mut T)>
pub fn into_iter_indexed(self) -> impl Iterator<Item = (I, T)>
pub fn iter_indexed_values(&self) -> impl Iterator<Item = (I, &T)>
pub fn into_iter_indexed_values(self) -> impl Iterator<Item = (I, T)>
pub fn iter_indices(&self) -> impl Iterator<Item = I> + '_
pub fn all_indices(&self) -> impl Iterator<Item = I> + use<I, T>
Methods from Deref<Target = IndexVec<I, T>>§
pub fn splice<R, It>(
&mut self,
range: R,
replace_with: It,
) -> Splice<'_, <It as IntoIterator>::IntoIter>where
It: IntoIterator<Item = T>,
R: IdxRangeBounds<I>,
pub fn splice<R, It>(
&mut self,
range: R,
replace_with: It,
) -> Splice<'_, <It as IntoIterator>::IntoIter>where
It: IntoIterator<Item = T>,
R: IdxRangeBounds<I>,
Creates a splicing iterator that replaces the specified range in the
vector with the given replace_with iterator and yields the removed
items. See Vec::splice
pub fn drain_enumerated<R>(
&mut self,
range: R,
) -> Map<Enumerate<Drain<'_, T>>, fn((usize, T)) -> (I, T)>where
R: IdxRangeBounds<I>,
pub fn drain_enumerated<R>(
&mut self,
range: R,
) -> Map<Enumerate<Drain<'_, T>>, fn((usize, T)) -> (I, T)>where
R: IdxRangeBounds<I>,
Similar to self.drain(r).enumerate() but with indices of I and not
usize.
pub fn next_idx(&self) -> I
pub fn next_idx(&self) -> I
Gives the next index that will be assigned when push is
called.
pub fn as_raw_slice(&self) -> &[T]
pub fn as_raw_slice(&self) -> &[T]
Get a the storage as a &[T]
pub fn as_raw_slice_mut(&mut self) -> &mut [T]
pub fn as_raw_slice_mut(&mut self) -> &mut [T]
Get a the storage as a &mut [T]
pub fn as_mut_vec(&mut self) -> &mut Vec<T>
pub fn as_mut_vec(&mut self) -> &mut Vec<T>
Equivalent to accessing our raw field mutably, but as a function, if
that’s what you’d prefer.
pub fn push(&mut self, d: T) -> I
pub fn push(&mut self, d: T) -> I
Push a new item onto the vector, and return it’s index.
pub fn drain<R>(&mut self, range: R) -> Drain<'_, T>where
R: IdxRangeBounds<I>,
pub fn drain<R>(&mut self, range: R) -> Drain<'_, T>where
R: IdxRangeBounds<I>,
Return an iterator that removes the items from the requested range. See
Vec::drain.
See also [IndexVec::drain_enumerated], which gives you indices (of the
correct type) as you iterate.
pub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of the vector as much as possible.
pub fn truncate(&mut self, a: usize)
pub fn truncate(&mut self, a: usize)
Shortens the vector, keeping the first len elements and dropping
the rest. See Vec::truncate
pub fn clear(&mut self)
pub fn clear(&mut self)
Clear our vector. See Vec::clear.
pub fn reserve(&mut self, c: usize)
pub fn reserve(&mut self, c: usize)
Reserve capacity for c more elements. See Vec::reserve
pub fn get<J>(&self, index: J) -> Option<&<J as IdxSliceIndex<I, T>>::Output>where
J: IdxSliceIndex<I, T>,
pub fn get<J>(&self, index: J) -> Option<&<J as IdxSliceIndex<I, T>>::Output>where
J: IdxSliceIndex<I, T>,
Get a ref to the item at the provided index, or None for out of bounds.
pub fn get_mut<J>(
&mut self,
index: J,
) -> Option<&mut <J as IdxSliceIndex<I, T>>::Output>where
J: IdxSliceIndex<I, T>,
pub fn get_mut<J>(
&mut self,
index: J,
) -> Option<&mut <J as IdxSliceIndex<I, T>>::Output>where
J: IdxSliceIndex<I, T>,
Get a mut ref to the item at the provided index, or None for out of bounds
pub fn resize(&mut self, new_len: usize, value: T)where
T: Clone,
pub fn resize(&mut self, new_len: usize, value: T)where
T: Clone,
Resize ourselves in-place to new_len. See Vec::resize.
pub fn resize_with<F>(&mut self, new_len: usize, f: F)where
F: FnMut() -> T,
pub fn resize_with<F>(&mut self, new_len: usize, f: F)where
F: FnMut() -> T,
Resize ourselves in-place to new_len. See Vec::resize_with.
pub fn append(&mut self, other: &mut IndexVec<I, T>)
pub fn append(&mut self, other: &mut IndexVec<I, T>)
Moves all the elements of other into Self, leaving other empty.
See Vec::append.
pub fn split_off(&mut self, idx: I) -> IndexVec<I, T>
pub fn split_off(&mut self, idx: I) -> IndexVec<I, T>
Splits the collection into two at the given index. See
Vec::split_off.
pub fn remove(&mut self, index: I) -> T
pub fn remove(&mut self, index: I) -> T
Remove the item at index. See Vec::remove.
pub fn swap_remove(&mut self, index: I) -> T
pub fn swap_remove(&mut self, index: I) -> T
Remove the item at index without maintaining order. See
Vec::swap_remove.
pub fn insert(&mut self, index: I, element: T)
pub fn insert(&mut self, index: I, element: T)
Insert an item at index. See Vec::insert.
pub fn extend_from_slice(&mut self, other: &IndexSlice<I, [T]>)where
T: Clone,
pub fn extend_from_slice(&mut self, other: &IndexSlice<I, [T]>)where
T: Clone,
Append all items in the slice to the end of our vector.
pub fn retain<F>(&mut self, f: F)
pub fn retain<F>(&mut self, f: F)
Forwards to the Vec::retain implementation.
pub fn dedup_by_key<F, K>(&mut self, key: F)
pub fn dedup_by_key<F, K>(&mut self, key: F)
Forwards to the Vec::dedup_by_key implementation.
pub fn dedup_by<F>(&mut self, same_bucket: F)
pub fn dedup_by<F>(&mut self, same_bucket: F)
Forwards to the Vec::dedup_by implementation.
pub fn as_slice(&self) -> &IndexSlice<I, [T]>
pub fn as_slice(&self) -> &IndexSlice<I, [T]>
Get a IndexSlice over this vector. See as_raw_slice for converting to
a &[T] (or access self.raw).
pub fn as_mut_slice(&mut self) -> &mut IndexSlice<I, [T]>
pub fn as_mut_slice(&mut self) -> &mut IndexSlice<I, [T]>
Get a mutable IndexSlice over this vector. See as_raw_slice_mut for
converting to a &mut [T] (or access self.raw).
Methods from Deref<Target = IndexSlice<I, [A]>>§
pub fn as_raw_slice_mut(&mut self) -> &mut [T]
pub fn as_raw_slice_mut(&mut self) -> &mut [T]
Returns the underlying slice.
pub fn as_raw_slice(&self) -> &[T]
pub fn as_raw_slice(&self) -> &[T]
Returns the underlying slice.
pub fn as_mut_ptr(&mut self) -> *mut T
pub fn as_mut_ptr(&mut self) -> *mut T
Returns an unsafe mutable pointer to the slice’s buffer.
pub fn last_idx(&self) -> I
pub fn last_idx(&self) -> I
Return the index of the last element, or panic.
pub fn len_idx(&self) -> I
pub fn len_idx(&self) -> I
Returns the length of our slice as an I.
pub fn iter(&self) -> Iter<'_, T>
pub fn iter(&self) -> Iter<'_, T>
Get a iterator over reverences to our values.
See also [IndexSlice::iter_enumerated], which gives you indices (of the
correct type) as you iterate.
pub fn iter_mut(&mut self) -> IterMut<'_, T>
pub fn iter_mut(&mut self) -> IterMut<'_, T>
Get a iterator over mut reverences to our values.
See also [IndexSlice::iter_mut_enumerated], which gives you indices (of
the correct type) as you iterate.
pub fn iter_enumerated(
&self,
) -> Map<Enumerate<Iter<'_, T>>, fn((usize, &T)) -> (I, &T)>
pub fn iter_enumerated( &self, ) -> Map<Enumerate<Iter<'_, T>>, fn((usize, &T)) -> (I, &T)>
Similar to self.iter().enumerate() but with indices of I and not
usize.
pub fn iter_mut_enumerated(
&mut self,
) -> Map<Enumerate<IterMut<'_, T>>, fn((usize, &mut T)) -> (I, &mut T)>
pub fn iter_mut_enumerated( &mut self, ) -> Map<Enumerate<IterMut<'_, T>>, fn((usize, &mut T)) -> (I, &mut T)>
Similar to self.iter_mut().enumerate() but with indices of I and not
usize.
pub fn sort_by<F>(&mut self, compare: F)
pub fn sort_by<F>(&mut self, compare: F)
Forwards to the slice’s sort_by implementation.
pub fn sort_by_key<F, K>(&mut self, f: F)
pub fn sort_by_key<F, K>(&mut self, f: F)
Forwards to the slice’s sort_by_key implementation.
pub fn sort_by_cached_key<F, K>(&mut self, f: F)
pub fn sort_by_cached_key<F, K>(&mut self, f: F)
Forwards to the slice’s sort_by_cached_key implementation.
pub fn sort_unstable(&mut self)where
T: Ord,
pub fn sort_unstable(&mut self)where
T: Ord,
Forwards to the slice’s sort_unstable implementation.
pub fn sort_unstable_by<F>(&mut self, compare: F)
pub fn sort_unstable_by<F>(&mut self, compare: F)
Forwards to the slice’s sort_unstable_by implementation.
pub fn sort_unstable_by_key<F, K>(&mut self, f: F)
pub fn sort_unstable_by_key<F, K>(&mut self, f: F)
Forwards to the slice’s sort_unstable_by_key implementation.
pub fn starts_with<S>(&self, needle: &S) -> bool
pub fn starts_with<S>(&self, needle: &S) -> bool
Forwards to the slice’s starts_with implementation.
pub fn contains(&self, x: &T) -> boolwhere
T: PartialEq,
pub fn contains(&self, x: &T) -> boolwhere
T: PartialEq,
Forwards to the slice’s contains implementation.
pub fn reverse(&mut self)
pub fn reverse(&mut self)
Forwards to the slice’s reverse implementation.
pub fn binary_search(&self, value: &T) -> Result<I, I>where
T: Ord,
pub fn binary_search(&self, value: &T) -> Result<I, I>where
T: Ord,
Call slice::binary_search converting the indices it gives us back as
needed.
pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<I, I>
pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<I, I>
Binary searches this sorted vec with a comparator function, converting the indices it gives us back to our Idx type.
pub fn copy_from_slice(&mut self, src: &IndexSlice<I, [T]>)where
T: Copy,
pub fn copy_from_slice(&mut self, src: &IndexSlice<I, [T]>)where
T: Copy,
Copies all elements from src into self, using a memcpy.
pub fn clone_from_slice(&mut self, src: &IndexSlice<I, [T]>)where
T: Clone,
pub fn clone_from_slice(&mut self, src: &IndexSlice<I, [T]>)where
T: Clone,
Copies the elements from src into self.
pub fn swap_with_slice(&mut self, other: &mut IndexSlice<I, [T]>)
pub fn swap_with_slice(&mut self, other: &mut IndexSlice<I, [T]>)
Swaps all elements in self with those in other.
pub fn binary_search_by_key<'a, B, F>(&'a self, b: &B, f: F) -> Result<I, I>
pub fn binary_search_by_key<'a, B, F>(&'a self, b: &B, f: F) -> Result<I, I>
Binary searches this sorted vec with a key extraction function, converting the indices it gives us back to our Idx type.
pub fn position<F>(&self, f: F) -> Option<I>
pub fn position<F>(&self, f: F) -> Option<I>
Searches for an element in an iterator, returning its index. This is
equivalent to Iterator::position, but returns I and not usize.
pub fn rposition<F>(&self, f: F) -> Option<I>
pub fn rposition<F>(&self, f: F) -> Option<I>
Searches for an element in an iterator from the right, returning its
index. This is equivalent to Iterator::position, but returns I and
not usize.
pub fn swap(&mut self, a: I, b: I)
pub fn swap(&mut self, a: I, b: I)
Swaps two elements in our vector.
pub fn split_at(&self, a: I) -> (&IndexSlice<I, [T]>, &IndexSlice<I, [T]>)
pub fn split_at(&self, a: I) -> (&IndexSlice<I, [T]>, &IndexSlice<I, [T]>)
Divides our slice into two at an index.
pub fn split_at_mut(
&mut self,
a: I,
) -> (&mut IndexSlice<I, [T]>, &mut IndexSlice<I, [T]>)
pub fn split_at_mut( &mut self, a: I, ) -> (&mut IndexSlice<I, [T]>, &mut IndexSlice<I, [T]>)
Divides our slice into two at an index.
pub fn rotate_left(&mut self, mid: I)
pub fn rotate_left(&mut self, mid: I)
Rotates our data in-place such that the first mid elements of the
slice move to the end while the last self.len() - mid elements move to
the front
pub fn rotate_right(&mut self, k: I)
pub fn rotate_right(&mut self, k: I)
Rotates our data in-place such that the first self.len() - k elements
of the slice move to the end while the last k elements move to the
front
pub fn copy_within<R>(&mut self, src: R, dst: I)where
R: IdxRangeBounds<I>,
T: Copy,
pub fn copy_within<R>(&mut self, src: R, dst: I)where
R: IdxRangeBounds<I>,
T: Copy,
Copies elements from one part of the slice to another part of itself, using a memmove.
pub fn get<J>(&self, index: J) -> Option<&<J as IdxSliceIndex<I, T>>::Output>where
J: IdxSliceIndex<I, T>,
pub fn get<J>(&self, index: J) -> Option<&<J as IdxSliceIndex<I, T>>::Output>where
J: IdxSliceIndex<I, T>,
Get a ref to the item at the provided index, or None for out of bounds.
pub fn get_mut<J>(
&mut self,
index: J,
) -> Option<&mut <J as IdxSliceIndex<I, T>>::Output>where
J: IdxSliceIndex<I, T>,
pub fn get_mut<J>(
&mut self,
index: J,
) -> Option<&mut <J as IdxSliceIndex<I, T>>::Output>where
J: IdxSliceIndex<I, T>,
Get a mut ref to the item at the provided index, or None for out of bounds
pub fn windows(
&self,
size: usize,
) -> Map<Windows<'_, T>, fn(&[T]) -> &IndexSlice<I, [T]>>
pub fn windows( &self, size: usize, ) -> Map<Windows<'_, T>, fn(&[T]) -> &IndexSlice<I, [T]>>
Wraps the underlying slice’s windows iterator with one that yields
IndexSlices with the correct index type.
pub fn chunks(
&self,
size: usize,
) -> Map<Chunks<'_, T>, fn(&[T]) -> &IndexSlice<I, [T]>>
pub fn chunks( &self, size: usize, ) -> Map<Chunks<'_, T>, fn(&[T]) -> &IndexSlice<I, [T]>>
Wraps the underlying slice’s chunks iterator with one that yields
IndexSlices with the correct index type.
pub fn chunks_mut(
&mut self,
size: usize,
) -> Map<ChunksMut<'_, T>, fn(&mut [T]) -> &mut IndexSlice<I, [T]>>
pub fn chunks_mut( &mut self, size: usize, ) -> Map<ChunksMut<'_, T>, fn(&mut [T]) -> &mut IndexSlice<I, [T]>>
Wraps the underlying slice’s chunks_mut iterator with one that yields
IndexSlices with the correct index type.
pub fn chunks_exact(
&self,
chunk_size: usize,
) -> Map<ChunksExact<'_, T>, fn(&[T]) -> &IndexSlice<I, [T]>>
pub fn chunks_exact( &self, chunk_size: usize, ) -> Map<ChunksExact<'_, T>, fn(&[T]) -> &IndexSlice<I, [T]>>
Wraps the underlying slice’s chunks_exact iterator with one that
yields IndexSlices with the correct index type.
pub fn chunks_exact_mut(
&mut self,
chunk_size: usize,
) -> Map<ChunksExactMut<'_, T>, fn(&mut [T]) -> &mut IndexSlice<I, [T]>>
pub fn chunks_exact_mut( &mut self, chunk_size: usize, ) -> Map<ChunksExactMut<'_, T>, fn(&mut [T]) -> &mut IndexSlice<I, [T]>>
Wraps the underlying slice’s chunks_exact_mut iterator with one that
yields IndexSlices with the correct index type.
pub fn rchunks(
&self,
size: usize,
) -> Map<RChunks<'_, T>, fn(&[T]) -> &IndexSlice<I, [T]>>
pub fn rchunks( &self, size: usize, ) -> Map<RChunks<'_, T>, fn(&[T]) -> &IndexSlice<I, [T]>>
Wraps the underlying slice’s rchunks iterator with one that yields
IndexSlices with the correct index type.
pub fn rchunks_mut(
&mut self,
size: usize,
) -> Map<RChunksMut<'_, T>, fn(&mut [T]) -> &mut IndexSlice<I, [T]>>
pub fn rchunks_mut( &mut self, size: usize, ) -> Map<RChunksMut<'_, T>, fn(&mut [T]) -> &mut IndexSlice<I, [T]>>
Wraps the underlying slice’s rchunks_mut iterator with one that yields
IndexSlices with the correct index type.
pub fn rchunks_exact(
&self,
chunk_size: usize,
) -> Map<RChunksExact<'_, T>, fn(&[T]) -> &IndexSlice<I, [T]>>
pub fn rchunks_exact( &self, chunk_size: usize, ) -> Map<RChunksExact<'_, T>, fn(&[T]) -> &IndexSlice<I, [T]>>
Wraps the underlying slice’s rchunks_exact iterator with one that
yields IndexSlices with the correct index type.
pub fn rchunks_exact_mut(
&mut self,
chunk_size: usize,
) -> Map<RChunksExactMut<'_, T>, fn(&mut [T]) -> &mut IndexSlice<I, [T]>>
pub fn rchunks_exact_mut( &mut self, chunk_size: usize, ) -> Map<RChunksExactMut<'_, T>, fn(&mut [T]) -> &mut IndexSlice<I, [T]>>
Wraps the underlying slice’s rchunks_exact_mut iterator with one that
yields IndexSlices with the correct index type.
pub fn split<F>(
&self,
f: F,
) -> Map<Split<'_, T, F>, fn(&[T]) -> &IndexSlice<I, [T]>>
pub fn split<F>( &self, f: F, ) -> Map<Split<'_, T, F>, fn(&[T]) -> &IndexSlice<I, [T]>>
Wraps the underlying slice’s split iterator with one that yields
IndexSlices with the correct index type.
pub fn split_mut<F>(
&mut self,
f: F,
) -> Map<SplitMut<'_, T, F>, fn(&mut [T]) -> &mut IndexSlice<I, [T]>>
pub fn split_mut<F>( &mut self, f: F, ) -> Map<SplitMut<'_, T, F>, fn(&mut [T]) -> &mut IndexSlice<I, [T]>>
Wraps the underlying slice’s split_mut iterator with one that yields
IndexSlices with the correct index type.
pub fn rsplit<F>(
&self,
f: F,
) -> Map<RSplit<'_, T, F>, fn(&[T]) -> &IndexSlice<I, [T]>>
pub fn rsplit<F>( &self, f: F, ) -> Map<RSplit<'_, T, F>, fn(&[T]) -> &IndexSlice<I, [T]>>
Wraps the underlying slice’s rsplit iterator with one that yields
IndexSlices with the correct index type.
pub fn rsplit_mut<F>(
&mut self,
f: F,
) -> Map<RSplitMut<'_, T, F>, fn(&mut [T]) -> &mut IndexSlice<I, [T]>>
pub fn rsplit_mut<F>( &mut self, f: F, ) -> Map<RSplitMut<'_, T, F>, fn(&mut [T]) -> &mut IndexSlice<I, [T]>>
Wraps the underlying slice’s rsplit_mut iterator with one that yields
IndexSlices with the correct index type.
pub fn splitn<F>(
&self,
n: usize,
f: F,
) -> Map<SplitN<'_, T, F>, fn(&[T]) -> &IndexSlice<I, [T]>>
pub fn splitn<F>( &self, n: usize, f: F, ) -> Map<SplitN<'_, T, F>, fn(&[T]) -> &IndexSlice<I, [T]>>
Wraps the underlying slice’s splitn iterator with one that yields
IndexSlices with the correct index type.
pub fn splitn_mut<F>(
&mut self,
n: usize,
f: F,
) -> Map<SplitNMut<'_, T, F>, fn(&mut [T]) -> &mut IndexSlice<I, [T]>>
pub fn splitn_mut<F>( &mut self, n: usize, f: F, ) -> Map<SplitNMut<'_, T, F>, fn(&mut [T]) -> &mut IndexSlice<I, [T]>>
Wraps the underlying slice’s splitn_mut iterator with one that yields
IndexSlices with the correct index type.
pub fn rsplitn<F>(
&self,
n: usize,
f: F,
) -> Map<RSplitN<'_, T, F>, fn(&[T]) -> &IndexSlice<I, [T]>>
pub fn rsplitn<F>( &self, n: usize, f: F, ) -> Map<RSplitN<'_, T, F>, fn(&[T]) -> &IndexSlice<I, [T]>>
Wraps the underlying slice’s rsplitn iterator with one that yields
IndexSlices with the correct index type.
pub fn rsplitn_mut<F>(
&mut self,
n: usize,
f: F,
) -> Map<RSplitNMut<'_, T, F>, fn(&mut [T]) -> &mut IndexSlice<I, [T]>>
pub fn rsplitn_mut<F>( &mut self, n: usize, f: F, ) -> Map<RSplitNMut<'_, T, F>, fn(&mut [T]) -> &mut IndexSlice<I, [T]>>
Wraps the underlying slice’s rsplitn_mut iterator with one that yields
IndexSlices with the correct index type.
pub fn split_first(&self) -> Option<(&T, &IndexSlice<I, [T]>)>
pub fn split_first(&self) -> Option<(&T, &IndexSlice<I, [T]>)>
Returns the first and all the rest of the elements of the slice, or None if it is empty.
pub fn split_first_mut(&mut self) -> Option<(&mut T, &mut IndexSlice<I, [T]>)>
pub fn split_first_mut(&mut self) -> Option<(&mut T, &mut IndexSlice<I, [T]>)>
Returns the first and all the rest of the elements of the slice, or None if it is empty.
pub fn split_last(&self) -> Option<(&T, &IndexSlice<I, [T]>)>
pub fn split_last(&self) -> Option<(&T, &IndexSlice<I, [T]>)>
Returns the last and all the rest of the elements of the slice, or None if it is empty.
pub fn split_last_mut(&mut self) -> Option<(&mut T, &mut IndexSlice<I, [T]>)>
pub fn split_last_mut(&mut self) -> Option<(&mut T, &mut IndexSlice<I, [T]>)>
Returns the last and all the rest of the elements of the slice, or None if it is empty.
Trait Implementations§
Source§impl<I: Idx, T: AstVisitable> AstVisitable for IndexVec<I, T>
impl<I: Idx, T: AstVisitable> AstVisitable for IndexVec<I, T>
Source§fn drive<V: VisitAst>(&self, v: &mut V) -> ControlFlow<V::Break>
fn drive<V: VisitAst>(&self, v: &mut V) -> ControlFlow<V::Break>
visit_$any
method if it exists, otherwise visit_inner.Source§fn drive_mut<V: VisitAstMut>(&mut self, v: &mut V) -> ControlFlow<V::Break>
fn drive_mut<V: VisitAstMut>(&mut self, v: &mut V) -> ControlFlow<V::Break>
visit_$any
method if it exists, otherwise visit_inner.Source§fn dyn_visit<T: AstVisitable>(&self, f: impl FnMut(&T))
fn dyn_visit<T: AstVisitable>(&self, f: impl FnMut(&T))
self, in pre-order traversal.Source§fn dyn_visit_mut<T: AstVisitable>(&mut self, f: impl FnMut(&mut T))
fn dyn_visit_mut<T: AstVisitable>(&mut self, f: impl FnMut(&mut T))
self, in pre-order traversal.Source§impl<I: Idx, T: BodyVisitable> BodyVisitable for IndexVec<I, T>
impl<I: Idx, T: BodyVisitable> BodyVisitable for IndexVec<I, T>
Source§fn drive_body<V: VisitBody>(&self, v: &mut V) -> ControlFlow<V::Break>
fn drive_body<V: VisitBody>(&self, v: &mut V) -> ControlFlow<V::Break>
visit_$any
method if it exists, otherwise visit_inner.Source§fn drive_body_mut<V: VisitBodyMut>(
&mut self,
v: &mut V,
) -> ControlFlow<V::Break>
fn drive_body_mut<V: VisitBodyMut>( &mut self, v: &mut V, ) -> ControlFlow<V::Break>
visit_$any
method if it exists, otherwise visit_inner.Source§fn dyn_visit_in_body<T: BodyVisitable>(&self, f: impl FnMut(&T))
fn dyn_visit_in_body<T: BodyVisitable>(&self, f: impl FnMut(&T))
self, in pre-order traversal.Source§fn dyn_visit_in_body_mut<T: BodyVisitable>(&mut self, f: impl FnMut(&mut T))
fn dyn_visit_in_body_mut<T: BodyVisitable>(&mut self, f: impl FnMut(&mut T))
self, in pre-order traversal.Source§impl<'de, I: Idx, T: Deserialize<'de>> Deserialize<'de> for IndexVec<I, T>
impl<'de, I: Idx, T: Deserialize<'de>> Deserialize<'de> for IndexVec<I, T>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<'de, I: Idx, State, T: DeserializeState<'de, State>> DeserializeState<'de, State> for IndexVec<I, T>
impl<'de, I: Idx, State, T: DeserializeState<'de, State>> DeserializeState<'de, State> for IndexVec<I, T>
fn deserialize_state<D>(
state: &State,
deserializer: D,
) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<'s, I: Idx, T, V: Visit<'s, T>> Drive<'s, V> for IndexVec<I, T>
impl<'s, I: Idx, T, V: Visit<'s, T>> Drive<'s, V> for IndexVec<I, T>
Source§fn drive_inner(&'s self, v: &mut V) -> ControlFlow<V::Break>
fn drive_inner(&'s self, v: &mut V) -> ControlFlow<V::Break>
v.visit() on the immediate contents of self.Source§impl<'s, I: Idx, T, V: VisitMut<'s, T>> DriveMut<'s, V> for IndexVec<I, T>
impl<'s, I: Idx, T, V: VisitMut<'s, T>> DriveMut<'s, V> for IndexVec<I, T>
Source§fn drive_inner_mut(&'s mut self, v: &mut V) -> ControlFlow<V::Break>
fn drive_inner_mut(&'s mut self, v: &mut V) -> ControlFlow<V::Break>
v.visit() on the immediate contents of self.Source§impl<I, T> FromIterator<T> for IndexVec<I, T>where
I: Idx,
impl<I, T> FromIterator<T> for IndexVec<I, T>where
I: Idx,
Source§impl<I, R, T> IndexMut<R> for IndexVec<I, T>where
I: Idx,
R: IdxSliceIndex<I, T, Output = T>,
impl<I, R, T> IndexMut<R> for IndexVec<I, T>where
I: Idx,
R: IdxSliceIndex<I, T, Output = T>,
Source§impl<'a, I, T> IntoIterator for &'a IndexVec<I, T>where
I: Idx,
impl<'a, I, T> IntoIterator for &'a IndexVec<I, T>where
I: Idx,
Source§impl<'a, I, T> IntoIterator for &'a mut IndexVec<I, T>where
I: Idx,
impl<'a, I, T> IntoIterator for &'a mut IndexVec<I, T>where
I: Idx,
Source§impl<I, T> IntoIterator for IndexVec<I, T>where
I: Idx,
impl<I, T> IntoIterator for IndexVec<I, T>where
I: Idx,
Source§impl<I, T: Ord> Ord for IndexVec<I, T>
impl<I, T: Ord> Ord for IndexVec<I, T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<I, T: PartialOrd> PartialOrd for IndexVec<I, T>where
I: Idx + PartialOrd,
impl<I, T: PartialOrd> PartialOrd for IndexVec<I, T>where
I: Idx + PartialOrd,
Source§impl<I: Idx, State, T: SerializeState<State>> SerializeState<State> for IndexVec<I, T>
impl<I: Idx, State, T: SerializeState<State>> SerializeState<State> for IndexVec<I, T>
fn serialize_state<S>(
&self,
state: &State,
serializer: S,
) -> Result<S::Ok, S::Error>where
S: Serializer,
impl<I, T: Eq> Eq for IndexVec<I, T>
impl<I, T> StructuralPartialEq for IndexVec<I, T>where
I: Idx,
Auto Trait Implementations§
impl<I, T> Freeze for IndexVec<I, T>
impl<I, T> RefUnwindSafe for IndexVec<I, T>where
T: RefUnwindSafe,
impl<I, T> Send for IndexVec<I, T>where
T: Send,
impl<I, T> Sync for IndexVec<I, T>where
T: Sync,
impl<I, T> Unpin for IndexVec<I, T>where
T: Unpin,
impl<I, T> UnwindSafe for IndexVec<I, T>where
T: UnwindSafe,
Blanket Implementations§
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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more§impl<T> Joinable for Twhere
&'a T: for<'a> IntoIterator,
impl<T> Joinable for Twhere
&'a T: for<'a> IntoIterator,
type Collection = T
§fn join_with<S>(self, sep: S) -> Join<T, S>
fn join_with<S>(self, sep: S) -> Join<T, S>
Join] instance.
Note that the separator does not have to share the same type as the
iterator’s values. Read more§fn join_concat(self) -> Join<Self::Collection, NoSeparator>
fn join_concat(self) -> Join<Self::Collection, NoSeparator>
Display, the underlying elements will be directly concatenated.
Note that the separator, while empty, is still present, and will show
up if you iterate this instance. Read more§impl<I> RecreateContext<I> for I
impl<I> RecreateContext<I> for I
§fn recreate_context(_original_input: I, tail: I) -> I
fn recreate_context(_original_input: I, tail: I) -> I
Source§impl<T> TyVisitable for Twhere
T: AstVisitable,
impl<T> TyVisitable for Twhere
T: AstVisitable,
Source§fn visit_vars(&mut self, v: &mut impl VarsVisitor)
fn visit_vars(&mut self, v: &mut impl VarsVisitor)
self, as seen from the outside of self. This means
that any variable bound inside self will be skipped, and all the seen De Bruijn indices
will count from the outside of self.Source§fn substitute(self, generics: &GenericArgs) -> Self
fn substitute(self, generics: &GenericArgs) -> Self
self by replacing them with the provided values.
Note: if self is an item that comes from a TraitDecl, you most likely want to use
substitute_with_self.Source§fn substitute_explicits(self, generics: &GenericArgs) -> Self
fn substitute_explicits(self, generics: &GenericArgs) -> Self
Source§fn substitute_with_self(
self,
generics: &GenericArgs,
self_ref: &TraitRefKind,
) -> Self
fn substitute_with_self( self, generics: &GenericArgs, self_ref: &TraitRefKind, ) -> Self
TraitRefKind::Self trait ref.fn try_substitute( self, generics: &GenericArgs, ) -> Result<Self, GenericsMismatch>
fn try_substitute_with_self( self, generics: &GenericArgs, self_ref: &TraitRefKind, ) -> Result<Self, GenericsMismatch>
Source§fn move_under_binder(self) -> Self
fn move_under_binder(self) -> Self
Source§fn move_under_binders(self, depth: DeBruijnId) -> Self
fn move_under_binders(self, depth: DeBruijnId) -> Self
depth binders.Source§fn move_from_under_binder(self) -> Option<Self>
fn move_from_under_binder(self) -> Option<Self>
Source§fn move_from_under_binders(self, depth: DeBruijnId) -> Option<Self>
fn move_from_under_binders(self, depth: DeBruijnId) -> Option<Self>
depth binders. Returns None if it contains a variable bound in
one of these depth binders.Source§fn visit_db_id<B>(
&mut self,
f: impl FnMut(&mut DeBruijnId) -> ControlFlow<B>,
) -> ControlFlow<B>
fn visit_db_id<B>( &mut self, f: impl FnMut(&mut DeBruijnId) -> ControlFlow<B>, ) -> ControlFlow<B>
self, as seen from the outside of self. This means
that any variable bound inside self will be skipped, and all the seen indices will count
from the outside of self.