Hi,
Awesome. I have been waiting for this for a long time :D
On 04/02/2014 02:00, Alex Crichton wrote:
2. The new if_ok!() macro. This macro has a fairly simple definition
[0], and the idea is to return-early if an Err is encountered, and
otherwise unwrap the Ok value. Some sample usage looks like:
This opens the question how to compose errors or handle them if they are not
self contained. For instance think of an SSL library that wraps a socket. All
the sudden it has to return all the IO errors (as it's still doing IO) but it
also has to return additional SSL errors (like a failed handshake).
Right now that does not work for two reasons:
a) the IO interface is a trait, so you cannot change the signature.
b) there is no nice way to compose errors.
What's the general suggested solution for users for this?
I would love to see some sort of generic error trait that gives some basic
interface to extract information about an error (maybe have a way to get an
error identifier to test for and a human readable message).
Regards,
Armin
PS.: since we have if_ok! now may I propose also introducing something like
this?
macro_rules! try_unwrap {
($expr:expr, $err_result:expr) => (
match ($expr) {
Some(x) => x,
None => { return $err_result },
}
)
}
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev