Skip to main content

Convert

Trait Convert 

Source
pub trait Convert:
    Sized
    + Clone
    + Ty {
    // Required method
    fn convert_to(&self, ty: &Type) -> Option<Self>;

    // Provided methods
    fn convert_inner_to(&self, ty: &Type) -> Option<Self> { ... }
    fn concretize(&self) -> Option<Self> { ... }
}

Required Methods§

Source

fn convert_to(&self, ty: &Type) -> Option<Self>

Convert an instance to another type, if a feasible conversion exists.

E.g. array<u32>.convert_inner_to(array<f32>) becomes array<f32>.

Reference: https://www.w3.org/TR/WGSL/#conversion-rank

Provided Methods§

Source

fn convert_inner_to(&self, ty: &Type) -> Option<Self>

Convert an instance by changing its inner type to another.

E.g. array<u32>.convert_inner_to(f32) becomes array<f32>.

Identical to Convert::convert_to if the type has no inner type. Does not check that the resulting type exists, e.g. i32 is not a valid inner type for matrix types.

See Ty::inner_ty See Convert::convert_to

Source

fn concretize(&self) -> Option<Self>

Convert an abstract instance to a concrete type.

E.g. array<vec<AbstractInt>> becomes array<vec<i32>>.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§