@@ -1,7 +1,6 @@
11use std::collections::BTreeMap;
22use std::ffi::OsStr;
3−use std::fs::{self, File};
4−use std::io::BufReader;
3+use std::fs;
54use std::path::Path;
65
76use syntect::dumps::{dump_to_file, from_binary, from_reader};
@@ -298,15 +297,14 @@ fn asset_to_cache<T: serde::Serialize>(asset: &T, path: &Path, description: &str
298297}
299298
300299fn asset_from_cache<T: serde::de::DeserializeOwned>(path: &Path, description: &str) -> Result<T> {
301− let asset_file = File::open(&path).chain_err(|| {
300+ let contents = fs::read(path).chain_err(|| {
302301 format!(
303302 "Could not load cached {} '{}'",
304303 description,
305304 path.to_string_lossy()
306305 )
307306 })?;
308− from_reader(BufReader::new(asset_file))
309− .chain_err(|| format!("Could not parse cached {}", description))
307+ from_reader(&contents[..]).chain_err(|| format!("Could not parse cached {}", description))
310308}
311309
312310#[cfg(test)]
@@ -316,7 +314,7 @@ mod tests {
316314 use std::ffi::OsStr;
317315
318316 use std::fs::File;
319− use std::io::Write;
317+ use std::io::{BufReader, Write};
320318 use tempfile::TempDir;
321319
322320 use crate::input::Input;