Do not clone ancestors when serializing

This commit is contained in:
Vincent Prouillet 2021-05-23 18:19:18 +02:00
parent fe79798b0f
commit c38d9e56c8

View file

@ -69,7 +69,7 @@ pub struct SerializingPage<'a> {
content: &'a str,
permalink: &'a str,
slug: &'a str,
ancestors: Vec<String>,
ancestors: Vec<&'a str>,
title: &'a Option<String>,
description: &'a Option<String>,
updated: &'a Option<String>,
@ -138,7 +138,7 @@ impl<'a> SerializingPage<'a> {
let ancestors = page
.ancestors
.iter()
.map(|k| library.get_section_by_key(*k).file.relative.clone())
.map(|k| library.get_section_by_key(*k).file.relative.as_str())
.collect();
let translations = TranslatedContent::find_all_pages(page, library);
@ -197,7 +197,7 @@ impl<'a> SerializingPage<'a> {
let ancestors = if let Some(ref lib) = library {
page.ancestors
.iter()
.map(|k| lib.get_section_by_key(*k).file.relative.clone())
.map(|k| lib.get_section_by_key(*k).file.relative.as_str())
.collect()
} else {
vec![]
@ -251,7 +251,7 @@ pub struct SerializingSection<'a> {
relative_path: &'a str,
content: &'a str,
permalink: &'a str,
ancestors: Vec<String>,
ancestors: Vec<&'a str>,
title: &'a Option<String>,
description: &'a Option<String>,
extra: &'a Map<String, Value>,
@ -283,7 +283,7 @@ impl<'a> SerializingSection<'a> {
let ancestors = section
.ancestors
.iter()
.map(|k| library.get_section_by_key(*k).file.relative.clone())
.map(|k| library.get_section_by_key(*k).file.relative.as_str())
.collect();
let translations = TranslatedContent::find_all_sections(section, library);
@ -317,7 +317,7 @@ impl<'a> SerializingSection<'a> {
ancestors = section
.ancestors
.iter()
.map(|k| lib.get_section_by_key(*k).file.relative.clone())
.map(|k| lib.get_section_by_key(*k).file.relative.as_str())
.collect();
translations = TranslatedContent::find_all_sections(section, lib);
subsections =