use crate::base::storage::{RawStorage, RawStorageMut}; use crate::{OVector, Point, Scalar}; use std::convert::{AsMut, AsRef}; macro_rules! impl_from_into_mint_1D( ($($NRows: expr => $PT:ident, $VT:ident [$SZ: expr]);* $(;)*) => {$( impl From> for Point where T: Scalar { #[inline] fn from(p: mint::$PT) -> Self { Self { coords: OVector::from(mint::$VT::from(p)), } } } impl Into> for Point where T: Scalar { #[inline] fn into(self) -> mint::$PT { let mint_vec: mint::$VT = self.coords.into(); mint::$PT::from(mint_vec) } } impl AsRef> for Point where T: Scalar { #[inline] fn as_ref(&self) -> &mint::$PT { unsafe { &*(self.coords.data.ptr() as *const mint::$PT) } } } impl AsMut> for Point where T: Scalar { #[inline] fn as_mut(&mut self) -> &mut mint::$PT { unsafe { &mut *(self.coords.data.ptr_mut() as *mut mint::$PT) } } } )*} ); // Implement for points of dimension 2, 3. impl_from_into_mint_1D!( 2 => Point2, Vector2[2]; 3 => Point3, Vector3[3]; );