File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -885,6 +885,7 @@ impl<A: Array> Extend<A::Item> for ArrayVec<A> {
885
885
unsafe {
886
886
let len = self . len ( ) ;
887
887
let mut ptr = self . as_mut_ptr ( ) . offset ( len as isize ) ;
888
+ let end_ptr = ptr. offset ( take as isize ) ;
888
889
// Keep the length in a separate variable, write it back on scope
889
890
// exit. To help the compiler with alias analysis and stuff.
890
891
// We update the length to handle panic in the iteration of the
@@ -896,10 +897,16 @@ impl<A: Array> Extend<A::Item> for ArrayVec<A> {
896
897
* * self_len = Index :: from ( len) ;
897
898
}
898
899
} ;
899
- for elt in iter. into_iter ( ) . take ( take) {
900
- ptr:: write ( ptr, elt) ;
901
- ptr = ptr. offset ( 1 ) ;
902
- guard. data += 1 ;
900
+ let mut iter = iter. into_iter ( ) ;
901
+ loop {
902
+ if ptr == end_ptr { break ; }
903
+ if let Some ( elt) = iter. next ( ) {
904
+ ptr:: write ( ptr, elt) ;
905
+ ptr = ptr. offset ( 1 ) ;
906
+ guard. data += 1 ;
907
+ } else {
908
+ break ;
909
+ }
903
910
}
904
911
}
905
912
}
You can’t perform that action at this time.
0 commit comments