diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2017-12-06 14:10:51 +0100 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2017-12-06 14:10:51 +0100 |
| commit | 1cf11b3d0bb0c448b221953d0227a28306d8e297 (patch) | |
| tree | c27c94f4a5c24db02dc87a676e3162279f6fb265 | |
| parent | 7e2f756583b4c7cbbb0bd2fc2543fa02eefea96b (diff) | |
| download | rust-1cf11b3d0bb0c448b221953d0227a28306d8e297.tar.gz rust-1cf11b3d0bb0c448b221953d0227a28306d8e297.zip | |
Rename fs::read_utf8 to read_string
| -rw-r--r-- | src/libstd/fs.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 7bb3789da88..a5884f75e0a 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -281,12 +281,12 @@ pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> { /// use std::net::SocketAddr; /// /// # fn foo() -> Result<(), Box<std::error::Error + 'static>> { -/// let foo: SocketAddr = fs::read_utf8("address.txt")?.parse()?; +/// let foo: SocketAddr = fs::read_string("address.txt")?.parse()?; /// # Ok(()) /// # } /// ``` #[unstable(feature = "fs_read_write", issue = /* FIXME */ "0")] -pub fn read_utf8<P: AsRef<Path>>(path: P) -> io::Result<String> { +pub fn read_string<P: AsRef<Path>>(path: P) -> io::Result<String> { let mut string = String::new(); File::open(path)?.read_to_string(&mut string)?; Ok(string) @@ -3044,12 +3044,12 @@ mod tests { assert!(v == &bytes[..]); check!(fs::write(&tmpdir.join("not-utf8"), &[0xFF])); - error_contains!(fs::read_utf8(&tmpdir.join("not-utf8")), + error_contains!(fs::read_string(&tmpdir.join("not-utf8")), "stream did not contain valid UTF-8"); let s = "𐁁𐀓𐀠𐀴𐀍"; check!(fs::write(&tmpdir.join("utf8"), s.as_bytes())); - let string = check!(fs::read_utf8(&tmpdir.join("utf8"))); + let string = check!(fs::read_string(&tmpdir.join("utf8"))); assert_eq!(string, s); } |
