diff --git a/src/accelerometer_noise.rs b/src/accelerometer_noise.rs index 596bac6..5b3ba77 100644 --- a/src/accelerometer_noise.rs +++ b/src/accelerometer_noise.rs @@ -1,7 +1,9 @@ use crate::impl_standard_traits; use core::fmt::{Debug, Formatter}; use core::ops::Mul; +use uniform_array_derive::UniformArray; +#[derive(UniformArray)] #[cfg_attr(test, ensure_uniform_type::ensure_uniform_type)] #[repr(C)] pub struct AccelerometerNoise { @@ -19,13 +21,6 @@ impl AccelerometerNoise { pub const fn new(x: T, y: T, z: T) -> Self { Self { x, y, z } } - - /// Returns the length of the [`AccelerometerNoise`] vector. - #[inline(always)] - #[allow(clippy::len_without_is_empty)] - pub const fn len(&self) -> usize { - 3 - } } impl Default for AccelerometerNoise @@ -79,34 +74,6 @@ where } } -#[cfg(not(feature = "unsafe"))] -impl core::ops::Index for AccelerometerNoise { - type Output = T; - - #[inline(always)] - fn index(&self, index: usize) -> &Self::Output { - match index { - 0 => &self.x, - 1 => &self.y, - 2 => &self.z, - _ => panic!("Index out of bounds"), - } - } -} - -#[cfg(not(feature = "unsafe"))] -impl core::ops::IndexMut for AccelerometerNoise { - #[inline(always)] - fn index_mut(&mut self, index: usize) -> &mut Self::Output { - match index { - 0 => &mut self.x, - 1 => &mut self.y, - 2 => &mut self.z, - _ => panic!("Index out of bounds"), - } - } -} - impl_standard_traits!(AccelerometerNoise, T); #[cfg(test)] diff --git a/src/accelerometer_reading.rs b/src/accelerometer_reading.rs index cf3db69..5da998a 100644 --- a/src/accelerometer_reading.rs +++ b/src/accelerometer_reading.rs @@ -1,7 +1,9 @@ use crate::impl_standard_traits; use core::fmt::{Debug, Formatter}; use core::ops::Mul; +use uniform_array_derive::UniformArray; +#[derive(UniformArray)] #[cfg_attr(test, ensure_uniform_type::ensure_uniform_type)] #[repr(C)] pub struct AccelerometerReading { @@ -35,13 +37,6 @@ impl AccelerometerReading { z: coordinate.z(), } } - - /// Returns the length of the [`AccelerometerReading`] vector. - #[inline(always)] - #[allow(clippy::len_without_is_empty)] - pub const fn len(&self) -> usize { - 3 - } } impl Default for AccelerometerReading @@ -107,34 +102,6 @@ where } } -#[cfg(not(feature = "unsafe"))] -impl core::ops::Index for AccelerometerReading { - type Output = T; - - #[inline(always)] - fn index(&self, index: usize) -> &Self::Output { - match index { - 0 => &self.x, - 1 => &self.y, - 2 => &self.z, - _ => panic!("Index out of bounds"), - } - } -} - -#[cfg(not(feature = "unsafe"))] -impl core::ops::IndexMut for AccelerometerReading { - #[inline(always)] - fn index_mut(&mut self, index: usize) -> &mut Self::Output { - match index { - 0 => &mut self.x, - 1 => &mut self.y, - 2 => &mut self.z, - _ => panic!("Index out of bounds"), - } - } -} - impl_standard_traits!(AccelerometerReading, T); #[cfg(test)] diff --git a/src/euler_angles.rs b/src/euler_angles.rs index ac3d800..b68cf6b 100644 --- a/src/euler_angles.rs +++ b/src/euler_angles.rs @@ -1,6 +1,8 @@ use crate::impl_standard_traits; use core::fmt::{Debug, Formatter}; +use uniform_array_derive::UniformArray; +#[derive(UniformArray)] #[cfg_attr(test, ensure_uniform_type::ensure_uniform_type)] #[repr(C)] pub struct EulerAngles { @@ -22,14 +24,6 @@ impl EulerAngles { yaw_psi, } } - - /// Returns the length of the [`EulerAngles`] vector. - #[inline(always)] - #[allow(unused)] - #[allow(clippy::len_without_is_empty)] - pub const fn len(&self) -> usize { - 3 - } } impl Default for EulerAngles @@ -68,36 +62,6 @@ where } } -#[cfg_attr(docsrs, doc(cfg(not(feature = "unsafe"))))] -#[cfg(not(feature = "unsafe"))] -impl core::ops::Index for EulerAngles { - type Output = T; - - #[inline(always)] - fn index(&self, index: usize) -> &Self::Output { - match index { - 0 => &self.roll_phi, - 1 => &self.pitch_theta, - 2 => &self.yaw_psi, - _ => panic!("Index out of bounds"), - } - } -} - -#[cfg_attr(docsrs, doc(cfg(not(feature = "unsafe"))))] -#[cfg(not(feature = "unsafe"))] -impl core::ops::IndexMut for EulerAngles { - #[inline(always)] - fn index_mut(&mut self, index: usize) -> &mut Self::Output { - match index { - 0 => &mut self.roll_phi, - 1 => &mut self.pitch_theta, - 2 => &mut self.yaw_psi, - _ => panic!("Index out of bounds"), - } - } -} - impl_standard_traits!(EulerAngles, T); #[cfg(test)] diff --git a/src/gyroscope_bias.rs b/src/gyroscope_bias.rs index 8ae1bb6..d863657 100644 --- a/src/gyroscope_bias.rs +++ b/src/gyroscope_bias.rs @@ -1,7 +1,9 @@ use crate::impl_standard_traits; use core::fmt::{Debug, Formatter}; use core::ops::{Mul, Sub}; +use uniform_array_derive::UniformArray; +#[derive(UniformArray)] #[cfg_attr(test, ensure_uniform_type::ensure_uniform_type)] #[repr(C)] pub struct GyroscopeBias { @@ -23,14 +25,6 @@ impl GyroscopeBias { omega_z, } } - - /// Returns the length of the [`GyroscopeBias`] vector. - #[inline(always)] - #[allow(unused)] - #[allow(clippy::len_without_is_empty)] - pub const fn len(&self) -> usize { - 3 - } } impl Default for GyroscopeBias @@ -99,34 +93,6 @@ where } } -#[cfg(not(feature = "unsafe"))] -impl core::ops::Index for GyroscopeBias { - type Output = T; - - #[inline(always)] - fn index(&self, index: usize) -> &Self::Output { - match index { - 0 => &self.omega_x, - 1 => &self.omega_y, - 2 => &self.omega_z, - _ => panic!("Index out of bounds"), - } - } -} - -#[cfg(not(feature = "unsafe"))] -impl core::ops::IndexMut for GyroscopeBias { - #[inline(always)] - fn index_mut(&mut self, index: usize) -> &mut Self::Output { - match index { - 0 => &mut self.omega_x, - 1 => &mut self.omega_y, - 2 => &mut self.omega_z, - _ => panic!("Index out of bounds"), - } - } -} - impl_standard_traits!(GyroscopeBias, T); #[cfg(test)] diff --git a/src/gyroscope_noise.rs b/src/gyroscope_noise.rs index 1c8dcda..f1b3160 100644 --- a/src/gyroscope_noise.rs +++ b/src/gyroscope_noise.rs @@ -1,7 +1,9 @@ use crate::impl_standard_traits; use core::fmt::{Debug, Formatter}; use core::ops::Mul; +use uniform_array_derive::UniformArray; +#[derive(UniformArray)] #[cfg_attr(test, ensure_uniform_type::ensure_uniform_type)] #[repr(C)] pub struct GyroscopeNoise { @@ -19,13 +21,6 @@ impl GyroscopeNoise { pub const fn new(x: T, y: T, z: T) -> Self { Self { x, y, z } } - - /// Returns the length of the [`GyroscopeNoise`] vector. - #[inline(always)] - #[allow(clippy::len_without_is_empty)] - pub const fn len(&self) -> usize { - 3 - } } impl Default for GyroscopeNoise @@ -79,34 +74,6 @@ where } } -#[cfg(not(feature = "unsafe"))] -impl core::ops::Index for GyroscopeNoise { - type Output = T; - - #[inline(always)] - fn index(&self, index: usize) -> &Self::Output { - match index { - 0 => &self.x, - 1 => &self.y, - 2 => &self.z, - _ => panic!("Index out of bounds"), - } - } -} - -#[cfg(not(feature = "unsafe"))] -impl core::ops::IndexMut for GyroscopeNoise { - #[inline(always)] - fn index_mut(&mut self, index: usize) -> &mut Self::Output { - match index { - 0 => &mut self.x, - 1 => &mut self.y, - 2 => &mut self.z, - _ => panic!("Index out of bounds"), - } - } -} - impl_standard_traits!(GyroscopeNoise, T); #[cfg(test)] diff --git a/src/gyroscope_reading.rs b/src/gyroscope_reading.rs index 92ffbf5..597c1cd 100644 --- a/src/gyroscope_reading.rs +++ b/src/gyroscope_reading.rs @@ -1,7 +1,9 @@ use crate::impl_standard_traits; use core::fmt::{Debug, Formatter}; use core::ops::{Mul, Sub}; +use uniform_array_derive::UniformArray; +#[derive(UniformArray)] #[cfg_attr(test, ensure_uniform_type::ensure_uniform_type)] #[repr(C)] pub struct GyroscopeReading { @@ -39,14 +41,6 @@ impl GyroscopeReading { omega_z: coordinate.z(), } } - - /// Returns the length of the [`GyroscopeReading`] vector. - #[inline(always)] - #[allow(unused)] - #[allow(clippy::len_without_is_empty)] - pub const fn len(&self) -> usize { - 3 - } } impl Default for GyroscopeReading @@ -127,34 +121,6 @@ where } } -#[cfg(not(feature = "unsafe"))] -impl core::ops::Index for GyroscopeReading { - type Output = T; - - #[inline(always)] - fn index(&self, index: usize) -> &Self::Output { - match index { - 0 => &self.omega_x, - 1 => &self.omega_y, - 2 => &self.omega_z, - _ => panic!("Index out of bounds"), - } - } -} - -#[cfg(not(feature = "unsafe"))] -impl core::ops::IndexMut for GyroscopeReading { - #[inline(always)] - fn index_mut(&mut self, index: usize) -> &mut Self::Output { - match index { - 0 => &mut self.omega_x, - 1 => &mut self.omega_y, - 2 => &mut self.omega_z, - _ => panic!("Index out of bounds"), - } - } -} - impl_standard_traits!(GyroscopeReading, T); #[cfg(test)] diff --git a/src/magnetometer_noise.rs b/src/magnetometer_noise.rs index e3e81d9..ebcfdfb 100644 --- a/src/magnetometer_noise.rs +++ b/src/magnetometer_noise.rs @@ -1,7 +1,9 @@ use crate::impl_standard_traits; use core::fmt::{Debug, Formatter}; use core::ops::Mul; +use uniform_array_derive::UniformArray; +#[derive(UniformArray)] #[cfg_attr(test, ensure_uniform_type::ensure_uniform_type)] #[repr(C)] pub struct MagnetometerNoise { @@ -19,13 +21,6 @@ impl MagnetometerNoise { pub const fn new(x: T, y: T, z: T) -> Self { Self { x, y, z } } - - /// Returns the length of the [`MagnetometerNoise`] vector. - #[inline(always)] - #[allow(clippy::len_without_is_empty)] - pub const fn len(&self) -> usize { - 3 - } } impl Default for MagnetometerNoise @@ -79,34 +74,6 @@ where } } -#[cfg(not(feature = "unsafe"))] -impl core::ops::Index for MagnetometerNoise { - type Output = T; - - #[inline(always)] - fn index(&self, index: usize) -> &Self::Output { - match index { - 0 => &self.x, - 1 => &self.y, - 2 => &self.z, - _ => panic!("Index out of bounds"), - } - } -} - -#[cfg(not(feature = "unsafe"))] -impl core::ops::IndexMut for MagnetometerNoise { - #[inline(always)] - fn index_mut(&mut self, index: usize) -> &mut Self::Output { - match index { - 0 => &mut self.x, - 1 => &mut self.y, - 2 => &mut self.z, - _ => panic!("Index out of bounds"), - } - } -} - impl_standard_traits!(MagnetometerNoise, T); #[cfg(test)] diff --git a/src/magnetometer_reading.rs b/src/magnetometer_reading.rs index 3c854b1..77ca840 100644 --- a/src/magnetometer_reading.rs +++ b/src/magnetometer_reading.rs @@ -1,7 +1,9 @@ use crate::impl_standard_traits; use core::fmt::{Debug, Formatter}; use core::ops::Mul; +use uniform_array_derive::UniformArray; +#[derive(UniformArray)] #[cfg_attr(test, ensure_uniform_type::ensure_uniform_type)] #[repr(C)] pub struct MagnetometerReading { @@ -36,13 +38,6 @@ impl MagnetometerReading { } } - /// Returns the length of the [`MagnetometerReading`] vector. - #[inline(always)] - #[allow(clippy::len_without_is_empty)] - pub const fn len(&self) -> usize { - 3 - } - /// Represents this reading as a tuple. pub fn as_tuple(&self) -> (T, T, T) where @@ -115,34 +110,6 @@ where } } -#[cfg(not(feature = "unsafe"))] -impl core::ops::Index for MagnetometerReading { - type Output = T; - - #[inline(always)] - fn index(&self, index: usize) -> &Self::Output { - match index { - 0 => &self.x, - 1 => &self.y, - 2 => &self.z, - _ => panic!("Index out of bounds"), - } - } -} - -#[cfg(not(feature = "unsafe"))] -impl core::ops::IndexMut for MagnetometerReading { - #[inline(always)] - fn index_mut(&mut self, index: usize) -> &mut Self::Output { - match index { - 0 => &mut self.x, - 1 => &mut self.y, - 2 => &mut self.z, - _ => panic!("Index out of bounds"), - } - } -} - impl_standard_traits!(MagnetometerReading, T); #[cfg(test)] diff --git a/src/vector3.rs b/src/vector3.rs index b2a0ad1..1194b67 100644 --- a/src/vector3.rs +++ b/src/vector3.rs @@ -4,9 +4,10 @@ use core::borrow::Borrow; use core::fmt::{Debug, Formatter}; use core::ops::{Add, Mul, Neg, Sub}; use minikalman::matrix::MatrixDataType; +use uniform_array_derive::UniformArray; /// A three-dimensional vector. -#[derive(uniform_array_derive::UniformArray, Copy)] +#[derive(UniformArray, Copy)] #[cfg_attr(test, ensure_uniform_type::ensure_uniform_type)] #[repr(C)] pub struct Vector3 {