macro_rules! disp { ($expr:expr) => { ... }; }
👎Deprecated since 0.4.0: use
format_args!("{}", ...)
insteadExpand description
Wraps a Display
in RenderDisplay
, making it implement Render
.
This is a convenience macro that wraps the given expression in RenderDisplay
.
Beginning with laby 0.4
, Arguments
struct implements Render
directly so disp!
and RenderDisplay
are deprecated. You should write
format_args!("{}", expr)
instead of disp!(expr)
.
Expansion
ⓘ
// disp!($expr)
{
RenderDisplay($expr)
}
Example
This example renders a value that implements Display
by wrapping it using
disp!
.
struct Name<'a> {
s: &'a str,
}
impl Display for Name<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.s)
}
}
let s = render!(disp!(Name {
s: "laby"
}));
assert_eq!(s, "laby");