Skip to content

Commit 88cbf2c

Browse files
committed
Change throttle test to run in milliseconds
1 parent ef958f0 commit 88cbf2c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/stream/stream/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -319,23 +319,23 @@ extension_trait! {
319319
Limit the amount of items yielded per timeslice in a stream.
320320
321321
# Examples
322-
```ignore
322+
```
323323
# fn main() { async_std::task::block_on(async {
324324
#
325+
use async_std::prelude::*;
325326
use async_std::stream;
326327
use std::time::Duration;
327328
328329
// emit value every 1 second
329-
let s = stream::interval(Duration::from_nanos(1000000)).enumerate();
330+
let s = stream::interval(Duration::from_millis(5)).enumerate().take(3);
330331
331332
// throttle for 2 seconds
332-
let s = s.throttle(Duration::from_secs(2));
333+
let mut s = s.throttle(Duration::from_millis(10));
333334
334-
s.for_each(|(n, _)| {
335-
dbg!(n);
336-
})
337-
.await;
338-
// => 0 .. 1 .. 2 .. 3
335+
assert_eq!(s.next().await, Some((0, ())));
336+
assert_eq!(s.next().await, Some((1, ())));
337+
assert_eq!(s.next().await, Some((2, ())));
338+
assert_eq!(s.next().await, None);
339339
// with a pause of 2 seconds between each print
340340
#
341341
# }) }

0 commit comments

Comments
 (0)