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