cargo clippy fixes

This commit is contained in:
Tomáš Mládek 2020-10-25 15:56:03 +01:00
parent 38e560aa51
commit 9d8f308a4d

View file

@ -239,7 +239,7 @@ fn update_garden<P: AsRef<Path>>(
garden_path: P, garden_path: P,
current: GardenCache, current: GardenCache,
) -> anyhow::Result<GardenCache> { ) -> anyhow::Result<GardenCache> {
let garden_path = garden_path.as_ref().clone(); let garden_path = garden_path.as_ref();
let mut files: Vec<PathBuf> = fs::read_dir(&garden_path)? let mut files: Vec<PathBuf> = fs::read_dir(&garden_path)?
.filter_map(|entry| { .filter_map(|entry| {
@ -247,7 +247,7 @@ fn update_garden<P: AsRef<Path>>(
let path = entry.path(); let path = entry.path();
if path.is_file() { if path.is_file() {
let stripped_path = path.strip_prefix(&garden_path).unwrap().to_path_buf(); let stripped_path = path.strip_prefix(&garden_path).unwrap().to_path_buf();
if !stripped_path.to_str().unwrap().starts_with(".") { if !stripped_path.to_str().unwrap().starts_with('.') {
return Some(stripped_path); return Some(stripped_path);
} }
} }
@ -261,7 +261,7 @@ fn update_garden<P: AsRef<Path>>(
return Err(anyhow!("Garden is empty.")); return Err(anyhow!("Garden is empty."));
} }
let mut pages = current.pages.clone(); let mut pages = current.pages;
let markdown_paths = files let markdown_paths = files
.iter() .iter()
@ -271,14 +271,11 @@ fn update_garden<P: AsRef<Path>>(
trace!("Loading {} into cache...", path.display()); trace!("Loading {} into cache...", path.display());
let mtime = path.metadata().unwrap().modified().ok(); let mtime = path.metadata().unwrap().modified().ok();
if let Some(page) = pages.get(&path) { if let Some(page) = pages.get(&path) {
match (mtime, page.timestamp) { if let (Some(fs_time), Some(last_time)) = (mtime, page.timestamp) {
(Some(fs_time), Some(last_time)) => {
if fs_time == last_time { if fs_time == last_time {
continue; continue;
} }
} }
_ => {}
}
} }
let mut file = File::open(&path)?; let mut file = File::open(&path)?;