Created
March 11, 2022 09:07
-
-
Save akiradeveloper/da5d67833ea14eae18131c4f736664fd to your computer and use it in GitHub Desktop.
stream that includes panicking future
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[tokio::test(flavor = "multi_thread")] | |
async fn test_buffered_unordered() { | |
use futures::FutureExt; | |
let mut futs = vec![]; | |
futs.push(async move { 1 / 0 }.boxed()); | |
for i in 1..=10 { | |
futs.push(async move { i }.boxed()) | |
} | |
let stream = futures::stream::iter(futs); | |
let mut buffered = stream.buffer_unordered(100); | |
// My expection is only those completed in success are summed up | |
// ignoring the one that panicked. | |
let mut sum = 0; | |
while let Some(x) = buffered.next().await { | |
sum += x; | |
} | |
assert_eq!(sum, 55); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment