Trait naga::proc::constant_evaluator::TryFromAbstract
source · trait TryFromAbstract<T>: Sized {
// Required method
fn try_from_abstract(value: T) -> Result<Self, ConstantEvaluatorError>;
}
Expand description
Trait for conversions of abstract values to concrete types.
Required Methods§
sourcefn try_from_abstract(value: T) -> Result<Self, ConstantEvaluatorError>
fn try_from_abstract(value: T) -> Result<Self, ConstantEvaluatorError>
Convert an abstract literal value
to Self
.
Since Naga’s AbstractInt
and AbstractFloat
exist to support
WGSL, we follow WGSL’s conversion rules here:
-
WGSL §6.1.2. Conversion Rank says that automatic conversions to integers are either lossless or an error.
-
WGSL §14.6.4 Floating Point Conversion says that conversions to floating point in constant expressions and override expressions are errors if the value is out of range for the destination type, but rounding is okay.
Object Safety§
This trait is not object safe.