Skip to content

Commit

Permalink
Implement TryIntoCtx for references to primitive types.
Browse files Browse the repository at this point in the history
This should help in fixing m4b/scroll_derive#15 .
  • Loading branch information
luser committed Sep 13, 2018
1 parent 18dc415 commit 12fbcc7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ macro_rules! into_ctx_impl {
}
}
}
impl<'a> TryIntoCtx<Endian> for &'a $typ {
type Error = error::Error;
type Size = usize;
#[inline]
fn try_into_ctx(self, dst: &mut [u8], le: Endian) -> error::Result<Self::Size> {
(*self).try_into_ctx(dst, le)
}
}
}
}

Expand Down Expand Up @@ -358,6 +366,14 @@ macro_rules! into_ctx_float_impl {
}
}
}
impl<'a> TryIntoCtx<Endian> for &'a $typ {
type Error = error::Error;
type Size = usize;
#[inline]
fn try_into_ctx(self, dst: &mut [u8], le: Endian) -> error::Result<Self::Size> {
(*self).try_into_ctx(dst, le)
}
}
}
}

Expand Down

0 comments on commit 12fbcc7

Please sign in to comment.