diff options
author | Hristo Venev <hristo@venev.name> | 2019-09-30 14:51:59 +0300 |
---|---|---|
committer | Hristo Venev <hristo@venev.name> | 2019-09-30 15:30:56 +0300 |
commit | 785da58fc732931a9a45cf598e5876a337e24011 (patch) | |
tree | dfabdd0d482edecf87a16d80a05742ff4e13794e /src/fileutil.rs | |
parent | a4ff443588ad83f668a5434257dfcbb2716d5ef8 (diff) |
Simplify main functions.
Diffstat (limited to 'src/fileutil.rs')
-rw-r--r-- | src/fileutil.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/fileutil.rs b/src/fileutil.rs index 0d76dfe..d00575b 100644 --- a/src/fileutil.rs +++ b/src/fileutil.rs @@ -84,7 +84,12 @@ pub fn update(path: &Path, data: &[u8]) -> io::Result<()> { tmp.sync_done()?.rename_to(path) } -pub fn load(path: &Path) -> io::Result<Option<Vec<u8>>> { +#[inline] +pub fn load(path: &impl AsRef<Path>) -> io::Result<Option<Vec<u8>>> { + _load(path.as_ref()) +} + +fn _load(path: &Path) -> io::Result<Option<Vec<u8>>> { let mut file = match fs::File::open(&path) { Ok(file) => file, Err(e) => { |