Skip to content

Commit

Permalink
Revert "Add #call_box instruction"
Browse files Browse the repository at this point in the history
This reverts commit 0311bab.
  • Loading branch information
lambda-fairy committed Sep 26, 2015
1 parent 7fde2aa commit cf0cf09
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 44 deletions.
5 changes: 0 additions & 5 deletions maud_macros/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,6 @@ impl<'cx, 'i> Parser<'cx, 'i> {
let func = try!(self.splice(sp));
self.render.emit_call(func);
},
[pound!(), ident!(sp, name), ..] if name.name == "call_box" => {
self.shift(2);
let func = try!(self.splice(sp));
self.render.emit_call_box(func);
},
// Splice
[ref tt @ dollar!(), dollar!(), ..] => {
self.shift(2);
Expand Down
10 changes: 0 additions & 10 deletions maud_macros/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,6 @@ impl<'cx> Renderer<'cx> {
let stmt = self.wrap_try(expr);
self.push(stmt);
}

pub fn emit_call_box(&mut self, func: P<Expr>) {
let w = self.writer;
let expr = quote_expr!(self.cx,
::std::boxed::FnBox::call_box(
$func,
(&mut *$w as &mut ::std::fmt::Write,)));
let stmt = self.wrap_try(expr);
self.push(stmt);
}
}

fn html_escape(s: &str) -> String {
Expand Down
47 changes: 18 additions & 29 deletions maud_macros/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#![feature(fnbox, plugin)]
#![feature(plugin)]
#![plugin(maud_macros)]

extern crate maud;

use std::fmt;

#[test]
fn literals() {
let mut s = String::new();
Expand Down Expand Up @@ -272,35 +274,22 @@ mod issue_10 {
}
}

mod subtemplates {
use std::fmt;

#[test]
fn call() {
fn ducks(w: &mut fmt::Write) -> fmt::Result {
write!(w, "Ducks")
}

#[test]
fn call() {
let mut s = String::new();
let swans = |yes|
if yes {
|w: &mut fmt::Write| write!(w, "Swans")
} else {
panic!("oh noes")
};
html!(s, {
#call ducks
#call (|w: &mut fmt::Write| write!(w, "Geese"))
#call swans(true)
}).unwrap();
assert_eq!(s, "DucksGeeseSwans");
}

#[test]
fn call_box() {
let mut s = String::new();
let ducks = Box::new(ducks);
html!(s, #call_box ducks).unwrap();
assert_eq!(s, "Ducks");
}
let mut s = String::new();
let swans = |yes|
if yes {
|w: &mut fmt::Write| write!(w, "Swans")
} else {
panic!("oh noes")
};
html!(s, {
#call ducks
#call (|w: &mut fmt::Write| write!(w, "Geese"))
#call swans(true)
}).unwrap();
assert_eq!(s, "DucksGeeseSwans");
}

0 comments on commit cf0cf09

Please sign in to comment.