Enum naga::front::wgsl::parse::ast::ConstructorType

source ·
pub enum ConstructorType<'a> {
    Scalar(Scalar),
    PartialVector {
        size: VectorSize,
    },
    Vector {
        size: VectorSize,
        ty: Handle<Type<'a>>,
        ty_span: Span,
    },
    PartialMatrix {
        columns: VectorSize,
        rows: VectorSize,
    },
    Matrix {
        columns: VectorSize,
        rows: VectorSize,
        ty: Handle<Type<'a>>,
        ty_span: Span,
    },
    PartialArray,
    Array {
        base: Handle<Type<'a>>,
        size: ArraySize<'a>,
    },
    Type(Handle<Type>),
}
Expand description

A type at the head of a Construct expression.

WGSL has two types of type constructor expressions:

  • Those that fully specify the type being constructed, like vec3<f32>(x,y,z), which obviously constructs a vec3<f32>.

  • Those that leave the component type of the composite being constructed implicit, to be inferred from the argument types, like vec3(x,y,z), which constructs a vec3<T> where T is the type of x, y, and z.

This enum represents the head type of both cases. The PartialFoo variants represent the second case, where the component type is implicit.

This does not cover structs or types referred to by type aliases. See the documentation for Construct and Call expressions for details.

Variants§

§

Scalar(Scalar)

A scalar type or conversion: f32(1).

§

PartialVector

A vector construction whose component type is inferred from the argument: vec3(1.0).

Fields

§

Vector

A vector construction whose component type is written out: vec3<f32>(1.0).

Fields

§ty: Handle<Type<'a>>
§ty_span: Span
§

PartialMatrix

A matrix construction whose component type is inferred from the argument: mat2x2(1,2,3,4).

Fields

§columns: VectorSize
§

Matrix

A matrix construction whose component type is written out: mat2x2<f32>(1,2,3,4).

Fields

§columns: VectorSize
§ty: Handle<Type<'a>>
§ty_span: Span
§

PartialArray

An array whose component type and size are inferred from the arguments: array(3,4,5).

§

Array

An array whose component type and size are written out: array<u32, 4>(3,4,5).

Fields

§base: Handle<Type<'a>>
§size: ArraySize<'a>
§

Type(Handle<Type>)

Constructing a value of a known Naga IR type.

This variant is produced only during lowering, when we have Naga types available, never during parsing.

Trait Implementations§

source§

impl<'a> Debug for ConstructorType<'a>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ConstructorType<'a>

§

impl<'a> RefUnwindSafe for ConstructorType<'a>

§

impl<'a> Send for ConstructorType<'a>

§

impl<'a> Sync for ConstructorType<'a>

§

impl<'a> Unpin for ConstructorType<'a>

§

impl<'a> UnwindSafe for ConstructorType<'a>

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>,

§

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>,

§

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.