clippy fixups

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2022-01-07 12:17:52 +01:00
parent 8261331958
commit cff598eb29
2 changed files with 4 additions and 6 deletions

View File

@ -14,11 +14,10 @@ pub const fn capacity<T: Sized>() -> usize {
pub fn buffer<T: Sized>() -> Vec<u8> {
let capacity = capacity::<T>();
let mut buf = Vec::with_capacity(capacity);
unsafe {
buf.set_len(capacity);
let data = std::alloc::alloc(std::alloc::Layout::array::<u8>(capacity).unwrap());
Vec::from_raw_parts(data as *mut u8, capacity, capacity)
}
buf
}
pub struct RawCmsgIterator<'a> {

View File

@ -54,9 +54,8 @@ pub mod vec {
/// This is generally safe to call, but the contents of the vector are undefined.
#[inline]
pub unsafe fn uninitialized(len: usize) -> Vec<u8> {
let mut out = Vec::with_capacity(len);
out.set_len(len);
out
let data = std::alloc::alloc(std::alloc::Layout::array::<u8>(len).unwrap());
Vec::from_raw_parts(data as *mut u8, len, len)
}
}