Make Resource::get consume self, for copyless futures
This commit is contained in:
parent
76302353e1
commit
94758adaf4
2 changed files with 4 additions and 7 deletions
|
@ -86,15 +86,12 @@ impl Resource for ArticleResource {
|
||||||
).boxed()
|
).boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get(&self) -> futures::BoxFuture<Response, Box<::std::error::Error + Send>> {
|
fn get(self) -> futures::BoxFuture<Response, Box<::std::error::Error + Send>> {
|
||||||
// Accidental clone here:
|
|
||||||
let data = self.data.clone();
|
|
||||||
|
|
||||||
self.head().map(move |head|
|
self.head().map(move |head|
|
||||||
head
|
head
|
||||||
.with_body(Layout {
|
.with_body(Layout {
|
||||||
title: &data.title,
|
title: &self.data.title,
|
||||||
body: &data
|
body: &self.data
|
||||||
}.to_string())
|
}.to_string())
|
||||||
).boxed()
|
).boxed()
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ type Error = Box<std::error::Error + Send>;
|
||||||
pub trait Resource {
|
pub trait Resource {
|
||||||
fn allow(&self) -> Vec<hyper::Method>;
|
fn allow(&self) -> Vec<hyper::Method>;
|
||||||
fn head(&self) -> futures::BoxFuture<server::Response, Error>;
|
fn head(&self) -> futures::BoxFuture<server::Response, Error>;
|
||||||
fn get(&self) -> futures::BoxFuture<server::Response, Error>;
|
fn get(self) -> futures::BoxFuture<server::Response, Error>;
|
||||||
|
|
||||||
fn options(&self) -> Response {
|
fn options(&self) -> Response {
|
||||||
Response::new()
|
Response::new()
|
||||||
|
|
Loading…
Reference in a new issue