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()
|
||||
}
|
||||
|
||||
fn get(&self) -> futures::BoxFuture<Response, Box<::std::error::Error + Send>> {
|
||||
// Accidental clone here:
|
||||
let data = self.data.clone();
|
||||
|
||||
fn get(self) -> futures::BoxFuture<Response, Box<::std::error::Error + Send>> {
|
||||
self.head().map(move |head|
|
||||
head
|
||||
.with_body(Layout {
|
||||
title: &data.title,
|
||||
body: &data
|
||||
title: &self.data.title,
|
||||
body: &self.data
|
||||
}.to_string())
|
||||
).boxed()
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ type Error = Box<std::error::Error + Send>;
|
|||
pub trait Resource {
|
||||
fn allow(&self) -> Vec<hyper::Method>;
|
||||
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 {
|
||||
Response::new()
|
||||
|
|
Loading…
Reference in a new issue