diff options
| author | Ben Blum <bblum@andrew.cmu.edu> | 2013-08-21 18:43:50 -0400 |
|---|---|---|
| committer | Ben Blum <bblum@andrew.cmu.edu> | 2013-08-21 18:57:22 -0400 |
| commit | 598072afa46d3c4fca7659c49ef3c9dc9f85787e (patch) | |
| tree | f009a9d0492e66ddca9dd26923aba64ebdf21e43 /src/libstd/rt | |
| parent | b81f5c547c41571be3814ad4b2802f3305e12152 (diff) | |
| download | rust-598072afa46d3c4fca7659c49ef3c9dc9f85787e.tar.gz rust-598072afa46d3c4fca7659c49ef3c9dc9f85787e.zip | |
Don't fail in port.try_recv() the second time. Close #7800.
Diffstat (limited to 'src/libstd/rt')
| -rw-r--r-- | src/libstd/rt/comm.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/libstd/rt/comm.rs b/src/libstd/rt/comm.rs index 49cf8c239b7..c6b87d88979 100644 --- a/src/libstd/rt/comm.rs +++ b/src/libstd/rt/comm.rs @@ -499,13 +499,14 @@ impl<T> GenericPort<T> for Port<T> { } fn try_recv(&self) -> Option<T> { - let pone = self.next.take(); - match pone.try_recv() { - Some(StreamPayload { val, next }) => { - self.next.put_back(next); - Some(val) + do self.next.take_opt().map_move_default(None) |pone| { + match pone.try_recv() { + Some(StreamPayload { val, next }) => { + self.next.put_back(next); + Some(val) + } + None => None } - None => None } } } |
