Remove redundant clone

This commit is contained in:
Shotaro Yamada 2018-11-19 23:04:22 +09:00
parent 5d75849c9b
commit 692103bff4
5 changed files with 11 additions and 13 deletions

View file

@ -80,7 +80,7 @@ impl Section {
pub fn parse(file_path: &Path, content: &str, config: &Config) -> Result<Section> { pub fn parse(file_path: &Path, content: &str, config: &Config) -> Result<Section> {
let (meta, content) = split_section_content(file_path, content)?; let (meta, content) = split_section_content(file_path, content)?;
let mut section = Section::new(file_path, meta); let mut section = Section::new(file_path, meta);
section.raw_content = content.clone(); section.raw_content = content;
let (word_count, reading_time) = get_reading_analytics(&section.raw_content); let (word_count, reading_time) = get_reading_analytics(&section.raw_content);
section.word_count = Some(word_count); section.word_count = Some(word_count);
section.reading_time = Some(reading_time); section.reading_time = Some(reading_time);

View file

@ -31,7 +31,7 @@ pub struct Rendered {
// means we will have example, example-1, example-2 etc // means we will have example, example-1, example-2 etc
fn find_anchor(anchors: &[String], name: String, level: u8) -> String { fn find_anchor(anchors: &[String], name: String, level: u8) -> String {
if level == 0 && !anchors.contains(&name) { if level == 0 && !anchors.contains(&name) {
return name.to_string(); return name;
} }
let new_anchor = format!("{}-{}", name, level + 1); let new_anchor = format!("{}-{}", name, level + 1);

View file

@ -20,9 +20,9 @@ lazy_static! {
fn replace_string_markers(input: &str) -> String { fn replace_string_markers(input: &str) -> String {
match input.chars().next().unwrap() { match input.chars().next().unwrap() {
'"' => input.replace('"', "").to_string(), '"' => input.replace('"', ""),
'\'' => input.replace('\'', "").to_string(), '\'' => input.replace('\'', ""),
'`' => input.replace('`', "").to_string(), '`' => input.replace('`', ""),
_ => unreachable!("How did you even get there"), _ => unreachable!("How did you even get there"),
} }
} }

View file

@ -771,7 +771,7 @@ impl Site {
pages.par_sort_unstable_by(sort_actual_pages_by_date); pages.par_sort_unstable_by(sort_actual_pages_by_date);
context.insert("last_build_date", &pages[0].meta.date.clone().map(|d| d.to_string())); context.insert("last_build_date", &pages[0].meta.date.clone());
// limit to the last n elements if the limit is set; otherwise use all. // limit to the last n elements if the limit is set; otherwise use all.
let num_entries = self.config.rss_limit.unwrap_or(pages.len()); let num_entries = self.config.rss_limit.unwrap_or(pages.len());
let p = pages let p = pages
@ -794,7 +794,7 @@ impl Site {
let feed = &render_template("rss.xml", &self.tera, &context, &self.config.theme)?; let feed = &render_template("rss.xml", &self.tera, &context, &self.config.theme)?;
if let Some(ref base) = base_path { if let Some(ref base) = base_path {
let mut output_path = self.output_path.clone().to_path_buf(); let mut output_path = self.output_path.clone();
for component in base.components() { for component in base.components() {
output_path.push(component); output_path.push(component);
if !output_path.exists() { if !output_path.exists() {
@ -812,9 +812,7 @@ impl Site {
/// Renders a single section /// Renders a single section
pub fn render_section(&self, section: &Section, render_pages: bool) -> Result<()> { pub fn render_section(&self, section: &Section, render_pages: bool) -> Result<()> {
ensure_directory_exists(&self.output_path)?; ensure_directory_exists(&self.output_path)?;
let public = self.output_path.clone(); let mut output_path = self.output_path.clone();
let mut output_path = public.to_path_buf();
for component in &section.file.components { for component in &section.file.components {
output_path.push(component); output_path.push(component);

View file

@ -184,8 +184,8 @@ pub fn make_get_taxonomy_url(all_taxonomies: &[Taxonomy]) -> GlobalFn {
} }
}; };
if let Some(ref permalink) = container.get(&name) { if let Some(permalink) = container.get(&name) {
return Ok(to_value(permalink.clone()).unwrap()); return Ok(to_value(permalink).unwrap());
} }
Err(format!("`get_taxonomy_url`: couldn't find `{}` in `{}` taxonomy", name, kind).into()) Err(format!("`get_taxonomy_url`: couldn't find `{}` in `{}` taxonomy", name, kind).into())
@ -226,7 +226,7 @@ pub fn make_resize_image(imageproc: Arc<Mutex<imageproc::Processor>>) -> GlobalF
return Err(format!("`resize_image`: Cannot find path: {}", path).into()); return Err(format!("`resize_image`: Cannot find path: {}", path).into());
} }
let imageop = imageproc::ImageOp::from_args(path.clone(), &op, width, height, quality) let imageop = imageproc::ImageOp::from_args(path, &op, width, height, quality)
.map_err(|e| format!("`resize_image`: {}", e))?; .map_err(|e| format!("`resize_image`: {}", e))?;
let url = imageproc.insert(imageop); let url = imageproc.insert(imageop);