From 36e064d73af351a72893e9050a272e606a50e96b Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 29 Nov 2021 14:51:26 +0100 Subject: [PATCH] io: clippy fixes Signed-off-by: Wolfgang Bumiller --- proxmox-io/src/read.rs | 2 +- proxmox-io/src/vec/mod.rs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/proxmox-io/src/read.rs b/proxmox-io/src/read.rs index d24a32fd..062615b3 100644 --- a/proxmox-io/src/read.rs +++ b/proxmox-io/src/read.rs @@ -296,7 +296,7 @@ impl ReadExt for R { fn read_exact_or_eof(&mut self, mut buf: &mut [u8]) -> io::Result { let mut read_bytes = 0; loop { - match self.read(&mut buf) { + match self.read(buf) { Ok(0) => { if read_bytes == 0 { return Ok(false); diff --git a/proxmox-io/src/vec/mod.rs b/proxmox-io/src/vec/mod.rs index 730dbb3b..98dce291 100644 --- a/proxmox-io/src/vec/mod.rs +++ b/proxmox-io/src/vec/mod.rs @@ -52,9 +52,8 @@ pub use byte_vec::ByteVecExt; /// marked as unsafe for good measure. #[inline] pub unsafe fn uninitialized(len: usize) -> Vec { - let mut out = Vec::with_capacity(len); - out.set_len(len); - out + let data = std::alloc::alloc(std::alloc::Layout::array::(len).unwrap()); + Vec::from_raw_parts(data as *mut u8, len, len) } /// Shortcut to zero out a slice of bytes.