all: replace debug_fn with fmt::from_fn
This commit is contained in:
parent
0932ad11b5
commit
b3c46bf52d
11 changed files with 41 additions and 70 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue