Skip to content

Commit 7e2f756

Browse files
committed
Generalize fs::write from &[u8] to AsRef<[u8]>
1 parent a379e69 commit 7e2f756

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/libstd/fs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ pub fn read_utf8<P: AsRef<Path>>(path: P) -> io::Result<String> {
316316
/// # }
317317
/// ```
318318
#[unstable(feature = "fs_read_write", issue = /* FIXME */ "0")]
319-
pub fn write<P: AsRef<Path>>(path: P, contents: &[u8]) -> io::Result<()> {
320-
File::create(path)?.write_all(contents)
319+
pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result<()> {
320+
File::create(path)?.write_all(contents.as_ref())
321321
}
322322

323323
impl File {
@@ -3039,7 +3039,7 @@ mod tests {
30393039

30403040
let tmpdir = tmpdir();
30413041

3042-
check!(fs::write(&tmpdir.join("test"), &bytes));
3042+
check!(fs::write(&tmpdir.join("test"), &bytes[..]));
30433043
let v = check!(fs::read(&tmpdir.join("test")));
30443044
assert!(v == &bytes[..]);
30453045

0 commit comments

Comments
 (0)