Skip to content

Commit 0dec3fe

Browse files
committed
replace try_reserve_exact with try_with_capacity in std::fs::read
1 parent ac17c34 commit 0dec3fe

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

library/std/src/fs.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,7 @@ pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
285285
fn inner(path: &Path) -> io::Result<Vec<u8>> {
286286
let mut file = File::open(path)?;
287287
let size = file.metadata().map(|m| m.len() as usize).ok();
288-
let mut bytes = Vec::new();
289-
bytes.try_reserve_exact(size.unwrap_or(0))?;
288+
let mut bytes = Vec::try_with_capacity(size.unwrap_or(0))?;
290289
io::default_read_to_end(&mut file, &mut bytes, size)?;
291290
Ok(bytes)
292291
}

0 commit comments

Comments
 (0)