#[cfg(feature = "alloc")]
mod arc;
#[cfg(feature = "alloc")]
mod boxed;
#[cfg(feature = "alloc")]
mod rc;
mod tuple;
pub trait Reducer<A> {
fn reduce(&mut self, action: A);
}
#[cfg(test)]
mod tests {
use super::*;
use mockall::{predicate::*, *};
use test_strategy::proptest;
mock! {
pub Reducer<A: 'static> {
pub fn id(&self) -> usize;
}
impl<A: 'static> Reducer<A> for Reducer<A> {
fn reduce(&mut self, action: A);
}
impl<A: 'static> Clone for Reducer<A> {
fn clone(&self) -> Self;
}
}
#[proptest]
fn reduce(action: u8) {
let mut mock = MockReducer::new();
mock.expect_reduce()
.with(eq(action))
.once()
.return_const(());
let reducer: &mut dyn Reducer<_> = &mut mock;
reducer.reduce(action);
}
}
#[cfg(test)]
pub(crate) use self::tests::MockReducer;