#[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<ForSource>
pub fn comprehension(tree: Comprehension, span: Span) -> Option<ForSource>
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) -> ForSource
pub fn producer(name: impl Into<String>, span: Span) -> ForSource
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,
) -> ForSource
pub fn derived( base: impl Into<String>, filter: Option<String>, order: Option<String>, span: Span, ) -> ForSource
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.
Trait Implementations§
Auto Trait Implementations§
impl Forget for ForSource
impl Freeze for ForSourcewhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<LiteralValue>: Freeze,
PhantomData<ProductMeasure>: Freeze,
PhantomData<f64>: Freeze,
PhantomData<Comprehension>: Freeze,
*const Comprehension is !null: Freeze,
impl Move for ForSource
impl RefUnwindSafe for ForSource
impl Send for ForSource
impl Sync for ForSource
impl Unpin for ForSource
impl UnsafeUnpin for ForSourcewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<LiteralValue>: UnsafeUnpin,
PhantomData<ProductMeasure>: UnsafeUnpin,
PhantomData<f64>: UnsafeUnpin,
PhantomData<Comprehension>: UnsafeUnpin,
*const Comprehension is !null: UnsafeUnpin,
impl UnwindSafe for ForSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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