|
| 1 | +#![deny( |
| 2 | + clippy::missing_trait_methods, |
| 3 | + reason = "Methods should be forwarded to the underlying type" |
| 4 | +)] |
| 5 | + |
| 6 | +use core::fmt; |
| 7 | + |
| 8 | +use crate::{ |
| 9 | + BufRead, Read, ReadExactError, ReadReady, Seek, SeekFrom, Write, WriteFmtError, WriteReady, |
| 10 | +}; |
| 11 | + |
| 12 | +impl<T: ?Sized + Read> Read for &mut T { |
| 13 | + #[inline] |
| 14 | + fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { |
| 15 | + T::read(self, buf) |
| 16 | + } |
| 17 | + |
| 18 | + #[inline] |
| 19 | + fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ReadExactError<Self::Error>> { |
| 20 | + T::read_exact(self, buf) |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +impl<T: ?Sized + BufRead> BufRead for &mut T { |
| 25 | + #[inline] |
| 26 | + fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { |
| 27 | + T::fill_buf(self) |
| 28 | + } |
| 29 | + |
| 30 | + #[inline] |
| 31 | + fn consume(&mut self, amt: usize) { |
| 32 | + T::consume(self, amt); |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +impl<T: ?Sized + Write> Write for &mut T { |
| 37 | + #[inline] |
| 38 | + fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { |
| 39 | + T::write(self, buf) |
| 40 | + } |
| 41 | + |
| 42 | + #[inline] |
| 43 | + fn flush(&mut self) -> Result<(), Self::Error> { |
| 44 | + T::flush(self) |
| 45 | + } |
| 46 | + |
| 47 | + #[inline] |
| 48 | + fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error> { |
| 49 | + T::write_all(self, buf) |
| 50 | + } |
| 51 | + |
| 52 | + #[inline] |
| 53 | + fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> Result<(), WriteFmtError<Self::Error>> { |
| 54 | + T::write_fmt(self, fmt) |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | +impl<T: ?Sized + Seek> Seek for &mut T { |
| 59 | + #[inline] |
| 60 | + fn seek(&mut self, pos: SeekFrom) -> Result<u64, Self::Error> { |
| 61 | + T::seek(self, pos) |
| 62 | + } |
| 63 | + |
| 64 | + #[inline] |
| 65 | + fn rewind(&mut self) -> Result<(), Self::Error> { |
| 66 | + T::rewind(self) |
| 67 | + } |
| 68 | + |
| 69 | + #[inline] |
| 70 | + fn stream_position(&mut self) -> Result<u64, Self::Error> { |
| 71 | + T::stream_position(self) |
| 72 | + } |
| 73 | + |
| 74 | + #[inline] |
| 75 | + fn seek_relative(&mut self, offset: i64) -> Result<(), Self::Error> { |
| 76 | + T::seek_relative(self, offset) |
| 77 | + } |
| 78 | +} |
| 79 | + |
| 80 | +impl<T: ?Sized + ReadReady> ReadReady for &mut T { |
| 81 | + #[inline] |
| 82 | + fn read_ready(&mut self) -> Result<bool, Self::Error> { |
| 83 | + T::read_ready(self) |
| 84 | + } |
| 85 | +} |
| 86 | + |
| 87 | +impl<T: ?Sized + WriteReady> WriteReady for &mut T { |
| 88 | + #[inline] |
| 89 | + fn write_ready(&mut self) -> Result<bool, Self::Error> { |
| 90 | + T::write_ready(self) |
| 91 | + } |
| 92 | +} |
0 commit comments