about summary refs log tree commit diff
path: root/src/libstd/sys/unix/stack_overflow.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-12-08 21:33:50 +0000
committerbors <bors@rust-lang.org>2017-12-08 21:33:50 +0000
commitc7b6d8263b0c106503d102ab8148769ac9f7d086 (patch)
tree7ca26adbc35853f2715399407195409f07e4b16f /src/libstd/sys/unix/stack_overflow.rs
parentad3543db3408b8d4ca53133a2999833befde8494 (diff)
parentc5eff5442ca963e20225c8229aff7be28f65a0a6 (diff)
downloadrust-c7b6d8263b0c106503d102ab8148769ac9f7d086.tar.gz
rust-c7b6d8263b0c106503d102ab8148769ac9f7d086.zip
Auto merge of #45837 - SimonSapin:file_read_write, r=dtolnay
Add read, read_string, and write functions to std::fs

New APIs in `std::fs`:

```rust
pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> { … }
pub fn read_string<P: AsRef<Path>>(path: P) -> io::Result<String> { … }
pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result<()> { ... }
```

(`read_string` is based on `read_to_string` and so returns an error on non-UTF-8 content.)

Before:

```rust
use std::fs::File;
use std::io::Read;

let mut bytes = Vec::new();
File::open(filename)?.read_to_end(&mut bytes)?;
do_something_with(bytes)
```

After:

```rust
use std::fs;

do_something_with(fs::read(filename)?)
```
Diffstat (limited to 'src/libstd/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions