use super::{
Arc,
Rc,
};
use self::{
arc_stateful_tester::ArcStatefulTester,
box_stateful_tester::BoxStatefulTester,
rc_stateful_tester::RcStatefulTester,
};
pub mod arc_stateful_tester;
pub mod box_stateful_tester;
pub mod fn_stateful_tester_ops;
pub mod rc_stateful_tester;
pub trait StatefulTester {
fn test(&mut self) -> bool;
#[inline]
fn into_box(mut self) -> BoxStatefulTester
where
Self: Sized + 'static,
{
BoxStatefulTester::new(move || self.test())
}
#[inline]
fn into_rc(mut self) -> RcStatefulTester
where
Self: Sized + 'static,
{
RcStatefulTester::new(move || self.test())
}
#[inline]
fn into_arc(mut self) -> ArcStatefulTester
where
Self: Sized + Send + 'static,
{
ArcStatefulTester::new(move || self.test())
}
fn into_fn(mut self) -> impl FnMut() -> bool
where
Self: Sized + 'static,
{
move || self.test()
}
fn into_mut_fn(self) -> impl FnMut() -> bool
where
Self: Sized + 'static,
{
self.into_fn()
}
#[inline]
fn to_box(&self) -> BoxStatefulTester
where
Self: Clone + Sized + 'static,
{
self.clone().into_box()
}
#[inline]
fn to_rc(&self) -> RcStatefulTester
where
Self: Clone + Sized + 'static,
{
self.clone().into_rc()
}
#[inline]
fn to_arc(&self) -> ArcStatefulTester
where
Self: Clone + Sized + Send + 'static,
{
self.clone().into_arc()
}
fn to_fn(&self) -> impl FnMut() -> bool
where
Self: Clone + Sized + 'static,
{
self.clone().into_fn()
}
fn to_mut_fn(&self) -> impl FnMut() -> bool
where
Self: Clone + Sized + 'static,
{
self.to_fn()
}
}
impl<F> StatefulTester for F
where
F: FnMut() -> bool,
{
#[inline]
fn test(&mut self) -> bool {
self()
}
}