Skip to content

Commit

Permalink
Replace Future::boxed with Box::new.
Browse files Browse the repository at this point in the history
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 rust-lang/futures-rs#228
  • Loading branch information
rillian authored and luser committed Oct 11, 2017
1 parent 646be05 commit 48d9257
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions src/cache/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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<Duration> {
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/mock_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ impl CommandChild for MockChild {
fn take_stderr(&mut self) -> Option<io::Cursor<Vec<u8>>> { self.stderr.take() }

fn wait(mut self) -> Box<Future<Item = ExitStatus, Error = io::Error>> {
future::result(self.wait_result.take().unwrap()).boxed()
Box::new(future::result(self.wait_result.take().unwrap()))
}


Expand All @@ -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))
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/simples3/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub struct EnvironmentProvider;

impl ProvideAwsCredentials for EnvironmentProvider {
fn credentials(&self) -> SFuture<AwsCredentials> {
future::result(credentials_from_environment()).boxed()
Box::new(future::result(credentials_from_environment()))
}
}

Expand Down Expand Up @@ -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))
}
}

Expand Down

0 comments on commit 48d9257

Please sign in to comment.