Some clippy fixes

This commit is contained in:
Vincent Prouillet 2021-04-07 21:14:42 +02:00
parent 0afd31d660
commit fc808f2aa8
6 changed files with 6 additions and 10 deletions

View file

@ -59,7 +59,7 @@ impl Markdown {
pub fn construct_external_link_tag(&self, url: &str, title: &str) -> String {
let mut rel_opts = Vec::new();
let mut target = "".to_owned();
let title = if title == "" { "".to_owned() } else { format!("title=\"{}\" ", title) };
let title = if title.is_empty() { "".to_owned() } else { format!("title=\"{}\" ", title) };
if self.external_links_target_blank {
// Security risk otherwise

View file

@ -3,9 +3,7 @@ use serde_derive::{Deserialize, Serialize};
use errors::{bail, Error, Result};
use regex::Regex;
use serde_yaml;
use std::path::Path;
use toml;
mod page;
mod section;

View file

@ -81,7 +81,7 @@ impl PageFrontMatter {
}
if let Some(ref path) = f.path {
if path == "" {
if path.is_empty() {
bail!("`path` can't be empty if present")
}
}

View file

@ -319,8 +319,7 @@ impl ImageOp {
Some(q) => encoder.encode(q as f32 / 100.),
None => encoder.encode_lossless(),
};
let mut bytes = memory.as_bytes();
f.write_all(&mut bytes)?;
f.write_all(&memory.as_bytes())?;
}
}

View file

@ -84,7 +84,7 @@ impl Library {
let file_path = section.file.path.clone();
let rel_path = section.path.clone();
let mut entries = vec![rel_path.clone()];
let mut entries = vec![rel_path];
entries.extend(section.meta.aliases.iter().map(|a| a.clone()).collect::<Vec<String>>());
self.insert_reverse_aliases(entries, &section.file.relative);
@ -98,7 +98,7 @@ impl Library {
let file_path = page.file.path.clone();
let rel_path = page.path.clone();
let mut entries = vec![rel_path.clone()];
let mut entries = vec![rel_path];
entries.extend(page.meta.aliases.iter().map(|a| a.clone()).collect::<Vec<String>>());
self.insert_reverse_aliases(entries, &page.file.relative);

View file

@ -1,6 +1,5 @@
use std::fs::{canonicalize, create_dir};
use std::path::Path;
use std::path::PathBuf;
use errors::{bail, Result};
use utils::fs::create_file;
@ -68,7 +67,7 @@ pub fn is_directory_quasi_empty(path: &Path) -> Result<bool> {
}
// Remove the unc part of a windows path
fn strip_unc(path: &PathBuf) -> String {
fn strip_unc(path: &Path) -> String {
let path_to_refine = path.to_str().unwrap();
path_to_refine.trim_start_matches(LOCAL_UNC).to_string()
}