pub trait TryToWgsl: Sized {
const DESCRIPTION: &'static str;
// Required method
fn try_to_wgsl(self) -> Option<&'static str>;
// Provided method
fn to_wgsl_for_diagnostics(self) -> String
where Self: Debug + Copy { ... }
}Expand description
Types that may be able to return the WGSL source representation
for their values as a 'static string.
This trait is specifically for types whose values are either simple enough that their WGSL form can be represented a static string, or aren’t representable in WGSL at all.
-
If all values in the type have
&'static strrepresentations in WGSL, consider implementingToWgslinstead. -
If a type’s WGSL form requires dynamic formatting, so that returning a
&'static strisn’t feasible, consider implementingcore::fmt::Displayon some wrapper type instead.
Required Associated Constants§
Sourceconst DESCRIPTION: &'static str
const DESCRIPTION: &'static str
What kind of WGSL thing Self represents.
Required Methods§
Sourcefn try_to_wgsl(self) -> Option<&'static str>
fn try_to_wgsl(self) -> Option<&'static str>
Return the WGSL form of self as a 'static string.
If self doesn’t have a representation in WGSL (standard or
as extended by Naga), then return None.
Provided Methods§
Sourcefn to_wgsl_for_diagnostics(self) -> String
fn to_wgsl_for_diagnostics(self) -> String
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.