pub trait HasXY:
Sync
+ Send
+ Copy
+ Debug
+ Sized {
type Scalar: GenericScalar;
// Required methods
fn new_2d(x: Self::Scalar, y: Self::Scalar) -> Self;
fn x(self) -> Self::Scalar;
fn x_mut(&mut self) -> &mut Self::Scalar;
fn set_x(&mut self, val: Self::Scalar);
fn y(self) -> Self::Scalar;
fn y_mut(&mut self) -> &mut Self::Scalar;
fn set_y(&mut self, val: Self::Scalar);
}Expand description
A basic two-dimensional vector trait, designed for flexibility in precision.
The HasXY trait abstracts over two-dimensional vectors, allowing for easy
transition between different precisions (e.g., f32 and f64) without necessitating
significant codebase modifications. It only provides the most basic vector interface.
It is intended to be used in situations where you need a custom storage type of vectors.
For example a FFI type.
Implementors of this trait can benefit from the ability to switch between different precision representations seamlessly, making it ideal for applications where varying precision levels might be desirable at different stages or configurations.
The associated Scalar type represents the scalar type (e.g., f32 or f64) used
by the vector.
Required Associated Types§
type Scalar: GenericScalar
Required Methods§
Sourcefn new_2d(x: Self::Scalar, y: Self::Scalar) -> Self
fn new_2d(x: Self::Scalar, y: Self::Scalar) -> Self
create a new instance of Self, note that this creates a 3d vector if the instanced type is a 3d type
fn x(self) -> Self::Scalar
fn x_mut(&mut self) -> &mut Self::Scalar
fn set_x(&mut self, val: Self::Scalar)
fn y(self) -> Self::Scalar
fn y_mut(&mut self) -> &mut Self::Scalar
fn set_y(&mut self, val: Self::Scalar)
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.