Trait bevy_hanabi::ToWgslString
source · pub trait ToWgslString {
// Required method
fn to_wgsl_string(&self) -> String;
}
Expand description
Extension trait to convert an object to WGSL code.
This is mainly used for floating-point constants. This is required because
WGSL doesn’t support a floating point constant without a decimal separator
(e.g. 0.
instead of 0
), which would be what a regular string
formatting function like format!()
would produce, but which is
interpreted as an integral type by WGSL instead.
§Example
let x = 2.0_f32;
assert_eq!("let x = 2.;", format!("let x = {};", x.to_wgsl_string()));
§Remark
This trait is soft-deprecated. It serves the same purpose as
EvalContext::eval()
, however it lacks any context for the evaluation of
an expression producing WGSL code, so its use is limited. It’s still useful
for constant (literal) expressions, which do not require any context to
evaluate.
Required Methods§
sourcefn to_wgsl_string(&self) -> String
fn to_wgsl_string(&self) -> String
Convert an object to a string representing its WGSL code.