@@ -297,12 +297,12 @@ pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
297
297
/// use std::net::SocketAddr;
298
298
///
299
299
/// 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()?;
301
301
/// Ok(())
302
302
/// }
303
303
/// ```
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 > {
306
306
let mut file = File :: open ( path) ?;
307
307
let mut string = String :: with_capacity ( initial_buffer_size ( & file) ) ;
308
308
file. read_to_string ( & mut string) ?;
@@ -3122,12 +3122,12 @@ mod tests {
3122
3122
assert ! ( v == & bytes[ ..] ) ;
3123
3123
3124
3124
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" ) ) ,
3126
3126
"stream did not contain valid UTF-8" ) ;
3127
3127
3128
3128
let s = "𐁁𐀓𐀠𐀴𐀍" ;
3129
3129
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" ) ) ) ;
3131
3131
assert_eq ! ( string, s) ;
3132
3132
}
3133
3133
0 commit comments