pub trait Vector<T, const LEN: usize>: IntoIterator {
    fn name(&self) -> &'static str;
    fn as_array(self) -> [T; LEN];
    fn as_vec(self) -> Vec<T>;

    fn size(&self) -> usize { ... }
    fn fields(&self) -> usize { ... }
}
Expand description

Trait for structs that represent a Vector, will be implemented by default when using the impl_vector Macro.

Required Methods

Returns the name of the Vector struct.

Example
let vector = Vector4::new(0, 0, 0, 0);
assert_eq!(vector.name(), "Vector4");

Converts the given Vector into an array coresponding to the size of the Vector.

Example
let vector = Vector3::new(1, 2, 3);
assert_eq!(vector.as_array(), [1, 2, 3]);

Converts the given Vector into a Vec coresponding to the size of the Vector.

Example
let vector = Vector3::new(1, 2, 3);
assert_eq!(vector.as_vec(), vec![1, 2, 3]);

Provided Methods

Returns the size of the Vector struct in bytes.

Example
let vector = Vector2::<u16>::new(0, 0);
assert_eq!(vector.size(), 4);

Returns the number of fields in the Vector struct.

Example
let vec2 = Vector2::new(0, 0);
let vec3 = Vector3::new(0, 0, 0);
let vec4 = Vector4::new(0, 0, 0, 0);
 
assert_eq!(vec2.len(), 2);
assert_eq!(vec3.len(), 3);
assert_eq!(vec4.len(), 4);

Implementors