use nunny::Vec as NonEmpty;
use tokio::task::JoinSet;
pub async fn collect_errs<E: 'static>(
mut handles: JoinSet<Result<(), E>>,
) -> Result<(), NonEmpty<E>> {
let mut errors = Vec::new();
while let Some(result) = handles.join_next().await {
if let Ok(Err(e)) = result {
errors.push(e);
}
}
match errors.try_into() {
Ok(it) => Err(it),
Err(_) => Ok(()),
}
}