Add reference implementation for Writer and remove unnecessary lifetimes from Reader's one (#507)

This commit is contained in:
Pietro 2022-02-23 11:08:28 +01:00 committed by GitHub
parent 7c72e4c1fa
commit 1c5041390f
2 changed files with 8 additions and 1 deletions

View File

@ -31,7 +31,7 @@ pub trait Reader {
fn consume(&mut self, _: usize) {}
}
impl<'a, T> Reader for &'a mut T
impl<T> Reader for &mut T
where
T: Reader,
{

View File

@ -12,6 +12,13 @@ pub trait Writer {
fn write(&mut self, bytes: &[u8]) -> Result<(), EncodeError>;
}
impl<T: Writer> Writer for &mut T {
#[inline]
fn write(&mut self, bytes: &[u8]) -> Result<(), EncodeError> {
(**self).write(bytes)
}
}
/// A helper struct that implements `Writer` for a `&[u8]` slice.
///
/// ```