summaryrefslogtreecommitdiff
path: root/src/utils.rs
diff options
context:
space:
mode:
authorMaxVerevkin <maxxverrr@gmail.com>2024-05-06 19:51:46 +0300
committerMaxVerevkin <maxxverrr@gmail.com>2024-05-06 19:51:46 +0300
commit2d6268ba72bc27ee35a05821775cfb6166596951 (patch)
treec6599e5595e42e9f6ef351246ce1625f46d8e0fe /src/utils.rs
parent179f33a1fde61d75e339d9935ab83e3c03e8731d (diff)
downloadi3bar-mango-2d6268ba72bc27ee35a05821775cfb6166596951.tar.gz
simplify read_to_vec
Diffstat (limited to 'src/utils.rs')
-rw-r--r--src/utils.rs7
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(