]> git.lizzy.rs Git - rust.git/commitdiff
Derive Debug for io::Chain instead of manually implementing it.
authorMara Bos <m-ou.se@m-ou.se>
Sat, 27 Mar 2021 12:36:07 +0000 (13:36 +0100)
committerMara Bos <m-ou.se@m-ou.se>
Sat, 27 Mar 2021 12:37:52 +0000 (13:37 +0100)
The manual implementation has the same bounds, so I don't think there's
any reason for a manual implementation. The names used in the derive
implementation are even nicer (`first`/`second`) than the manual
implementation (`t`/`u`), and include the `done_first` field too.

library/std/src/io/mod.rs

index 5316305a30370a67486f30c97b444c7fd55d241e..9953bcd556dd937a32ab803f087a5224bbdc0132 100644 (file)
@@ -2114,6 +2114,7 @@ fn lines(self) -> Lines<Self>
 ///
 /// [`chain`]: Read::chain
 #[stable(feature = "rust1", since = "1.0.0")]
+#[derive(Debug)]
 pub struct Chain<T, U> {
     first: T,
     second: U,
@@ -2195,13 +2196,6 @@ pub fn get_mut(&mut self) -> (&mut T, &mut U) {
     }
 }
 
-#[stable(feature = "std_debug", since = "1.16.0")]
-impl<T: fmt::Debug, U: fmt::Debug> fmt::Debug for Chain<T, U> {
-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_struct("Chain").field("t", &self.first).field("u", &self.second).finish()
-    }
-}
-
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: Read, U: Read> Read for Chain<T, U> {
     fn read(&mut self, buf: &mut [u8]) -> Result<usize> {