From e5b5a9dc28401815f8e9a68007281d23b3f52825 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 23 Dec 2017 16:47:00 +0100 Subject: Don't import modules in macro. Didn't work well when macro was invoked more than once for each source file. Use full references to all symbols instead. --- src/lib.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0549a3f..b05ec3a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,16 +77,11 @@ macro_rules! implement_responder_for { // So it will have to be passed in to the argument at // the macro incovation instead. ($template_type:ty) => ( - use rocket::response::{Response, Responder}; - use rocket::http::{ContentType, Status}; - use std::io::Cursor; - use rocket::request::Request; - - impl<'a> Responder<'a> for $template_type { - fn respond_to(self, _: &Request) -> Result, Status> { - Response::build() - .header(ContentType::HTML) - .sized_body(Cursor::new(format!("{}", &self))) + impl<'a> ::rocket::response::Responder<'a> for $template_type { + fn respond_to(self, _: &::rocket::Request) -> Result<::rocket::Response<'static>, ::rocket::http::Status> { + ::rocket::Response::build() + .header(::rocket::http::ContentType::HTML) + .sized_body(::std::io::Cursor::new(format!("{}", &self))) .ok() } } -- cgit v1.2.3