Fix Task::collect not producing the collected outputs
This commit is contained in:
parent
43033c7f83
commit
ad2e4c535a
1 changed files with 12 additions and 5 deletions
|
|
@ -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))))
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue