#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ProfileKind {
Document,
Component,
}
pub trait Profile: Copy + Default + 'static {
const KIND: ProfileKind;
const TOLERATE_DECLARATIONS: bool;
const FOLD_NAME_CASE: bool;
const SELF_CLOSING_ANY_ELEMENT: bool;
const IMPLIED_END_TAGS: bool;
const SELECT_CONTENT_MODEL: bool = false;
const TABLE_CONTENT_MODEL: bool;
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct Document;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct Component;
impl Profile for Document {
const KIND: ProfileKind = ProfileKind::Document;
const TOLERATE_DECLARATIONS: bool = true;
const FOLD_NAME_CASE: bool = true;
const SELF_CLOSING_ANY_ELEMENT: bool = false;
const IMPLIED_END_TAGS: bool = true;
const SELECT_CONTENT_MODEL: bool = true;
const TABLE_CONTENT_MODEL: bool = true;
}
impl Profile for Component {
const KIND: ProfileKind = ProfileKind::Component;
const TOLERATE_DECLARATIONS: bool = false;
const FOLD_NAME_CASE: bool = false;
const SELF_CLOSING_ANY_ELEMENT: bool = true;
const IMPLIED_END_TAGS: bool = false;
const SELECT_CONTENT_MODEL: bool = false;
const TABLE_CONTENT_MODEL: bool = false;
}
#[cfg(test)]
mod tests {
use super::{Component, Document, Profile, ProfileKind};
#[derive(Clone, Copy, Default)]
struct ExistingProfile;
impl Profile for ExistingProfile {
const KIND: ProfileKind = ProfileKind::Component;
const TOLERATE_DECLARATIONS: bool = false;
const FOLD_NAME_CASE: bool = false;
const SELF_CLOSING_ANY_ELEMENT: bool = true;
const IMPLIED_END_TAGS: bool = false;
const TABLE_CONTENT_MODEL: bool = false;
}
#[test]
fn existing_profile_implementations_need_no_new_required_constant() {
assert_eq!(
(
ExistingProfile::SELECT_CONTENT_MODEL,
Component::SELECT_CONTENT_MODEL,
Document::SELECT_CONTENT_MODEL,
),
(false, false, true)
);
}
}