pub trait ArrayIter<T: ArrayElement>{
// Required methods
fn for_each<F: FnMut(&T)>(&self, f: F) -> Result<(), ArrayError>;
fn for_each_e<F: FnMut(usize, &T)>(&self, f: F) -> Result<(), ArrayError>;
fn filter<F: FnMut(&T) -> bool>(&self, f: F) -> Result<Array<T>, ArrayError>;
fn filter_e<F: FnMut(usize, &T) -> bool>(
&self,
f: F,
) -> Result<Array<T>, ArrayError>;
}
Expand description
ArrayTrait
- Array Iterable functions
Required Methods§
Sourcefn for_each_e<F: FnMut(usize, &T)>(&self, f: F) -> Result<(), ArrayError>
fn for_each_e<F: FnMut(usize, &T)>(&self, f: F) -> Result<(), ArrayError>
Sourcefn filter<F: FnMut(&T) -> bool>(&self, f: F) -> Result<Array<T>, ArrayError>
fn filter<F: FnMut(&T) -> bool>(&self, f: F) -> Result<Array<T>, ArrayError>
Filter over array elements Returns a flat filtered array
§Arguments
f
- function to be called on each array element
§Examples
use arr_rs::prelude::*;
let arr: Array<i32> = Array::new(vec![1, 2, 3, 4, 5, 6, 7, 8], vec![2, 4]).unwrap();
arr.filter(|item| item % 2 == 0).unwrap();
§Errors
may returns ArrayError
Sourcefn filter_e<F: FnMut(usize, &T) -> bool>(
&self,
f: F,
) -> Result<Array<T>, ArrayError>
fn filter_e<F: FnMut(usize, &T) -> bool>( &self, f: F, ) -> Result<Array<T>, ArrayError>
Filter over enumerated array elements Returns a flat filtered array
§Arguments
f
- function to be called on each array element
§Examples
use arr_rs::prelude::*;
let arr: Array<i32> = Array::new(vec![1, 2, 3, 4, 5, 6, 7, 8], vec![2, 4]).unwrap();
arr.filter_e(|idx, item| item % (idx + 1) as i32 == 0).unwrap();
§Errors
may returns ArrayError
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.