pub trait Scalar:
Copy
+ ScalarBackend<2, Aligned>
+ ScalarBackend<3, Aligned>
+ ScalarBackend<4, Aligned>
+ ScalarBackend<2, Unaligned>
+ ScalarBackend<3, Unaligned>
+ ScalarBackend<4, Unaligned> { }Expand description
A trait for types that can be stored in vectors.
All scalars must implement the Copy trait, and the
ScalarBackend<N, A> trait which controls the internal representation and
function implementations of the scalar’s math types.
For simple implementations there is the ScalarDefault trait which
provides a default implementation for ScalarBackend.
§Example
use ggmath::{Scalar, ScalarDefault, Vec2, Vec3, Vec4, vec2, vec3, vec4};
#[derive(Debug, Clone, Copy)]
struct Foo(f32);
impl Scalar for Foo {}
impl ScalarDefault for Foo {}
let v2: Vec2<Foo> = vec2!(Foo(1.0), Foo(2.0));
let v3: Vec3<Foo> = vec3!(Foo(1.0), Foo(2.0), Foo(3.0));
let v4: Vec4<Foo> = vec4!(Foo(1.0), Foo(2.0), Foo(3.0), Foo(4.0));
println!("{v2:?}, {v3:?}, {v4:?}");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.