Struct TiSlice

Source
#[repr(transparent)]
pub struct TiSlice<K, V> { pub raw: [V], /* private fields */ }
Expand description

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 From<usize> and Into<usize> traits. Their implementation can be easily done with derive_more crate and #[derive(From, Into)].

There are zero-cost conversions available between types and references:

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 type K.
  • first_key - Returns the first slice element index of type K, or None if the slice is empty.
  • first_key_value - Returns the first slice element index of type K and the element itself, or None if the slice is empty.
  • first_key_value_mut - Returns the first slice element index of type K and a mutable reference to the element itself, or None if the slice is empty.
  • last_key - Returns the last slice element index of type K, or None if the slice is empty.
  • last_key_value - Returns the last slice element index of type K and the element itself, or None if the slice is empty.
  • last_key_value_mut - Returns the last slice element index of type K and a mutable reference to the element itself, or None if the slice is empty.
  • iter_enumerated - Returns an iterator over all key-value pairs. It acts like self.iter().enumerate(), but use K instead of usize for iteration indices.
  • iter_mut_enumerated - Returns an iterator over all key-value pairs, with mutable references to the values. It acts like self.iter_mut().enumerate(), but use K instead of usize for iteration indices.
  • position - Searches for an element in an iterator, returning its index of type K. It acts like self.iter().position(...), but instead of usize it returns index of type K.
  • rposition - Searches for an element in an iterator from the right, returning its index of type K. It acts like self.iter().rposition(...), but instead of usize it returns index of type K.

§Example

use derive_more::{From, Into};
use typed_index_collections::TiSlice;

#[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§

Source§

impl<K, V> TiSlice<K, V>

Source

pub const fn from_ref(raw: &[V]) -> &Self

Converts a &[V] into a &TiSlice<K, V>.

§Example
pub struct Id(usize);
let slice: &TiSlice<Id, usize> = TiSlice::from_ref(&[1, 2, 4]);
Source

pub const fn from_mut(raw: &mut [V]) -> &mut Self

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]);
Source

pub const fn len(&self) -> usize

Returns the number of elements in the slice.

See slice::len for more details.

Source

pub fn next_key(&self) -> K
where K: From<usize>,

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));
Source

pub const fn is_empty(&self) -> bool

Returns true if the slice has a length of 0.

See slice::is_empty for more details.

Source

pub fn keys(&self) -> TiSliceKeys<K>
where K: From<usize>,

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);
Source

pub const fn first(&self) -> Option<&V>

Returns the first element of the slice, or None if it is empty.

See slice::first for more details.

Source

pub const fn first_mut(&mut self) -> Option<&mut V>

Returns a mutable reference to the first element of the slice, or None if it is empty.

See slice::first_mut for more details.

Source

pub fn first_key(&self) -> Option<K>
where K: From<usize>,

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)));
Source

pub fn first_key_value(&self) -> Option<(K, &V)>
where K: From<usize>,

Returns the first slice element index of type K and the element itself, or None if the slice is empty.

See slice::first for more details.

§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)));
Source

pub fn first_key_value_mut(&mut self) -> Option<(K, &mut V)>
where K: From<usize>,

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 for more details.

§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]);
Source

pub fn split_first(&self) -> Option<(&V, &Self)>

Returns the first and all the rest of the elements of the slice, or None if it is empty.

See slice::split_first for more details.

Source

pub const fn split_first_mut(&mut self) -> Option<(&mut V, &mut Self)>

Returns the first and all the rest of the elements of the slice, or None if it is empty.

See slice::split_first_mut for more details.

Source

pub fn split_last(&self) -> Option<(&V, &Self)>

Returns the last and all the rest of the elements of the slice, or None if it is empty.

See slice::split_last for more details.

Source

pub const fn split_last_mut(&mut self) -> Option<(&mut V, &mut Self)>

Returns the last and all the rest of the elements of the slice, or None if it is empty.

See slice::split_last_mut for more details.

Source

pub const fn last(&self) -> Option<&V>

Returns the last element of the slice of type K, or None if it is empty.

See slice::last for more details.

Source

pub const fn last_mut(&mut self) -> Option<&mut V>

Returns a mutable reference to the last item in the slice.

See slice::last_mut for more details.

Source

pub fn last_key(&self) -> Option<K>
where K: From<usize>,

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)));
Source

