Create a template for new element functions that will take in the affiliated keywords instead of re-parsing them multiple times.

This commit is contained in:
Tom Alexander
2023-10-12 15:47:06 -04:00
parent 176e37874e
commit a6f36ba679
5 changed files with 29 additions and 4 deletions

View File

@@ -25,12 +25,15 @@ use crate::types::AffiliatedKeywordValue;
use crate::types::AffiliatedKeywords;
use crate::types::Keyword;
pub(crate) fn parse_affiliated_keywords<'g, 's>(
pub(crate) fn parse_affiliated_keywords<'g, 's, AK>(
global_settings: &'g GlobalSettings<'g, 's>,
input: Vec<Keyword<'s>>,
) -> AffiliatedKeywords<'s> {
input: AK,
) -> AffiliatedKeywords<'s>
where
AK: IntoIterator<Item = Keyword<'s>>,
{
let mut ret = BTreeMap::new();
for kw in input.into_iter() {
for kw in input {
let translated_name = translate_name(global_settings, kw.key);
if is_single_string_keyword(global_settings, translated_name.as_str()) {
ret.insert(