use super::*;
#[derive(Clone, Debug, Default)]
pub struct Cell<M> {
mutator: M,
}
pub fn cell<M>(mutator: M) -> Cell<M> {
Cell { mutator }
}
impl<M, T> Mutate<core::cell::Cell<T>> for Cell<M>
where
M: Mutate<T>,
{
#[inline]
fn mutate(&mut self, c: &mut Candidates, value: &mut core::cell::Cell<T>) -> Result<()> {
self.mutator.mutate(c, value.get_mut())
}
}
impl<M, T> Generate<core::cell::Cell<T>> for Cell<M>
where
M: Generate<T>,
{
#[inline]
fn generate(&mut self, ctx: &mut Context) -> Result<core::cell::Cell<T>> {
Ok(core::cell::Cell::new(self.mutator.generate(ctx)?))
}
}
impl<T> DefaultMutate for core::cell::Cell<T>
where
T: DefaultMutate,
{
type DefaultMutate = Cell<T::DefaultMutate>;
}