Trait fera_ext::VecExt
[−]
[src]
pub trait VecExt<T> { 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; }
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
unsafe fn new_uninitialized(len: usize) -> Self
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.
fn appended(self, other: &mut Self) -> Self
fn deduped(self) -> Self where
T: PartialEq,
T: PartialEq,
fn deduped_by<F>(self, same_bucket: F) -> Self where
F: FnMut(&mut T, &mut T) -> bool,
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>,
F: FnMut(&mut T) -> K,
K: PartialEq<K>,
fn resized(self, new_len: usize, value: T) -> Self where
T: Clone,
T: Clone,
fn reversed(self) -> Self
fn shrinked_to_fit(self) -> Self
fn shuffled(self) -> Self
Shuffle this vector using rand::weak_rng
.
fn shuffled_with<R: Rng>(self, rng: R) -> Self
Shuffle this vector using rng
.
fn sorted(self) -> Self where
T: Ord,
T: Ord,
fn sorted_by<F>(self, compare: F) -> Self where
F: FnMut(&T, &T) -> Ordering,
F: FnMut(&T, &T) -> Ordering,
fn sorted_by_key<F, K>(self, key: F) -> Self where
F: FnMut(&T) -> K,
K: Ord,
F: FnMut(&T) -> K,
K: Ord,
fn truncated(self, len: usize) -> Self
Implementations on Foreign Types
impl<T> VecExt<T> for Vec<T>
[src]
unsafe fn new_uninitialized(size: usize) -> Self
[src]
fn deduped(self) -> Self where
T: PartialEq,
[src]
T: PartialEq,
fn deduped_by<F>(self, same_bucket: F) -> Self where
F: FnMut(&mut T, &mut T) -> bool,
[src]
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>,
[src]
F: FnMut(&mut T) -> K,
K: PartialEq<K>,
fn appended(self, other: &mut Self) -> Self
[src]
fn resized(self, new_len: usize, value: T) -> Self where
T: Clone,
[src]
T: Clone,
fn reversed(self) -> Self
[src]
fn shrinked_to_fit(self) -> Self
[src]
fn shuffled(self) -> Self
[src]
fn shuffled_with<R: Rng>(self, rng: R) -> Self
[src]
fn sorted(self) -> Self where
T: Ord,
[src]
T: Ord,
fn sorted_by<F>(self, compare: F) -> Self where
F: FnMut(&T, &T) -> Ordering,
[src]
F: FnMut(&T, &T) -> Ordering,
fn sorted_by_key<F, K>(self, key: F) -> Self where
F: FnMut(&T) -> K,
K: Ord,
[src]
F: FnMut(&T) -> K,
K: Ord,