Borrow spliced values instead of moving them

Closes 
This commit is contained in:
Chris Wong 2015-04-30 16:32:15 +12:00
parent 054453be88
commit d6677b3319
2 changed files with 4 additions and 4 deletions
maud/src
maud_macros/src

View file

@ -85,8 +85,8 @@ pub mod rt {
///
/// See <https://github.com/rust-lang/rust/issues/16617>
#[inline]
pub fn write_fmt<T: fmt::Display>(w: &mut fmt::Write, value: T) -> fmt::Result {
write!(w, "{}", value)
pub fn write_fmt<T: fmt::Display>(w: &mut fmt::Write, value: &T) -> fmt::Result {
write!(w, "{}", *value)
}
pub struct Escaper<'a, 'b: 'a> {

View file

@ -96,12 +96,12 @@ impl<'cx> Renderer<'cx> {
let w = self.w;
let expr = match escape {
Escape::PassThru =>
quote_expr!(self.cx, ::maud::rt::write_fmt($w, $expr)),
quote_expr!(self.cx, ::maud::rt::write_fmt($w, &$expr)),
Escape::Escape =>
quote_expr!(self.cx,
::maud::rt::write_fmt(
&mut ::maud::rt::Escaper { inner: $w },
$expr)),
&$expr)),
};
let stmt = self.cx.stmt_expr(self.cx.expr_try(expr.span, expr));
self.push(stmt);