pub trait RullstCollection<T> {
// Required methods
fn key_by<K, F>(self, f: F) -> HashMap<K, T>
where F: Fn(&T) -> K,
K: Hash + Eq;
fn chunk(self, size: usize) -> Vec<Vec<T>>;
fn implode<F>(&self, separator: &str, f: F) -> String
where F: Fn(&T) -> String;
fn sum_by<N, F>(&self, f: F) -> N
where F: Fn(&T) -> N,
N: Sum;
fn max_by_key<K, F>(&self, f: F) -> Option<&T>
where F: Fn(&T) -> K,
K: Ord;
fn min_by_key<K, F>(&self, f: F) -> Option<&T>
where F: Fn(&T) -> K,
K: Ord;
fn collection_resource(&self) -> Value
where T: ApiResource;
}Expand description
An extension trait that brings Laravel-style Collection methods natively to Rust’s Vec
Required Methods§
Sourcefn key_by<K, F>(self, f: F) -> HashMap<K, T>
fn key_by<K, F>(self, f: F) -> HashMap<K, T>
Keys the collection by the given closure’s return value
Sourcefn implode<F>(&self, separator: &str, f: F) -> String
fn implode<F>(&self, separator: &str, f: F) -> String
Joins the items into a single string using the given separator and closure
Sourcefn max_by_key<K, F>(&self, f: F) -> Option<&T>
fn max_by_key<K, F>(&self, f: F) -> Option<&T>
Finds the maximum value returned by the closure
Sourcefn min_by_key<K, F>(&self, f: F) -> Option<&T>
fn min_by_key<K, F>(&self, f: F) -> Option<&T>
Finds the minimum value returned by the closure
Sourcefn collection_resource(&self) -> Valuewhere
T: ApiResource,
fn collection_resource(&self) -> Valuewhere
T: ApiResource,
Serializes the entire collection using an ApiResource transformer
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".