#![allow(unused_imports)]
use super::*;
pub struct RcRunnableWith<T, E> {
pub(super) function: Rc<RefCell<dyn FnMut(&mut T) -> Result<(), E>>>,
pub(super) name: Option<String>,
}
impl<T, E> Clone for RcRunnableWith<T, E> {
#[inline]
fn clone(&self) -> Self {
Self {
function: Rc::clone(&self.function),
name: self.name.clone(),
}
}
}
impl<T, E> RcRunnableWith<T, E> {
impl_common_new_methods!(
(FnMut(&mut T) -> Result<(), E> + 'static),
|function| Rc::new(RefCell::new(function)),
"runnable-with"
);
impl_common_name_methods!("runnable-with");
}
impl<T, E> RunnableWith<T, E> for RcRunnableWith<T, E> {
#[inline]
fn run_with(&mut self, input: &mut T) -> Result<(), E> {
(self.function.borrow_mut())(input)
}
impl_rc_conversions!(
RcRunnableWith<T, E>,
BoxRunnableWith,
FnMut(input: &mut T) -> Result<(), E>
);
}