@@ -10,23 +10,21 @@ pub use crate::{
10
10
async_stream:: AsyncStream ,
11
11
} ;
12
12
13
- use proc_macro_hack:: proc_macro_hack;
14
-
15
- #[ doc( hidden) ]
16
- #[ proc_macro_hack]
17
- pub use async_stream_impl:: async_stream_impl;
18
-
19
13
#[ doc( hidden) ]
20
- #[ proc_macro_hack]
21
- pub use async_stream_impl:: async_try_stream_impl;
14
+ pub use async_stream_impl:: { AsyncStreamHack , AsyncTryStreamHack } ;
22
15
23
16
/// Asynchronous stream
24
17
#[ macro_export]
25
18
macro_rules! stream {
26
19
( $( $body: tt) * ) => { {
27
20
let ( mut __yield_tx, __yield_rx) = $crate:: yielder:: pair( ) ;
28
21
$crate:: AsyncStream :: new( __yield_rx, async move {
29
- $crate:: async_stream_impl!( __yield_tx, $( $body) * )
22
+ #[ derive( $crate:: AsyncStreamHack ) ]
23
+ enum Dummy {
24
+ Value = $crate:: scrub! { $( $body) * }
25
+ }
26
+
27
+ $crate:: dispatch!( ( $( $body) * ) )
30
28
} )
31
29
} }
32
30
}
@@ -37,7 +35,115 @@ macro_rules! try_stream {
37
35
( $( $body: tt) * ) => { {
38
36
let ( mut __yield_tx, __yield_rx) = $crate:: yielder:: pair( ) ;
39
37
$crate:: AsyncStream :: new( __yield_rx, async move {
40
- $crate:: async_try_stream_impl!( __yield_tx, $( $body) * )
38
+ #[ derive( $crate:: AsyncTryStreamHack ) ]
39
+ enum Dummy {
40
+ Value = $crate:: scrub! { $( $body) * }
41
+ }
42
+
43
+ $crate:: dispatch!( ( $( $body) * ) )
41
44
} )
42
45
} }
43
46
}
47
+
48
+ #[ macro_export]
49
+ macro_rules! scrub {
50
+ ( $( $body: tt) * ) => { {
51
+ 0
52
+ } } ;
53
+ }
54
+
55
+ #[ doc( hidden) ]
56
+ #[ macro_export]
57
+ macro_rules! dispatch {
58
+ ( ( ) $( $bang: tt) * ) => {
59
+ $crate:: count!( $( $bang) * )
60
+ } ;
61
+ ( ( ( $( $first: tt) * ) $( $rest: tt) * ) $( $bang: tt) * ) => {
62
+ $crate:: dispatch!( ( $( $first) * $( $rest) * ) $( $bang) * )
63
+ } ;
64
+ ( ( [ $( $first: tt) * ] $( $rest: tt) * ) $( $bang: tt) * ) => {
65
+ $crate:: dispatch!( ( $( $first) * $( $rest) * ) $( $bang) * )
66
+ } ;
67
+ ( ( { $( $first: tt) * } $( $rest: tt) * ) $( $bang: tt) * ) => {
68
+ $crate:: dispatch!( ( $( $first) * $( $rest) * ) $( $bang) * )
69
+ } ;
70
+ ( ( ! $( $rest: tt) * ) $( $bang: tt) * ) => {
71
+ $crate:: dispatch!( ( $( $rest) * ) $( $bang) * !)
72
+ } ;
73
+ ( ( != $( $rest: tt) * ) $( $bang: tt) * ) => {
74
+ $crate:: dispatch!( ( $( $rest) * ) $( $bang) * !)
75
+ } ;
76
+ ( ( $first: tt $( $rest: tt) * ) $( $bang: tt) * ) => {
77
+ $crate:: dispatch!( ( $( $rest) * ) $( $bang) * )
78
+ } ;
79
+ }
80
+
81
+ #[ doc( hidden) ]
82
+ #[ macro_export]
83
+ macro_rules! count {
84
+ ( ) => { stream_0!( ) } ;
85
+ ( !) => { stream_1!( ) } ;
86
+ ( !!) => { stream_2!( ) } ;
87
+ ( !!!) => { stream_3!( ) } ;
88
+ ( !!!!) => { stream_4!( ) } ;
89
+ ( !!!!!) => { stream_5!( ) } ;
90
+ ( !!!!!!) => { stream_6!( ) } ;
91
+ ( !!!!!!!) => { stream_7!( ) } ;
92
+ ( !!!!!!!!) => { stream_8!( ) } ;
93
+ ( !!!!!!!!!) => { stream_9!( ) } ;
94
+ ( !!!!!!!!!!) => { stream_10!( ) } ;
95
+ ( !!!!!!!!!!!) => { stream_11!( ) } ;
96
+ ( !!!!!!!!!!!!) => { stream_12!( ) } ;
97
+ ( !!!!!!!!!!!!!) => { stream_13!( ) } ;
98
+ ( !!!!!!!!!!!!!!) => { stream_14!( ) } ;
99
+ ( !!!!!!!!!!!!!!!) => { stream_15!( ) } ;
100
+ ( !!!!!!!!!!!!!!!!) => { stream_16!( ) } ;
101
+ ( !!!!!!!!!!!!!!!!!) => { stream_17!( ) } ;
102
+ ( !!!!!!!!!!!!!!!!!!) => { stream_18!( ) } ;
103
+ ( !!!!!!!!!!!!!!!!!!!) => { stream_19!( ) } ;
104
+ ( !!!!!!!!!!!!!!!!!!!!) => { stream_20!( ) } ;
105
+ ( !!!!!!!!!!!!!!!!!!!!!) => { stream_21!( ) } ;
106
+ ( !!!!!!!!!!!!!!!!!!!!!!) => { stream_22!( ) } ;
107
+ ( !!!!!!!!!!!!!!!!!!!!!!!) => { stream_23!( ) } ;
108
+ ( !!!!!!!!!!!!!!!!!!!!!!!!) => { stream_24!( ) } ;
109
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_25!( ) } ;
110
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_26!( ) } ;
111
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_27!( ) } ;
112
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_28!( ) } ;
113
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_29!( ) } ;
114
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_30!( ) } ;
115
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_31!( ) } ;
116
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_32!( ) } ;
117
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_33!( ) } ;
118
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_34!( ) } ;
119
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_35!( ) } ;
120
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_36!( ) } ;
121
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_37!( ) } ;
122
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_38!( ) } ;
123
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_39!( ) } ;
124
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_40!( ) } ;
125
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_41!( ) } ;
126
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_42!( ) } ;
127
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_43!( ) } ;
128
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_44!( ) } ;
129
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_45!( ) } ;
130
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_46!( ) } ;
131
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_47!( ) } ;
132
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_48!( ) } ;
133
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_49!( ) } ;
134
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_50!( ) } ;
135
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_51!( ) } ;
136
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_52!( ) } ;
137
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_53!( ) } ;
138
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_54!( ) } ;
139
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_55!( ) } ;
140
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_56!( ) } ;
141
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_57!( ) } ;
142
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_58!( ) } ;
143
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_59!( ) } ;
144
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_60!( ) } ;
145
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_61!( ) } ;
146
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_62!( ) } ;
147
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_63!( ) } ;
148
+ ( !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) => { stream_64!( ) } ;
149
+ }
0 commit comments