Avoid name collisions when Render trait is already in scope

Closes 
This commit is contained in:
Chris Wong 2017-08-11 19:57:07 +12:00
parent 9fc96ea5c3
commit f046b64409
3 changed files with 22 additions and 2 deletions
CHANGELOG.md
maud/tests
maud_macros/src

View file

@ -1,5 +1,10 @@
# Change Log
## [Unreleased]
- [Fixed] "Multiple applicable items in scope" error when using `Render` trait
[#97](https://github.com/lfairy/maud/issues/97)
## [0.17.0] - 2017-08-04
- [Added] Allow terminating void elements with semicolons (`;`)

View file

@ -67,3 +67,18 @@ fn render_impl() {
assert_eq!(s1, "pinkie");
assert_eq!(s2, "pinkie");
}
#[test]
fn issue_97() {
use maud::Render;
struct Pinkie;
impl Render for Pinkie {
fn render(&self) -> maud::Markup {
let x = 42;
html! { (x) }
}
}
assert_eq!(html!((Pinkie)).into_string(), "42");
}

View file

@ -84,12 +84,12 @@ impl Renderer {
extern crate maud;
// Create a local trait alias so that autoref works
trait Render: maud::Render {
fn render_to(&self, output: &mut String) {
fn __maud_render_to(&self, output: &mut String) {
maud::Render::render_to(self, output);
}
}
impl<T: maud::Render> Render for T {}
$expr.render_to(&mut $output);
$expr.__maud_render_to(&mut $output);
}));
}