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 extend_with_slice_fn(b: &mut Bencher) {
let data = [1; 512];
b.iter(|| {
v.clear();
black_box(v.extend_from_slice(&data));
black_box(v.try_extend_from_slice(&data));
v[0]
});
b.bytes = v.capacity() as u64;