FIX: Remake extend_from_slice to try_extend_from_slice

Do nothing and return an error, if the slice doesn't fit in the
remaining capacity.
This commit is contained in:
bluss
2018-11-28 15:59:11 +01:00
parent 8e5ff2d0fb
commit 47827e4843
3 changed files with 12 additions and 9 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ fn test_capacity_left() {
fn test_extend_from_slice() {
let mut vec: ArrayVec<[usize; 10]> = ArrayVec::new();
vec.extend_from_slice(&[1, 2, 3]);
vec.try_extend_from_slice(&[1, 2, 3]);
assert_eq!(vec.len(), 3);
assert_eq!(&vec[..], &[1, 2, 3]);
assert_eq!(vec.pop(), Some(3));