Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 8be691f

Browse files
nevakrienzesterer
authored andcommitted
modified new code to call the old
1 parent 6526d03 commit 8be691f

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/source.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ pub struct FileCache {
325325
files: HashMap<PathBuf, Source>,
326326
}
327327

328+
// this is here for backwards compatibility
328329
impl Cache<Path> for FileCache {
329330
type Storage = String;
330331

@@ -344,14 +345,10 @@ impl Cache<&Path> for FileCache {
344345
type Storage = String;
345346

346347
fn fetch(&mut self, path: &&Path) -> Result<&Source, impl fmt::Debug> {
347-
Ok::<_, Error>(match self.files.entry(path.to_path_buf()) {
348-
// TODO: Don't allocate here
349-
Entry::Occupied(entry) => entry.into_mut(),
350-
Entry::Vacant(entry) => entry.insert(Source::from(fs::read_to_string(path)?)),
351-
})
348+
Cache::<Path>::fetch(self, *path)
352349
}
353-
fn display<'a>(&self, path: &'a& Path) -> Option<impl fmt::Display + 'a> {
354-
Some(Box::new(path.display()))
350+
fn display<'a>(&self, path: &'a &Path) -> Option<impl fmt::Display + 'a> {
351+
Cache::<Path>::display(self, *path)
355352
}
356353
}
357354

0 commit comments

Comments
 (0)