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§
Sourcefn append(&mut self, elem: &mut Self)
fn append(&mut self, elem: &mut Self)
ArrayLike::append describes a method for appending another array to the end of the array
fn as_slice(&self) -> &[T]
Sourcefn clear(&mut self)
fn clear(&mut self)
ArrayLike::clear describes a method for clearing the array
Sourcefn contains(&self, elem: &T) -> bool
fn contains(&self, elem: &T) -> bool
ArrayLike::contains describes a method for checking if an element is present in the array
Sourcefn count(&self, elem: &T) -> usize
fn count(&self, elem: &T) -> usize
ArrayLike::count describes a method for counting the number of times an element appears in the array
Sourcefn dedup(&mut self)
fn dedup(&mut self)
ArrayLike::dedup describes a method for removing duplicate elements from the array
Sourcefn dedup_by<F>(&mut self, same_bucket: F)
fn dedup_by<F>(&mut self, same_bucket: F)
ArrayLike::dedup_by describes a method for removing duplicate elements from the array using a custom comparison function
Sourcefn dedup_by_key<F, K>(&mut self, key: F)
fn dedup_by_key<F, K>(&mut self, key: F)
ArrayLike::dedup_by_key describes a method for removing duplicate elements from the array using a custom key extraction function
Sourcefn drain(&mut self, range: Range<usize>) -> Drain<'_, T>
fn drain(&mut self, range: Range<usize>) -> Drain<'_, T>
ArrayLike::drain describes a method for removing a range of elements from the array
Sourcefn filter(&self, predicate: impl Fn(&T) -> bool) -> Vec<T>
fn filter(&self, predicate: impl Fn(&T) -> bool) -> Vec<T>
ArrayLike::filter describes a method for filtering the array
Sourcefn first(&self) -> Option<&T>
fn first(&self) -> Option<&T>
ArrayLike::first describes a method for getting a reference to the first element in the array
Sourcefn get(&self, index: usize) -> Option<&T>
fn get(&self, index: usize) -> Option<&T>
ArrayLike::get describes a method for getting a reference to an element at a specific position
Sourcefn get_mut(&mut self, index: usize) -> Option<&mut T>
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
Sourcefn is_empty(&self) -> bool
fn is_empty(&self) -> bool
ArrayLike::is_empty checks if the array is empty
Sourcefn last(&self) -> Option<&T>
fn last(&self) -> Option<&T>
ArrayLike::last describes a method for gettings the last element in the array
Sourcefn len(&self) -> usize
fn len(&self) -> usize
ArrayLike::len describes a method for getting the length of the array
Sourcefn pop(&mut self) -> Option<T>
fn pop(&mut self) -> Option<T>
ArrayLike::pop describes a method for removing the last element from the array
Sourcefn push(&mut self, elem: T)
fn push(&mut self, elem: T)
ArrayLike::push describes a method for adding an element to the end of the array
Sourcefn remove(&mut self, index: usize) -> T
fn remove(&mut self, index: usize) -> T
ArrayLike::remove describes a method for removing an element at a specific position
fn reverse(&mut self)
Sourcefn set(&mut self, index: usize, elem: T)
fn set(&mut self, index: usize, elem: T)
ArrayLike::set describes a method for setting the value of an element at a specific position
Sourcefn shrink_to(&mut self, min_capacity: usize)
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
Sourcefn shrink_to_fit(&mut self)
fn shrink_to_fit(&mut self)
ArrayLike::shrink_to_fit describes a method for shrinking the capacity of the array to match its length
Sourcefn splice(&mut self, range: Range<usize>, replace_with: Vec<T>) -> Vec<T>
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
Sourcefn split_off(&mut self, at: usize) -> Vec<T>
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
Sourcefn swap_remove(&mut self, index: usize) -> T
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
Sourcefn truncate(&mut self, len: usize)
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.