File tree 3 files changed +21
-19
lines changed
3 files changed +21
-19
lines changed Original file line number Diff line number Diff line change @@ -173,7 +173,7 @@ impl VisitMut for Scrub<'_> {
173
173
} ;
174
174
#label
175
175
loop {
176
- let #pat = match #crate_path:: reexport :: next( & mut __pinned) . await {
176
+ let #pat = match #crate_path:: __private :: next( & mut __pinned) . await {
177
177
:: core:: option:: Option :: Some ( e) => e,
178
178
:: core:: option:: Option :: None => break ,
179
179
} ;
@@ -227,8 +227,8 @@ pub fn stream_inner(input: TokenStream) -> TokenStream {
227
227
} ;
228
228
229
229
quote ! ( {
230
- let ( mut __yield_tx, __yield_rx) = #crate_path:: yielder:: pair( ) ;
231
- #crate_path:: AsyncStream :: new( __yield_rx, async move {
230
+ let ( mut __yield_tx, __yield_rx) = unsafe { #crate_path:: __private :: yielder:: pair( ) } ;
231
+ #crate_path:: __private :: AsyncStream :: new( __yield_rx, async move {
232
232
#dummy_yield
233
233
#( #stmts) *
234
234
} )
@@ -261,8 +261,8 @@ pub fn try_stream_inner(input: TokenStream) -> TokenStream {
261
261
} ;
262
262
263
263
quote ! ( {
264
- let ( mut __yield_tx, __yield_rx) = #crate_path:: yielder:: pair( ) ;
265
- #crate_path:: AsyncStream :: new( __yield_rx, async move {
264
+ let ( mut __yield_tx, __yield_rx) = unsafe { #crate_path:: __private :: yielder:: pair( ) } ;
265
+ #crate_path:: __private :: AsyncStream :: new( __yield_rx, async move {
266
266
#dummy_yield
267
267
#( #stmts) *
268
268
} )
Original file line number Diff line number Diff line change 158
158
159
159
mod async_stream;
160
160
mod next;
161
- #[ doc( hidden) ]
162
- pub mod yielder;
163
-
164
- // Used by the macro, but not intended to be accessed publicly.
165
- #[ doc( hidden) ]
166
- pub use crate :: async_stream:: AsyncStream ;
167
-
168
- #[ doc( hidden) ]
169
- pub use async_stream_impl;
161
+ mod yielder;
170
162
171
163
/// Asynchronous stream
172
164
///
@@ -198,7 +190,7 @@ pub use async_stream_impl;
198
190
#[ macro_export]
199
191
macro_rules! stream {
200
192
( $( $tt: tt) * ) => {
201
- $crate:: async_stream_impl :: stream_inner!( ( $crate) $( $tt) * )
193
+ $crate:: __private :: stream_inner!( ( $crate) $( $tt) * )
202
194
}
203
195
}
204
196
@@ -234,12 +226,17 @@ macro_rules! stream {
234
226
#[ macro_export]
235
227
macro_rules! try_stream {
236
228
( $( $tt: tt) * ) => {
237
- $crate:: async_stream_impl :: try_stream_inner!( ( $crate) $( $tt) * )
229
+ $crate:: __private :: try_stream_inner!( ( $crate) $( $tt) * )
238
230
}
239
231
}
240
232
233
+ // Not public API.
241
234
#[ doc( hidden) ]
242
- pub mod reexport {
243
- # [ doc ( hidden ) ]
235
+ pub mod __private {
236
+ pub use crate :: async_stream :: AsyncStream ;
244
237
pub use crate :: next:: next;
238
+ pub use async_stream_impl:: { stream_inner, try_stream_inner} ;
239
+ pub mod yielder {
240
+ pub use crate :: yielder:: pair;
241
+ }
245
242
}
Original file line number Diff line number Diff line change @@ -20,7 +20,12 @@ pub(crate) struct Enter<'a, T> {
20
20
prev : * mut ( ) ,
21
21
}
22
22
23
- pub fn pair < T > ( ) -> ( Sender < T > , Receiver < T > ) {
23
+ // Note: It is considered unsound for anyone other than our macros to call
24
+ // this function. This is a private API intended only for calls from our
25
+ // macros, and users should never call it, but some people tend to
26
+ // misinterpret it as fine to call unless it is marked unsafe.
27
+ #[ doc( hidden) ]
28
+ pub unsafe fn pair < T > ( ) -> ( Sender < T > , Receiver < T > ) {
24
29
let tx = Sender { _p : PhantomData } ;
25
30
let rx = Receiver { _p : PhantomData } ;
26
31
( tx, rx)
You can’t perform that action at this time.
0 commit comments