From 9539fbde1c47ac1c3a1a212bc6fa4635dfe78b2f Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Tue, 8 Feb 2022 14:26:46 +0100 Subject: [PATCH] proxmox-async: clippy fixup Signed-off-by: Wolfgang Bumiller --- proxmox-async/src/stream/async_reader_stream.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/proxmox-async/src/stream/async_reader_stream.rs b/proxmox-async/src/stream/async_reader_stream.rs index caa6736a..c79468ef 100644 --- a/proxmox-async/src/stream/async_reader_stream.rs +++ b/proxmox-async/src/stream/async_reader_stream.rs @@ -8,6 +8,8 @@ use futures::ready; use futures::stream::Stream; use tokio::io::{AsyncRead, ReadBuf}; +use proxmox_io::vec; + /// Wrapper struct to convert an [AsyncRead] into a [Stream] pub struct AsyncReaderStream { reader: R, @@ -16,19 +18,11 @@ pub struct AsyncReaderStream { impl AsyncReaderStream { pub fn new(reader: R) -> Self { - let mut buffer = Vec::with_capacity(64 * 1024); - unsafe { - buffer.set_len(buffer.capacity()); - } - Self { reader, buffer } + Self::with_buffer_size(reader, 64 * 1024) } pub fn with_buffer_size(reader: R, buffer_size: usize) -> Self { - let mut buffer = Vec::with_capacity(buffer_size); - unsafe { - buffer.set_len(buffer.capacity()); - } - Self { reader, buffer } + Self { reader, buffer: vec::undefined(buffer_size) } } }