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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
use crateCoro;
use crateSuspended;
use crateSuspendedVisitor;
/// A stand-in for the 'never' type `!`, which can be used as the `Next` type
/// for a coroutine that will never yield again.
///
/// This type cannot be instantiated, so it is impossible to `Yield` from a
/// coroutine whose `Next` type is `Void`. Likewise, it is impossible to
/// `Return` from a coroutine whose return type is `Void` and it is impossible
/// to `Yield` from a coroutine whose yield type is `Void`.
///
/// It is useful to mark coroutines that never return as having a return type of
/// `Void`, and coroutines that never yield as having a yield type of `Void`.
///
/// ```rust
/// use cocoro::Coro;
/// use cocoro::Void;
/// use cocoro::from_fn;
/// use cocoro::just_return;
/// use cocoro::just_yield;
///
/// #[derive(Clone, Copy)]
/// struct Foo;
///
/// // A coroutine that never yields.
/// fn never_yield() -> impl Coro<(), Void, Foo> {
/// just_return(Foo)
/// }
///
/// // A coroutine that never returns.
/// fn never_return() -> impl Coro<(), Foo, Void> {
/// just_yield(Foo)
/// }
///
/// // A coroutine that can never be resumed.
/// fn never_resume() -> impl Coro<Void, (), ()> {
/// // The input type to the closure is `Void`, so it can never be called.
/// // Because `Void` implements `Suspended`, it can be used as the result
/// // of the closure to meet the requirements of `from_fn()`.
/// from_fn(|void| void)
/// }
/// ```