pub fn last_key_value(&self) -> Option<(K, &V)>
where K: From<usize>,

Returns the last slice element index of type K and the element itself, or None if the slice is empty.

See slice::last for more details.

§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)));
Source

pub fn last_key_value_mut(&mut self) -> Option<(K, &mut V)>
where K: From<usize>,

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 for more details.

§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]);
Source

pub fn get<I>(&self, index: I) -> Option<&I::Output>
where 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 for more details.

Source

pub fn get_mut<I>(&mut self, index: I) -> Option<&mut I::Output>
where 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 for more details.

Source

pub unsafe fn get_unchecked<I>(&self, index: I) -> &I::Output
where I: TiSliceIndex<K, V>,

Returns a reference to an element or subslice depending on the type of index, without doing bounds checking.

See slice::get_unchecked for more details.

§Safety

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.

Source

pub unsafe fn get_unchecked_mut<I>(&mut self, index: I) -> &mut I::Output
where I: TiSliceIndex<K, V>,

Returns a mutable reference to an element or subslice depending on the type of index, without doing bounds checking.

See slice::get_unchecked_mut for more details.

§Safety

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.

Source

pub const fn as_ptr(&self) -> *const V

Returns a raw pointer to the slice’s buffer.

See slice::as_ptr for more details.

Source

pub const fn as_mut_ptr(&mut self) -> *mut V

Returns an unsafe mutable reference to the slice’s buffer.

See slice::as_mut_ptr for more details.

Source

pub const fn as_ptr_range(&self) -> Range<*const V>

Returns the two raw pointers spanning the slice.

See slice::as_ptr_range for more details.

Source

pub const fn as_mut_ptr_range(&mut self) -> Range<*mut V>

Returns the two unsafe mutable pointers spanning the slice.

See slice::as_mut_ptr_range for more details.

Source

pub fn swap(&mut self, a: K, b: K)
where usize: From<K>,

Swaps two elements in the slice.

See slice::swap for more details.

Source

pub fn reverse(&mut self)

Reverses the order of elements in the slice, in place.

See slice::reverse for more details.

Source

pub fn iter(&self) -> Iter<'_, V>

Returns an iterator over the slice.

See slice::iter for more details.

Source

pub fn iter_enumerated(&self) -> TiEnumerated<Iter<'_, V>, K, &V>
where K: From<usize>,

Returns an iterator over all key-value pairs.

It acts like self.iter().enumerate(), but use K instead of usize for iteration indices.

See slice::iter for more details.

§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);
Source

pub fn iter_mut(&mut self) -> IterMut<'_, V>

Returns an iterator that allows modifying each value.

See slice::iter_mut for more details.

Source

pub fn iter_mut_enumerated(&mut self) -> TiEnumerated<IterMut<'_, V>, K, &mut V>
where K: From<usize>,

Returns an iterator over all key-value pairs, with mutable references to the values.

It acts like self.iter_mut().enumerate(), but use K instead of usize for iteration indices.

§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]);
Source

pub fn position<P>(&self, predicate: P) -> Option<K>
where K: From<usize>, P: FnMut(&V) -> bool,

Searches for an element in an iterator, returning its index of type K.

It acts like self.iter().position(...), but instead of usize it returns index of type K.

See slice::iter and Iterator::position for more details.

§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)));
Source

pub fn rposition<P>(&self, predicate: P) -> Option<K>
where K: From<usize>, P: FnMut(&V) -> bool,

Searches for an element in an iterator from the right, returning its index of type K.

It acts like self.iter().rposition(...), but instead of usize it returns index of type K.

See slice::iter and Iterator::rposition for more details.

§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)));
Source

pub fn windows(&self, size: usize) -> TiSliceRefMap<Windows<'_, V>, K, V>

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 for more details.

Source

pub fn chunks(&self, chunk_size: usize) -> TiSliceRefMap<Chunks<'_, 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 for more details.

Source

