exhaust 0.1.2

Trait and derive macro for working with all possible values of a type (exhaustive enumeration).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use crate::Exhaust;

/// Return an iterator over all values satisfying the given predicate.
///
/// This is equivalent to `T::exhaust().filter(filter)` but infers the value type.
///
/// TODO: Is this really part of the public API we want to offer?
pub fn brute_force_search<T, F>(filter: F) -> impl Iterator<Item = T>
where
    T: Exhaust,
    F: FnMut(&T) -> bool,
{
    T::exhaust().filter(filter)
}