[−][src]Struct typed_index_collections::TiSlice
A dynamically-sized view into a contiguous sequence of T
that only accepts keys of the type K
.
TiSlice<K, V>
is a wrapper around Rust primitive type slice
.
The struct mirrors the stable API of Rust slice
and forwards to it as much as possible.
TiSlice<K, V>
uses K
instead of usize
for element indices.
It also uses Range
, RangeTo
, RangeFrom
, RangeInclusive
and
RangeToInclusive
range types with K
indices for get
-methods and index expressions.
The RangeFull
trait is not currently supported.
TiSlice<K, V>
require the index to implement Index
trait.
If default feature impl-index-from
is not disabled, this trait is automatically implemented
when From<usize>
and Into<usize>
are implemented.
And their implementation can be easily done
with derive_more
crate and #[derive(From, Into)]
.
There are also From
and Into
conversions available between types:
Added methods:
from_ref
- Converts a&[V]
into a&TiSlice<K, V>
.from_mut
- Converts a&mut [V]
into a&mut TiSlice<K, V>
.keys
- Returns an iterator over all keys.next_key
- Returns the index of the next slice element to be appended and at the same time number of elements in the slice of typeK
.first_key
- Returns the first slice element index of typeK
, orNone
if the slice is empty.first_key_value
- Returns the first slice element index of typeK
and the element itself, orNone
if the slice is empty.first_key_value_mut
- Returns the first slice element index of typeK
and a mutable reference to the element itself, orNone
if the slice is empty.last_key
- Returns the last slice element index of typeK
, orNone
if the slice is empty.last_key_value
- Returns the last slice element index of typeK
and the element itself, orNone
if the slice is empty.last_key_value_mut
- Returns the last slice element index of typeK
and a mutable reference to the element itself, orNone
if the slice is empty.iter_enumerated
- Returns an iterator over all key-value pairs. It acts likeself.iter().enumerate()
, but useK
instead ofusize
for iteration indices.iter_mut_enumerated
- Returns an iterator over all key-value pairs, with mutable references to the values. It acts likeself.iter_mut().enumerated()
, but useK
instead ofusize
for iteration indices.position
- Searches for an element in an iterator, returning its index of typeK
. It acts likeself.iter().position(...)
, but instead ofusize
it returns index of typeK
.rposition
- Searches for an element in an iterator from the right, returning its index of typeK
. It acts likeself.iter().rposition(...)
, but instead ofusize
it returns index of typeK
.
Example
use typed_index_collections::TiSlice; use derive_more::{From, Into}; #[derive(From, Into)] struct FooId(usize); let mut foos_raw = [1, 2, 5, 8]; let foos: &mut TiSlice<FooId, usize> = TiSlice::from_mut(&mut foos_raw); foos[FooId(2)] = 4; assert_eq!(foos[FooId(2)], 4);
Fields
raw: [V]
Raw slice property
Implementations
impl<K, V> TiSlice<K, V>
[src]
pub fn from_ref(raw: &[V]) -> &Self
[src]
Converts a &[V]
into a &TiSlice<K, V>
.
Example
pub struct Id(usize); let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4]);
pub fn from_mut(raw: &mut [V]) -> &mut Self
[src]
Converts a &mut [V]
into a &mut TiSlice<K, V>
.
Example
pub struct Id(usize); let slice: &mut TiSlice<Id, usize> = TiSlice::from_mut(&mut [1, 2, 4]);
pub fn len(&self) -> usize
[src]
Returns the number of elements in the slice.
See slice::len
.
pub fn next_key(&self) -> K where
K: Index,
[src]
K: Index,
Returns the index of the next slice element to be appended
and at the same time number of elements in the slice of type K
.
Example
#[derive(Eq, Debug, From, Into, PartialEq)] pub struct Id(usize); let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4]); assert_eq!(slice.next_key(), Id(3));
pub const fn is_empty(&self) -> bool
[src]
Returns true
if the slice has a length of 0.
See slice::is_empty
.
pub fn keys(&self) -> TiSliceKeys<K> where
K: Index,
[src]
K: Index,
Returns an iterator over all keys.
Example
#[derive(Debug, Eq, From, Into, PartialEq)] pub struct Id(usize); let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4]); let mut iterator = slice.keys(); assert_eq!(iterator.next(), Some(Id(0))); assert_eq!(iterator.next(), Some(Id(1))); assert_eq!(iterator.next(), Some(Id(2))); assert_eq!(iterator.next(), None);
pub fn first(&self) -> Option<&V>
[src]
Returns the first element of the slice, or None
if it is empty.
See slice::first
.
pub fn first_mut(&mut self) -> Option<&mut V>
[src]
Returns a mutable reference to the first element of the slice, or None
if it is empty.
See slice::first_mut
.
pub fn first_key(&self) -> Option<K> where
K: Index,
[src]
K: Index,
Returns the first slice element index of type K
, or None
if the slice is empty.
Example
#[derive(Debug, Eq, From, Into, PartialEq)] pub struct Id(usize); let empty_slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[]); let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4]); assert_eq!(empty_slice.first_key(), None); assert_eq!(slice.first_key(), Some(Id(0)));
pub fn first_key_value(&self) -> Option<(K, &V)> where
K: Index,
[src]
K: Index,
Returns the first slice element index of type K
and the element itself,
or None
if the slice is empty.
See slice::first
.
Example
#[derive(Debug, Eq, From, Into, PartialEq)] pub struct Id(usize); let empty_slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[]); let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4]); assert_eq!(empty_slice.first_key_value(), None); assert_eq!(slice.first_key_value(), Some((Id(0), &1)));
pub fn first_key_value_mut(&mut self) -> Option<(K, &mut V)> where
K: Index,
[src]
K: Index,
Returns the first slice element index of type K
and a mutable reference
to the element itself, or None
if the slice is empty.
See slice::first_mut
.
Example
#[derive(Debug, Eq, From, Into, PartialEq)] pub struct Id(usize); let empty_slice: &mut TiSlice<Id, usize> = TiSlice::from_mut(&mut []); let mut array = [1, 2, 4]; let slice: &mut TiSlice<Id, usize> = TiSlice::from_mut(&mut array); assert_eq!(empty_slice.first_key_value_mut(), None); assert_eq!(slice.first_key_value_mut(), Some((Id(0), &mut 1))); *slice.first_key_value_mut().unwrap().1 = 123; assert_eq!(slice.raw, [123, 2, 4]);
pub fn split_first(&self) -> Option<(&V, &TiSlice<K, V>)>
[src]
Returns the first and all the rest of the elements of the slice, or None
if it is empty.
See slice::split_first
.
pub fn split_first_mut(&mut self) -> Option<(&mut V, &mut TiSlice<K, V>)>
[src]
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<(&V, &TiSlice<K, V>)>
[src]
Returns the last and all the rest of the elements of the slice, or None
if it is empty.
See slice::split_last
.
pub fn split_last_mut(&mut self) -> Option<(&mut V, &mut TiSlice<K, V>)>
[src]
Returns the last and all the rest of the elements of the slice, or None
if it is empty.
pub fn last(&self) -> Option<&V>
[src]
Returns the last element of the slice of type K
, or None
if it is empty.
See slice::last
.
pub fn last_mut(&mut self) -> Option<&mut V>
[src]
Returns a mutable reference to the last item in the slice.
See slice::last_mut
.
pub fn last_key(&self) -> Option<K> where
K: Index,
[src]
K: Index,
Returns the last slice element index of type K
, or None
if the slice is empty.
Example
#[derive(Debug, Eq, From, Into, PartialEq)] pub struct Id(usize); let empty_slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[]); let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4]); assert_eq!(empty_slice.last_key(), None); assert_eq!(slice.last_key(), Some(Id(2)));
pub fn last_key_value(&self) -> Option<(K, &V)> where
K: Index,
[src]
K: Index,
Returns the last slice element index of type K
and the element itself,
or None
if the slice is empty.
See slice::last
.
Example
#[derive(Debug, Eq, From, Into, PartialEq)] pub struct Id(usize); let empty_slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[]); let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4]); assert_eq!(empty_slice.last_key_value(), None); assert_eq!(slice.last_key_value(), Some((Id(2), &4)));
pub fn last_key_value_mut(&mut self) -> Option<(K, &mut V)> where
K: Index,
[src]
K: Index,
Returns the last slice element index of type K
and a mutable reference
to the element itself, or None
if the slice is empty.
See slice::last_mut
.
Example
#[derive(Debug, Eq, From, Into, PartialEq)] pub struct Id(usize); let empty_slice: &mut TiSlice<Id, usize> = TiSlice::from_mut(&mut []); let mut array = [1, 2, 4]; let slice: &mut TiSlice<Id, usize> = TiSlice::from_mut(&mut array); assert_eq!(empty_slice.last_key_value_mut(), None); assert_eq!(slice.last_key_value_mut(), Some((Id(2), &mut 4))); *slice.last_key_value_mut().unwrap().1 = 123; assert_eq!(slice.raw, [1, 2, 123]);
pub fn get<I>(&self, index: I) -> Option<&I::Output> where
I: TiSliceIndex<K, V>,
[src]
I: TiSliceIndex<K, V>,
Returns a reference to an element or subslice
depending on the type of index or None
if the index is out of bounds.
See slice::get
.
pub fn get_mut<I>(&mut self, index: I) -> Option<&mut I::Output> where
I: TiSliceIndex<K, V>,
[src]
I: TiSliceIndex<K, V>,
Returns a mutable reference to an element or subslice
depending on the type of index or None
if the index is out of bounds.
See slice::get_mut
.
pub unsafe fn get_unchecked<I>(&self, index: I) -> &I::Output where
I: TiSliceIndex<K, V>,
[src]
I: TiSliceIndex<K, V>,
Returns a reference to an element or subslice depending on the type of index, without doing bounds checking.
This is generally not recommended, use with caution!
Calling this method with an out-of-bounds index is undefined behavior
even if the resulting reference is not used.
For a safe alternative see get
.
See slice::get_unchecked
.
pub unsafe fn get_unchecked_mut<I>(&mut self, index: I) -> &mut I::Output where
I: TiSliceIndex<K, V>,
[src]
I: TiSliceIndex<K, V>,
Returns a mutable reference to an element or subslice depending on the type of index, without doing bounds checking.
This is generally not recommended, use with caution!
Calling this method with an out-of-bounds index is undefined behavior
even if the resulting reference is not used.
For a safe alternative see get_mut
.
pub const fn as_ptr(&self) -> *const V
[src]
Returns a raw pointer to the slice's buffer.
See slice::as_ptr
.
pub fn as_mut_ptr(&mut self) -> *mut V
[src]
Returns an unsafe mutable reference to the slice's buffer.
See slice::as_mut_ptr
.
pub fn swap(&mut self, a: K, b: K) where
K: Index,
[src]
K: Index,
Swaps two elements in the slice.
See slice::swap
.
pub fn reverse(&mut self)
[src]
Reverses the order of elements in the slice, in place.
See slice::reverse
.
pub fn iter(&self) -> Iter<V>
[src]
Returns an iterator over the slice.
See slice::iter
.
pub fn iter_enumerated(&self) -> TiEnumerated<Iter<V>, K, &V> where
K: Index,
[src]
K: Index,
Returns an iterator over all key-value pairs.
See slice::iter
.
Example
#[derive(Debug, Eq, From, Into, PartialEq)] pub struct Id(usize); let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4]); let mut iterator = slice.iter_enumerated(); assert_eq!(iterator.next(), Some((Id(0), &1))); assert_eq!(iterator.next(), Some((Id(1), &2))); assert_eq!(iterator.next(), Some((Id(2), &4))); assert_eq!(iterator.next(), None);
pub fn iter_mut(&mut self) -> IterMut<V>
[src]
Returns an iterator that allows modifying each value.
See slice::iter_mut
.
pub fn iter_mut_enumerated(&mut self) -> TiEnumerated<IterMut<V>, K, &mut V> where
K: Index,
[src]
K: Index,
Returns an iterator over all key-value pairs, with mutable references to the values.
Example
#[derive(Debug, Eq, From, Into, PartialEq)] pub struct Id(usize); let mut array = [1, 2, 4]; let slice: &mut TiSlice<Id, usize> = TiSlice::from_mut(&mut array); for (key, value) in slice.iter_mut_enumerated() { *value += key.0; } assert_eq!(array, [1, 3, 6]);
pub fn position<P>(&self, predicate: P) -> Option<K> where
K: Index,
P: FnMut(&V) -> bool,
[src]
K: Index,
P: FnMut(&V) -> bool,
Searches for an element in an iterator, returning its index of type K
.
See slice::iter
and Iterator::position
.
Example
#[derive(Debug, Eq, From, Into, PartialEq)] pub struct Id(usize); let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4, 2, 1]); assert_eq!(slice.position(|&value| value == 1), Some(Id(0))); assert_eq!(slice.position(|&value| value == 2), Some(Id(1))); assert_eq!(slice.position(|&value| value == 3), None); assert_eq!(slice.position(|&value| value == 4), Some(Id(2)));
pub fn rposition<P>(&self, predicate: P) -> Option<K> where
K: Index,
P: FnMut(&V) -> bool,
[src]
K: Index,
P: FnMut(&V) -> bool,
Searches for an element in an iterator from the right, returning its index of type K
.
See slice::iter
and Iterator::position
.
Example
#[derive(Debug, Eq, From, Into, PartialEq)] pub struct Id(usize); let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4, 2, 1]); assert_eq!(slice.rposition(|&value| value == 1), Some(Id(4))); assert_eq!(slice.rposition(|&value| value == 2), Some(Id(3))); assert_eq!(slice.rposition(|&value| value == 3), None); assert_eq!(slice.rposition(|&value| value == 4), Some(Id(2)));
pub fn windows(&self, size: usize) -> TiSliceRefMap<Windows<V>, K, V>
[src]
Returns an iterator over all contiguous windows of length
size
. The windows overlap. If the slice is shorter than
size
, the iterator returns no values.
See slice::windows
.
pub fn chunks(&self, chunk_size: usize) -> TiSliceRefMap<Chunks<V>, K, V>
[src]
Returns an iterator over chunk_size
elements of the slice at a time, starting at the
beginning of the slice.
See slice::chunks
.
pub fn chunks_mut(
&mut self,
chunk_size: usize
) -> TiSliceMutMap<ChunksMut<V>, K, V>
[src]
&mut self,
chunk_size: usize
) -> TiSliceMutMap<ChunksMut<V>, K, V>
Returns an iterator over chunk_size
elements of the slice at a time, starting at the
beginning of the slice.
See slice::chunks_mut
.
pub fn chunks_exact(
&self,
chunk_size: usize
) -> TiSliceRefMap<ChunksExact<V>, K, V>
[src]
&self,
chunk_size: usize
) -> TiSliceRefMap<ChunksExact<V>, K, V>
Returns an iterator over chunk_size
elements of the slice at a time, starting at the
beginning of the slice.
See slice::chunks_exact
.
pub fn chunks_exact_mut(
&mut self,
chunk_size: usize
) -> TiSliceMutMap<ChunksExactMut<V>, K, V>
[src]
&mut self,
chunk_size: usize
) -> TiSliceMutMap<ChunksExactMut<V>, K, V>
Returns an iterator over chunk_size
elements of the slice at a time, starting at the
beginning of the slice.
pub fn rchunks(&self, chunk_size: usize) -> TiSliceRefMap<RChunks<V>, K, V>
[src]
Returns an iterator over chunk_size
elements of the slice at a time, starting at the end
of the slice.
See slice::rchunks
.
pub fn rchunks_mut(
&mut self,
chunk_size: usize
) -> TiSliceMutMap<RChunksMut<V>, K, V>
[src]
&mut self,
chunk_size: usize
) -> TiSliceMutMap<RChunksMut<V>, K, V>
Returns an iterator over chunk_size
elements of the slice at a time, starting at the end
of the slice.
See slice::rchunks_mut
.
pub fn rchunks_exact(
&self,
chunk_size: usize
) -> TiSliceRefMap<RChunksExact<V>, K, V>
[src]
&self,
chunk_size: usize
) -> TiSliceRefMap<RChunksExact<V>, K, V>
Returns an iterator over chunk_size
elements of the slice at a time, starting at the
end of the slice.
See slice::rchunks_exact
.
pub fn rchunks_exact_mut(
&mut self,
chunk_size: usize
) -> TiSliceMutMap<RChunksExactMut<V>, K, V>
[src]
&mut self,
chunk_size: usize
) -> TiSliceMutMap<RChunksExactMut<V>, K, V>
Returns an iterator over chunk_size
elements of the slice at a time, starting at the end
of the slice.
pub fn split_at(&self, mid: K) -> (&Self, &Self) where
K: Index,
[src]
K: Index,
Divides one slice into two at an index.
See slice::split_at
.
pub fn split_at_mut(&mut self, mid: K) -> (&mut Self, &mut Self) where
K: Index,
[src]
K: Index,
Divides one mutable slice into two at an index.
See slice::split_at_mut
.
pub fn split<F>(&self, pred: F) -> TiSliceRefMap<Split<V, F>, K, V> where
F: FnMut(&V) -> bool,
[src]
F: FnMut(&V) -> bool,
Returns an iterator over subslices separated by elements that match
pred
. The matched element is not contained in the subslices.
See slice::split
.
pub fn split_mut<F>(&mut self, pred: F) -> TiSliceMutMap<SplitMut<V, F>, K, V> where
F: FnMut(&V) -> bool,
[src]
F: FnMut(&V) -> bool,
Returns an iterator over mutable subslices separated by elements that
match pred
. The matched element is not contained in the subslices.
See slice::split_mut
.
pub fn rsplit<F>(&self, pred: F) -> TiSliceRefMap<RSplit<V, F>, K, V> where
F: FnMut(&V) -> bool,
[src]
F: FnMut(&V) -> bool,
Returns an iterator over subslices separated by elements that match
pred
, starting at the end of the slice and working backwards.
The matched element is not contained in the subslices.
See slice::rsplit
.
pub fn rsplit_mut<F>(&mut self, pred: F) -> TiSliceMutMap<RSplitMut<V, F>, K, V> where
F: FnMut(&V) -> bool,
[src]
F: FnMut(&V) -> bool,
Returns an iterator over mutable subslices separated by elements that
match pred
, starting at the end of the slice and working
backwards. The matched element is not contained in the subslices.
See slice::rsplit_mut
.
pub fn splitn<F>(&self, n: usize, pred: F) -> TiSliceRefMap<SplitN<V, F>, K, V> where
F: FnMut(&V) -> bool,
[src]
F: FnMut(&V) -> bool,
Returns an iterator over subslices separated by elements that match
pred
, limited to returning at most n
items. The matched element is
not contained in the subslices.
See slice::splitn
.
pub fn splitn_mut<F>(
&mut self,
n: usize,
pred: F
) -> TiSliceMutMap<SplitNMut<V, F>, K, V> where
F: FnMut(&V) -> bool,
[src]
&mut self,
n: usize,
pred: F
) -> TiSliceMutMap<SplitNMut<V, F>, K, V> where
F: FnMut(&V) -> bool,
Returns an iterator over subslices separated by elements that match
pred
, limited to returning at most n
items. The matched element is
not contained in the subslices.
See slice::splitn_mut
.
pub fn rsplitn<F>(
&self,
n: usize,
pred: F
) -> TiSliceRefMap<RSplitN<V, F>, K, V> where
F: FnMut(&V) -> bool,
[src]
&self,
n: usize,
pred: F
) -> TiSliceRefMap<RSplitN<V, F>, K, V> where
F: FnMut(&V) -> bool,
Returns an iterator over subslices separated by elements that match
pred
limited to returning at most n
items. This starts at the end of
the slice and works backwards. The matched element is not contained in
the subslices.
See slice::rsplitn
.
pub fn rsplitn_mut<F>(
&mut self,
n: usize,
pred: F
) -> TiSliceMutMap<RSplitNMut<V, F>, K, V> where
F: FnMut(&V) -> bool,
[src]
&mut self,
n: usize,
pred: F
) -> TiSliceMutMap<RSplitNMut<V, F>, K, V> where
F: FnMut(&V) -> bool,
Returns an iterator over subslices separated by elements that match
pred
limited to returning at most n
items. This starts at the end of
the slice and works backwards. The matched element is not contained in
the subslices.
See slice::rsplitn_mut
.
pub fn contains(&self, x: &V) -> bool where
V: PartialEq,
[src]
V: PartialEq,
Returns true
if the slice contains an element with the given value.
See slice::contains
.
pub fn starts_with(&self, needle: &Self) -> bool where
V: PartialEq,
[src]
V: PartialEq,
Returns true
if needle
is a prefix of the slice.
See slice::starts_with
.
pub fn ends_with(&self, needle: &Self) -> bool where
V: PartialEq,
[src]
V: PartialEq,
Returns true
if needle
is a suffix of the slice.
See slice::ends_with
.
pub fn binary_search(&self, x: &V) -> Result<K, K> where
V: Ord,
K: Index,
[src]
V: Ord,
K: Index,
Binary searches this sorted slice for a given element.
See slice::binary_search
.
pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<K, K> where
F: FnMut(&'a V) -> Ordering,
K: Index,
[src]
F: FnMut(&'a V) -> Ordering,
K: Index,
Binary searches this sorted slice with a comparator function.
pub fn binary_search_by_key<'a, B, F>(&'a self, b: &B, f: F) -> Result<K, K> where
F: FnMut(&'a V) -> B,
B: Ord,
K: Index,
[src]
F: FnMut(&'a V) -> B,
B: Ord,
K: Index,
Binary searches this sorted slice with a key extraction function.
pub fn sort_unstable(&mut self) where
V: Ord,
[src]
V: Ord,
Sorts the slice, but may not preserve the order of equal elements.
See slice::sort_unstable
.
pub fn sort_unstable_by<F>(&mut self, compare: F) where
F: FnMut(&V, &V) -> Ordering,
[src]
F: FnMut(&V, &V) -> Ordering,
Sorts the slice with a comparator function, but may not preserve the order of equal elements.
pub fn sort_unstable_by_key<K2, F>(&mut self, f: F) where
F: FnMut(&V) -> K2,
K2: Ord,
[src]
F: FnMut(&V) -> K2,
K2: Ord,
Sorts the slice with a key extraction function, but may not preserve the order of equal elements.
pub fn rotate_left(&mut self, mid: K) where
K: Index,
[src]
K: Index,
Rotates the slice in-place such that the first mid
elements of the
slice move to the end while the last self.next_key() - mid
elements move to
the front. After calling rotate_left
, the element previously at index
mid
will become the first element in the slice.
See slice::rotate_left
.
pub fn rotate_right(&mut self, k: K) where
K: Index,
[src]
K: Index,
Rotates the slice in-place such that the first self.next_key() - k
elements of the slice move to the end while the last k
elements move
to the front. After calling rotate_right
, the element previously at
index self.next_key() - k
will become the first element in the slice.
See slice::rotate_right
.
pub fn clone_from_slice(&mut self, src: &Self) where
V: Clone,
[src]
V: Clone,
Copies the elements from src
into self
.
pub fn copy_from_slice(&mut self, src: &Self) where
V: Copy,
[src]
V: Copy,
Copies all elements from src
into self
, using a memcpy.
pub fn copy_within<R>(&mut self, src: R, dest: K) where
R: TiRangeBounds<K>,
V: Copy,
K: Index,
[src]
R: TiRangeBounds<K>,
V: Copy,
K: Index,
Copies elements from one part of the slice to another part of itself, using a memmove.
See slice::copy_within
.
pub fn swap_with_slice(&mut self, other: &mut Self)
[src]
Swaps all elements in self
with those in other
.
pub unsafe fn align_to<U>(&self) -> (&Self, &TiSlice<K, U>, &Self)
[src]
Transmute the slice to a slice of another type, ensuring alignment of the types is maintained.
See slice::align_to
.
pub unsafe fn align_to_mut<U>(
&mut self
) -> (&mut Self, &mut TiSlice<K, U>, &mut Self)
[src]
&mut self
) -> (&mut Self, &mut TiSlice<K, U>, &mut Self)
Transmute the slice to a slice of another type, ensuring alignment of the types is maintained.
See slice::align_to_mut
.
impl<K, V> TiSlice<K, V>
[src]
pub fn sort(&mut self) where
V: Ord,
[src]
V: Ord,
Sorts the slice.
See slice::sort
.
pub fn sort_by<F>(&mut self, compare: F) where
F: FnMut(&V, &V) -> Ordering,
[src]
F: FnMut(&V, &V) -> Ordering,
Sorts the slice with a comparator function.
See slice::sort_by
.
pub fn sort_by_key<K2, F>(&mut self, f: F) where
F: FnMut(&V) -> K2,
K2: Ord,
[src]
F: FnMut(&V) -> K2,
K2: Ord,
Sorts the slice with a key extraction function.
See slice::sort_by_key
.
pub fn sort_by_cached_key<K2, F>(&mut self, f: F) where
F: FnMut(&V) -> K2,
K2: Ord,
[src]
F: FnMut(&V) -> K2,
K2: Ord,
Sorts the slice with a key extraction function.
pub fn to_vec(&self) -> TiVec<K, V> where
V: Clone,
[src]
V: Clone,
Copies self
into a new TiVec
.
See slice::to_vec
.
pub fn into_vec(self: Box<Self>) -> TiVec<K, V>
[src]
Converts self
into a vector without clones or allocation.
See slice::into_vec
.
pub fn repeat(&self, n: usize) -> TiVec<K, V> where
V: Copy,
[src]
V: Copy,
Creates a vector by repeating a slice n
times.
See slice::repeat
.
pub fn concat<Item: ?Sized>(&self) -> Self::Output where
Self: Concat<Item>,
[src]
Self: Concat<Item>,
Flattens a slice of T
into a single value Self::Output
.
See slice::Concat
.
pub fn join<Separator>(&self, sep: Separator) -> Self::Output where
Self: Join<Separator>,
[src]
Self: Join<Separator>,
Flattens a slice of T
into a single value Self::Output
, placing a
given separator between each.
See slice::join
.
Trait Implementations
impl<K, V> AsMut<TiSlice<K, V>> for TiSlice<K, V>
[src]
impl<K, V> AsMut<TiSlice<K, V>> for TiVec<K, V>
[src]
impl<K, V> AsRef<TiSlice<K, V>> for TiSlice<K, V>
[src]
impl<K, V> AsRef<TiSlice<K, V>> for TiVec<K, V>
[src]
impl<K, V> Borrow<TiSlice<K, V>> for TiVec<K, V>
[src]
impl<K, V> BorrowMut<TiSlice<K, V>> for TiVec<K, V>
[src]
fn borrow_mut(&mut self) -> &mut TiSlice<K, V>
[src]
impl<K, V> Debug for TiSlice<K, V> where
K: Debug + Index,
V: Debug,
[src]
K: Debug + Index,
V: Debug,
impl<'_, K, V> Default for &'_ TiSlice<K, V>
[src]
impl<'_, K, V> Default for &'_ mut TiSlice<K, V>
[src]
impl<K: Eq, V: Eq> Eq for TiSlice<K, V>
[src]
impl<'_, K, V: Copy> From<&'_ TiSlice<K, V>> for Box<TiSlice<K, V>>
[src]
impl<'a, K, V> From<&'a [V]> for &'a TiSlice<K, V>
[src]
impl<'a, K, V> From<&'a TiSlice<K, V>> for &'a [V]
[src]
impl<'a, K, V> From<&'a mut [V]> for &'a mut TiSlice<K, V>
[src]
fn from(slice: &'a mut [V]) -> Self
[src]
impl<'a, K, V> From<&'a mut TiSlice<K, V>> for &'a mut [V]
[src]
impl<K: Hash, V: Hash> Hash for TiSlice<K, V>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<I, K, V> Index<I> for TiSlice<K, V> where
I: TiSliceIndex<K, V>,
[src]
I: TiSliceIndex<K, V>,
type Output = I::Output
The returned type after indexing.
fn index(&self, index: I) -> &Self::Output
[src]
impl<I, K, V> IndexMut<I> for TiSlice<K, V> where
I: TiSliceIndex<K, V>,
[src]
I: TiSliceIndex<K, V>,
impl<'a, K, V> IntoIterator for &'a TiSlice<K, V>
[src]
type Item = &'a V
The type of the elements being iterated over.
type IntoIter = Iter<'a, V>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter<'a, V>
[src]
impl<'a, K, V> IntoIterator for &'a mut TiSlice<K, V>
[src]
type Item = &'a mut V
The type of the elements being iterated over.
type IntoIter = IterMut<'a, V>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IterMut<'a, V>
[src]
impl<K: Ord, V: Ord> Ord for TiSlice<K, V>
[src]
fn cmp(&self, other: &TiSlice<K, V>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<K, A, B> PartialEq<TiSlice<K, B>> for TiSlice<K, A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
fn eq(&self, other: &TiSlice<K, B>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<K: PartialOrd, V: PartialOrd> PartialOrd<TiSlice<K, V>> for TiSlice<K, V>
[src]
fn partial_cmp(&self, other: &TiSlice<K, V>) -> Option<Ordering>
[src]
fn lt(&self, other: &TiSlice<K, V>) -> bool
[src]
fn le(&self, other: &TiSlice<K, V>) -> bool
[src]
fn gt(&self, other: &TiSlice<K, V>) -> bool
[src]
fn ge(&self, other: &TiSlice<K, V>) -> bool
[src]
impl<K, V: Serialize> Serialize for TiSlice<K, V>
[src]
impl<K, V> StructuralEq for TiSlice<K, V>
[src]
impl<K, V: Clone> ToOwned for TiSlice<K, V>
[src]
Auto Trait Implementations
impl<K, V> RefUnwindSafe for TiSlice<K, V> where
V: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for TiSlice<K, V> where
V: Send,
V: Send,
impl<K, V> Sync for TiSlice<K, V> where
V: Sync,
V: Sync,
impl<K, V> Unpin for TiSlice<K, V> where
V: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for TiSlice<K, V> where
V: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut 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> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,