pub fn chunks_mut( &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 for more details.

Source

pub fn chunks_exact( &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 for more details.

Source

pub fn chunks_exact_mut( &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.

See slice::chunks_exact_mut for more details.

Source

pub fn rchunks(&self, chunk_size: usize) -> TiSliceRefMap<RChunks<'_, 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 for more details.

Source

pub fn rchunks_mut( &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 for more details.

Source

pub fn rchunks_exact( &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 for more details.

Source

pub fn rchunks_exact_mut( &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.

See slice::rchunks_exact_mut for more details.

Source

pub fn chunk_by<F>(&self, pred: F) -> TiSliceRefMap<ChunkBy<'_, V, F>, K, V>
where F: FnMut(&V, &V) -> bool,

Returns an iterator over the slice producing non-overlapping runs of elements using the predicate to separate them.

See slice::chunk_by for more details.

Source

pub fn chunk_by_mut<F>( &mut self, pred: F, ) -> TiSliceMutMap<ChunkByMut<'_, V, F>, K, V>
where F: FnMut(&V, &V) -> bool,

Returns an iterator over the slice producing non-overlapping mutable runs of elements using the predicate to separate them.

See slice::chunk_by_mut for more details.

Source

pub fn split_at(&self, mid: K) -> (&Self, &Self)
where usize: From<K>,

Divides one slice into two at an index.

See slice::split_at for more details.

Source

pub fn split_at_mut(&mut self, mid: K) -> (&mut Self, &mut Self)
where usize: From<K>,

Divides one mutable slice into two at an index.

See slice::split_at_mut for more details.

Source

pub unsafe fn split_at_unchecked(&self, mid: K) -> (&Self, &Self)
where usize: From<K>,

Divides one slice into two at an index, without doing bounds checking.

See slice::split_at_unchecked for more details.

§Safety

Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used. The caller has to ensure that 0 <= mid <= self.len().

Source

pub unsafe fn split_at_mut_unchecked( &mut self, mid: K, ) -> (&mut Self, &mut Self)
where usize: From<K>,

Divides one mutable slice into two at an index, without doing bounds checking.

See slice::split_at_mut_unchecked for more details.

§Safety

Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used. The caller has to ensure that 0 <= mid <= self.len().

Source

pub fn split_at_checked(&self, mid: K) -> Option<(&Self, &Self)>
where usize: From<K>,

Divides one slice into two at an index, returning None if the slice is too short.

See slice::split_at_checked for more details.

Source

pub fn split_at_mut_checked(&mut self, mid: K) -> Option<(&mut Self, &mut Self)>
where usize: From<K>,

Divides one mutable slice into two at an index, returning None if the slice is too short.

See slice::split_at_mut_checked for more details.

Source

pub fn split<F>(&self, pred: F) -> TiSliceRefMap<Split<'_, V, F>, K, V>
where 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 for more details.

Source

pub fn split_mut<F>( &mut self, pred: F, ) -> TiSliceMutMap<SplitMut<'_, V, F>, K, V>
where 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 for more details.

Source

pub fn split_inclusive<F>( &self, pred: F, ) -> TiSliceRefMap<SplitInclusive<'_, V, F>, K, V>
where F: FnMut(&V) -> bool,

Returns an iterator over subslices separated by elements that match pred. The matched element is contained in the end of the previous subslice as a terminator.

See slice::split_inclusive for more details.

Source

pub fn split_inclusive_mut<F>( &mut self, pred: F, ) -> TiSliceMutMap<SplitInclusiveMut<'_, V, F>, K, V>
where F: FnMut(&V) -> bool,

Returns an iterator over mutable subslices separated by elements that match pred. The matched element is contained in the previous subslice as a terminator.

See slice::split_inclusive_mut for more details.

Source

pub fn rsplit<F>(&self, pred: F) -> TiSliceRefMap<RSplit<'_, V, F>, K, V>
where 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 for more details.

Source

pub fn rsplit_mut<F>( &mut self, pred: F, ) -> TiSliceMutMap<RSplitMut<'_, V, F>, K, V>
where 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 for more details.

Source

pub fn splitn<F>( &self, n: usize, pred: F, ) -> TiSliceRefMap<SplitN<'_, 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 for more details.

Source

pub fn splitn_mut<F>( &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 for more details.

Source

pub fn rsplitn<F>( &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 for more details.

Source

pub fn rsplitn_mut<F>( &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 for more details.

Source

pub fn contains(&self, x: &V) -> bool
where V: PartialEq,

Returns true if the slice contains an element with the given value.

See slice::contains for more details.

Source

pub fn starts_with(&self, needle: &Self) -> bool
where V: PartialEq,

Returns true if needle is a prefix of the slice.

See slice::starts_with for more details.

Source

pub fn ends_with(&self, needle: &Self) -> bool
where V: PartialEq,

Returns true if needle is a suffix of the slice.

See slice::ends_with for more details.

Binary searches this sorted slice for a given element.

See slice::binary_search for more details.

Source

pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<K, K>
where F: FnMut(&'a V) -> Ordering, K: From<usize>,

Binary searches this sorted slice with a comparator function.

See slice::binary_search_by for more details.

Source

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: From<usize>,

Binary searches this sorted slice with a key extraction function.

See slice::binary_search_by_key for more details.

Source

pub fn sort_unstable(&mut self)
where V: Ord,

Sorts the slice, but may not preserve the order of equal elements.

See slice::sort_unstable for more details.

Source

pub fn sort_unstable_by<F>(&mut self, compare: F)
where F: FnMut(&V, &V) -> Ordering,

Sorts the slice with a comparator function, but may not preserve the order of equal elements.

See slice::sort_unstable_by for more details.

Source

pub fn sort_unstable_by_key<K2, F>(&mut self, f: F)
where F: FnMut(&V) -> K2, K2: Ord,

Sorts the slice with a key extraction function, but may not preserve the order of equal elements.

See slice::sort_unstable_by_key for more details.

Source

pub fn select_nth_unstable( &mut self, index: K, ) -> (&mut Self, &mut V, &mut Self)
where usize: From<K>, V: Ord,

Reorder the slice such that the element at index after the reordering is at its final sorted position.

See slice::select_nth_unstable for more details.

§Panics

Panics when index >= len(), meaning it always panics on empty slices.

May panic if the implementation of Ord for T does not implement a [total order].

Source

pub fn select_nth_unstable_by<F>( &mut self, index: K, compare: F, ) -> (&mut Self, &mut V, &mut Self)
where usize: From<K>, F: FnMut(&V, &V) -> Ordering,

Reorder the slice with a comparator function such that the element at index after the reordering is at its final sorted position.

See slice::select_nth_unstable_by for more details.

§Panics

Panics when index >= len(), meaning it always panics on empty slices.

May panic if compare does not implement a [total order].

Source

pub fn select_nth_unstable_by_key<Key, F>( &mut self, index: K, f: F, ) -> (&mut Self, &mut V, &mut Self)
where usize: From<K>, F: FnMut(&V) -> Key, Key: Ord,

Reorder the slice with a key extraction function such that the element at index after the reordering is at its final sorted position.

See slice::select_nth_unstable_by_key for more details.

§Panics

Panics when index >= len(), meaning it always panics on empty slices.

May panic if K: Ord does not implement a total order.

Source

pub fn rotate_left(&mut self, mid: K)
where usize: From<K>,

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 for more details.

Source

pub fn rotate_right(&mut self, k: K)
where usize: From<K>,

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 for more details.

Source

pub fn fill(&mut self, value: V)
where V: Clone,

Fills self with elements by cloning value.

See slice::fill for more details.

Source

pub fn fill_with<F>(&mut self, f: F)
where F: FnMut() -> V,

Fills self with elements returned by calling a closure repeatedly.

See slice::fill_with for more details.

Source

pub fn clone_from_slice(&mut self, src: &Self)
where V: Clone,

Copies the elements from src into self.

See slice::clone_from_slice for more details.

Source

pub fn copy_from_slice(&mut self, src: &Self)
where V: Copy,

Copies all elements from src into self, using a memcpy.

See slice::copy_from_slice for more details.

Source

pub fn copy_within<R>(&mut self, src: R, dest: K)
where R: TiRangeBounds<K>, V: Copy, usize: From<K>,

Copies elements from one part of the slice to another part of itself, using a memmove.

See slice::copy_within for more details.

Source

pub fn swap_with_slice(&mut self, other: &mut Self)

Swaps all elements in self with those in other.

See slice::swap_with_slice for more details.

Source

pub unsafe fn align_to<U>(&self) -> (&Self, &TiSlice<K, U>, &Self)

Transmute the slice to a slice of another type, ensuring alignment of the types is maintained.

See slice::align_to for more details.

§Safety

This method is essentially a transmute with respect to the elements in the returned middle slice, so all the usual caveats pertaining to transmute::<T, U> also apply here.

Source

pub unsafe fn align_to_mut<U>( &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 for more details.

§Safety

This method is essentially a transmute with respect to the elements in the returned middle slice, so all the usual caveats pertaining to transmute::<T, U> also apply here.

Source

pub fn is_sorted(&self) -> bool
where V: PartialOrd,

Checks if the elements of this slice are sorted.

See slice::is_sorted for more details.

Source

pub fn is_sorted_by<'a, F>(&'a self, compare: F) -> bool
where F: FnMut(&'a V, &'a V) -> bool,

Checks if the elements of this slice are sorted using the given comparator function.

See slice::is_sorted_by for more details.

Source

pub fn is_sorted_by_key<'a, F, T>(&'a self, f: F) -> bool
where F: FnMut(&'a V) -> T, T: PartialOrd,

Checks if the elements of this slice are sorted using the given key extraction function.

See slice::is_sorted_by_key for more details.

Source

pub fn partition_point<P>(&self, pred: P) -> K
where K: From<usize>, P: FnMut(&V) -> bool,

Returns the index of the partition point according to the given predicate (the index of the first element of the second partition).

See slice::partition_point for more details.

Source§

impl<K> TiSlice<K, u8>

Source

pub const fn is_ascii(&self) -> bool

Checks if all bytes in this slice are within the ASCII range.

See slice::is_ascii for more details.

Source

pub fn eq_ignore_ascii_case(&self, other: &Self) -> bool

Checks that two slices are an ASCII case-insensitive match.

See slice::eq_ignore_ascii_case for more details.

Source

pub const fn make_ascii_uppercase(&mut self)

Converts this slice to its ASCII upper case equivalent in-place.

See slice::make_ascii_uppercase for more details.

Source

pub const fn make_ascii_lowercase(&mut self)

Converts this slice to its ASCII lower case equivalent in-place.

See slice::make_ascii_lowercase for more details.

Source

pub fn escape_ascii(&self) -> EscapeAscii<'_>

Returns an iterator that produces an escaped version of this slice, treating it as an ASCII string.

See slice::escape_ascii for more details.

Source

pub const fn trim_ascii_start(&self) -> &Self

Returns a byte slice with leading ASCII whitespace bytes removed.

See slice::trim_ascii_start for more details.

Source

pub const fn trim_ascii_end(&self) -> &Self

Returns a byte slice with trailing ASCII whitespace bytes removed.

See slice::trim_ascii_end for more details.

Source

pub const fn trim_ascii(&self) -> &Self

Returns a byte slice with leading and trailing ASCII whitespace bytes removed.

See slice::trim_ascii for more details.

Source

pub fn utf8_chunks(&self) -> Utf8Chunks<'_>

Creates an iterator over the contiguous valid UTF-8 ranges of this slice, and the non-UTF-8 fragments in between.

See slice::utf8_chunks for more details.

Source§

impl<K, V> TiSlice<K, V>

Source

pub fn sort(&mut self)
where V: Ord,

Available on crate feature alloc only.

Sorts the slice.

See slice::sort for more details.

Source

pub fn sort_by<F>(&mut self, compare: F)
where F: FnMut(&V, &V) -> Ordering,

Available on crate feature alloc only.

Sorts the slice with a comparator function.

See slice::sort_by for more details.

Source

pub fn sort_by_key<K2, F>(&mut self, f: F)
where F: FnMut(&V) -> K2, K2: Ord,

Available on crate feature alloc only.

Sorts the slice with a key extraction function.

See slice::sort_by_key for more details.

Source

pub fn sort_by_cached_key<K2, F>(&mut self, f: F)
where F: FnMut(&V) -> K2, K2: Ord,

Available on crate feature alloc only.

Sorts the slice with a key extraction function.

See slice::sort_by_cached_key for more details.

Source

pub fn to_vec(&self) -> TiVec<K, V>
where V: Clone,

Available on crate feature alloc only.

Copies self into a new TiVec.

See slice::to_vec for more details.

Source

pub fn into_vec(self: Box<Self>) -> TiVec<K, V>

Available on crate feature alloc only.

Converts self into a vector without clones or allocation.

See slice::into_vec for more details.

Source

pub fn repeat(&self, n: usize) -> TiVec<K, V>
where V: Copy,

Available on crate feature alloc only.

Creates a vector by repeating a slice n times.

See slice::repeat for more details.

Source

pub fn concat<Item: ?Sized>(&self) -> <Self as Concat<Item>>::Output
where Self: Concat<Item>,

Available on crate feature alloc only.

Flattens a slice of T into a single value Self::Output.

See slice::concat for more details.

Source

pub fn join<Separator>( &self, sep: Separator, ) -> <Self as Join<Separator>>::Output
where Self: Join<Separator>,

Available on crate feature alloc only.

Flattens a slice of T into a single value Self::Output, placing a given separator between each.

See slice::join for more details.

Source§

impl<K> TiSlice<K, u8>

Source

pub fn to_ascii_uppercase(&self) -> TiVec<K, u8>

Available on crate feature alloc only.

Returns a vector containing a copy of this slice where each byte is mapped to its ASCII upper case equivalent.

See slice::to_ascii_uppercase for more details.

Source

pub fn to_ascii_lowercase(&self) -> TiVec<K, u8>

Available on crate feature alloc only.

Returns a vector containing a copy of this slice where each byte is mapped to its ASCII lower case equivalent.

See slice::to_ascii_lowercase for more details.

Trait Implementations§

Source§

impl<K, V> AsMut<[V]> for TiSlice<K, V>

Source§

fn as_mut(&mut self) -> &mut [V]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<K, V> AsMut<TiSlice<K, V>> for [V]

Source§

fn as_mut(&mut self) -> &mut TiSlice<K, V>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<K, V> AsMut<TiSlice<K, V>> for TiSlice<K, V>

Source§

fn as_mut(&mut self) -> &mut Self

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<K, V> AsMut<TiSlice<K, V>> for TiVec<K, V>

Available on crate feature alloc only.
Source§

fn as_mut(&mut self) -> &mut TiSlice<K, V>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<K, V> AsRef<[V]> for TiSlice<K, V>

Source§

fn as_ref(&self) -> &[V]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<K, V> AsRef<TiSlice<K, V>> for [V]

Source§

fn as_ref(&self) -> &TiSlice<K, V>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<K, V> AsRef<TiSlice<K, V>> for TiSlice<K, V>

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<K, V> AsRef<TiSlice<K, V>> for TiVec<K, V>

Available on crate feature alloc only.
Source§

fn as_ref(&self) -> &TiSlice<K, V>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<K, V> Borrow<TiSlice<K, V>> for TiVec<K, V>

Available on crate feature alloc only.
Source§

fn borrow(&self) -> &TiSlice<K, V>

Immutably borrows from an owned value. Read more
Source§

impl<'de, K, V, Context> BorrowDecode<'de, Context> for Box<TiSlice<K, V>>
where V: 'de + BorrowDecode<'de, Context>,

Available on crate features alloc and bincode only.
Source§

fn borrow_decode<D>(decoder: &mut D) -> Result<Self, DecodeError>
where D: BorrowDecoder<'de, Context = Context>,

Attempt to decode this type with the given BorrowDecode.
Source§

impl<K, V> BorrowMut<TiSlice<K, V>> for TiVec<K, V>

Available on crate feature alloc only.
Source§

fn borrow_mut(&mut self) -> &mut TiSlice<K, V>

Mutably borrows from an owned value. Read more
Source§

impl<K> BufRead for &TiSlice<K, u8>

Available on crate feature std only.
Source§

fn fill_buf(&mut self) -> IoResult<&[u8]>

Returns the contents of the internal buffer, filling it with more data, via Read methods, if empty. Read more
Source§

fn consume(&mut self, amt: usize)

Marks the given amount of additional bytes from the internal buffer as having been read. Subsequent calls to read only return bytes that have not been marked as read. Read more
Source§

fn has_data_left(&mut self) -> Result<bool, Error>

🔬This is a nightly-only experimental API. (buf_read_has_data_left)
Checks if there is any data left to be read. Read more
1.0.0 · Source§

fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize, Error>

Reads all bytes into buf until the delimiter byte or EOF is reached. Read more
1.83.0 · Source§

fn skip_until(&mut self, byte: u8) -> Result<usize, Error>

Skips all bytes until the delimiter byte or EOF is reached. Read more
1.0.0 · Source§

fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>

Reads all bytes until a newline (the 0xA byte) is reached, and append them to the provided String buffer. Read more
1.0.0 · Source§

fn split(self, byte: u8) -> Split<Self>
where Self: Sized,

Returns an iterator over the contents of this reader split on the byte byte. Read more
1.0.0 · Source§

fn lines(self) -> Lines<Self>
where Self: Sized,

Returns an iterator over the lines of this reader. Read more
Source§

impl<K, V: Clone> Clone for Box<TiSlice<K, V>>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<K, V> Debug for TiSlice<K, V>
where K: Debug + From<usize>, V: Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<K, V, Context> Decode<Context> for Box<TiSlice<K, V>>
where V: 'static + Decode<Context>,

Available on crate features alloc and bincode only.
Source§

fn decode<D>(decoder: &mut D) -> Result<Self, DecodeError>
where D: Decoder<Context = Context>,

Attempt to decode this type with the given Decode.
Source§

impl<K, V> Default for &TiSlice<K, V>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<K, V> Default for &mut TiSlice<K, V>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<K, V> Default for Box<TiSlice<K, V>>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, K, V> Deserialize<'de> for Box<TiSlice<K, V>>
where V: Deserialize<'de>,

Available on crate features alloc and serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<K, V> Encode for TiSlice<K, V>
where V: Encode,

Available on crate feature bincode only.
Source§

fn encode<E>(&self, encoder: &mut E) -> Result<(), EncodeError>
where E: Encoder,

Encode a given type.
Source§

impl<K, V: Copy> From<&TiSlice<K, V>> for Box<TiSlice<K, V>>

Source§

fn from(slice: &TiSlice<K, V>) -> Self

Converts to this type from the input type.
Source§

impl<'a, K, V: Clone> From<&'a TiSlice<K, V>> for Cow<'a, TiSlice<K, V>>

Available on crate feature alloc only.
Source§

fn from(value: &'a TiSlice<K, V>) -> Self

Converts to this type from the input type.
Source§

impl<K, V> From<&TiSlice<K, V>> for TiVec<K, V>
where V: Clone,

Available on crate feature alloc only.
Source§

fn from(slice: &TiSlice<K, V>) -> Self

Converts to this type from the input type.
Source§

impl<K, V> From<&mut TiSlice<K, V>> for TiVec<K, V>
where V: Clone,

Available on crate feature alloc only.
Source§

fn from(slice: &mut TiSlice<K, V>) -> Self

Converts to this type from the input type.
Source§

impl<K, V> From<Box<[V]>> for Box<TiSlice<K, V>>

Source§

fn from(slice: Box<[V]>) -> Self

Converts to this type from the input type.
Source§

impl<K, V> From<TiVec<K, V>> for Box<TiSlice<K, V>>

Source§

fn from(v: TiVec<K, V>) -> Self

Converts to this type from the input type.
Source§

impl<K, V> FromIterator<V> for Box<TiSlice<K, V>>

Source§

fn from_iter<T: IntoIterator<Item = V>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl<K, V> Hash for TiSlice<K, V>
where V: Hash,

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl<I, K, V> Index<I> for TiSlice<K, V>
where I: TiSliceIndex<K, V>,

Source§

type Output = <I as TiSliceIndex<K, V>>::Output

The returned type after indexing.
Source§

fn index(&self, index: I) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<I, K, V> IndexMut<I> for TiSlice<K, V>
where I: TiSliceIndex<K, V>,

Source§

fn index_mut(&mut self, index: I) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a, K, V> IntoIterator for &'a TiSlice<K, V>

Source§

type Item = &'a V

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Iter<'a, V>

Creates an iterator from a value. Read more
Source§

impl<'a, K, V> IntoIterator for &'a mut TiSlice<K, V>

Source§

type Item = &'a mut V

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> IterMut<'a, V>

Creates an iterator from a value. Read more
Source§

impl<K, V> IntoIterator for Box<TiSlice<K, V>>

Source§

type Item = V

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K, V> Ord for TiSlice<K, V>
where V: Ord,

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

impl<'a, K, A, B> PartialEq<&'a TiSlice<K, B>> for TiVec<K, A>
where A: PartialEq<B>,

Available on crate feature alloc only.
Source§

fn eq(&self, other: &&'a TiSlice<K, B>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, K, A, B> PartialEq<&'a mut TiSlice<K, B>> for TiVec<K, A>
where A: PartialEq<B>,

Available on crate feature alloc only.
Source§

fn eq(&self, other: &&'a mut TiSlice<K, B>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<K, A, B> PartialEq<TiSlice<K, B>> for TiSlice<K, A>
where A: PartialEq<B>,

Source§

fn eq(&self, other: &TiSlice<K, B>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<K, A, B> PartialEq<TiSlice<K, B>> for TiVec<K, A>
where A: PartialEq<B>,

Available on crate feature alloc only.
Source§

fn eq(&self, other: &TiSlice<K, B>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<K, A, B> PartialEq<TiVec<K, B>> for &TiSlice<K, A>
where A: PartialEq<B>,

Available on crate feature alloc only.
Source§

fn eq(&self, other: &TiVec<K, B>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<K, A, B> PartialEq<TiVec<K, B>> for &mut TiSlice<K, A>
where A: PartialEq<B>,

Available on crate feature alloc only.
Source§

fn eq(&self, other: &TiVec<K, B>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<K, A, B> PartialEq<TiVec<K, B>> for TiSlice<K, A>
where A: PartialEq<B>,

Available on crate feature alloc only.
Source§

fn eq(&self, other: &TiVec<K, B>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<K, V> PartialOrd for TiSlice<K, V>
where V: PartialOrd<V>,

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<K> Read for &TiSlice<K, u8>

Available on crate feature std only.

Read is implemented for &TiSlice<K, u8> by copying from the slice.

Note that reading updates the slice to point to the yet unread part. The slice will be empty when EOF is reached.

Source§

fn read(&mut self, buf: &mut [u8]) -> IoResult<usize>

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> IoResult<usize>

Like read, except that it reads into a slice of buffers. Read more
Source§

fn read_exact(&mut self, buf: &mut [u8]) -> IoResult<()>

Reads the exact number of bytes required to fill buf. Read more
Source§

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> IoResult<usize>

Reads all bytes until EOF in this source, placing them into buf. Read more
Source§

fn read_to_string(&mut self, buf: &mut String) -> IoResult<usize>

Reads all bytes until EOF in this source, appending them to buf. Read more
Source§

fn is_read_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
Source§

fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
Source§

fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Reads the exact number of bytes required to fill cursor. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adaptor for this instance of Read. Read more
1.0.0 · Source§

fn bytes(self) -> Bytes<Self>
where Self: Sized,

Transforms this Read instance to an Iterator over its bytes. Read more
1.0.0 · Source§

fn chain<R>(self, next: R) -> Chain<Self, R>
where R: Read, Self: Sized,

Creates an adapter which will chain this stream with another. Read more
1.0.0 · Source§

fn take(self, limit: u64) -> Take<Self>
where Self: Sized,

Creates an adapter which will read at most limit bytes from it. Read more
Source§

impl<K, V> Serialize for TiSlice<K, V>
where V: Serialize,

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<K, V: Clone> ToOwned for TiSlice<K, V>

Available on crate feature alloc only.
Source§

type Owned = TiVec<K, V>

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> TiVec<K, V>

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<K> Write for &mut TiSlice<K, u8>

Available on crate feature std only.

Write is implemented for &mut TiSlice<K, u8> by copying into the slice, overwriting its data.

Note that writing updates the slice to point to the yet unwritten part. The slice will be empty when it has been completely overwritten.

If the number of bytes to be written exceeds the size of the slice, write operations will return short writes: ultimately, Ok(0); in this situation, write_all returns an error of kind ErrorKind::WriteZero.

Source§

fn write(&mut self, buf: &[u8]) -> IoResult<usize>

Writes a buffer into this writer, returning how many bytes were written. Read more
Source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> IoResult<usize>

Like write, except that it writes from a slice of buffers. Read more
Source§

fn write_all(&mut self, buf: &[u8]) -> IoResult<()>

Attempts to write an entire buffer into this writer. Read more
Source§

fn flush(&mut self) -> IoResult<()>

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
Source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
Source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more
Source§

impl<K, V> Eq for TiSlice<K, V>
where V: Eq,

Auto Trait Implementations§

§

impl<K, V> Freeze for TiSlice<K, V>
where V: Freeze,

§

impl<K, V> RefUnwindSafe for TiSlice<K, V>
where V: RefUnwindSafe,

§

impl<K, V> Send for TiSlice<K, V>
where V: Send,

§

impl<K, V> !Sized for TiSlice<K, V>

§

impl<K, V> Sync for TiSlice<K, V>
where V: Sync,

§

impl<K, V> Unpin for TiSlice<K, V>
where V: Unpin,

§

impl<K, V> UnwindSafe for TiSlice<K, V>
where V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more