From 48d925773f563b0fdbe8905684e5fbb37057c595 Mon Sep 17 00:00:00 2001 From: Ralph Giles Date: Tue, 10 Oct 2017 16:33:40 -0700 Subject: [PATCH] Replace Future::boxed with Box::new. In futures 0.1.15, the boxed() method on Future structs was deprecated. This returned a BoxFuture type which had to be declared either Send or 'static while wrapping a Future in Box::new() allows inference of the appropriate trait bounds. We already don't use the BoxFuture trait, so just call Box::new() directly instead to avoid the deprecation warning and make it easier to port to future releases. See also https://github.com/alexcrichton/futures-rs/issues/228 --- src/cache/disk.rs | 9 ++++----- src/mock_command.rs | 4 ++-- src/simples3/credential.rs | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/cache/disk.rs b/src/cache/disk.rs index b5ee2de3b..a71c68b51 100644 --- a/src/cache/disk.rs +++ b/src/cache/disk.rs @@ -18,7 +18,6 @@ use cache::{ CacheWrite, Storage, }; -use futures::Future; use futures_cpupool::CpuPool; use lru_disk_cache::LruDiskCache; use lru_disk_cache::Error as LruError; @@ -62,7 +61,7 @@ impl Storage for DiskCache { let path = make_key_path(key); let lru = self.lru.clone(); let key = key.to_owned(); - self.pool.spawn_fn(move || { + Box::new(self.pool.spawn_fn(move || { let mut lru = lru.lock().unwrap(); let f = match lru.get(&path) { Ok(f) => f, @@ -78,7 +77,7 @@ impl Storage for DiskCache { }; let hit = CacheRead::from(f)?; Ok(Cache::Hit(hit)) - }).boxed() + })) } fn put(&self, key: &str, entry: CacheWrite) -> SFuture { @@ -87,12 +86,12 @@ impl Storage for DiskCache { trace!("DiskCache::finish_put({})", key); let lru = self.lru.clone(); let key = make_key_path(key); - self.pool.spawn_fn(move || { + Box::new(self.pool.spawn_fn(move || { let start = Instant::now(); let v = entry.finish()?; lru.lock().unwrap().insert_bytes(key, &v)?; Ok(start.elapsed()) - }).boxed() + })) } fn location(&self) -> String { diff --git a/src/mock_command.rs b/src/mock_command.rs index a131594c5..9e898d235 100644 --- a/src/mock_command.rs +++ b/src/mock_command.rs @@ -357,7 +357,7 @@ impl CommandChild for MockChild { fn take_stderr(&mut self) -> Option>> { self.stderr.take() } fn wait(mut self) -> Box> { - future::result(self.wait_result.take().unwrap()).boxed() + Box::new(future::result(self.wait_result.take().unwrap())) } @@ -370,7 +370,7 @@ impl CommandChild for MockChild { stderr: stderr.map(|c| c.into_inner()).unwrap_or(vec!()), }) }); - future::result(result).boxed() + Box::new(future::result(result)) } } diff --git a/src/simples3/credential.rs b/src/simples3/credential.rs index d8e3c5f22..9aebb30a8 100644 --- a/src/simples3/credential.rs +++ b/src/simples3/credential.rs @@ -87,7 +87,7 @@ pub struct EnvironmentProvider; impl ProvideAwsCredentials for EnvironmentProvider { fn credentials(&self) -> SFuture { - future::result(credentials_from_environment()).boxed() + Box::new(future::result(credentials_from_environment())) } } @@ -189,7 +189,7 @@ impl ProvideAwsCredentials for ProfileProvider { let result = result.and_then(|mut profiles| { profiles.remove(self.profile()).ok_or("profile not found".into()) }); - future::result(result).boxed() + Box::new(future::result(result)) } }