1
0
Fork 0
forked from wry/wry

all: replace debug_fn with fmt::from_fn

This commit is contained in:
Julian Orth 2026-02-13 11:13:37 +01:00
parent 0932ad11b5
commit b3c46bf52d
11 changed files with 41 additions and 70 deletions

View file

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