pub enum SetArg {
Named {
key: String,
value: SetValue,
key_span: SourceSpan,
value_span: SourceSpan,
},
Positional {
value: SetValue,
value_span: SourceSpan,
},
}Expand description
One argument inside a directive body: either a key: value
pair (the only form #set accepts) or a positional value (a
leading string literal allowed on #image(...) / #figure(...)).
This used to be a struct with an empty-string key standing in
for “positional,” but that sentinel was a brittle public contract:
any consumer that forgot the special-case would silently treat a
positional path as a named arg called "". The enum form makes
the two shapes explicit so the compiler can enforce exhaustive
matches.
Variants§
Named
A key: value argument. key_span covers the identifier
before the colon; value_span covers the literal.
Positional
A leading positional value. The parser currently only accepts
string literals here (used for #image("path.png")); other
literal kinds in a positional slot would surface as a parse
error rather than land in this variant.
Implementations§
Source§impl SetArg
impl SetArg
Sourcepub fn value(&self) -> &SetValue
pub fn value(&self) -> &SetValue
Borrow the value carried by this argument, regardless of shape.
Sourcepub fn value_span(&self) -> &SourceSpan
pub fn value_span(&self) -> &SourceSpan
The span covering the argument’s value literal.
Sourcepub fn key(&self) -> Option<&str>
pub fn key(&self) -> Option<&str>
The key identifier for Self::Named; None for
Self::Positional.
Sourcepub fn key_span(&self) -> Option<&SourceSpan>
pub fn key_span(&self) -> Option<&SourceSpan>
The span covering the key identifier, for Self::Named.
None for Self::Positional.