-
Notifications
You must be signed in to change notification settings - Fork 9
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
Extract errors #4
Comments
Hi Mathieu, that's good to hear! What is the code that you're trying to write? |
I was wondering if it was possible to write something like that if_chain! {
if let Ok(thing) = result_thing;
then { do stuff with thing; }
else(my_error) { do stuff with the Err(e) aliased to my_error }
} The most bothering thing about |
In that case, you can use a normal match: match result_thing {
Ok(thing) => ... ,
Err(my_error) => ... ,
} That won't work if there are multiple steps of pattern matching involved (what if_chain was designed for), but I don't think there's an easy way to handle the else in that case. |
That would somewhat defeat the purpose of using the |
You tell me ;) In this code snippet: let result_thing: Result<String, MyError>;
if_chain! {
if let Ok(thing) = result_thing;
if thing.len() > 2;
then { /* ... */ }
else(foo) { /* ... */ }
} What do you want the type of |
I think it would be |
Then what do we do when |
Hmm, I see what you mean, then I guess it's simply not possible to do so 🤔 |
Hey,
First of all, thanks for the amazing crate!
Is there any way to extract
Err(T)
in theelse
statement?Thanks,
Mathieu
The text was updated successfully, but these errors were encountered: