@@ -743,7 +743,7 @@ fn buffer_capacity_required(mut file: &File) -> Option<usize> {
743743}
744744
745745#[ stable( feature = "rust1" , since = "1.0.0" ) ]
746- impl Read for File {
746+ impl Read for & File {
747747 fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
748748 self . inner . read ( buf)
749749 }
@@ -776,7 +776,7 @@ impl Read for File {
776776 }
777777}
778778#[ stable( feature = "rust1" , since = "1.0.0" ) ]
779- impl Write for File {
779+ impl Write for & File {
780780 fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
781781 self . inner . write ( buf)
782782 }
@@ -795,67 +795,54 @@ impl Write for File {
795795 }
796796}
797797#[ stable( feature = "rust1" , since = "1.0.0" ) ]
798- impl Seek for File {
798+ impl Seek for & File {
799799 fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
800800 self . inner . seek ( pos)
801801 }
802802}
803+
803804#[ stable( feature = "rust1" , since = "1.0.0" ) ]
804- impl Read for & File {
805+ impl Read for File {
805806 fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
806- self . inner . read ( buf)
807+ ( & * self ) . read ( buf)
807808 }
808-
809- fn read_buf ( & mut self , cursor : BorrowedCursor < ' _ > ) -> io:: Result < ( ) > {
810- self . inner . read_buf ( cursor)
811- }
812-
813809 fn read_vectored ( & mut self , bufs : & mut [ IoSliceMut < ' _ > ] ) -> io:: Result < usize > {
814- self . inner . read_vectored ( bufs)
810+ ( & * self ) . read_vectored ( bufs)
811+ }
812+ fn read_buf ( & mut self , cursor : BorrowedCursor < ' _ > ) -> io:: Result < ( ) > {
813+ ( & * self ) . read_buf ( cursor)
815814 }
816-
817815 #[ inline]
818816 fn is_read_vectored ( & self ) -> bool {
819- self . inner . is_read_vectored ( )
817+ ( & & * self ) . is_read_vectored ( )
820818 }
821-
822- // Reserves space in the buffer based on the file size when available.
823819 fn read_to_end ( & mut self , buf : & mut Vec < u8 > ) -> io:: Result < usize > {
824- let size = buffer_capacity_required ( self ) ;
825- buf. reserve ( size. unwrap_or ( 0 ) ) ;
826- io:: default_read_to_end ( self , buf, size)
820+ ( & * self ) . read_to_end ( buf)
827821 }
828-
829- // Reserves space in the buffer based on the file size when available.
830822 fn read_to_string ( & mut self , buf : & mut String ) -> io:: Result < usize > {
831- let size = buffer_capacity_required ( self ) ;
832- buf. reserve ( size. unwrap_or ( 0 ) ) ;
833- io:: default_read_to_string ( self , buf, size)
823+ ( & * self ) . read_to_string ( buf)
834824 }
835825}
836826#[ stable( feature = "rust1" , since = "1.0.0" ) ]
837- impl Write for & File {
827+ impl Write for File {
838828 fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
839- self . inner . write ( buf)
829+ ( & * self ) . write ( buf)
840830 }
841-
842831 fn write_vectored ( & mut self , bufs : & [ IoSlice < ' _ > ] ) -> io:: Result < usize > {
843- self . inner . write_vectored ( bufs)
832+ ( & * self ) . write_vectored ( bufs)
844833 }
845-
846834 #[ inline]
847835 fn is_write_vectored ( & self ) -> bool {
848- self . inner . is_write_vectored ( )
836+ ( & & * self ) . is_write_vectored ( )
849837 }
850-
851838 fn flush ( & mut self ) -> io:: Result < ( ) > {
852- self . inner . flush ( )
839+ ( & * self ) . flush ( )
853840 }
854841}
855842#[ stable( feature = "rust1" , since = "1.0.0" ) ]
856- impl Seek for & File {
843+ impl Seek for File {
857844 fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
858- self . inner . seek ( pos)
845+ ( & * self ) . seek ( pos)
859846 }
860847}
861848
0 commit comments