Skip to main content

StatefulTester

Trait StatefulTester 

Source
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§

Source

fn test(&mut self) -> bool

Executes the stateful test and returns the test result.

This method uses &mut self to match FnMut() -> bool, allowing each call to update internal state before producing the boolean result.

§Return Value

Returns true if the condition holds, otherwise returns false.

Provided Methods§

Source

fn into_box(self) -> BoxStatefulTester
where Self: Sized + 'static,

Converts this tester to BoxStatefulTester.

Source

fn into_rc(self) -> RcStatefulTester
where Self: Sized + 'static,

Converts this tester to RcStatefulTester.

Source

fn into_arc(self) -> ArcStatefulTester
where Self: Sized + Send + 'static,

Converts this tester to ArcStatefulTester.

Source

fn into_fn(self) -> impl FnMut() -> bool
where 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.

Source

fn into_mut_fn(self) -> impl FnMut() -> bool
where 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.

Source

fn to_box(&self) -> BoxStatefulTester
where Self: Clone + Sized + 'static,

Converts a clone of this tester to BoxStatefulTester.

Source

fn to_rc(&self) -> RcStatefulTester
where Self: Clone + Sized + 'static,

Converts a clone of this tester to RcStatefulTester.

Source

fn to_arc(&self) -> ArcStatefulTester
where Self: Clone + Sized + Send + 'static,

Converts a clone of this tester to ArcStatefulTester.

Source

fn to_fn(&self) -> impl FnMut() -> bool
where Self: Clone + Sized + 'static,

Creates a mutable closure from a cloned tester.

The original tester remains available. The returned closure owns a clone and mutates that clone on each call.

Source

fn to_mut_fn(&self) -> impl FnMut() -> bool
where Self: Clone + Sized + 'static,

Creates a mutable closure from a cloned tester with an explicit method name.

This is a naming alias of StatefulTester::to_fn and preserves the same clone-based behavior.

Implementors§