Skip to content

Commit 4e6793d

Browse files
Merge pull request #1161 from tinaun/remove-boxedexec
remove BoxedExecutor
2 parents 1a83bba + f29c5f3 commit 4e6793d

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

futures-util/src/compat/executor.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,8 @@ use futures_core::task::Executor as Executor03;
66
use futures_core::task as task03;
77
use futures_core::future::FutureObj;
88

9-
pub struct BoxedExecutor03(Box<dyn Executor03 + Send>);
10-
11-
impl Executor03 for BoxedExecutor03 {
12-
fn spawn_obj(
13-
&mut self,
14-
future: FutureObj<'static, ()>,
15-
) -> Result<(), task03::SpawnObjError> {
16-
(&mut *self.0).spawn_obj(future)
17-
}
18-
}
19-
209
/// A future that can run on a futures 0.1 executor.
21-
pub type Executor01Future = Compat<UnitError<FutureObj<'static, ()>>, BoxedExecutor03>;
10+
pub type Executor01Future = Compat<UnitError<FutureObj<'static, ()>>, Box<dyn Executor03 + Send>>;
2211

2312
/// Extension trait for futures 0.1 Executors.
2413
pub trait Executor01CompatExt: Executor01<Executor01Future> +
@@ -53,7 +42,8 @@ where Ex: Executor01<Executor01Future>,
5342
&mut self,
5443
future: FutureObj<'static, ()>,
5544
) -> Result<(), task03::SpawnObjError> {
56-
let future = future.unit_error().compat(BoxedExecutor03(Box::new(self.clone())));
45+
let exec: Box<dyn Executor03 + Send> = Box::new(self.clone());
46+
let future = future.unit_error().compat(exec);
5747

5848
match self.executor01.execute(future) {
5949
Ok(()) => Ok(()),

0 commit comments

Comments
 (0)