Skip to content

Commit 1cf11b3

Browse files
committed
Rename fs::read_utf8 to read_string
1 parent 7e2f756 commit 1cf11b3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/libstd/fs.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,12 @@ pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
281281
/// use std::net::SocketAddr;
282282
///
283283
/// # 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()?;
285285
/// # Ok(())
286286
/// # }
287287
/// ```
288288
#[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> {
290290
let mut string = String::new();
291291
File::open(path)?.read_to_string(&mut string)?;
292292
Ok(string)
@@ -3044,12 +3044,12 @@ mod tests {
30443044
assert!(v == &bytes[..]);
30453045

30463046
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")),
30483048
"stream did not contain valid UTF-8");
30493049

30503050
let s = "𐁁𐀓𐀠𐀴𐀍";
30513051
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")));
30533053
assert_eq!(string, s);
30543054
}
30553055

0 commit comments

Comments
 (0)