File tree 2 files changed +22
-0
lines changed
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 10
10
11
11
#![ feature( box_syntax) ]
12
12
#![ feature( cell_update) ]
13
+ #![ feature( copied) ]
13
14
#![ feature( core_private_bignum) ]
14
15
#![ feature( core_private_diy_float) ]
15
16
#![ feature( dec2flt) ]
Original file line number Diff line number Diff line change @@ -248,6 +248,27 @@ fn test_collect() {
248
248
assert ! ( v == None ) ;
249
249
}
250
250
251
+ #[ test]
252
+ fn test_copied ( ) {
253
+ let val = 1 ;
254
+ let val_ref = & val;
255
+ let opt_none: Option < & ' static u32 > = None ;
256
+ let opt_ref = Some ( & val) ;
257
+ let opt_ref_ref = Some ( & val_ref) ;
258
+
259
+ // None works
260
+ assert_eq ! ( opt_none. clone( ) , None ) ;
261
+ assert_eq ! ( opt_none. copied( ) , None ) ;
262
+
263
+ // Immutable ref works
264
+ assert_eq ! ( opt_ref. clone( ) , Some ( & val) ) ;
265
+ assert_eq ! ( opt_ref. copied( ) , Some ( 1 ) ) ;
266
+
267
+ // Double Immutable ref works
268
+ assert_eq ! ( opt_ref_ref. clone( ) , Some ( & val_ref) ) ;
269
+ assert_eq ! ( opt_ref_ref. clone( ) . copied( ) , Some ( & val) ) ;
270
+ assert_eq ! ( opt_ref_ref. copied( ) . copied( ) , Some ( 1 ) ) ;
271
+ }
251
272
252
273
#[ test]
253
274
fn test_cloned ( ) {
You can’t perform that action at this time.
0 commit comments