mod private
{
use core::
{
fmt,
ops::{ Add, Mul },
cmp::PartialOrd,
};
pub trait MdOffset< T >
{
fn md_offset( & self, md_index : Self ) -> T;
}
impl< T > MdOffset< T > for [ T ; 2 ]
where
T : Mul< T, Output = T > + Add< T, Output = T > + PartialOrd + Copy + fmt::Debug,
{
fn md_offset( & self, md_index : [ T ; 2 ] ) -> T
{
debug_assert!( md_index[ 0 ] < self[ 0 ], "md_index : {md_index:?} | md_size : {self:?}" );
debug_assert!( md_index[ 1 ] < self[ 1 ], "md_index : {md_index:?} | md_size : {self:?}" );
let m1 = self[ 0 ];
md_index[ 0 ] + m1 * md_index[ 1 ]
}
}
impl< T > MdOffset< T > for [ T ; 3 ]
where
T : Mul< T, Output = T > + Add< T, Output = T > + PartialOrd + Copy + fmt::Debug,
{
fn md_offset( & self, md_index : [ T ; 3 ] ) -> T
{
debug_assert!( md_index[ 0 ] < self[ 0 ], "md_index : {md_index:?} | md_size : {self:?}" );
debug_assert!( md_index[ 1 ] < self[ 1 ], "md_index : {md_index:?} | md_size : {self:?}" );
debug_assert!( md_index[ 2 ] < self[ 2 ], "md_index : {md_index:?} | md_size : {self:?}" );
let m1 = self[ 0 ];
let m2 = m1 * self[ 1 ];
md_index[ 0 ] + m1 * md_index[ 1 ] + m2 * md_index[ 2 ]
}
}
}
#[ allow( unused_imports ) ]
pub use own::*;
#[ allow( unused_imports ) ]
pub mod own
{
use super::*;
#[ doc( inline ) ]
pub use orphan::*;
#[ doc( inline ) ]
pub use private::
{
MdOffset,
};
}
#[ allow( unused_imports ) ]
pub mod orphan
{
use super::*;
#[ doc( inline ) ]
pub use exposed::*;
}
#[ allow( unused_imports ) ]
pub mod exposed
{
use super::*;
pub use super::super::md_math;
}
#[ allow( unused_imports ) ]
pub mod prelude
{
use super::*;
}