io: clippy fixes

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-11-29 14:51:26 +01:00
parent eac7ebfc55
commit 36e064d73a
2 changed files with 3 additions and 4 deletions

View File

@ -296,7 +296,7 @@ impl<R: io::Read> ReadExt for R {
fn read_exact_or_eof(&mut self, mut buf: &mut [u8]) -> io::Result<bool> {
let mut read_bytes = 0;
loop {
match self.read(&mut buf) {
match self.read(buf) {
Ok(0) => {
if read_bytes == 0 {
return Ok(false);

View File

@ -52,9 +52,8 @@ pub use byte_vec::ByteVecExt;
/// marked as unsafe for good measure.
#[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)
}
/// Shortcut to zero out a slice of bytes.