Skip to main content

TheoremsConfig

Struct TheoremsConfig 

Source
pub struct TheoremsConfig {
    pub classes: BTreeMap<Name, TheoremClass>,
    pub kinds: BTreeMap<Name, TheoremKind>,
    pub number_format: NumberTemplate,
    pub label_types: Vec<String>,
}
Expand description

The configuration of the Theorems feature: the theorem classes and the theorem kinds, the number format of every kind, and the label types every numbered kind accepts.

Every kind is an environment of its own name, \begin{lemma}…\end{lemma}, with no code written for it: a host adds exercise by declaring it here.

The default (TheoremsConfig::new) declares three classes and eight kinds:

classnumberedcounterclosing markback-referencekinds
theoremlikeyessharednonenotheorem, proposition, lemma, corollary, conjecture
definitionlikeyessharednonenodefinition, remark
prooflikeno—□yesproof

with the heading DEFAULT_HEADING for every class. theorem, proposition, lemma and corollary expect a proof; the others do not. simpleset and richset are two other complete sets a host may start from. A host edits any of them through the builders:

use flm_core::stdlib::features::numbering::{PluralWords, PrefixWords};
use flm_core::stdlib::features::theorems::{TheoremKind, TheoremsConfig};

let config = TheoremsConfig::new()
    .kind(
        "exercise",
        TheoremKind::new(
            "definitionlike",
            PrefixWords::new("Exercise", "Exercises")
                .with_variant("short", PluralWords::new("Ex.", "Exs.")),
        ),
    )
    .without_kind("conjecture");
assert_eq!(config.kinds.len(), 8);
assert!(config.validate().is_ok());

The value is what Theorems::new takes, and a host passes it through StdlibConfig::theorems. It is the feature’s configuration, fixed when the registry is built (see settings, options and configuration), because the environments are part of the language and the counters and counter styles the feature declares depend on it. For the same reason it enters the registry digest (digest_bytes).

The configuration is checked when the registry is built. The feature’s registration fails, with a message that identifies the class or the kind, on what validate refuses: a kind whose class the configuration does not declare, a class or kind name that is not a valid environment name, or a kind that expects a proof but accepts no label. Once the language is built, the registry build also fails on a heading template that does not compile, a closing mark that does not parse and a word that does not parse. A kind whose environment name another feature already declares is reported as any clash of names in the registry is.

Fields§

§classes: BTreeMap<Name, TheoremClass>

The theorem classes, by name.

§kinds: BTreeMap<Name, TheoremKind>

The theorem kinds, by environment name.

§number_format: NumberTemplate

The number format every kind’s number is written in, a number template of the numbering feature, #{arabic} by default. To write one kind’s number otherwise, a host replaces that kind’s counter style (flm.theorems.style.<kind>, see numbers) by name through the numbering feature’s configuration.

§label_types: Vec<String>

The label types that every numbered kind accepts on a \label written on one of its theorems; DEFAULT_LABEL_TYPES by default. A theorem of an unnumbered kind accepts no label.

Implementations§

Source§

impl TheoremsConfig

Source

pub fn new() -> TheoremsConfig

The default set of kinds, the set the Python implementation of FLM calls defaultset: eight kinds in the three shipped classes, theorem, proposition, lemma, corollary, conjecture, definition, remark and proof (TheoremsConfig lists them by class).

Source

pub fn simpleset() -> TheoremsConfig

The smallest shipped set, the set the Python implementation of FLM calls simpleset: six kinds, theorem, proposition, lemma, corollary, definition and proof, in the three shipped classes.

Source

pub fn richset() -> TheoremsConfig

The largest shipped set, the set the Python implementation of FLM calls richset: thirteen kinds, the eight of TheoremsConfig::new, and idea, question, claim, observation and problem in the class definitionlike.

Source

pub fn empty() -> TheoremsConfig

A configuration declaring no class and no kind, with the default number format and label types: the start of a configuration built entirely by the builders.

Source

pub fn kind(self, name: impl Into<Name>, kind: TheoremKind) -> TheoremsConfig

Builder: declares the kind name, replacing the kind of that name if there is one.

Source

pub fn without_kind(self, name: &str) -> TheoremsConfig

Builder: removes the kind name, if there is one.

Source

pub fn class(self, name: impl Into<Name>, class: TheoremClass) -> TheoremsConfig

Builder: declares the class name, replacing the class of that name if there is one.

Source

pub fn number_format(self, number_format: NumberTemplate) -> TheoremsConfig

Builder: sets the number format of every kind.

Source

pub fn label_types( self, label_types: impl IntoIterator<Item = impl Into<String>>, ) -> TheoremsConfig

Builder: sets the label types that every numbered kind accepts.

Source

pub fn kind_and_class( &self, name: &str, ) -> Option<(&TheoremKind, &TheoremClass)>

The kind name and its class; None where the kind or its class is not declared.

Source

pub fn validate(&self) -> Result<(), String>

Checks the parts of the configuration that can be checked before the language is built. The feature calls it when it registers; a host may call it earlier to report a mistake in its own terms.

The texts (heading templates, closing marks, words) are compiled only once the language is built, so a text that does not compile passes this check and fails the registry build later.

§Errors

A sentence that describes the first problem found: a class or kind name that is empty or holds whitespace, a brace, a backslash or a comment character (%); a kind whose class is not declared; a kind that expects a proof but accepts no label (a kind of an unnumbered class, or any kind under a configuration declaring no label_types), which no proof could refer back to.

Source

pub fn digest_bytes(&self) -> Vec<u8> ⓘ

The configuration written out as bytes: what the feature feeds into the registry digest, and what the Hash implementation hashes.

Every class and every kind is written in the order of its name, with every field of it, each text preceded by its length; then the number format and the label types. Two configurations give the same bytes exactly when they are equal. The code takes the fields apart by name, so a field added to a type and not written here fails to compile.

Trait Implementations§

Source§

impl Clone for TheoremsConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TheoremsConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TheoremsConfig

Source§

fn default() -> TheoremsConfig

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for TheoremsConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for TheoremsConfig

Source§

impl Hash for TheoremsConfig

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl JsonSchema for TheoremsConfig

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for TheoremsConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TheoremsConfig

Auto Trait Implementations§

§

impl Forget for TheoremsConfig

§

impl Freeze for TheoremsConfig

§

impl Move for TheoremsConfig

§

impl RefUnwindSafe for TheoremsConfig

§

impl Send for TheoremsConfig
where NodeRef<Owned, Name, TheoremClass, LeafOrInternal>: Send, BoxRaw<(Name, TheoremClass)>: Send, NodeRef<Owned, Name, TheoremKind, LeafOrInternal>: Send, BoxRaw<(Name, TheoremKind)>: Send, RawVecInner: Send,

§

impl Sync for TheoremsConfig
where NodeRef<Owned, Name, TheoremClass, LeafOrInternal>: Sync, BoxRaw<(Name, TheoremClass)>: Sync, NodeRef<Owned, Name, TheoremKind, LeafOrInternal>: Sync, BoxRaw<(Name, TheoremKind)>: Sync, RawVecInner: Sync,

§

impl Unpin for TheoremsConfig
where *const LeafNode<Name, TheoremClass> is !null: Unpin, Box<(Name, TheoremClass)>: Unpin, *const LeafNode<Name, TheoremKind> is !null: Unpin, Box<(Name, TheoremKind)>: Unpin, *const u8 is !null: Unpin,

§

impl UnsafeUnpin for TheoremsConfig

§

impl UnwindSafe for TheoremsConfig

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> Options for T
where T: Any + Send + Sync + Default + Hash + Debug,

Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> SettingsData for T

Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.