mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-08 00:00:24 +02:00
Use map_while (#1720)
This commit is contained in:
@@ -137,15 +137,12 @@ where
|
|||||||
{
|
{
|
||||||
let a = a.map(Some).chain(std::iter::repeat_with(|| None));
|
let a = a.map(Some).chain(std::iter::repeat_with(|| None));
|
||||||
let b = b.map(Some).chain(std::iter::repeat_with(|| None));
|
let b = b.map(Some).chain(std::iter::repeat_with(|| None));
|
||||||
a.zip(b)
|
a.zip(b).map_while(|(a, b)| match (a, b) {
|
||||||
// use `map_while` when its stable in our MSRV (1.57)
|
(Some(a), Some(b)) => Some(Item::Both(a, b)),
|
||||||
.take_while(|(a, b)| a.is_some() || b.is_some())
|
(Some(a), None) => Some(Item::First(a)),
|
||||||
.filter_map(|(a, b)| match (a, b) {
|
(None, Some(b)) => Some(Item::Second(b)),
|
||||||
(Some(a), Some(b)) => Some(Item::Both(a, b)),
|
(None, None) => None,
|
||||||
(Some(a), None) => Some(Item::First(a)),
|
})
|
||||||
(None, Some(b)) => Some(Item::Second(b)),
|
|
||||||
(None, None) => unreachable!("take_while removes these"),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
Reference in New Issue
Block a user