This gets a bit more awkward if you need to decide where to put the Ok(...).
Overall I don’t think it is a huge improvement, and I probably wouldn’t add the dep and tag my functions to use it, but I see why it exists and it does make me wonder if a more implicit error handling syntax would make sense. (Maybe just implicitly converting the return value, but that could be surprising)
Whats the catch? (scnr)
Also I don’t get it. Is this just a complicated way of writing Result<x, y> that saves you from wrapping return values in Ok?
Honestly this is temping for me. I frequently write functions that look like
fn foo() -> Result<(), Error> { do_bar()?; do_baz()?; Ok(()) }
But that Ok at the bottom is a little annoying. IIUC this lets you do:
#[fehler::throws] fn foo() { do_bar()?; do_baz()?; }
Which is a bit tidier.
If the error types match you can do
fn foo() -> Result<(), Error> { do_bar()?; do_baz() }
But I find that a bit weird as it is asymmetrical for not much reason. And you lose the error conversion.
You also have complex examples where it gets a bit more awkward:
#[fehler::throws] fn foo() -> u32 { match is_cool()? { true => do_foo()? + 1 false => do_bar()? + 2 } }
This gets a bit more awkward if you need to decide where to put the
Ok(...)
.Overall I don’t think it is a huge improvement, and I probably wouldn’t add the dep and tag my functions to use it, but I see why it exists and it does make me wonder if a more implicit error handling syntax would make sense. (Maybe just implicitly converting the return value, but that could be surprising)