Fix Task::collect not producing the collected outputs

This commit is contained in:
Héctor Ramón Jiménez 2024-06-15 01:16:04 +02:00
parent 43033c7f83
commit ad2e4c535a
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -208,18 +208,25 @@ impl<T> Task<T> {
None => Task::done(Vec::new()),
Some(stream) => Task(Some(boxed_stream(
stream::unfold(
(stream, Vec::new()),
|(mut stream, mut outputs)| async move {
let action = stream.next().await?;
(stream, Some(Vec::new())),
move |(mut stream, outputs)| async move {
let mut outputs = outputs?;
let Some(action) = stream.next().await else {
return Some((
Some(Action::Output(outputs)),
(stream, None),
));
};
match action.output() {
Ok(output) => {
outputs.push(output);
Some((None, (stream, outputs)))
Some((None, (stream, Some(outputs))))
}
Err(action) => {
Some((Some(action), (stream, outputs)))
Some((Some(action), (stream, Some(outputs))))
}
}
},