Skip to content

Commit 1d8cf45

Browse files
committed
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 rust-lang/futures-rs#228
1 parent 646be05 commit 1d8cf45

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/cache/disk.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use cache::{
1818
CacheWrite,
1919
Storage,
2020
};
21-
use futures::Future;
2221
use futures_cpupool::CpuPool;
2322
use lru_disk_cache::LruDiskCache;
2423
use lru_disk_cache::Error as LruError;
@@ -62,7 +61,7 @@ impl Storage for DiskCache {
6261
let path = make_key_path(key);
6362
let lru = self.lru.clone();
6463
let key = key.to_owned();
65-
self.pool.spawn_fn(move || {
64+
Box::new(self.pool.spawn_fn(move || {
6665
let mut lru = lru.lock().unwrap();
6766
let f = match lru.get(&path) {
6867
Ok(f) => f,
@@ -78,7 +77,7 @@ impl Storage for DiskCache {
7877
};
7978
let hit = CacheRead::from(f)?;
8079
Ok(Cache::Hit(hit))
81-
}).boxed()
80+
}))
8281
}
8382

8483
fn put(&self, key: &str, entry: CacheWrite) -> SFuture<Duration> {
@@ -87,12 +86,12 @@ impl Storage for DiskCache {
8786
trace!("DiskCache::finish_put({})", key);
8887
let lru = self.lru.clone();
8988
let key = make_key_path(key);
90-
self.pool.spawn_fn(move || {
89+
Box::new(self.pool.spawn_fn(move || {
9190
let start = Instant::now();
9291
let v = entry.finish()?;
9392
lru.lock().unwrap().insert_bytes(key, &v)?;
9493
Ok(start.elapsed())
95-
}).boxed()
94+
}))
9695
}
9796

9897
fn location(&self) -> String {

src/mock_command.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ impl CommandChild for MockChild {
357357
fn take_stderr(&mut self) -> Option<io::Cursor<Vec<u8>>> { self.stderr.take() }
358358

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

363363

@@ -370,7 +370,7 @@ impl CommandChild for MockChild {
370370
stderr: stderr.map(|c| c.into_inner()).unwrap_or(vec!()),
371371
})
372372
});
373-
future::result(result).boxed()
373+
Box::new(future::result(result))
374374
}
375375
}
376376

src/simples3/credential.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub struct EnvironmentProvider;
8787

8888
impl ProvideAwsCredentials for EnvironmentProvider {
8989
fn credentials(&self) -> SFuture<AwsCredentials> {
90-
future::result(credentials_from_environment()).boxed()
90+
Box::new(future::result(credentials_from_environment()))
9191
}
9292
}
9393

@@ -189,7 +189,7 @@ impl ProvideAwsCredentials for ProfileProvider {
189189
let result = result.and_then(|mut profiles| {
190190
profiles.remove(self.profile()).ok_or("profile not found".into())
191191
});
192-
future::result(result).boxed()
192+
Box::new(future::result(result))
193193
}
194194
}
195195

0 commit comments

Comments
 (0)