autocommit 2022-04-05 21:08:07 CEST
This commit is contained in:
parent
a3e9f21fc5
commit
1d33088dba
27 changed files with 982 additions and 699 deletions
|
|
@ -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,
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue