diff options
| author | Thom Chiovoloni <chiovolonit@gmail.com> | 2021-08-08 01:04:33 -0700 |
|---|---|---|
| committer | Thom Chiovoloni <chiovolonit@gmail.com> | 2022-02-04 18:47:29 -0800 |
| commit | 554918e311a1221744aa9b6d60e2f00f5b3155e5 (patch) | |
| tree | e8affa7ee0e7729cf05633c7b7989aaaa96bdd8c /library/std/src/io/impls.rs | |
| parent | 71226d717a1fb57122e47e63b97295e703319cb0 (diff) | |
| download | rust-554918e311a1221744aa9b6d60e2f00f5b3155e5.tar.gz rust-554918e311a1221744aa9b6d60e2f00f5b3155e5.zip | |
Hide Repr details from io::Error, and rework `io::Error::new_const`.
Diffstat (limited to 'library/std/src/io/impls.rs')
| -rw-r--r-- | library/std/src/io/impls.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/library/std/src/io/impls.rs b/library/std/src/io/impls.rs index 23201f9fc5c..64d2457bce1 100644 --- a/library/std/src/io/impls.rs +++ b/library/std/src/io/impls.rs @@ -5,7 +5,7 @@ use crate::alloc::Allocator; use crate::cmp; use crate::fmt; use crate::io::{ - self, BufRead, Error, ErrorKind, IoSlice, IoSliceMut, Read, ReadBuf, Seek, SeekFrom, Write, + self, BufRead, ErrorKind, IoSlice, IoSliceMut, Read, ReadBuf, Seek, SeekFrom, Write, }; use crate::mem; @@ -279,7 +279,10 @@ impl Read for &[u8] { #[inline] fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { if buf.len() > self.len() { - return Err(Error::new_const(ErrorKind::UnexpectedEof, &"failed to fill whole buffer")); + return Err(io::const_io_error!( + ErrorKind::UnexpectedEof, + "failed to fill whole buffer" + )); } let (a, b) = self.split_at(buf.len()); @@ -361,7 +364,7 @@ impl Write for &mut [u8] { if self.write(data)? == data.len() { Ok(()) } else { - Err(Error::new_const(ErrorKind::WriteZero, &"failed to write whole buffer")) + Err(io::const_io_error!(ErrorKind::WriteZero, "failed to write whole buffer")) } } |
