Skip to content

Commit 3a32d84

Browse files
committed
---
yaml --- r: 144309 b: refs/heads/try2 c: 598072a h: refs/heads/master i: 144307: 6b64e7a v: v3
1 parent cdc4921 commit 3a32d84

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: b81f5c547c41571be3814ad4b2802f3305e12152
8+
refs/heads/try2: 598072afa46d3c4fca7659c49ef3c9dc9f85787e
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/cell.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ impl<T> Cell<T> {
5050
this.value.take_unwrap()
5151
}
5252

53+
/// Yields the value if the cell is full, or `None` if it is empty.
54+
pub fn take_opt(&self) -> Option<T> {
55+
let this = unsafe { transmute_mut(self) };
56+
this.value.take()
57+
}
58+
5359
/// Returns the value, failing if the cell is full.
5460
pub fn put_back(&self, value: T) {
5561
let this = unsafe { transmute_mut(self) };

branches/try2/src/libstd/rt/comm.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -499,13 +499,14 @@ impl<T> GenericPort<T> for Port<T> {
499499
}
500500

501501
fn try_recv(&self) -> Option<T> {
502-
let pone = self.next.take();
503-
match pone.try_recv() {
504-
Some(StreamPayload { val, next }) => {
505-
self.next.put_back(next);
506-
Some(val)
502+
do self.next.take_opt().map_move_default(None) |pone| {
503+
match pone.try_recv() {
504+
Some(StreamPayload { val, next }) => {
505+
self.next.put_back(next);
506+
Some(val)
507+
}
508+
None => None
507509
}
508-
None => None
509510
}
510511
}
511512
}

0 commit comments

Comments
 (0)