diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2021-03-21 20:22:38 +0100 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2021-03-21 20:22:38 +0100 |
| commit | 7b71719faf5ba6a230d097fddb288f79ccc570f1 (patch) | |
| tree | 73e747cd70df4cf394414d1894096d1fd759667a /library/std/src/io/impls.rs | |
| parent | 96783625a0a2906d70690a5d76f83b1ccc028434 (diff) | |
| download | rust-7b71719faf5ba6a230d097fddb288f79ccc570f1.tar.gz rust-7b71719faf5ba6a230d097fddb288f79ccc570f1.zip | |
Use io::Error::new_const everywhere to avoid allocations.
Diffstat (limited to 'library/std/src/io/impls.rs')
| -rw-r--r-- | library/std/src/io/impls.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/io/impls.rs b/library/std/src/io/impls.rs index 9870cfc4c95..6891bd8a664 100644 --- a/library/std/src/io/impls.rs +++ b/library/std/src/io/impls.rs @@ -263,7 +263,7 @@ impl Read for &[u8] { #[inline] fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { if buf.len() > self.len() { - return Err(Error::new(ErrorKind::UnexpectedEof, "failed to fill whole buffer")); + return Err(Error::new_const(ErrorKind::UnexpectedEof, &"failed to fill whole buffer")); } let (a, b) = self.split_at(buf.len()); @@ -345,7 +345,7 @@ impl Write for &mut [u8] { if self.write(data)? == data.len() { Ok(()) } else { - Err(Error::new(ErrorKind::WriteZero, "failed to write whole buffer")) + Err(Error::new_const(ErrorKind::WriteZero, &"failed to write whole buffer")) } } |
