pub trait StatefulBiPredicate<T, U> {
// Required method
fn test(&mut self, first: &T, second: &U) -> bool;
// Provided methods
fn into_box(self) -> BoxStatefulBiPredicate<T, U>
where Self: Sized + 'static { ... }
fn into_rc(self) -> RcStatefulBiPredicate<T, U>
where Self: Sized + 'static { ... }
fn into_arc(self) -> ArcStatefulBiPredicate<T, U>
where Self: Sized + Send + 'static { ... }
fn into_fn(self) -> impl FnMut(&T, &U) -> bool
where Self: Sized + 'static { ... }
fn to_box(&self) -> BoxStatefulBiPredicate<T, U>
where Self: Clone + Sized + 'static { ... }
fn to_rc(&self) -> RcStatefulBiPredicate<T, U>
where Self: Clone + Sized + 'static { ... }
fn to_arc(&self) -> ArcStatefulBiPredicate<T, U>
where Self: Clone + Sized + Send + 'static { ... }
fn to_fn(&self) -> impl FnMut(&T, &U) -> bool
where Self: Clone + Sized + 'static { ... }
}Expand description
A stateful bi-predicate trait for testing pairs with mutable internal state.
This trait represents closures and wrapper types equivalent to
FnMut(&T, &U) -> bool: each call borrows the predicate mutably so the
predicate can update counters, caches, rolling state, or other internal
data while leaving both tested values borrowed immutably.
§Type Parameters
T- The type of the first value being tested.U- The type of the second value being tested.
Required Methods§
Sourcefn test(&mut self, first: &T, second: &U) -> bool
fn test(&mut self, first: &T, second: &U) -> bool
Tests whether the given values satisfy this bi-predicate.
The method takes &mut self because evaluating the predicate may
update internal state. The tested values themselves are only borrowed
immutably and are not modified by this API.
§Parameters
first- The first value to test.second- The second value to test.
§Returns
true if the values satisfy this bi-predicate, false otherwise.
Provided Methods§
Sourcefn into_box(self) -> BoxStatefulBiPredicate<T, U>where
Self: Sized + 'static,
fn into_box(self) -> BoxStatefulBiPredicate<T, U>where
Self: Sized + 'static,
Sourcefn into_rc(self) -> RcStatefulBiPredicate<T, U>where
Self: Sized + 'static,
fn into_rc(self) -> RcStatefulBiPredicate<T, U>where
Self: Sized + 'static,
Converts this bi-predicate into an RcStatefulBiPredicate.
This consumes self and wraps it in a single-threaded shared
stateful bi-predicate using Rc<RefCell<_>>.
§Returns
An RcStatefulBiPredicate wrapping this predicate.
Sourcefn into_arc(self) -> ArcStatefulBiPredicate<T, U>
fn into_arc(self) -> ArcStatefulBiPredicate<T, U>
Converts this bi-predicate into an ArcStatefulBiPredicate.
This consumes self and wraps it in a thread-safe shared stateful
bi-predicate using Arc<Mutex<_>>. The wrapped predicate must be
Send so it can be stored behind the thread-safe wrapper.
§Returns
An ArcStatefulBiPredicate wrapping this predicate.
Sourcefn to_box(&self) -> BoxStatefulBiPredicate<T, U>
fn to_box(&self) -> BoxStatefulBiPredicate<T, U>
Converts a clone of this bi-predicate into a BoxStatefulBiPredicate.
The original predicate remains available after this call. The cloned predicate owns independent state unless its clone implementation shares state internally.
§Returns
A BoxStatefulBiPredicate wrapping a clone of this predicate.
Sourcefn to_rc(&self) -> RcStatefulBiPredicate<T, U>
fn to_rc(&self) -> RcStatefulBiPredicate<T, U>
Converts a clone of this bi-predicate into an RcStatefulBiPredicate.
The original predicate remains available after this call. The cloned predicate owns independent state unless its clone implementation shares state internally.
§Returns
An RcStatefulBiPredicate wrapping a clone of this predicate.
Sourcefn to_arc(&self) -> ArcStatefulBiPredicate<T, U>
fn to_arc(&self) -> ArcStatefulBiPredicate<T, U>
Converts a clone of this bi-predicate into an ArcStatefulBiPredicate.
The original predicate remains available after this call. The cloned
predicate must be Send so it can be stored behind the thread-safe
wrapper.
§Returns
An ArcStatefulBiPredicate wrapping a clone of this predicate.
Sourcefn to_fn(&self) -> impl FnMut(&T, &U) -> bool
fn to_fn(&self) -> impl FnMut(&T, &U) -> bool
Converts a clone of this bi-predicate into a mutable closure.
The original predicate remains available after this call. The cloned predicate owns independent state unless its clone implementation shares state internally.
§Returns
A closure implementing FnMut(&T, &U) -> bool.