use std::fmt::{Debug, Formatter}; pub fn debug_fn(f: F) -> impl Debug where F: Fn(&mut Formatter<'_>) -> std::fmt::Result, { DebugFn { f } } struct DebugFn { f: F, } impl Debug for DebugFn where F: Fn(&mut Formatter<'_>) -> std::fmt::Result, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { (self.f)(f) } }