File tree Expand file tree Collapse file tree 2 files changed +24
-24
lines changed Expand file tree Collapse file tree 2 files changed +24
-24
lines changed Original file line number Diff line number Diff line change @@ -303,6 +303,30 @@ fn cell_into_inner() {
303303 assert_eq ! ( "Hello world" . to_owned( ) , cell. into_inner( ) ) ;
304304}
305305
306+ #[ test]
307+ fn cell_exterior ( ) {
308+ #[ derive( Copy , Clone ) ]
309+ #[ allow( dead_code) ]
310+ struct Point {
311+ x : isize ,
312+ y : isize ,
313+ z : isize ,
314+ }
315+
316+ fn f ( p : & Cell < Point > ) {
317+ assert_eq ! ( p. get( ) . z, 12 ) ;
318+ p. set ( Point { x : 10 , y : 11 , z : 13 } ) ;
319+ assert_eq ! ( p. get( ) . z, 13 ) ;
320+ }
321+
322+ let a = Point { x : 10 , y : 11 , z : 12 } ;
323+ let b = & Cell :: new ( a) ;
324+ assert_eq ! ( b. get( ) . z, 12 ) ;
325+ f ( b) ;
326+ assert_eq ! ( a. z, 12 ) ;
327+ assert_eq ! ( b. get( ) . z, 13 ) ;
328+ }
329+
306330#[ test]
307331fn refcell_default ( ) {
308332 let cell: RefCell < u64 > = Default :: default ( ) ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments