Constructor

Enum Constructor 

Source
pub enum Constructor<T> {
    PartialVector {
        size: VectorSize,
    },
    PartialMatrix {
        columns: VectorSize,
        rows: VectorSize,
    },
    PartialArray,
    Type(T),
}
Expand description

A constructor built-in function.

WGSL has two types of such functions:

  • 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 both cases. The PartialFoo variants represent the second case, where the component type is implicit.

Variants§

§

PartialVector

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

Fields

§

PartialMatrix

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

Fields

§columns: VectorSize
§

PartialArray

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

§

Type(T)

A known Naga type.

When we match on this type, we need to see the TypeInner here, but at the point that we build this value we’ll still need mutable access to the module later. To avoid borrowing from the module, the type parameter T is Handle<Type> initially. Then we use borrow_inner to produce a version holding a tuple (Handle<Type>, &TypeInner).

Implementations§

Source§

impl Constructor<Handle<Type>>

Source

fn borrow_inner( self, module: &Module, ) -> Constructor<(Handle<Type>, &TypeInner)>

Return an equivalent Constructor value that includes borrowed TypeInner values alongside any type handles.

The returned form is more convenient to match on, since the patterns can actually see what the handle refers to.

Auto Trait Implementations§

§

impl<T> Freeze for Constructor<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Constructor<T>
where T: RefUnwindSafe,

§

impl<T> Send for Constructor<T>
where T: Send,

§

impl<T> Sync for Constructor<T>
where T: Sync,

§

impl<T> Unpin for Constructor<T>
where T: Unpin,

§

impl<T> UnwindSafe for Constructor<T>
where T: UnwindSafe,

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.