pub struct Declarations {
pub environments: EnvironmentDecls,
}Expand description
Every declaration a project makes, as authored — unresolved and unvalidated.
BTreeMap rather than HashMap so iteration order is deterministic:
resolution reports errors in the order the user reads them, and the value
ends up on a salsa input whose equality must not depend on hash order.
Fields§
§environments: EnvironmentDeclsThe [environments.<name>] entries.
Implementations§
Source§impl Declarations
impl Declarations
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the project declares nothing at all — the overwhelmingly common case, and the one the parse must not pay anything for.
Sourcepub fn resolve(&self) -> Result<ResolvedDeclarations, DeclarationError>
pub fn resolve(&self) -> Result<ResolvedDeclarations, DeclarationError>
Check every rule and project the declarations into a
ResolvedDeclarations: an environment signature per like, and the
delimiter spellings as opener and closer alias entries.
Internally a SignatureDb, because that is already the shape holding
exactly these three maps: the declared tier folds into a document’s scope
with the existing SignatureDb::merge_from, and the ParseCtx seed
reads it the same way it already reads the per-file scan’s — no new
plumbing, and [commands.*] slots in later without changing the
signature of this function.
Every failure is an error, never a silent no-op. A declaration that
quietly does nothing is the worst outcome available here: the user sees
unchanged output and has no way to tell a typo from an unimplemented
feature. Errors surface in key order (the map is a BTreeMap), so the
message is stable across runs.
An entry that declares behavior alone is unrestricted — like = "lstlisting" is exactly how a project names a verbatim environment the
definition scan cannot find. The extra restrictions below apply only to
an entry that declares delimiter spellings, since those are the ones a
command has to stand in for. An entry that declares nothing is the
one shape rejected for saying too little rather than too much.
One side alone is fine (issue #117): the literal \begin{X}/\end{X} is
a spelling of each side too, so begin = ['\bsplit'] with no end
declares an opener the written-out \end{split} closes. This used to be
two errors, on the reasoning that a half-declared pair could never pair.
Trait Implementations§
Source§impl Clone for Declarations
impl Clone for Declarations
Source§fn clone(&self) -> Declarations
fn clone(&self) -> Declarations
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more