1 use core::fmt::{self, Display}; 2 display(fmt: impl Fn(&mut fmt::Formatter) -> fmt::Result) -> impl Display3pub(crate) fn display(fmt: impl Fn(&mut fmt::Formatter) -> fmt::Result) -> impl Display { 4 DisplayInvoke(fmt) 5 } 6 7 struct DisplayInvoke<T>(T); 8 9 impl<T> Display for DisplayInvoke<T> 10 where 11 T: Fn(&mut fmt::Formatter) -> fmt::Result, 12 { fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result13 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 14 (self.0)(formatter) 15 } 16 } 17