pub trait ScalarComposite:
Copy
+ Send
+ Sync
+ 'static {
// Required method
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self;
}Expand description
A ScalarComposite is a type that is either
- a
Scalar - a
Vector(since vectors are made from scalars) - an array of
ScalarComposite - a struct where all members are
ScalarComposite - an enum with a
reprthat is aScalar
By calling Self::transform you can visit all the individual Scalar and Vector values this composite is
build out of and transform them into some other value. This is particularly useful for subgroup intrinsics sending
data to other threads.
To derive ScalarComposite on a struct, all members must also implement ScalarComposite.
To derive ScalarComposite on an enum, the enum must implement From<N> and Into<N> where N is defined by the
#[repr(N)] attribute on the enum and must be an Integer, like u32.
Note that some safe subgroup operations may return an “undefined result”, so your From<N> must gracefully handle
arbitrary bit patterns being passed to it. While panicking is legal, it is discouraged as it may result in
unexpected control flow.
To implement these conversion traits, we recommend FromPrimitive and IntoPrimitive from the num_enum
crate. FromPrimitive requires the enum to either be exhaustive or have a variant to default to, by either
implementing Default or marking a variant with #[num_enum(default)]. Note to disable default
features on the num_enum crate, or it won’t compile on SPIR-V.
Required Methods§
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.
Implementations on Foreign Types§
Source§impl ScalarComposite for bool
impl ScalarComposite for bool
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for f32
impl ScalarComposite for f32
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for f64
impl ScalarComposite for f64
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for i8
impl ScalarComposite for i8
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for i16
impl ScalarComposite for i16
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for i32
impl ScalarComposite for i32
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for i64
impl ScalarComposite for i64
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for u8
impl ScalarComposite for u8
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for u16
impl ScalarComposite for u16
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for u32
impl ScalarComposite for u32
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for u64
impl ScalarComposite for u64
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for BVec2
impl ScalarComposite for BVec2
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for BVec3
impl ScalarComposite for BVec3
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for BVec4
impl ScalarComposite for BVec4
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for Vec3A
impl ScalarComposite for Vec3A
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for Vec4
impl ScalarComposite for Vec4
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for Vec2
impl ScalarComposite for Vec2
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for Vec3
impl ScalarComposite for Vec3
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for DVec2
impl ScalarComposite for DVec2
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for DVec3
impl ScalarComposite for DVec3
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for DVec4
impl ScalarComposite for DVec4
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for IVec2
impl ScalarComposite for IVec2
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for IVec3
impl ScalarComposite for IVec3
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for IVec4
impl ScalarComposite for IVec4
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for UVec2
impl ScalarComposite for UVec2
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for UVec3
impl ScalarComposite for UVec3
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl ScalarComposite for UVec4
impl ScalarComposite for UVec4
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self
Source§impl<T: ScalarComposite + Default, const N: usize> ScalarComposite for [T; N]
Default is unfortunately necessary until rust-gpu improves
impl<T: ScalarComposite + Default, const N: usize> ScalarComposite for [T; N]
Default is unfortunately necessary until rust-gpu improves