Closed
Description
Code:
pub fn skip_while<St, F, Fut>(stream: St, f: F) -> impl Stream<Item = St::Item>
where
St: Stream,
F: FnMut(&St::Item) -> Fut,
Fut: Future<Output = bool>,
{
let stream = Box::pin(stream);
let should_skip = true;
crate::stream::unfold(
(stream, f, should_skip),
|(mut stream, mut f, should_skip)| async move {
while should_skip {
if let Some(item) = next(&mut stream).await {
if f(&item).await {
continue;
} else {
return Some((item, (stream, f, /* should_skip */ false)));
}
} else {
return None;
}
}
if let Some(item) = next(&mut stream).await {
Some((item, (stream, f, /* should_skip */ false)))
} else {
None
}
},
)
}
Error:
error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop.
--> src/stream.rs:717:19
|
717 | while should_skip {
| ^^^^^^^^^^^
|