File tree Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
5
5
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
- refs/heads/try2: b81f5c547c41571be3814ad4b2802f3305e12152
8
+ refs/heads/try2: 598072afa46d3c4fca7659c49ef3c9dc9f85787e
9
9
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
10
10
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
11
11
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Original file line number Diff line number Diff line change @@ -50,6 +50,12 @@ impl<T> Cell<T> {
50
50
this. value . take_unwrap ( )
51
51
}
52
52
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
+
53
59
/// Returns the value, failing if the cell is full.
54
60
pub fn put_back ( & self , value : T ) {
55
61
let this = unsafe { transmute_mut ( self ) } ;
Original file line number Diff line number Diff line change @@ -499,13 +499,14 @@ impl<T> GenericPort<T> for Port<T> {
499
499
}
500
500
501
501
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
507
509
}
508
- None => None
509
510
}
510
511
}
511
512
}
You can’t perform that action at this time.
0 commit comments