From fee4992fb160ae59f0a35bb5333b801e6c12ac9d Mon Sep 17 00:00:00 2001 From: Kornel Date: Wed, 31 Jan 2024 23:26:50 +0000 Subject: [PATCH] Make File::read_to_end less special Follow-up to #117925 --- library/std/src/fs.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 80d369eb067..25ed51f1233 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -776,14 +776,14 @@ fn is_read_vectored(&self) -> bool { // Reserves space in the buffer based on the file size when available. fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { let size = buffer_capacity_required(self); - buf.try_reserve_exact(size.unwrap_or(0)).map_err(|_| io::ErrorKind::OutOfMemory)?; + buf.try_reserve(size.unwrap_or(0)).map_err(|_| io::ErrorKind::OutOfMemory)?; io::default_read_to_end(self, buf, size) } // Reserves space in the buffer based on the file size when available. fn read_to_string(&mut self, buf: &mut String) -> io::Result { let size = buffer_capacity_required(self); - buf.try_reserve_exact(size.unwrap_or(0)).map_err(|_| io::ErrorKind::OutOfMemory)?; + buf.try_reserve(size.unwrap_or(0)).map_err(|_| io::ErrorKind::OutOfMemory)?; io::default_read_to_string(self, buf, size) } }