pub enum DefinitionContent {
Both(String),
ByMode(ModeTemplates),
}Expand description
The content key of a DefinitionData: one template for both parsing
modes, or one template per mode.
In data, it is a text or a map with the keys text and math. A map that
gives neither key, and a value of any other form, are refused when the
settings are read.
Variants§
Both(String)
One template for text mode and mathematics mode; the definition applies in each mode where it parses.
ByMode(ModeTemplates)
One template per mode, at least one of the two given.
Implementations§
Source§impl DefinitionContent
impl DefinitionContent
Sourcepub fn definitions(self, base: Definition) -> Vec<Definition>
pub fn definitions(self, base: Definition) -> Vec<Definition>
Returns the definitions this content declares from base, a
definition complete except for its template: for one text, one
definition that applies in both modes (in each mode where the text
parses); for a content given per mode, one definition per mode written,
the one for text mode first, each applying in its mode alone (as
Definition::text and Definition::math declare).
Every feature that reads a definition’s content key from data calls
this function, so that the key has the same meaning wherever it is
written.
§Examples
use flm_core::lang::rewrites::userdefs::DefinitionModes;
use flm_core::stdlib::features::userdefs::{Definition, DefinitionContent};
let base = Definition::macro_("ket", Vec::new());
let one = DefinitionContent::Both(String::from("x")).definitions(base.clone());
assert_eq!(one.len(), 1);
assert_eq!(one[0].modes, DefinitionModes::Both);
let by_mode: DefinitionContent = serde_json::from_str(r#"{"text": "t", "math": "m"}"#).unwrap();
let two = by_mode.definitions(base);
let modes: Vec<DefinitionModes> = two.iter().map(|definition| definition.modes).collect();
assert_eq!(modes, [DefinitionModes::Text, DefinitionModes::Math]);Trait Implementations§
Source§impl Clone for DefinitionContent
impl Clone for DefinitionContent
Source§impl Debug for DefinitionContent
impl Debug for DefinitionContent
Source§impl<'de> Deserialize<'de> for DefinitionContent
impl<'de> Deserialize<'de> for DefinitionContent
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for DefinitionContent
Source§impl JsonSchema for DefinitionContent
impl JsonSchema for DefinitionContent
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for DefinitionContent
impl PartialEq for DefinitionContent
impl StructuralPartialEq for DefinitionContent
Auto Trait Implementations§
impl Forget for DefinitionContent
impl Freeze for DefinitionContent
impl Move for DefinitionContent
impl RefUnwindSafe for DefinitionContent
impl Send for DefinitionContent
impl Sync for DefinitionContent
impl Unpin for DefinitionContent
impl UnsafeUnpin for DefinitionContent
impl UnwindSafe for DefinitionContent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more