File tree Expand file tree Collapse file tree 3 files changed +6
-10
lines changed
branches/auto/src/libcollections Expand file tree Collapse file tree 3 files changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
8
8
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
9
9
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
10
10
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11
- refs/heads/auto: e9946f99b97fa1efda39b657448aae0238b66220
11
+ refs/heads/auto: 97f2a325644eb88b50fb5b52e09933535fa29c40
12
12
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
13
13
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
14
14
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1
Original file line number Diff line number Diff line change 62
62
#![ feature( unsafe_no_drop_flag, filling_drop) ]
63
63
#![ feature( decode_utf16) ]
64
64
#![ feature( utf8_error) ]
65
- #![ cfg_attr( test, feature( rand, test) ) ]
65
+ #![ cfg_attr( test, feature( clone_from_slice , rand, test) ) ]
66
66
67
67
#![ feature( no_std) ]
68
68
#![ no_std]
Original file line number Diff line number Diff line change @@ -1007,19 +1007,15 @@ impl<T:Clone> Clone for Vec<T> {
1007
1007
1008
1008
fn clone_from ( & mut self , other : & Vec < T > ) {
1009
1009
// drop anything in self that will not be overwritten
1010
- if self . len ( ) > other. len ( ) {
1011
- self . truncate ( other. len ( ) )
1012
- }
1010
+ self . truncate ( other. len ( ) ) ;
1011
+ let len = self . len ( ) ;
1013
1012
1014
1013
// reuse the contained values' allocations/resources.
1015
- for ( place, thing) in self . iter_mut ( ) . zip ( other) {
1016
- place. clone_from ( thing)
1017
- }
1014
+ self . clone_from_slice ( & other[ ..len] ) ;
1018
1015
1019
1016
// self.len <= other.len due to the truncate above, so the
1020
1017
// slice here is always in-bounds.
1021
- let slice = & other[ self . len ( ) ..] ;
1022
- self . push_all ( slice) ;
1018
+ self . push_all ( & other[ len..] ) ;
1023
1019
}
1024
1020
}
1025
1021
You can’t perform that action at this time.
0 commit comments