fix clippy
This commit is contained in:
parent
fe8046cf58
commit
976610d06f
1 changed files with 8 additions and 8 deletions
16
src/main.rs
16
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<String> = 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::<Vec<(String, Duration)>>();
|
||||
recently_changed.sort_by_key(|i| i.1);
|
||||
|
@ -430,7 +430,7 @@ fn update_garden<P: AsRef<Path>>(
|
|||
);
|
||||
}
|
||||
|
||||
let result = GardenCache { files, pages };
|
||||
let result = GardenCache { pages, files };
|
||||
trace!("{:#?}", result);
|
||||
Ok(result)
|
||||
}
|
||||
|
@ -576,5 +576,5 @@ fn postprocess_html<T: AsRef<str>>(document: T) -> anyhow::Result<String> {
|
|||
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()))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue