Expose the underlying array in addition to a ptr to the same

This commit is contained in:
Matt Corallo 2020-05-28 18:57:43 -04:00
parent a5147bbf01
commit 0052bc92fb
1 changed files with 7 additions and 0 deletions

View File

@ -34,6 +34,13 @@ macro_rules! impl_array_newtype {
dat.as_mut_ptr() dat.as_mut_ptr()
} }
#[inline]
/// Gets a reference to the underlying array
pub fn as_ref(&self) -> &[$ty; $len] {
let &$thing(ref dat) = self;
dat
}
#[inline] #[inline]
/// Returns the length of the object as an array /// Returns the length of the object as an array
pub fn len(&self) -> usize { $len } pub fn len(&self) -> usize { $len }