#[non_exhaustive]pub struct ForSource {
pub kind: ForSourceKind,
pub span: Span,
}Expand description
What a for iterates: inline comprehension text, or the name of a
bound producer wire.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.kind: ForSourceKindWhat the source denotes. This is the source: its text is
rendered from here (ForSource::to_text), never stored
beside it, so a source cannot read as one thing and traverse
another.
span: SpanWhere the source appears, for diagnostics. Position is provenance and belongs on the node; a copy of the text the author wrote is not provenance, it is a second answer to a question that has one.
Implementations§
Source§impl ForSource
impl ForSource
Sourcepub fn comprehension(tree: Comprehension, span: Span) -> Option<Self>
pub fn comprehension(tree: Comprehension, span: Span) -> Option<Self>
A traversal source over a comprehension, its text the tree’s
canonical text
(Comprehension::to_text).
None when the
tree is outside the text grammar, so a source never carries a
text that reads back as a different comprehension.
Sourcepub fn producer(name: impl Into<String>, span: Span) -> Self
pub fn producer(name: impl Into<String>, span: Span) -> Self
A traversal source naming a producer bound in the same scope.
Sourcepub fn derived(
base: impl Into<String>,
filter: Option<String>,
order: Option<String>,
span: Span,
) -> Self
pub fn derived( base: impl Into<String>, filter: Option<String>, order: Option<String>, span: Span, ) -> Self
A traversal source deriving from a bound producer: the base with an optional filter and order, written as the text writes them.
Sourcepub fn to_text(&self) -> String
pub fn to_text(&self) -> String
The source as the text after for writes it, rendered from
what it denotes.
A comprehension renders through
Comprehension::to_text,
a producer is its name, and a derivation is its base with the
where and order it carries. Re-reading the result yields
the same source, so nothing downstream can traverse one thing
and report another.
Total for every source that exists: Self::comprehension
refuses a tree the text cannot write, so the fallback below is
unreachable through the constructors. It renders a form no
parser accepts rather than a plausible one, so a source that
somehow evaded them fails loudly at the next read instead of
quietly meaning something else.
Sourcepub fn element_names(&self) -> Vec<String>
pub fn element_names(&self) -> Vec<String>
The element names the source dispenses, when known statically. A producer reference or derivation resolves its names at compile time.