diff rust/hg-core/src/utils/files.rs @ 46481:0d734c0ae1cf

rust: replace read_whole_file with std::fs::read It does the same thing Differential Revision: https://phab.mercurial-scm.org/D9959
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 01 Feb 2021 12:25:53 +0100
parents 95d6f31e88db
children d2e61f00ee9d
line wrap: on
line diff
--- a/rust/hg-core/src/utils/files.rs	Tue Feb 09 09:37:39 2021 -0800
+++ b/rust/hg-core/src/utils/files.rs	Mon Feb 01 12:25:53 2021 +0100
@@ -18,7 +18,6 @@
 use same_file::is_same_file;
 use std::borrow::{Cow, ToOwned};
 use std::fs::Metadata;
-use std::io::Read;
 use std::iter::FusedIterator;
 use std::ops::Deref;
 use std::path::{Path, PathBuf};
@@ -309,17 +308,6 @@
     }
 }
 
-/// Reads a file in one big chunk instead of doing multiple reads
-pub fn read_whole_file(filepath: &Path) -> std::io::Result<Vec<u8>> {
-    let mut file = std::fs::File::open(filepath)?;
-    let size = file.metadata()?.len();
-
-    let mut res = vec![0; size as usize];
-    file.read_exact(&mut res)?;
-
-    Ok(res)
-}
-
 #[cfg(test)]
 mod tests {
     use super::*;