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