Discourage use of Option<Error> #102
Replies: 7 comments 1 reply
-
|
Beta Was this translation helpful? Give feedback.
-
I think partial failures need to use a custom type that also set |
Beta Was this translation helpful? Give feedback.
-
It would be nice to annotate the method itself if that were possible as |
Beta Was this translation helpful? Give feedback.
-
Unbeknownst to me, there was actually an RFC proposing the addition of @behnam What do you think of renaming this issue? I think it's less about "discourage |
Beta Was this translation helpful? Give feedback.
-
Oh, I didn't realize that the function/method must-use has got a new RFC! That's great! Sure, @BurntSushi! With this RFC, the focus of this matter shifts towards "remember to must-use if returning any failure status with a type that's not must-use", for me. I don't have much clue on what a good API for "partial success/failure" would be. Here's another example that kept me busy today: |
Beta Was this translation helpful? Give feedback.
-
I can't actually think of an example of an API that returns |
Beta Was this translation helpful? Give feedback.
-
@KodrAus It's not an either-or thing. Of course, if But this is somewhat of a niche use case. Maybe the right thing to do here is to say that folks "should use Stepping back a bit, it seems a little weird to even suggest this at all. I haven't really seen folks use |
Beta Was this translation helpful? Give feedback.
-
I'm seeing
Option<Error>
function return types, which are actually something very hard to handle using Rust's core/std libs. Basically, there's no one method to do expect-to-be-None.Also, IIUC, means that
?
cannot be used on it.And, there's no single method to convert it to
Result<(), Error>
to handle.So, maybe we can have a guideline for how to use
Option
vsResult
and discourage use ofOption<Error>
?Beta Was this translation helpful? Give feedback.
All reactions