Trait ScalarComposite

Source
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 repr that is a Scalar

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§

Source

fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self

Transform the individual Scalar and Vector values of this type to a different value.

See Self for more detail.

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

Source§

impl ScalarComposite for f32

Source§

impl ScalarComposite for f64

Source§

impl ScalarComposite for i8

Source§

impl ScalarComposite for i16

Source§

impl ScalarComposite for i32

Source§

impl ScalarComposite for i64

Source§

impl ScalarComposite for u8

Source§

impl ScalarComposite for u16

Source§

impl ScalarComposite for u32

Source§

impl ScalarComposite for u64

Source§

impl ScalarComposite for BVec2

Source§

impl ScalarComposite for BVec3

Source§

impl ScalarComposite for BVec4

Source§

impl ScalarComposite for Vec3A

Source§

impl ScalarComposite for Vec4

Source§

impl ScalarComposite for Vec2

Source§

impl ScalarComposite for Vec3

Source§

impl ScalarComposite for DVec2

Source§

impl ScalarComposite for DVec3

Source§

impl ScalarComposite for DVec4

Source§

impl ScalarComposite for IVec2

Source§

impl ScalarComposite for IVec3

Source§

impl ScalarComposite for IVec4

Source§

impl ScalarComposite for UVec2

Source§

impl ScalarComposite for UVec3

Source§

impl ScalarComposite for UVec4

Source§

impl<T: ScalarComposite + Default, const N: usize> ScalarComposite for [T; N]

Default is unfortunately necessary until rust-gpu improves

Implementors§