replace try_reserve_exact with try_with_capacity in std::fs::read
This commit is contained in:
parent
ac17c3486c
commit
0dec3fee34
1 changed files with 1 additions and 2 deletions
|
|
@ -285,8 +285,7 @@ pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
|
|||
fn inner(path: &Path) -> io::Result<Vec<u8>> {
|
||||
let mut file = File::open(path)?;
|
||||
let size = file.metadata().map(|m| m.len() as usize).ok();
|
||||
let mut bytes = Vec::new();
|
||||
bytes.try_reserve_exact(size.unwrap_or(0))?;
|
||||
let mut bytes = Vec::try_with_capacity(size.unwrap_or(0))?;
|
||||
io::default_read_to_end(&mut file, &mut bytes, size)?;
|
||||
Ok(bytes)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue