use std::fmt::Debug; pub trait CloneableFnWithArg: FnOnce(Arg) { fn clone_box(&self) -> Box>; } impl CloneableFnWithArg for F where F: FnOnce(Arg) + Clone + 'static, { fn clone_box(&self) -> Box> { Box::new(self.clone()) } } impl Clone for Box> { fn clone(&self) -> Self { (**self).clone_box() } } impl Default for Box> { fn default() -> Self { Box::new(|_| {}) } } impl Debug for Box> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( f, "Box>", std::any::type_name::() ) } }