diff options
| author | MaxVerevkin <maxxverrr@gmail.com> | 2024-05-06 19:51:46 +0300 |
|---|---|---|
| committer | MaxVerevkin <maxxverrr@gmail.com> | 2024-05-06 19:51:46 +0300 |
| commit | 2d6268ba72bc27ee35a05821775cfb6166596951 (patch) | |
| tree | c6599e5595e42e9f6ef351246ce1625f46d8e0fe /src/utils.rs | |
| parent | 179f33a1fde61d75e339d9935ab83e3c03e8731d (diff) | |
| download | i3bar-mango-2d6268ba72bc27ee35a05821775cfb6166596951.tar.gz | |
simplify read_to_vec
Diffstat (limited to 'src/utils.rs')
| -rw-r--r-- | src/utils.rs | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/utils.rs b/src/utils.rs index 128493d..c7913f1 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -9,11 +9,8 @@ use serde_json::{Deserializer, Error as JsonError}; /// Read from a raw file descriptor to the vector. /// /// Appends data at the end of the buffer. Resizes vector as needed. -#[allow(clippy::needless_pass_by_ref_mut)] -pub fn read_to_vec(fd: &mut impl AsFd, buf: &mut Vec<u8>) -> io::Result<usize> { - if buf.capacity() - buf.len() < 1024 { - buf.reserve(buf.capacity().max(1024)); - } +pub fn read_to_vec(fd: impl AsFd, buf: &mut Vec<u8>) -> io::Result<usize> { + buf.reserve(1024); let res = unsafe { libc::read( |
