File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 0e3825d38cc459f9fcb24f1e95d4f6e867265300
2
+ refs/heads/master: 6d7b143036e1d61c8f58864db3445d2a0ae4ad11
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
5
5
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
Original file line number Diff line number Diff line change @@ -39,6 +39,13 @@ impl<T> Cell<T> {
39
39
fn is_empty ( ) -> bool {
40
40
self . value . is_none ( )
41
41
}
42
+
43
+ // Calls a closure with a reference to the value.
44
+ fn with_ref ( f : fn ( v : & T ) ) {
45
+ let val = move self . take ( ) ;
46
+ f ( & val) ;
47
+ self . put_back ( move val) ;
48
+ }
42
49
}
43
50
44
51
#[ test]
@@ -66,4 +73,4 @@ fn test_take_empty() {
66
73
fn test_put_back_non_empty ( ) {
67
74
let value_cell = Cell ( ~10 ) ;
68
75
value_cell. put_back ( ~20 ) ;
69
- }
76
+ }
You can’t perform that action at this time.
0 commit comments