Skip to main content

ForSource

Struct ForSource 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§kind: ForSourceKind

What 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: Span

Where 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

Source

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.

Source

pub fn producer(name: impl Into<String>, span: Span) -> Self

A traversal source naming a producer bound in the same scope.

Source

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.

Source

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.

Source

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§

Source§

impl Clone for ForSource

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ForSource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.