-
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
replace uwraps with expect #5
Comments
In general, I don't think this is a good thing to do. I tend to think of |
Sadly the "it failed at line L in file F" looks like this:
So it actually doesn't tell you where you try to unwrap. If you have multiple unwraps within the same function, it actually is really hard to identify which one caused the failure. If you use |
I just do |
This won't tell you which one failed. Example: fn two(a: Option<u32>, b: Option<u32>) {
a.unwrap();
b.unwrap();
}
fn main() {
two(None, Some(1));
} You cannot tell from the stack-trace which one failed:
|
It should give you line numbers, in general. Maybe you need to use |
No, it doesn't; even if you run it with full:
|
Ah, this may be a flaw in Rust's OS X support. If you try this on Linux, I'm pretty sure you'll see line numbers. [Though I might be wrong!] |
The code has a lot of
.unwrap()
s, which should be replaced with.expect(...)
.E.g.:
Better:
The text was updated successfully, but these errors were encountered: