pub enum Guard {
Attr {
ns: Ns,
key: Option<String>,
val: Option<String>,
},
}Expand description
One namespaced guard predicate. Every guard in the language is a namespace plus an optional subject plus an optional value; the single disjointness rule compares the whole triple, so no domain ever needs its own table.
Construction (fixed by the parser, never hand-built):
os/bool carry the value ([os:linux]), env carries the
variable as subject ([env:MODE], [env:MODE=dev]).
family:unix and family:windows are accepted aliases lowered
at parse to any(os:macos, os:linux) and os:windows
respectively, so every platform check executes uniformly under
the os: namespace.
Variants§
Implementations§
Source§impl Guard
impl Guard
Sourcepub fn is_disjoint_from(&self, other: &Self) -> bool
pub fn is_disjoint_from(&self, other: &Self) -> bool
The one disjointness rule for the entire guard language:
same namespace, same subject, both valued, different values.
Everything else overlaps — different namespaces are
independent axes, different subjects are independent
variables, and a missing value is a presence claim compatible
with any value. No per-domain tables: os:macos vs
os:linux, env:MODE=dev vs env:MODE=prod, and
bool:true vs bool:false all decide here.
Trait Implementations§
Source§impl Display for Guard
impl Display for Guard
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Bare form without brackets (the step renderer adds them):
[os:linux] prints os:linux, [env:MODE=dev]
prints eq(env:MODE, dev), [env:MODE] prints env:MODE.
The eq() spelling roundtrips through the parser; the rest
print verbatim. Roundtrips by construction.