Skip to main content

ToWgsl

Trait ToWgsl 

pub trait ToWgsl: Sized {
    // Required method
    fn to_wgsl(self) -> &'static str;
}
Available on crate feature unstable-wgpu-28 only.
Expand description

Types that can return the WGSL source representation of their values as a 'static string.

This trait is specifically for types whose WGSL forms are simple enough that they can always be returned as a static string.

  • If only some values have a WGSL representation, consider implementing TryToWgsl instead.

  • If a type’s WGSL form requires dynamic formatting, so that returning a &'static str isn’t feasible, consider implementing core::fmt::Display on some wrapper type instead.

Required Methods§

fn to_wgsl(self) -> &'static str

Return WGSL source code representation of self.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§