Skip to content
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

Merged
merged 1 commit into from
Mar 21, 2015

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Mar 19, 2015

because then the call to unwrap() will not print the error object.

@rust-highfive
Copy link
Collaborator

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) {
Copy link
Contributor Author

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()?

Copy link
Member

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.

@@ -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
Copy link
Contributor Author

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

@oli-obk oli-obk force-pushed the result_ok_unwrap branch 4 times, most recently from ee74f02 to da18d83 Compare March 19, 2015 16:00
@alexcrichton
Copy link
Member

Looks good to me, thanks! r=me with a squash and a nit

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 19, 2015

make check running, will squash once it's done

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 20, 2015

squashed and checked @alexcrichton

@alexcrichton
Copy link
Member

@bors: r+ b4a1e59

bors added a commit that referenced this pull request Mar 20, 2015
because then the call to `unwrap()` will not print the error object.
@bors
Copy link
Contributor

bors commented Mar 20, 2015

⌛ Testing commit b4a1e59 with merge e2fa53e...

@bors bors merged commit b4a1e59 into rust-lang:master Mar 21, 2015
@oli-obk oli-obk deleted the result_ok_unwrap branch March 23, 2015 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants