Merge pull request #219 from TheBlueMatt/master

Expose the underlying array in addition to a ptr to the same
This commit is contained in:
Matt Corallo 2020-07-21 20:13:57 -07:00 committed by GitHub
commit c9741d4846
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -34,6 +34,13 @@ macro_rules! impl_array_newtype {
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]
/// Returns the length of the object as an array
pub fn len(&self) -> usize { $len }