-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cancelling on Result Err #496
Comments
You're on the right track. let r: Result<Vec<_>, _> = collection.par_iter().map(fn_to_result).collect() This will collect the This reminds me, I should add
Well, |
Thanks, I wasn't aware of the type hint, but seems pretty obvious in hindsight. |
497: impl FromParallelIterator<()> for () r=cuviper a=cuviper This is more useful when combined with higher-level abstractions, like collecting to a `Result<(), E>` where you only care about errors. This is a parallel version of rust-lang/rust#45379. Cc #496 498: FromParallelIterator and ParallelExtend Cow for String r=cuviper a=cuviper Parallel version of rust-lang/rust#41449.
497: impl FromParallelIterator<()> for () r=cuviper a=cuviper This is more useful when combined with higher-level abstractions, like collecting to a `Result<(), E>` where you only care about errors. This is a parallel version of rust-lang/rust#45379. Cc #496
497: impl FromParallelIterator<()> for () r=cuviper a=cuviper This is more useful when combined with higher-level abstractions, like collecting to a `Result<(), E>` where you only care about errors. This is a parallel version of rust-lang/rust#45379. Cc #496
|
Hello, I'm doing fn main() -> anyhow::Result<()> {
0..123123
.into_par_iter()
.map(|num| {
/* something with lots of foo()? */
println!("Hi from {num}");
anyhow::Ok(())
})
.collect::<Result<Vec<_>, _>>()?
;
Ok(())
} And then running with What am I doing wrong please? Rayon 1.6.1. |
@YuriGeinishO the use std::io::{stdout, Write};
// ...
writeln!(stdout(), "Hi from {num}")?; |
Hi I have a function, which returns an Result<(), Error>. I want to early return on errors.
I saw in result.rs something, that uses while_some may be the right method here, although I don't know how to use that. I couldn't find something in the documentation.
Also a while_ok method would probably be nice.
The text was updated successfully, but these errors were encountered: