pub trait Filter<Item> {
type Item;
// Required method
fn filter<P>(self, predicate: P) -> Option<Item>
where P: FnOnce(&Self::Item) -> bool;
}
Expand description
This trait creates a filter
method for Option
so that it can be
filtered on when used in the map_for
macro.
§Example:
use map_for::{ Filter, FlatMap };
let c = map_for!{
a <- Some (1);
if (a%2) == 0;
b <- Some (2);
=> { a + b } };
assert_eq!(c, None);
Required Associated Types§
Required Methods§
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.