[][src]Struct thin_vec::ThinVec

#[repr(C)]pub struct ThinVec<T> { /* fields omitted */ }

See the crate's top level documentation for a description of this type.

Implementations

impl<T> ThinVec<T>[src]

pub fn new() -> ThinVec<T>

Notable traits for ThinVec<u8>

impl Write for ThinVec<u8>
[src]

pub fn with_capacity(cap: usize) -> ThinVec<T>

Notable traits for ThinVec<u8>

impl Write for ThinVec<u8>
[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]

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]

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]

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>

Notable traits for ThinVec<u8>

impl Write for ThinVec<u8>
[src]

pub fn append(&mut self, other: &mut ThinVec<T>)[src]

pub fn drain<R>(&mut self, range: R) -> Drain<'_, T>

Notable traits for Drain<'a, T>

impl<'a, T> Iterator for Drain<'a, T> type Item = T;
where
    R: RangeBounds<usize>, 
[src]

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]

impl<T> Clone for ThinVec<T> where
    T: Clone
[src]

impl<T: Debug> Debug for ThinVec<T>[src]

impl<T> Default for ThinVec<T>[src]

impl<T> Deref for ThinVec<T>[src]

type Target = [T]

The resulting type after dereferencing.

impl<T> DerefMut for ThinVec<T>[src]

impl<T> Drop for ThinVec<T>[src]

impl<T> Eq for ThinVec<T> where
    T: Eq
[src]

impl<T> Extend<T> for ThinVec<T>[src]

impl<T> FromIterator<T> for ThinVec<T>[src]

impl<T> Hash for ThinVec<T> where
    T: Hash
[src]

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?

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?

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?

impl<T> Ord for ThinVec<T> where
    T: Ord
[src]

impl<'a, A, B> PartialEq<&'a [B; 0]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 1]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 10]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 11]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 12]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 13]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 14]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 15]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 16]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 17]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 18]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 19]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 2]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 20]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 21]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 22]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 23]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 24]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 25]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 26]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 27]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 28]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 29]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 3]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 30]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 31]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 32]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 4]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 5]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 6]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 7]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 8]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B; 9]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<'a, A, B> PartialEq<&'a [B]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 0]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 1]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 10]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 11]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 12]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 13]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 14]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 15]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 16]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 17]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 18]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 19]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 2]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 20]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 21]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 22]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 23]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 24]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 25]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 26]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 27]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 28]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 29]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 3]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 30]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 31]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 32]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 4]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 5]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 6]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 7]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 8]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B; 9]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<[B]> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<ThinVec<B>> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<A, B> PartialEq<Vec<B>> for ThinVec<A> where
    A: PartialEq<B>, 
[src]

impl<T> PartialOrd<ThinVec<T>> for ThinVec<T> where
    T: PartialOrd
[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>.

Auto Trait Implementations

impl<T> RefUnwindSafe for ThinVec<T> where
    T: RefUnwindSafe

impl<T> !Send for ThinVec<T>

impl<T> !Sync for ThinVec<T>

impl<T> Unpin for ThinVec<T> where
    T: Unpin

impl<T> UnwindSafe for ThinVec<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

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?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.