Skip to content

Commit

Permalink
Auto merge of #49422 - mbrubeck:fs_read, r=TimNN
Browse files Browse the repository at this point in the history
Stabilize fs::read and fs::write

As discussed in #46588 (comment)
  • Loading branch information
bors committed Mar 30, 2018
2 parents d8a1bc7 + 0600d0f commit 6960761
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ fn initial_buffer_size(file: &File) -> usize {
/// # Examples
///
/// ```no_run
/// #![feature(fs_read_write)]
///
/// use std::fs;
/// use std::net::SocketAddr;
///
Expand All @@ -261,7 +259,7 @@ fn initial_buffer_size(file: &File) -> usize {
/// Ok(())
/// }
/// ```
#[unstable(feature = "fs_read_write", issue = "46588")]
#[stable(feature = "fs_read_write_bytes", since = "1.27.0")]
pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
let mut file = File::open(path)?;
let mut bytes = Vec::with_capacity(initial_buffer_size(&file));
Expand Down Expand Up @@ -325,16 +323,14 @@ pub fn read_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
/// # Examples
///
/// ```no_run
/// #![feature(fs_read_write)]
///
/// use std::fs;
///
/// fn main() -> std::io::Result<()> {
/// fs::write("foo.txt", b"Lorem ipsum")?;
/// Ok(())
/// }
/// ```
#[unstable(feature = "fs_read_write", issue = "46588")]
#[stable(feature = "fs_read_write_bytes", since = "1.27.0")]
pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result<()> {
File::create(path)?.write_all(contents.as_ref())
}
Expand Down

0 comments on commit 6960761

Please sign in to comment.