Always implement 'Responder' with 'r instead of 'static.

This commit is contained in:
Yong Wen Chua 2017-07-14 21:58:16 +08:00 committed by Sergio Benitez
parent 722959ee29
commit 10efcb1af9
1 changed files with 6 additions and 6 deletions

View File

@ -193,8 +193,8 @@ impl<'r> Responder<'r> for &'r str {
/// Returns a response with Content-Type `text/plain` and a fixed-size body /// Returns a response with Content-Type `text/plain` and a fixed-size body
/// containing the string `self`. Always returns `Ok`. /// containing the string `self`. Always returns `Ok`.
impl Responder<'static> for String { impl<'r> Responder<'r> for String {
fn respond_to(self, _: &Request) -> Result<Response<'static>, Status> { fn respond_to(self, _: &Request) -> Result<Response<'r>, Status> {
Response::build() Response::build()
.header(ContentType::Plain) .header(ContentType::Plain)
.sized_body(Cursor::new(self)) .sized_body(Cursor::new(self))
@ -203,15 +203,15 @@ impl Responder<'static> for String {
} }
/// Returns a response with a sized body for the file. Always returns `Ok`. /// Returns a response with a sized body for the file. Always returns `Ok`.
impl Responder<'static> for File { impl<'r> Responder<'r> for File {
fn respond_to(self, _: &Request) -> Result<Response<'static>, Status> { fn respond_to(self, _: &Request) -> Result<Response<'r>, Status> {
Response::build().streamed_body(self).ok() Response::build().streamed_body(self).ok()
} }
} }
/// Returns an empty, default `Response`. Always returns `Ok`. /// Returns an empty, default `Response`. Always returns `Ok`.
impl Responder<'static> for () { impl<'r> Responder<'r> for () {
fn respond_to(self, _: &Request) -> Result<Response<'static>, Status> { fn respond_to(self, _: &Request) -> Result<Response<'r>, Status> {
Ok(Response::new()) Ok(Response::new())
} }
} }