task: stabilise JoinMap (#7075)

This commit is contained in:
Conrad Ludgate
2025-08-03 07:58:28 +00:00
committed by GitHub
parent 9741c90f9f
commit 416e36b0df
5 changed files with 37 additions and 36 deletions
+5 -5
View File
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "rt", tokio_unstable))]
#![cfg(feature = "join-map")]
use std::panic::AssertUnwindSafe;
@@ -26,7 +26,7 @@ async fn test_with_sleep() {
map.detach_all();
assert_eq!(map.len(), 0);
assert!(matches!(map.join_next().await, None));
assert!(map.join_next().await.is_none());
for i in 0..10 {
map.spawn(i, async move {
@@ -45,7 +45,7 @@ async fn test_with_sleep() {
for was_seen in &seen {
assert!(was_seen);
}
assert!(matches!(map.join_next().await, None));
assert!(map.join_next().await.is_none());
// Do it again.
for i in 0..10 {
@@ -64,7 +64,7 @@ async fn test_with_sleep() {
for was_seen in &seen {
assert!(was_seen);
}
assert!(matches!(map.join_next().await, None));
assert!(map.join_next().await.is_none());
}
#[tokio::test]
@@ -250,7 +250,7 @@ async fn join_map_coop() {
loop {
match map.join_next().now_or_never() {
Some(Some((key, Ok(i)))) => assert_eq!(key, i),
Some(Some((key, Err(err)))) => panic!("failed[{}]: {}", key, err),
Some(Some((key, Err(err)))) => panic!("failed[{key}]: {err}"),
None => {
coop_count += 1;
tokio::task::yield_now().await;