Skip to content

Instantly share code, notes, and snippets.

@amcsi
Created December 10, 2021 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amcsi/f25e270e8e208e0cd8e350bcc97f9d4f to your computer and use it in GitHub Desktop.
Save amcsi/f25e270e8e208e0cd8e350bcc97f9d4f to your computer and use it in GitHub Desktop.
Rust code needing deduplication
impl<'a> SerializingCommon<'a> {
pub fn serialize_page<T>(serialized: &SerializingPage) -> SerializingCommon<'a>
{
SerializingCommon {
ancestors: &serialized.ancestors,
assets: serialized.assets,
components: serialized.components,
content: serialized.content,
description: serialized.description,
draft: serialized.draft,
extra: serialized.extra,
lang: serialized.lang,
path: serialized.path,
permalink: serialized.permalink,
reading_time: serialized.reading_time,
relative_path: serialized.relative_path,
title: serialized.title,
toc: serialized.toc,
translations: &serialized.translations,
word_count: serialized.word_count,
}
}
pub fn serialize_section<T>(serialized: &SerializingSection) -> SerializingCommon<'a>
{
SerializingCommon {
ancestors: &serialized.ancestors,
assets: serialized.assets,
components: serialized.components,
content: serialized.content,
description: serialized.description,
draft: serialized.draft,
extra: serialized.extra,
lang: serialized.lang,
path: serialized.path,
permalink: serialized.permalink,
reading_time: serialized.reading_time,
relative_path: serialized.relative_path,
title: serialized.title,
toc: serialized.toc,
translations: &serialized.translations,
word_count: serialized.word_count,
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment