-
Notifications
You must be signed in to change notification settings - Fork 13k
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
don't use Result::ok just to be able to use unwrap/unwrap_or #23512
Conversation
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
@@ -591,8 +591,10 @@ impl<T: Send> Sender<T> { | |||
// This send cannot panic because the thread is | |||
// asleep (we're looking at it), so the receiver | |||
// can't go away. | |||
(*a.get()).send(t).ok().unwrap(); | |||
token.signal(); | |||
if let Err(_) = (*a.get()).send(t) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is really ugly, but it represents the comment more.
maybe I should just leave the ok().unwrap()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'd just leave this as it was.
65cf919
to
c1c786d
Compare
@@ -12,7 +12,7 @@ use std::thread; | |||
|
|||
pub fn main() { | |||
let t = thread::spawn(move|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); | |||
t.join().ok().unwrap(); | |||
t.join().ok().unwrap(); // forget Err value, since it doesn't implement Debug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
join()
returns a Result<T, Box<Any + Send + 'static>>
there are lots of other cases where the result is ignored since Debug
cannot be implemented generically to return "thread panicked" on Err
ee74f02
to
da18d83
Compare
Looks good to me, thanks! r=me with a squash and a nit |
make check running, will squash once it's done |
05fc098
to
b4a1e59
Compare
squashed and checked @alexcrichton |
because then the call to `unwrap()` will not print the error object.
because then the call to
unwrap()
will not print the error object.