1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use std::fmt;
mod template_impl;
pub mod template;
mod xml_impl;
pub mod xml;
mod html;
pub use self::html::*;
#[doc(hidden)]
#[derive(Copy, Clone)]
#[repr(transparent)]
pub struct FnFmt<F>(pub F);
impl<F> fmt::Display for FnFmt<F> where F: Fn(&mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
(self.0)(f)
}
}
impl<F> fmt::Debug for FnFmt<F> where F: Fn(&mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("fmt([closure])")
}
}
#[inline]
pub fn fmt<F>(f: F) -> impl fmt::Display + fmt::Debug where F: Fn(&mut fmt::Formatter) -> fmt::Result {
FnFmt(f)
}
#[doc(hidden)]
#[inline(never)]
pub fn noinline<T, F: FnOnce() -> T>(f: F) -> T { f() }