]> git.lizzy.rs Git - rust.git/commitdiff
Remove unnecessary adapter
authorShotaro Yamada <sinkuu@sinkuu.xyz>
Sun, 6 Jan 2019 06:33:11 +0000 (15:33 +0900)
committerShotaro Yamada <sinkuu@sinkuu.xyz>
Sun, 6 Jan 2019 06:33:11 +0000 (15:33 +0900)
src/libcore/fmt/mod.rs

index ec1aeb8a7d1e946abbfc42507d4b841804df6af4..bb6f511acf7e569749a1b227e384fb4c05190d2c 100644 (file)
@@ -191,29 +191,8 @@ fn write_char(&mut self, c: char) -> Result {
     /// assert_eq!(&buf, "world");
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn write_fmt(&mut self, args: Arguments) -> Result {
-        // This Adapter is needed to allow `self` (of type `&mut
-        // Self`) to be cast to a Write (below) without
-        // requiring a `Sized` bound.
-        struct Adapter<'a,T: ?Sized +'a>(&'a mut T);
-
-        impl<T: ?Sized> Write for Adapter<'_, T>
-            where T: Write
-        {
-            fn write_str(&mut self, s: &str) -> Result {
-                self.0.write_str(s)
-            }
-
-            fn write_char(&mut self, c: char) -> Result {
-                self.0.write_char(c)
-            }
-
-            fn write_fmt(&mut self, args: Arguments) -> Result {
-                self.0.write_fmt(args)
-            }
-        }
-
-        write(&mut Adapter(self), args)
+    fn write_fmt(mut self: &mut Self, args: Arguments) -> Result {
+        write(&mut self, args)
     }
 }