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>(path: P) -> io::Result { /// # } /// ``` #[unstable(feature = "fs_read_write", issue = /* FIXME */ "0")] -pub fn write>(path: P, contents: &[u8]) -> io::Result<()> { - File::create(path)?.write_all(contents) +pub fn write, 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[..]);