File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -640,3 +640,23 @@ fn test_newish_stable_uses_maybe_uninit() {
640
640
assert ! ( cfg!( has_stable_maybe_uninit) ) ;
641
641
}
642
642
}
643
+
644
+ #[ test]
645
+ fn test_extend_zst ( ) {
646
+ let mut range = 0 ..10 ;
647
+ #[ derive( Copy , Clone , PartialEq , Debug ) ]
648
+ struct Z ; // Zero sized type
649
+
650
+ let mut array: ArrayVec < [ _ ; 5 ] > = range. by_ref ( ) . map ( |_| Z ) . collect ( ) ;
651
+ assert_eq ! ( & array[ ..] , & [ Z ; 5 ] ) ;
652
+ assert_eq ! ( range. next( ) , Some ( 5 ) ) ;
653
+
654
+ array. extend ( range. by_ref ( ) . map ( |_| Z ) ) ;
655
+ assert_eq ! ( range. next( ) , Some ( 6 ) ) ;
656
+
657
+ let mut array: ArrayVec < [ _ ; 10 ] > = ( 0 ..3 ) . map ( |_| Z ) . collect ( ) ;
658
+ assert_eq ! ( & array[ ..] , & [ Z ; 3 ] ) ;
659
+ array. extend ( ( 3 ..5 ) . map ( |_| Z ) ) ;
660
+ assert_eq ! ( & array[ ..] , & [ Z ; 5 ] ) ;
661
+ assert_eq ! ( array. len( ) , 5 ) ;
662
+ }
You can’t perform that action at this time.
0 commit comments