|
3 | 3 | //! To interoperate with `std::io`, wrap a type in one of these
|
4 | 4 | //! adapters.
|
5 | 5 | //!
|
6 |
| -//! There's no separate adapters for Read/ReadBuf/Write traits. Instead, a single |
| 6 | +//! There are no separate adapters for `Read`/`ReadBuf`/`Write` traits. Instead, a single |
7 | 7 | //! adapter implements the right traits based on what the inner type implements.
|
8 |
| -//! This allows adapting a `Read+Write`, for example. |
| 8 | +//! This allows using these adapters when using `Read+Write`, for example. |
9 | 9 |
|
10 | 10 | use crate::SeekFrom;
|
11 | 11 |
|
@@ -107,26 +107,26 @@ impl<T: ?Sized> ToStd<T> {
|
107 | 107 |
|
108 | 108 | impl<T: crate::Read + ?Sized> std::io::Read for ToStd<T> {
|
109 | 109 | fn read(&mut self, buf: &mut [u8]) -> Result<usize, std::io::Error> {
|
110 |
| - self.inner.read(buf).map_err(to_io_error) |
| 110 | + self.inner.read(buf).map_err(to_std_error) |
111 | 111 | }
|
112 | 112 | }
|
113 | 113 |
|
114 | 114 | impl<T: crate::Write + ?Sized> std::io::Write for ToStd<T> {
|
115 | 115 | fn write(&mut self, buf: &[u8]) -> Result<usize, std::io::Error> {
|
116 |
| - self.inner.write(buf).map_err(to_io_error) |
| 116 | + self.inner.write(buf).map_err(to_std_error) |
117 | 117 | }
|
118 | 118 | fn flush(&mut self) -> Result<(), std::io::Error> {
|
119 |
| - self.inner.flush().map_err(to_io_error) |
| 119 | + self.inner.flush().map_err(to_std_error) |
120 | 120 | }
|
121 | 121 | }
|
122 | 122 |
|
123 | 123 | impl<T: crate::Seek + ?Sized> std::io::Seek for ToStd<T> {
|
124 | 124 | fn seek(&mut self, pos: std::io::SeekFrom) -> Result<u64, std::io::Error> {
|
125 |
| - self.inner.seek(pos.into()).map_err(to_io_error) |
| 125 | + self.inner.seek(pos.into()).map_err(to_std_error) |
126 | 126 | }
|
127 | 127 | }
|
128 | 128 |
|
129 |
| -fn to_io_error<T: core::fmt::Debug>(err: T) -> std::io::Error { |
| 129 | +fn to_std_error<T: core::fmt::Debug>(err: T) -> std::io::Error { |
130 | 130 | let kind = std::io::ErrorKind::Other;
|
131 | 131 | std::io::Error::new(kind, format!("{:?}", err))
|
132 | 132 | }
|
|
0 commit comments