@@ -297,12 +297,12 @@ pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
297297/// use std::net::SocketAddr;
298298///
299299/// fn main() -> Result<(), Box<std::error::Error + 'static>> {
300- /// let foo: SocketAddr = fs::read_string ("address.txt")?.parse()?;
300+ /// let foo: SocketAddr = fs::read_to_string ("address.txt")?.parse()?;
301301/// Ok(())
302302/// }
303303/// ```
304- #[ unstable ( feature = "fs_read_write" , issue = "46588 " ) ]
305- pub fn read_string < P : AsRef < Path > > ( path : P ) -> io:: Result < String > {
304+ #[ stable ( feature = "fs_read_write" , since = "1.26.0 " ) ]
305+ pub fn read_to_string < P : AsRef < Path > > ( path : P ) -> io:: Result < String > {
306306 let mut file = File :: open ( path) ?;
307307 let mut string = String :: with_capacity ( initial_buffer_size ( & file) ) ;
308308 file. read_to_string ( & mut string) ?;
@@ -3122,12 +3122,12 @@ mod tests {
31223122 assert ! ( v == & bytes[ ..] ) ;
31233123
31243124 check ! ( fs:: write( & tmpdir. join( "not-utf8" ) , & [ 0xFF ] ) ) ;
3125- error_contains ! ( fs:: read_string ( & tmpdir. join( "not-utf8" ) ) ,
3125+ error_contains ! ( fs:: read_to_string ( & tmpdir. join( "not-utf8" ) ) ,
31263126 "stream did not contain valid UTF-8" ) ;
31273127
31283128 let s = "𐁁𐀓𐀠𐀴𐀍" ;
31293129 check ! ( fs:: write( & tmpdir. join( "utf8" ) , s. as_bytes( ) ) ) ;
3130- let string = check ! ( fs:: read_string ( & tmpdir. join( "utf8" ) ) ) ;
3130+ let string = check ! ( fs:: read_to_string ( & tmpdir. join( "utf8" ) ) ) ;
31313131 assert_eq ! ( string, s) ;
31323132 }
31333133
0 commit comments