|
1 | 1 | use super::*;
|
2 | 2 |
|
| 3 | +use std::io::Error; |
3 | 4 | use std::{
|
4 | 5 | collections::{hash_map::Entry, HashMap},
|
5 | 6 | fs,
|
6 | 7 | path::{Path, PathBuf},
|
7 | 8 | };
|
8 |
| -use std::io::Error; |
9 | 9 |
|
10 | 10 | /// A trait implemented by [`Source`] caches.
|
11 | 11 | pub trait Cache<Id: ?Sized> {
|
@@ -332,9 +332,7 @@ impl Cache<Path> for FileCache {
|
332 | 332 | Ok::<_, Error>(match self.files.entry(path.to_path_buf()) {
|
333 | 333 | // TODO: Don't allocate here
|
334 | 334 | Entry::Occupied(entry) => entry.into_mut(),
|
335 |
| - Entry::Vacant(entry) => entry.insert(Source::from( |
336 |
| - fs::read_to_string(path)?, |
337 |
| - )), |
| 335 | + Entry::Vacant(entry) => entry.insert(Source::from(fs::read_to_string(path)?)), |
338 | 336 | })
|
339 | 337 | }
|
340 | 338 | fn display<'a>(&self, path: &'a Path) -> Option<impl fmt::Display + 'a> {
|
@@ -403,14 +401,12 @@ where
|
403 | 401 | I: IntoIterator<Item = (Id, S)>,
|
404 | 402 | S: AsRef<str>,
|
405 | 403 | {
|
406 |
| - FnCache::new( |
407 |
| - (move |id| Err(format!("Failed to fetch source '{}'", id))) as fn(&_) -> _, |
408 |
| - ) |
409 |
| - .with_sources( |
410 |
| - iter.into_iter() |
411 |
| - .map(|(id, s)| (id, Source::from(s))) |
412 |
| - .collect(), |
413 |
| - ) |
| 404 | + FnCache::new((move |id| Err(format!("Failed to fetch source '{}'", id))) as fn(&_) -> _) |
| 405 | + .with_sources( |
| 406 | + iter.into_iter() |
| 407 | + .map(|(id, s)| (id, Source::from(s))) |
| 408 | + .collect(), |
| 409 | + ) |
414 | 410 | }
|
415 | 411 |
|
416 | 412 | #[cfg(test)]
|
|
0 commit comments