diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2017-11-28 19:16:56 +0100 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2017-11-29 13:49:35 +0100 |
| commit | 7e2f756583b4c7cbbb0bd2fc2543fa02eefea96b (patch) | |
| tree | f45d85a164d9917afd1fc11ac6e9a9442a3637a3 /src | |
| parent | a379e697ab8ed7f3e73c79e303870ac208670bd7 (diff) | |
| download | rust-7e2f756583b4c7cbbb0bd2fc2543fa02eefea96b.tar.gz rust-7e2f756583b4c7cbbb0bd2fc2543fa02eefea96b.zip | |
Generalize fs::write from &[u8] to AsRef<[u8]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/libstd/fs.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index ab028802182..7bb3789da88 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -316,8 +316,8 @@ pub fn read_utf8<P: AsRef<Path>>(path: P) -> io::Result<String> { /// # } /// ``` #[unstable(feature = "fs_read_write", issue = /* FIXME */ "0")] -pub fn write<P: AsRef<Path>>(path: P, contents: &[u8]) -> io::Result<()> { - File::create(path)?.write_all(contents) +pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result<()> { + File::create(path)?.write_all(contents.as_ref()) } impl File { @@ -3039,7 +3039,7 @@ mod tests { let tmpdir = tmpdir(); - check!(fs::write(&tmpdir.join("test"), &bytes)); + check!(fs::write(&tmpdir.join("test"), &bytes[..])); let v = check!(fs::read(&tmpdir.join("test"))); assert!(v == &bytes[..]); |
