1use crate::{Executor, ExecutorBlocking, JoinHandle};
2use std::future::Future;
3use std::rc::Rc;
4
5impl<E> Executor for Rc<E>
6where
7 E: Executor,
8{
9 fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
10 where
11 F: Future + Send + 'static,
12 F::Output: Send + 'static,
13 {
14 (**self).spawn(future)
15 }
16}
17
18impl<E> ExecutorBlocking for Rc<E> where E: ExecutorBlocking {
19 fn spawn_blocking<F, R>(&self, f: F) -> JoinHandle<R>
20 where
21 F: FnOnce() -> R + Send + 'static,
22 R: Send + 'static,
23 {
24 (**self).spawn_blocking(f)
25 }
26}