@@ -32,23 +32,22 @@ pub trait StreamExt: Stream {
32
32
///
33
33
/// # Example
34
34
///
35
- /// ```
35
+ /// ```no_run
36
36
/// use futures_lite::prelude::*;
37
- /// use futures_time::prelude::*;
38
- /// use futures_time::time::{Instant, Duration};
39
- /// use futures_time::stream;
40
- ///
41
- /// fn main() {
42
- /// async_io::block_on(async {
43
- /// let mut counter = 0;
44
- /// stream::interval(Duration::from_millis(100))
45
- /// .take(4)
46
- /// .sample(Duration::from_millis(200))
47
- /// .for_each(|_| counter += 1)
48
- /// .await;
49
- ///
50
- /// assert_eq!(counter, 2);
51
- /// })
37
+ /// use wstd::prelude::*;
38
+ /// use wstd::time::{Instant, Duration};
39
+ /// use wstd::stream;
40
+ ///
41
+ /// #[wstd::main]
42
+ /// async fn main() {
43
+ /// let mut counter = 0;
44
+ /// stream::interval(Duration::from_millis(100))
45
+ /// .take(4)
46
+ /// .sample(Duration::from_millis(200))
47
+ /// .for_each(|_| counter += 1)
48
+ /// .await;
49
+ ///
50
+ /// assert_eq!(counter, 2);
52
51
/// }
53
52
/// ```
54
53
fn sample < I > ( self , interval : I ) -> Sample < Self , I :: IntoStream >
@@ -73,23 +72,22 @@ pub trait StreamExt: Stream {
73
72
///
74
73
/// # Example
75
74
///
76
- /// ```
75
+ /// ```no_run
77
76
/// use futures_lite::prelude::*;
78
- /// use futures_time::prelude::*;
79
- /// use futures_time::time::{Instant, Duration};
80
- /// use futures_time::stream;
81
- ///
82
- /// fn main() {
83
- /// async_io::block_on(async {
84
- /// let mut counter = 0;
85
- /// stream::interval(Duration::from_millis(5))
86
- /// .take(10)
87
- /// .buffer(Duration::from_millis(20))
88
- /// .for_each(|buf| counter += buf.len())
89
- /// .await;
90
- ///
91
- /// assert_eq!(counter, 10);
92
- /// })
77
+ /// use wstd::prelude::*;
78
+ /// use wstd::time::{Instant, Duration};
79
+ /// use wstd::stream;
80
+ ///
81
+ /// #[wstd::main]
82
+ /// async fn main() {
83
+ /// let mut counter = 0;
84
+ /// stream::interval(Duration::from_millis(5))
85
+ /// .take(10)
86
+ /// .buffer(Duration::from_millis(20))
87
+ /// .for_each(|buf| counter += buf.len())
88
+ /// .await;
89
+ ///
90
+ /// assert_eq!(counter, 10);
93
91
/// }
94
92
/// ```
95
93
fn buffer < I > ( self , interval : I ) -> Buffer < Self , I :: IntoStream >
@@ -119,23 +117,22 @@ pub trait StreamExt: Stream {
119
117
///
120
118
/// # Example
121
119
///
122
- /// ```
120
+ /// ```no_run
123
121
/// use futures_lite::prelude::*;
124
- /// use futures_time::prelude::*;
125
- /// use futures_time::time::{Instant, Duration};
126
- /// use futures_time::stream;
127
- ///
128
- /// fn main() {
129
- /// async_io::block_on(async {
130
- /// let mut counter = 0;
131
- /// stream::interval(Duration::from_millis(10))
132
- /// .take(10)
133
- /// .debounce(Duration::from_millis(20)) // the window is greater than the interval
134
- /// .for_each(|_| counter += 1)
135
- /// .await;
136
- ///
137
- /// assert_eq!(counter, 1); // so only the last item is received
138
- /// })
122
+ /// use wstd::prelude::*;
123
+ /// use wstd::time::{Instant, Duration};
124
+ /// use wstd::stream;
125
+ ///
126
+ /// #[wstd::main]
127
+ /// async fn main() {
128
+ /// let mut counter = 0;
129
+ /// stream::interval(Duration::from_millis(10))
130
+ /// .take(10)
131
+ /// .debounce(Duration::from_millis(20)) // the window is greater than the interval
132
+ /// .for_each(|_| counter += 1)
133
+ /// .await;
134
+ ///
135
+ /// assert_eq!(counter, 1); // so only the last item is received
139
136
/// }
140
137
/// ```
141
138
fn debounce < D > ( self , window : D ) -> Debounce < Self , D :: IntoFuture >
@@ -156,19 +153,18 @@ pub trait StreamExt: Stream {
156
153
///
157
154
/// # Example
158
155
///
159
- /// ```
156
+ /// ```no_run
160
157
/// use futures_lite::prelude::*;
161
- /// use futures_time::prelude::*;
162
- /// use futures_time::time::{Instant, Duration};
163
- /// use futures_lite::stream;
164
- ///
165
- /// fn main() {
166
- /// async_io::block_on(async {
167
- /// let now = Instant::now();
168
- /// let delay = Duration::from_millis(100);
169
- /// let _ = stream::once("meow").delay(delay).next().await;
170
- /// assert!(now.elapsed() >= *delay);
171
- /// });
158
+ /// use wstd::prelude::*;
159
+ /// use wstd::time::{Instant, Duration};
160
+ /// use wstd::stream;
161
+ ///
162
+ /// #[wstd::main]
163
+ /// async fn main() {
164
+ /// let now = Instant::now();
165
+ /// let delay = Duration::from_millis(100);
166
+ /// let _ = futures_lite::stream::once("meow").delay(delay).next().await;
167
+ /// assert!(now.elapsed() >= delay);
172
168
/// }
173
169
/// ```
174
170
fn delay < D > ( self , deadline : D ) -> Delay < Self , D :: IntoFuture >
@@ -214,23 +210,22 @@ pub trait StreamExt: Stream {
214
210
///
215
211
/// # Examples
216
212
///
217
- /// ```
213
+ /// ```no_run
218
214
/// use futures_lite::prelude::*;
219
- /// use futures_time::prelude::*;
220
- /// use futures_time::time::Duration;
221
- /// use futures_time::stream;
222
- ///
223
- /// fn main() {
224
- /// async_io::block_on(async {
225
- /// let mut counter = 0;
226
- /// stream::interval(Duration::from_millis(100)) // Yield an item every 100ms
227
- /// .take(4) // Stop after 4 items
228
- /// .throttle(Duration::from_millis(300)) // Only let an item through every 300ms
229
- /// .for_each(|_| counter += 1) // Increment a counter for each item
230
- /// .await;
231
- ///
232
- /// assert_eq!(counter, 2);
233
- /// })
215
+ /// use wstd::prelude::*;
216
+ /// use wstd::time::Duration;
217
+ /// use wstd::stream;
218
+ ///
219
+ /// #[wstd::main]
220
+ /// async fn main() {
221
+ /// let mut counter = 0;
222
+ /// stream::interval(Duration::from_millis(100)) // Yield an item every 100ms
223
+ /// .take(4) // Stop after 4 items
224
+ /// .throttle(Duration::from_millis(300)) // Only let an item through every 300ms
225
+ /// .for_each(|_| counter += 1) // Increment a counter for each item
226
+ /// .await;
227
+ ///
228
+ /// assert_eq!(counter, 2);
234
229
/// }
235
230
/// ```
236
231
fn throttle < I > ( self , interval : I ) -> Throttle < Self , I :: IntoStream >
@@ -254,29 +249,28 @@ pub trait StreamExt: Stream {
254
249
///
255
250
/// # Example
256
251
///
257
- /// ```
252
+ /// ```no_run
258
253
/// use futures_lite::prelude::*;
259
- /// use futures_time ::prelude::*;
260
- /// use futures_time ::time::{Instant, Duration};
261
- /// use futures_lite ::stream;
254
+ /// use wstd ::prelude::*;
255
+ /// use wstd ::time::{Instant, Duration};
256
+ /// use wstd ::stream;
262
257
/// use std::io;
263
258
///
264
- /// fn main() {
265
- /// async_io::block_on(async {
266
- /// let res = stream::once("meow")
267
- /// .delay(Duration::from_millis(100)) // longer delay
268
- /// .timeout(Duration::from_millis(50)) // shorter timeout
269
- /// .next()
270
- /// .await;
271
- /// assert_eq!(res.unwrap().unwrap_err().kind(), io::ErrorKind::TimedOut); // error
272
- ///
273
- /// let res = stream::once("meow")
274
- /// .delay(Duration::from_millis(50)) // shorter delay
275
- /// .timeout(Duration::from_millis(100)) // longer timeout
276
- /// .next()
277
- /// .await;
278
- /// assert_eq!(res.unwrap().unwrap(), "meow"); // success
279
- /// });
259
+ /// #[wstd::main]
260
+ /// async fn main() {
261
+ /// let res = futures_lite::stream::once("meow")
262
+ /// .delay(Duration::from_millis(100)) // longer delay
263
+ /// .timeout(Duration::from_millis(50)) // shorter timeout
264
+ /// .next()
265
+ /// .await;
266
+ /// assert_eq!(res.unwrap().unwrap_err().kind(), io::ErrorKind::TimedOut); // error
267
+ ///
268
+ /// let res = futures_lite::stream::once("meow")
269
+ /// .delay(Duration::from_millis(50)) // shorter delay
270
+ /// .timeout(Duration::from_millis(100)) // longer timeout
271
+ /// .next()
272
+ /// .await;
273
+ /// assert_eq!(res.unwrap().unwrap(), "meow"); // success
280
274
/// }
281
275
/// ```
282
276
fn timeout < D > ( self , deadline : D ) -> Timeout < Self , D :: IntoFuture >
0 commit comments