@@ -743,7 +743,7 @@ fn buffer_capacity_required(mut file: &File) -> Option<usize> {
743
743
}
744
744
745
745
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
746
- impl Read for File {
746
+ impl Read for & File {
747
747
fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
748
748
self . inner . read ( buf)
749
749
}
@@ -776,7 +776,7 @@ impl Read for File {
776
776
}
777
777
}
778
778
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
779
- impl Write for File {
779
+ impl Write for & File {
780
780
fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
781
781
self . inner . write ( buf)
782
782
}
@@ -795,67 +795,54 @@ impl Write for File {
795
795
}
796
796
}
797
797
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
798
- impl Seek for File {
798
+ impl Seek for & File {
799
799
fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
800
800
self . inner . seek ( pos)
801
801
}
802
802
}
803
+
803
804
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
804
- impl Read for & File {
805
+ impl Read for File {
805
806
fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
806
- self . inner . read ( buf)
807
+ ( & * self ) . read ( buf)
807
808
}
808
-
809
- fn read_buf ( & mut self , cursor : BorrowedCursor < ' _ > ) -> io:: Result < ( ) > {
810
- self . inner . read_buf ( cursor)
811
- }
812
-
813
809
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)
815
814
}
816
-
817
815
#[ inline]
818
816
fn is_read_vectored ( & self ) -> bool {
819
- self . inner . is_read_vectored ( )
817
+ ( & & * self ) . is_read_vectored ( )
820
818
}
821
-
822
- // Reserves space in the buffer based on the file size when available.
823
819
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)
827
821
}
828
-
829
- // Reserves space in the buffer based on the file size when available.
830
822
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)
834
824
}
835
825
}
836
826
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
837
- impl Write for & File {
827
+ impl Write for File {
838
828
fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
839
- self . inner . write ( buf)
829
+ ( & * self ) . write ( buf)
840
830
}
841
-
842
831
fn write_vectored ( & mut self , bufs : & [ IoSlice < ' _ > ] ) -> io:: Result < usize > {
843
- self . inner . write_vectored ( bufs)
832
+ ( & * self ) . write_vectored ( bufs)
844
833
}
845
-
846
834
#[ inline]
847
835
fn is_write_vectored ( & self ) -> bool {
848
- self . inner . is_write_vectored ( )
836
+ ( & & * self ) . is_write_vectored ( )
849
837
}
850
-
851
838
fn flush ( & mut self ) -> io:: Result < ( ) > {
852
- self . inner . flush ( )
839
+ ( & * self ) . flush ( )
853
840
}
854
841
}
855
842
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
856
- impl Seek for & File {
843
+ impl Seek for File {
857
844
fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
858
- self . inner . seek ( pos)
845
+ ( & * self ) . seek ( pos)
859
846
}
860
847
}
861
848
0 commit comments