[−][src]Struct thin_vec::ThinVec
See the crate's top level documentation for a description of this type.
Implementations
impl<T> ThinVec<T>
[src]
pub fn new() -> ThinVec<T>ⓘ
[src]
pub fn with_capacity(cap: usize) -> ThinVec<T>ⓘ
[src]
pub fn len(&self) -> usize
[src]
pub fn is_empty(&self) -> bool
[src]
pub fn capacity(&self) -> usize
[src]
pub unsafe fn set_len(&mut self, len: usize)
[src]
pub fn push(&mut self, val: T)
[src]
pub fn pop(&mut self) -> Option<T>
[src]
pub fn insert(&mut self, idx: usize, elem: T)
[src]
pub fn remove(&mut self, idx: usize) -> T
[src]
pub fn swap_remove(&mut self, idx: usize) -> T
[src]
pub fn truncate(&mut self, len: usize)
[src]
pub fn clear(&mut self)
[src]
pub fn as_slice(&self) -> &[T]
[src]
pub fn as_mut_slice(&mut self) -> &mut [T]
[src]
pub fn reserve(&mut self, additional: usize)
[src]
Reserve capacity for at least additional
more elements to be inserted.
May reserve more space than requested, to avoid frequent reallocations.
Panics if the new capacity overflows usize
.
Re-allocates only if self.capacity() < self.len() + additional
.
pub fn reserve_exact(&mut self, additional: usize)
[src]
Reserves the minimum capacity for additional
more elements to be inserted.
Panics if the new capacity overflows usize
.
Re-allocates only if self.capacity() < self.len() + additional
.
pub fn shrink_to_fit(&mut self)
[src]
pub fn retain<F>(&mut self, f: F) where
F: FnMut(&T) -> bool,
[src]
F: FnMut(&T) -> bool,
Retains only the elements specified by the predicate.
In other words, remove all elements e
such that f(&e)
returns false
.
This method operates in place and preserves the order of the retained
elements.
Examples
let mut vec = thin_vec![1, 2, 3, 4]; vec.retain(|&x| x%2 == 0); assert_eq!(vec, [2, 4]);
pub fn dedup_by_key<F, K>(&mut self, key: F) where
F: FnMut(&mut T) -> K,
K: PartialEq<K>,
[src]
F: FnMut(&mut T) -> K,
K: PartialEq<K>,
Removes consecutive elements in the vector that resolve to the same key.
If the vector is sorted, this removes all duplicates.
Examples
let mut vec = thin_vec![10, 20, 21, 30, 20]; vec.dedup_by_key(|i| *i / 10); assert_eq!(vec, [10, 20, 30, 20]);
pub fn dedup_by<F>(&mut self, same_bucket: F) where
F: FnMut(&mut T, &mut T) -> bool,
[src]
F: FnMut(&mut T, &mut T) -> bool,
Removes consecutive elements in the vector according to a predicate.
The same_bucket
function is passed references to two elements from the vector, and
returns true
if the elements compare equal, or false
if they do not. Only the first
of adjacent equal items is kept.
If the vector is sorted, this removes all duplicates.
Examples
let mut vec = thin_vec!["foo", "bar", "Bar", "baz", "bar"]; vec.dedup_by(|a, b| a.eq_ignore_ascii_case(b)); assert_eq!(vec, ["foo", "bar", "baz", "bar"]);
pub fn split_off(&mut self, at: usize) -> ThinVec<T>ⓘ
[src]
pub fn append(&mut self, other: &mut ThinVec<T>)
[src]
pub fn drain<R>(&mut self, range: R) -> Drain<'_, T>ⓘ where
R: RangeBounds<usize>,
[src]
R: RangeBounds<usize>,
impl<T: Clone> ThinVec<T>
[src]
pub fn resize(&mut self, new_len: usize, value: T)
[src]
Resizes the Vec
in-place so that len()
is equal to new_len
.
If new_len
is greater than len()
, the Vec
is extended by the
difference, with each additional slot filled with value
.
If new_len
is less than len()
, the Vec
is simply truncated.
Examples
let mut vec = thin_vec!["hello"]; vec.resize(3, "world"); assert_eq!(vec, ["hello", "world", "world"]); let mut vec = thin_vec![1, 2, 3, 4]; vec.resize(2, 0); assert_eq!(vec, [1, 2]);
pub fn extend_from_slice(&mut self, other: &[T])
[src]
impl<T: PartialEq> ThinVec<T>
[src]
pub fn dedup(&mut self)
[src]
Removes consecutive repeated elements in the vector.
If the vector is sorted, this removes all duplicates.
Examples
let mut vec = thin_vec![1, 2, 2, 3, 2]; vec.dedup(); assert_eq!(vec, [1, 2, 3, 2]);
Trait Implementations
impl<T> AsRef<[T]> for ThinVec<T>
[src]
impl<T> Borrow<[T]> for ThinVec<T>
[src]
impl<T> BorrowMut<[T]> for ThinVec<T>
[src]
fn borrow_mut(&mut self) -> &mut [T]
[src]
impl<T> Clone for ThinVec<T> where
T: Clone,
[src]
T: Clone,
impl<T: Debug> Debug for ThinVec<T>
[src]
impl<T> Default for ThinVec<T>
[src]
impl<T> Deref for ThinVec<T>
[src]
impl<T> DerefMut for ThinVec<T>
[src]
impl<T> Drop for ThinVec<T>
[src]
impl<T> Eq for ThinVec<T> where
T: Eq,
[src]
T: Eq,
impl<T> Extend<T> for ThinVec<T>
[src]
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = T>,
[src]
I: IntoIterator<Item = T>,
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
impl<T> FromIterator<T> for ThinVec<T>
[src]
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> ThinVec<T>ⓘ
[src]
impl<T> Hash for ThinVec<T> where
T: Hash,
[src]
T: Hash,
fn hash<H>(&self, state: &mut H) where
H: Hasher,
[src]
H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> IntoIterator for ThinVec<T>
[src]
type Item = T
The type of the elements being iterated over.
type IntoIter = IntoIter<T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IntoIter<T>ⓘ
[src]
impl<'a, T> IntoIterator for &'a ThinVec<T>
[src]
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = Iter<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter<'a, T>
[src]
impl<'a, T> IntoIterator for &'a mut ThinVec<T>
[src]
type Item = &'a mut T
The type of the elements being iterated over.
type IntoIter = IterMut<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IterMut<'a, T>
[src]
impl<T> Ord for ThinVec<T> where
T: Ord,
[src]
T: Ord,
fn cmp(&self, other: &ThinVec<T>) -> 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<'a, A, B> PartialEq<&'a [B; 0]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 1]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 10]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 11]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 12]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 13]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 14]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 15]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 16]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 17]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 18]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 19]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 2]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 20]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 21]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 22]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 23]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 24]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 25]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 26]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 27]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 28]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 29]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 3]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 30]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 31]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 32]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 4]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 5]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 6]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 7]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 8]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B; 9]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<'a, A, B> PartialEq<&'a [B]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 0]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 1]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 10]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 11]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 12]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 13]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 14]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 15]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 16]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 17]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 18]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 19]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 2]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 20]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 21]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 22]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 23]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 24]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 25]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 26]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 27]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 28]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 29]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 3]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 30]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 31]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 32]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 4]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 5]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 6]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 7]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 8]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B; 9]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<[B]> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<ThinVec<B>> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<A, B> PartialEq<Vec<B>> for ThinVec<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
impl<T> PartialOrd<ThinVec<T>> for ThinVec<T> where
T: PartialOrd,
[src]
T: PartialOrd,
fn partial_cmp(&self, other: &ThinVec<T>) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Write for ThinVec<u8>
[src]
Write is implemented for ThinVec<u8>
by appending to the vector.
The vector will grow as needed.
This implementation is identical to the one for Vec<u8>
.
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn write_all(&mut self, buf: &[u8]) -> Result<()>
[src]
fn flush(&mut self) -> Result<()>
[src]
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>
1.36.0[src]
fn is_write_vectored(&self) -> bool
[src]
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
[src]
fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for ThinVec<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> !Send for ThinVec<T>
impl<T> !Sync for ThinVec<T>
impl<T> Unpin for ThinVec<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for ThinVec<T> where
T: UnwindSafe,
T: 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<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
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>,