-
Notifications
You must be signed in to change notification settings - Fork 0
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
add expect_macro #3
Conversation
bors r= @killercup |
3: add expect_macro r=killercup a=vitiral This PR adds the `expect!` macro, which is an ergonomic replacement for `unwrap()`/`expect()`. The main advantages are: - Prints the line number/column of the failure with a better error message. - Can specify format parameters (The type of `expect` is `expect(&str)`, so you have to use `&format!(...)`) - Error conditions are lazily evaluated.
I don't think bors works like you think it works :) If you say |
well... you're right. I thought that was setting the reviewer I really did want you to take a look at this before I merged it. If you don't agree/etc I can back it out. |
Do I just assign a reviewer normally to assign a reviewer? I guess just mentioning you is probaly enough. or is it bors r? @killercup |
Just use the github ui, bors has no review request command |
okay, will do. Sorry I'm still getting used to this. I think I've seen What are your opinions of this macro? |
Ah, Regarding the expect_macro crate, it looks good! Not sure if it will be wildly used, though: RFC 2091 will, once implemented (cf. rust-lang/rust#47809), make line numbers in backtraces way more useful, and I'm unsure if the added formatting power is enough to make up for the "it's no longer a method call" weirdness. So, I totally see its usefulness but I don't feel like the pain is enough to make a lot of people look for a not-built-in solution. (I also just opened killercup/quicli#44 because I want to have quicli output useful back traces, but I this is for |
I was looking for that RFC, glad it was accepted! Ya, I think once that RFC is accepted this will be largely overshadowned. However, that probably won't happen for several months. Maybe that is reason enough to not include it in this library automatically. By the time this lib is stabilized, |
I think that is a good enough reason for me to not include it. I'll use it in my own projects, but there is no reason to add to the API when rust is about to just handle this. |
Reverting this in #4 |
This PR adds the
expect!
macro, which is an ergonomic replacement forunwrap()
/expect()
. The main advantages are:expect
isexpect(&str)
, so you have to use&format!(...)
)See the docs for expect_macro for more: http://docs.rs/expect_macro