1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use crateBox;
use ;
/// Asynchronous acceptor that returns a boxed trait-object future.
///
/// This trait is automatically implemented for every [`AsyncAccepts`](crate::AsyncAccepts) type when
/// the `alloc` feature is enabled. It is useful when the consumer needs to
/// store heterogeneous async acceptors behind trait objects.
///
/// ```rust
/// use accepts::{AsyncAccepts, DynAsyncAccepts};
/// use core::future::Future;
///
/// struct TaskRunner;
///
/// impl AsyncAccepts<String> for TaskRunner {
/// fn accept_async<'a>(&'a self, task: String) -> impl Future<Output = ()> + 'a
/// where
/// String: 'a,
/// {
/// async move {
/// println!("{}", task);
/// }
/// }
/// }
///
/// // DynAsyncAccepts is provided automatically when `alloc` is enabled.
/// let runner = TaskRunner;
/// let dyn_runner: &dyn DynAsyncAccepts<String> = &runner;
/// # let _ = dyn_runner;
/// ```