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
/*!
Format XML Templating
=====================

Minimal compiletime templating for XML in Rust!

The [`format_xml!` macro](macro.format_xml.html) accepts an XML-like syntax and transforms it into a `format_args!` invocation.
We say _XML-like_ because due to limitations of the macro system some concessions had to be made, see the examples below.

See the [`template!` macro](macro.template.html) to get started with regular formatting.
 */

use std::fmt;

#[macro_use]
mod template;

#[macro_use]
mod xml;

#[macro_use]
mod escape;
pub use self::escape::Escape;

mod html;
pub use self::html::*;

/// Implements `std::fmt::Display` for the Fn closure matching fmt's signature.
#[derive(Copy, Clone)]
#[repr(transparent)]
pub struct FnFmt<F: Fn(&mut fmt::Formatter) -> fmt::Result>(pub F);
impl<F: Fn(&mut fmt::Formatter) -> fmt::Result> fmt::Display for FnFmt<F> {
	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
		(self.0)(f)
	}
}
impl<F: Fn(&mut fmt::Formatter) -> fmt::Result> fmt::Debug for FnFmt<F> {
	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
		f.write_str("FnFmt([closure])")
	}
}