Skip to content

Commit

Permalink
Merge pull request #186 from a1phyr/use_truncate_in_clone_from
Browse files Browse the repository at this point in the history
Use `truncate` in `clone_from`
  • Loading branch information
bluss committed May 29, 2021
2 parents 7b290b7 + 6be5ed4 commit dfceb6d
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/arrayvec.rs
Expand Up @@ -1079,9 +1079,7 @@ impl<T, const CAP: usize> Clone for ArrayVec<T, CAP>

if prefix < self.len() {
// rhs was shorter
for _ in 0..self.len() - prefix {
self.pop();
}
self.truncate(prefix);
} else {
let rhs_elems = &rhs[self.len()..];
self.extend_from_slice(rhs_elems);
Expand Down

0 comments on commit dfceb6d

Please sign in to comment.