pub trait StatefulTester {
// Required method
fn test(&mut self) -> bool;
// Provided methods
fn into_box(self) -> BoxStatefulTester
where Self: Sized + 'static { ... }
fn into_rc(self) -> RcStatefulTester
where Self: Sized + 'static { ... }
fn into_arc(self) -> ArcStatefulTester
where Self: Sized + Send + 'static { ... }
fn into_fn(self) -> impl FnMut() -> bool
where Self: Sized + 'static { ... }
fn into_mut_fn(self) -> impl FnMut() -> bool
where Self: Sized + 'static { ... }
fn to_box(&self) -> BoxStatefulTester
where Self: Clone + Sized + 'static { ... }
fn to_rc(&self) -> RcStatefulTester
where Self: Clone + Sized + 'static { ... }
fn to_arc(&self) -> ArcStatefulTester
where Self: Clone + Sized + Send + 'static { ... }
fn to_fn(&self) -> impl FnMut() -> bool
where Self: Clone + Sized + 'static { ... }
fn to_mut_fn(&self) -> impl FnMut() -> bool
where Self: Clone + Sized + 'static { ... }
}Expand description
Tests whether a zero-argument condition holds while allowing state mutation.
StatefulTester is the stateful counterpart of
Tester.
It is equivalent to FnMut() -> bool: callers execute it through
&mut self, so the implementation may update captured or internal state
between calls.
§Examples
use qubit_function::StatefulTester;
let mut count = 0;
let mut tester = move || {
count += 1;
count >= 2
};
assert!(!tester.test());
assert!(tester.test());Required Methods§
Provided Methods§
Sourcefn into_box(self) -> BoxStatefulTesterwhere
Self: Sized + 'static,
fn into_box(self) -> BoxStatefulTesterwhere
Self: Sized + 'static,
Converts this tester to BoxStatefulTester.
Sourcefn into_rc(self) -> RcStatefulTesterwhere
Self: Sized + 'static,
fn into_rc(self) -> RcStatefulTesterwhere
Self: Sized + 'static,
Converts this tester to RcStatefulTester.
Sourcefn into_arc(self) -> ArcStatefulTester
fn into_arc(self) -> ArcStatefulTester
Converts this tester to ArcStatefulTester.
Sourcefn into_fn(self) -> impl FnMut() -> boolwhere
Self: Sized + 'static,
fn into_fn(self) -> impl FnMut() -> boolwhere
Self: Sized + 'static,
Converts this tester to a mutable closure.
§Return Value
A closure implementing FnMut() -> bool that owns this tester and
delegates each call to StatefulTester::test.
Sourcefn into_mut_fn(self) -> impl FnMut() -> boolwhere
Self: Sized + 'static,
fn into_mut_fn(self) -> impl FnMut() -> boolwhere
Self: Sized + 'static,
Converts this tester to a mutable closure with an explicit method name.
This is a naming alias of StatefulTester::into_fn for call sites
that want the returned FnMut shape to be obvious.
Sourcefn to_box(&self) -> BoxStatefulTester
fn to_box(&self) -> BoxStatefulTester
Converts a clone of this tester to BoxStatefulTester.
Sourcefn to_rc(&self) -> RcStatefulTester
fn to_rc(&self) -> RcStatefulTester
Converts a clone of this tester to RcStatefulTester.
Sourcefn to_arc(&self) -> ArcStatefulTester
fn to_arc(&self) -> ArcStatefulTester
Converts a clone of this tester to ArcStatefulTester.