diff --git a/src/ctx.rs b/src/ctx.rs index 6a42281..fdfb763 100644 --- a/src/ctx.rs +++ b/src/ctx.rs @@ -188,6 +188,12 @@ macro_rules! into_ctx_impl { write_into!($typ, $size, self, dst, le); } } + impl<'a> IntoCtx for &'a $typ { + #[inline] + fn into_ctx(self, dst: &mut [u8], le: Endian) { + (*self).into_ctx(dst, le) + } + } impl TryIntoCtx for $typ where $typ: IntoCtx { type Error = error::Error; type Size = usize; @@ -201,6 +207,14 @@ macro_rules! into_ctx_impl { } } } + impl<'a> TryIntoCtx for &'a $typ { + type Error = error::Error; + type Size = usize; + #[inline] + fn try_into_ctx(self, dst: &mut [u8], le: Endian) -> error::Result { + (*self).try_into_ctx(dst, le) + } + } } } @@ -295,7 +309,6 @@ macro_rules! from_ctx_float_impl { } } } - impl<'a> TryFromCtx<'a, Endian> for $typ where $typ: FromCtx { type Error = error::Error; type Size = usize; @@ -334,6 +347,12 @@ macro_rules! into_ctx_float_impl { write_into!(signed_to_unsigned!($typ), $size, transmute::<$typ, signed_to_unsigned!($typ)>(self), dst, le); } } + impl<'a> IntoCtx for &'a $typ { + #[inline] + fn into_ctx(self, dst: &mut [u8], le: Endian) { + (*self).into_ctx(dst, le) + } + } impl TryIntoCtx for $typ where $typ: IntoCtx { type Error = error::Error; type Size = usize; @@ -347,6 +366,14 @@ macro_rules! into_ctx_float_impl { } } } + impl<'a> TryIntoCtx for &'a $typ { + type Error = error::Error; + type Size = usize; + #[inline] + fn try_into_ctx(self, dst: &mut [u8], le: Endian) -> error::Result { + (*self).try_into_ctx(dst, le) + } + } } }