From 976610d06f96bdcf7d5e43f0b166e7f97b4003ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Mon, 4 Oct 2021 20:32:35 +0200 Subject: [PATCH] fix clippy --- src/main.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 430a203..7f19f09 100644 --- a/src/main.rs +++ b/src/main.rs @@ -196,7 +196,7 @@ async fn render( // If the path is not a markdown file (e.g. photos), just return it as it is. if full_path.exists() && !path.ends_with(".md") { - return Ok(NamedFile::open(full_path)?.into_response(&request)?); + return NamedFile::open(full_path)?.into_response(&request); } // Otherwise, retrieve it and check backlinks @@ -230,7 +230,7 @@ async fn render( }; let page = if path.as_str() != "!graph" { - cache.pages.get(path.as_ref()).clone() + cache.pages.get(path.as_ref()) } else { let mut context = Context::new(); @@ -239,7 +239,7 @@ async fn render( let page_ids: Vec = cache.pages.keys().map(|n| normalize_name(n)).collect(); - &cache.pages.iter().for_each(|(path, page)| { + cache.pages.iter().for_each(|(path, page)| { let normalized_path = normalize_name(path); nodes.push( [("id".to_string(), normalized_path.clone())] @@ -280,9 +280,9 @@ async fn render( .pages .clone() .into_iter() - .filter_map(|(path, page)| match page.timestamp { - Some(ts) => Some((path, SystemTime::now().duration_since(ts).unwrap())), - None => None, + .filter_map(|(path, page)| { + page.timestamp + .map(|ts| (path, SystemTime::now().duration_since(ts).unwrap())) }) .collect::>(); recently_changed.sort_by_key(|i| i.1); @@ -430,7 +430,7 @@ fn update_garden>( ); } - let result = GardenCache { files, pages }; + let result = GardenCache { pages, files }; trace!("{:#?}", result); Ok(result) } @@ -576,5 +576,5 @@ fn postprocess_html>(document: T) -> anyhow::Result { fn normalize_name(filename: &str) -> String { let decoded = percent_decode_str(filename).decode_utf8_lossy(); let result = decoded.strip_suffix(".md"); - String::from(result.unwrap_or(decoded.as_ref())) + String::from(result.unwrap_or_else(|| decoded.as_ref())) }