From 0052bc92fb88aaa0c146448858c7b516e37f32a7 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 28 May 2020 18:57:43 -0400 Subject: [PATCH] Expose the underlying array in addition to a ptr to the same --- secp256k1-sys/src/macros.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/secp256k1-sys/src/macros.rs b/secp256k1-sys/src/macros.rs index 3263ff1..afb0e2f 100644 --- a/secp256k1-sys/src/macros.rs +++ b/secp256k1-sys/src/macros.rs @@ -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 }