From 551cc22383b42cd5e729e519286d68bace071231 Mon Sep 17 00:00:00 2001 From: Magnus Hoff Date: Sun, 17 Sep 2017 11:45:35 +0200 Subject: [PATCH] Remove all calls to Future::boxed(), which is deprecated --- libs/static_resource_derive/src/lib.rs | 10 +++++----- src/article_resource.rs | 12 ++++++------ src/site.rs | 10 +++++----- src/wiki_lookup.rs | 12 ++++++------ 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/libs/static_resource_derive/src/lib.rs b/libs/static_resource_derive/src/lib.rs index f5e9a68..770c296 100644 --- a/libs/static_resource_derive/src/lib.rs +++ b/libs/static_resource_derive/src/lib.rs @@ -74,7 +74,7 @@ pub fn static_resource(input: TokenStream) -> TokenStream { fn head(&self) -> ::futures::BoxFuture<::hyper::server::Response, Box<::std::error::Error + Send + Sync>> { - ::futures::finished(::hyper::server::Response::new() + Box::new(::futures::finished(::hyper::server::Response::new() .with_status(::hyper::StatusCode::Ok) .with_header(::hyper::header::ContentType( #mime.parse().expect("Statically supplied mime type must be parseable"))) @@ -84,7 +84,7 @@ pub fn static_resource(input: TokenStream) -> TokenStream { ::hyper::header::CacheDirective::Public, ])) .with_header(::hyper::header::ETag(Self::etag())) - ).boxed() + )) } fn get(self: Box) -> @@ -92,17 +92,17 @@ pub fn static_resource(input: TokenStream) -> TokenStream { { let body = include_bytes!(#abs_filename); - self.head().map(move |head| + Box::new(self.head().map(move |head| head .with_header(::hyper::header::ContentLength(body.len() as u64)) .with_body(body as &'static [u8]) - ).boxed() + )) } fn put(self: Box, _body: ::hyper::Body) -> ::futures::BoxFuture<::hyper::server::Response, Box<::std::error::Error + Send + Sync>> { - ::futures::finished(self.method_not_allowed()).boxed() + Box::new(::futures::finished(self.method_not_allowed())) } } diff --git a/src/article_resource.rs b/src/article_resource.rs index 7e0d676..96de4b6 100644 --- a/src/article_resource.rs +++ b/src/article_resource.rs @@ -70,10 +70,10 @@ impl Resource for ArticleResource { } fn head(&self) -> futures::BoxFuture> { - futures::finished(Response::new() + Box::new(futures::finished(Response::new() .with_status(hyper::StatusCode::Ok) .with_header(ContentType(TEXT_HTML.clone())) - ).boxed() + )) } fn get(self: Box) -> futures::BoxFuture> { @@ -93,7 +93,7 @@ impl Resource for ArticleResource { script_js_checksum: &'a str, } - self.head().map(move |head| + Box::new(self.head().map(move |head| head .with_body(Layout { title: &self.data.title, @@ -108,7 +108,7 @@ impl Resource for ArticleResource { }, style_css_checksum: StyleCss::checksum(), }.to_string()) - ).boxed() + )) } fn put(self: Box, body: hyper::Body) -> @@ -132,7 +132,7 @@ impl Resource for ArticleResource { created: &'a str, } - body + Box::new(body .concat2() .map_err(Into::into) .and_then(|body| { @@ -153,6 +153,6 @@ impl Resource for ArticleResource { }).expect("Should never fail")) ) }) - .boxed() + ) } } diff --git a/src/site.rs b/src/site.rs index 845e3ff..4cac52b 100644 --- a/src/site.rs +++ b/src/site.rs @@ -77,21 +77,21 @@ impl Service for Site { let (method, uri, _http_version, _headers, body) = req.deconstruct(); println!("{} {}", method, uri); - self.root.lookup(uri.path(), uri.query(), None /*uri.fragment()*/) + Box::new(self.root.lookup(uri.path(), uri.query(), None /*uri.fragment()*/) .and_then(move |resource| match resource { Some(resource) => { use hyper::Method::*; match method { - Options => futures::finished(resource.options()).boxed(), + Options => Box::new(futures::finished(resource.options())), Head => resource.head(), Get => resource.get(), Put => resource.put(body), - _ => futures::finished(resource.method_not_allowed()).boxed() + _ => Box::new(futures::finished(resource.method_not_allowed())) } }, - None => futures::finished(Self::not_found()).boxed() + None => Box::new(futures::finished(Self::not_found())) }) .or_else(|err| Ok(Self::internal_server_error(err))) - .boxed() + ) } } diff --git a/src/wiki_lookup.rs b/src/wiki_lookup.rs index 4a2b766..5bbfc88 100644 --- a/src/wiki_lookup.rs +++ b/src/wiki_lookup.rs @@ -55,9 +55,9 @@ impl Lookup for WikiLookup { if path.starts_with("/_") { // Reserved namespace - return futures::finished( + return Box::new(futures::finished( LOOKUP_MAP.get(path).map(|x| x()) - ).boxed(); + )); } let mut split = path[1..].split('/'); @@ -66,18 +66,18 @@ impl Lookup for WikiLookup { if split.next() != None { // Currently disallow any URLs of the form /slug/... - return futures::finished(None).boxed(); + return Box::new(futures::finished(None)); } if let Ok(article_id) = slug.parse() { let state = self.state.clone(); - self.state.get_article_revision_by_id(article_id) + Box::new(self.state.get_article_revision_by_id(article_id) .and_then(|x| Ok(x.map(move |article| Box::new(ArticleResource::new(state, article)) as Box ))) - .boxed() + ) } else { - futures::finished(None).boxed() + Box::new(futures::finished(None)) } } }