From 44506136e2f3af1cf96ecf2e86cc80296c31737d Mon Sep 17 00:00:00 2001 From: RumovZ Date: Fri, 28 May 2021 15:42:09 +0200 Subject: [PATCH] Use HashSet for special fields --- rslib/src/notetype/mod.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/rslib/src/notetype/mod.rs b/rslib/src/notetype/mod.rs index e3605810f..cce6da6d9 100644 --- a/rslib/src/notetype/mod.rs +++ b/rslib/src/notetype/mod.rs @@ -11,8 +11,10 @@ mod stock; mod templates; pub(crate) mod undo; +use lazy_static::lazy_static; use std::{ collections::{HashMap, HashSet}, + iter::FromIterator, sync::Arc, }; @@ -48,16 +50,18 @@ define_newtype!(NotetypeId, i64); pub(crate) const DEFAULT_CSS: &str = include_str!("styling.css"); pub(crate) const DEFAULT_LATEX_HEADER: &str = include_str!("header.tex"); pub(crate) const DEFAULT_LATEX_FOOTER: &str = r"\end{document}"; -/// New entries must be handled in render.rs/add_special_fields(). -pub(crate) const SPECIAL_FIELDS: [&str; 7] = [ - "FrontSide", - "Card", - "CardFlag", - "Deck", - "Subdeck", - "Tags", - "Type", -]; +lazy_static! { + /// New entries must be handled in render.rs/add_special_fields(). + static ref SPECIAL_FIELDS: HashSet<&'static str> = HashSet::from_iter(vec![ + "FrontSide", + "Card", + "CardFlag", + "Deck", + "Subdeck", + "Tags", + "Type", + ]); +} #[derive(Debug, PartialEq, Clone)] pub struct Notetype {