TemplateElaboratedIdent

Struct TemplateElaboratedIdent 

Source
pub struct TemplateElaboratedIdent<'a> {
    pub ident: IdentExpr<'a>,
    pub ident_span: Span,
    pub template_list: Vec<Handle<Expression<'a>>>,
    pub template_list_span: Span,
}
Expand description

An identifier with optional template parameters.

Following the WGSL specification (see the template_list non-terminal), TemplateElaboratedIdent represents all template parameters as expressions: even parameters to type generators, like the f32 in vec3<f32>, are Type Expressions.

§Examples

  • A use of a global variable colors would be an Expression::Ident(v), where v is an TemplateElaboratedIdent whose ident is IdentExpr::Unresolved("colors"). Lowering will resolve this to a reference to the global variable.

  • The type f32 in a variable declaration is represented as a TemplateElaboratedIdent whose ident is IdentExpr::Unresolved("f32"). Lowering will resolve this to WGSL’s predeclared f32 type.

  • The type vec3<f32> can be represented as a TemplateElaboratedIdent whose ident is IdentExpr::Unresolved("vec3"), and whose template_list has one element: an ExpressionIdent(v) where v is a nested TemplateElaboratedIdent representing f32 as described above.

  • The type array<vec3<f32>, 4> has "array" as its ident, and then a two-element template_list:

    • template_list[0] is an Expression::Ident(v) where v is a nested TemplateElaboratedIdent representing vec3<f32> as described above.

    • template_list[1] is an Expression representing 4.

After indexing the module to ensure that declarations appear before uses, lowering can see which declaration a given TemplateElaboratedIdents ident refers to. The declaration then determines how to interpret the template_list.

Fields§

§ident: IdentExpr<'a>§ident_span: Span§template_list: Vec<Handle<Expression<'a>>>

If non-empty, the template parameters following the identifier.

§template_list_span: Span

Trait Implementations§

Source§

impl<'a> Debug for TemplateElaboratedIdent<'a>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.