Use HashSet for special fields

This commit is contained in:
RumovZ 2021-05-28 15:42:09 +02:00
parent 329f89c093
commit 44506136e2

View file

@ -11,8 +11,10 @@ mod stock;
mod templates; mod templates;
pub(crate) mod undo; pub(crate) mod undo;
use lazy_static::lazy_static;
use std::{ use std::{
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
iter::FromIterator,
sync::Arc, sync::Arc,
}; };
@ -48,8 +50,9 @@ define_newtype!(NotetypeId, i64);
pub(crate) const DEFAULT_CSS: &str = include_str!("styling.css"); 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_HEADER: &str = include_str!("header.tex");
pub(crate) const DEFAULT_LATEX_FOOTER: &str = r"\end{document}"; pub(crate) const DEFAULT_LATEX_FOOTER: &str = r"\end{document}";
lazy_static! {
/// New entries must be handled in render.rs/add_special_fields(). /// New entries must be handled in render.rs/add_special_fields().
pub(crate) const SPECIAL_FIELDS: [&str; 7] = [ static ref SPECIAL_FIELDS: HashSet<&'static str> = HashSet::from_iter(vec![
"FrontSide", "FrontSide",
"Card", "Card",
"CardFlag", "CardFlag",
@ -57,7 +60,8 @@ pub(crate) const SPECIAL_FIELDS: [&str; 7] = [
"Subdeck", "Subdeck",
"Tags", "Tags",
"Type", "Type",
]; ]);
}
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone)]
pub struct Notetype { pub struct Notetype {