1
0
Fork 0
forked from wry/wry

autocommit 2022-04-05 21:08:07 CEST

This commit is contained in:
Julian Orth 2022-04-05 21:08:07 +02:00
parent a3e9f21fc5
commit 1d33088dba
27 changed files with 982 additions and 699 deletions

View file

@ -1,17 +1,26 @@
use std::fmt::{Debug, Formatter};
use std::fmt::{Debug, Display, Formatter};
pub fn debug_fn<F>(f: F) -> impl Debug
pub fn debug_fn<F>(f: F) -> Printable<F>
where
F: Fn(&mut Formatter<'_>) -> std::fmt::Result,
{
DebugFn { f }
Printable { f }
}
struct DebugFn<F> {
pub struct Printable<F> {
f: F,
}
impl<F> Debug for DebugFn<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,
{