Trait ArrayLike

Source
pub trait ArrayLike<T: Clone + PartialEq + PartialOrd>:
    AsMut<Vec<T>>
    + AsRef<Vec<T>>
    + Eq
    + IndexMut<usize, Output = T>
    + Iterable<usize, T>
    + Ord {
Show 28 methods // Provided methods fn append(&mut self, elem: &mut Self) { ... } fn as_slice(&self) -> &[T] { ... } fn capacity(&self) -> usize { ... } fn clear(&mut self) { ... } fn contains(&self, elem: &T) -> bool { ... } fn count(&self, elem: &T) -> usize { ... } fn dedup(&mut self) { ... } fn dedup_by<F>(&mut self, same_bucket: F) where F: FnMut(&mut T, &mut T) -> bool { ... } fn dedup_by_key<F, K>(&mut self, key: F) where F: FnMut(&mut T) -> K, K: PartialEq<K> { ... } fn drain(&mut self, range: Range<usize>) -> Drain<'_, T> { ... } fn filter(&self, predicate: impl Fn(&T) -> bool) -> Vec<T> { ... } fn first(&self) -> Option<&T> { ... } fn get(&self, index: usize) -> Option<&T> { ... } fn get_mut(&mut self, index: usize) -> Option<&mut T> { ... } fn is_empty(&self) -> bool { ... } fn last(&self) -> Option<&T> { ... } fn len(&self) -> usize { ... } fn pop(&mut self) -> Option<T> { ... } fn push(&mut self, elem: T) { ... } fn remove(&mut self, index: usize) -> T { ... } fn reverse(&mut self) { ... } fn set(&mut self, index: usize, elem: T) { ... } fn shrink_to(&mut self, min_capacity: usize) { ... } fn shrink_to_fit(&mut self) { ... } fn splice(&mut self, range: Range<usize>, replace_with: Vec<T>) -> Vec<T> { ... } fn split_off(&mut self, at: usize) -> Vec<T> { ... } fn swap_remove(&mut self, index: usize) -> T { ... } fn truncate(&mut self, len: usize) { ... }
}
Expand description

ArrayLike describes the basic behaviors of an array-like structure

Provided Methods§

Source

fn append(&mut self, elem: &mut Self)

ArrayLike::append describes a method for appending another array to the end of the array

Source

fn as_slice(&self) -> &[T]

Source

fn capacity(&self) -> usize

The capacity of the array

Source

fn clear(&mut self)

ArrayLike::clear describes a method for clearing the array

Source

fn contains(&self, elem: &T) -> bool

ArrayLike::contains describes a method for checking if an element is present in the array

Source

fn count(&self, elem: &T) -> usize

ArrayLike::count describes a method for counting the number of times an element appears in the array

Source

fn dedup(&mut self)

ArrayLike::dedup describes a method for removing duplicate elements from the array

Source

fn dedup_by<F>(&mut self, same_bucket: F)
where F: FnMut(&mut T, &mut T) -> bool,

ArrayLike::dedup_by describes a method for removing duplicate elements from the array using a custom comparison function

Source

fn dedup_by_key<F, K>(&mut self, key: F)
where F: FnMut(&mut T) -> K, K: PartialEq<K>,

ArrayLike::dedup_by_key describes a method for removing duplicate elements from the array using a custom key extraction function

Source

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

ArrayLike::drain describes a method for removing a range of elements from the array

Source

fn filter(&self, predicate: impl Fn(&T) -> bool) -> Vec<T>

ArrayLike::filter describes a method for filtering the array

Source

fn first(&self) -> Option<&T>

ArrayLike::first describes a method for getting a reference to the first element in the array

Source

fn get(&self, index: usize) -> Option<&T>

ArrayLike::get describes a method for getting a reference to an element at a specific position

Source

fn get_mut(&mut self, index: usize) -> Option<&mut T>

ArrayLike::get_mut describes a method for getting a mutable reference to an element at a specific position

Source

fn is_empty(&self) -> bool

ArrayLike::is_empty checks if the array is empty

Source

fn last(&self) -> Option<&T>

ArrayLike::last describes a method for gettings the last element in the array

Source

fn len(&self) -> usize

ArrayLike::len describes a method for getting the length of the array

Source

fn pop(&mut self) -> Option<T>

ArrayLike::pop describes a method for removing the last element from the array

Source

fn push(&mut self, elem: T)

ArrayLike::push describes a method for adding an element to the end of the array

Source

fn remove(&mut self, index: usize) -> T

ArrayLike::remove describes a method for removing an element at a specific position

Source

fn reverse(&mut self)

Source

fn set(&mut self, index: usize, elem: T)

ArrayLike::set describes a method for setting the value of an element at a specific position

Source

fn shrink_to(&mut self, min_capacity: usize)

ArrayLike::shrink_to describes a method for shrinking the capacity of the array to a specific minimum

Source

fn shrink_to_fit(&mut self)

ArrayLike::shrink_to_fit describes a method for shrinking the capacity of the array to match its length

Source

fn splice(&mut self, range: Range<usize>, replace_with: Vec<T>) -> Vec<T>

ArrayLike::splice describes a method for removing a range of elements and replacing them with another array

Source

fn split_off(&mut self, at: usize) -> Vec<T>

ArrayLike::split_off describes a method for splitting the array into two at a specific position

Source

fn swap_remove(&mut self, index: usize) -> T

ArrayLike::swap_remove describes a method for removing an element at a specific position and returning it, replacing it with the last element

Source

fn truncate(&mut self, len: usize)

ArrayLike::truncate describes a method for truncating the array to a specific length

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§