Skip to content

Commit 97d3162

Browse files
hkBstnagisa
authored andcommitted
replace manual Vec::with_capacity
1 parent 35b6a30 commit 97d3162

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

‎src/util.rs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ pub(crate) fn check_null_bytes(data: &[u8]) -> Result<bool, Error> {
2626
}
2727

2828
/// This function copies the slice into a vec and appends an element to its end.
29-
/// The vec is allocated with reserve_exact.
3029
pub(crate) fn copy_and_push<T: Copy>(data: &[T], to_push: T) -> alloc::vec::Vec<T> {
31-
let mut copy = alloc::vec::Vec::new();
32-
copy.reserve_exact(data.len() + 1);
30+
let mut copy = alloc::vec::Vec::with_capacity(data.len() + 1);
3331
copy.extend_from_slice(data);
3432
copy.push(to_push);
3533
copy

0 commit comments

Comments
 (0)