File tree 1 file changed +4
-4
lines changed
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -281,12 +281,12 @@ pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
281
281
/// use std::net::SocketAddr;
282
282
///
283
283
/// # fn foo() -> Result<(), Box<std::error::Error + 'static>> {
284
- /// let foo: SocketAddr = fs::read_utf8 ("address.txt")?.parse()?;
284
+ /// let foo: SocketAddr = fs::read_string ("address.txt")?.parse()?;
285
285
/// # Ok(())
286
286
/// # }
287
287
/// ```
288
288
#[ unstable( feature = "fs_read_write" , issue = /* FIXME */ "0" ) ]
289
- pub fn read_utf8 < P : AsRef < Path > > ( path : P ) -> io:: Result < String > {
289
+ pub fn read_string < P : AsRef < Path > > ( path : P ) -> io:: Result < String > {
290
290
let mut string = String :: new ( ) ;
291
291
File :: open ( path) ?. read_to_string ( & mut string) ?;
292
292
Ok ( string)
@@ -3044,12 +3044,12 @@ mod tests {
3044
3044
assert ! ( v == & bytes[ ..] ) ;
3045
3045
3046
3046
check ! ( fs:: write( & tmpdir. join( "not-utf8" ) , & [ 0xFF ] ) ) ;
3047
- error_contains ! ( fs:: read_utf8 ( & tmpdir. join( "not-utf8" ) ) ,
3047
+ error_contains ! ( fs:: read_string ( & tmpdir. join( "not-utf8" ) ) ,
3048
3048
"stream did not contain valid UTF-8" ) ;
3049
3049
3050
3050
let s = "𐁁𐀓𐀠𐀴𐀍" ;
3051
3051
check ! ( fs:: write( & tmpdir. join( "utf8" ) , s. as_bytes( ) ) ) ;
3052
- let string = check ! ( fs:: read_utf8 ( & tmpdir. join( "utf8" ) ) ) ;
3052
+ let string = check ! ( fs:: read_string ( & tmpdir. join( "utf8" ) ) ) ;
3053
3053
assert_eq ! ( string, s) ;
3054
3054
}
3055
3055
You can’t perform that action at this time.
0 commit comments