Trait fera_ext::VecExt

source ·
pub trait VecExt<T> {
Show 14 methods unsafe fn new_uninitialized(len: usize) -> Self; fn appended(self, other: &mut Self) -> Self; fn deduped(self) -> Self
    where
        T: PartialEq
; fn deduped_by<F>(self, same_bucket: F) -> Self
    where
        F: FnMut(&mut T, &mut T) -> bool
; fn deduped_by_key<F, K>(self, key: F) -> Self
    where
        F: FnMut(&mut T) -> K,
        K: PartialEq<K>
; fn resized(self, new_len: usize, value: T) -> Self
    where
        T: Clone
; fn reversed(self) -> Self; fn shrinked_to_fit(self) -> Self; fn shuffled(self) -> Self; fn shuffled_with<R: Rng>(self, rng: R) -> Self; fn sorted(self) -> Self
    where
        T: Ord
; fn sorted_by<F>(self, compare: F) -> Self
    where
        F: FnMut(&T, &T) -> Ordering
; fn sorted_by_key<F, K>(self, key: F) -> Self
    where
        F: FnMut(&T) -> K,
        K: Ord
; fn truncated(self, len: usize) -> Self;
}
Expand description

An extension trait for std::vec::Vec.

Methods with the suffix ed are like the original methods, but consumes the vector. This is interesting to chain methods call. For example:

use fera_ext::VecExt;

assert_eq!(vec![1, 2, 3], vec![4, 3, 1, 3, 4, 2].sorted().deduped().truncated(3));

Required Methods

Creates a new vector with len uninitialized elements.

Safety

This is unsafe because some values may not be dropped or some values may be dropped without being initialized. See std::mem::uninitialized for more informations.

Shuffle this vector using SmallRng::from_entropy().

Shuffle this vector using rng.

Implementations on Foreign Types

Implementors