Skip to content

Commit

Permalink
Implement IntoCtx for references to primitive types
Browse files Browse the repository at this point in the history
  • Loading branch information
luser committed Sep 13, 2018
1 parent 62d6ade commit 18dc415
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ macro_rules! into_ctx_impl {
write_into!($typ, $size, self, dst, le);
}
}
impl<'a> IntoCtx<Endian> for &'a $typ {
#[inline]
fn into_ctx(self, dst: &mut [u8], le: Endian) {
(*self).into_ctx(dst, le)
}
}
impl TryIntoCtx<Endian> for $typ where $typ: IntoCtx<Endian> {
type Error = error::Error;
type Size = usize;
Expand Down Expand Up @@ -295,7 +301,6 @@ macro_rules! from_ctx_float_impl {
}
}
}

impl<'a> TryFromCtx<'a, Endian> for $typ where $typ: FromCtx<Endian> {
type Error = error::Error;
type Size = usize;
Expand Down Expand Up @@ -334,6 +339,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<Endian> for &'a $typ {
#[inline]
fn into_ctx(self, dst: &mut [u8], le: Endian) {
(*self).into_ctx(dst, le)
}
}
impl TryIntoCtx<Endian> for $typ where $typ: IntoCtx<Endian> {
type Error = error::Error;
type Size = usize;
Expand Down

0 comments on commit 18dc415

Please sign in to comment.