We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a379e69 commit 7e2f756Copy full SHA for 7e2f756
src/libstd/fs.rs
@@ -316,8 +316,8 @@ pub fn read_utf8<P: AsRef<Path>>(path: P) -> io::Result<String> {
316
/// # }
317
/// ```
318
#[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)
+pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result<()> {
+ File::create(path)?.write_all(contents.as_ref())
321
}
322
323
impl File {
@@ -3039,7 +3039,7 @@ mod tests {
3039
3040
let tmpdir = tmpdir();
3041
3042
- check!(fs::write(&tmpdir.join("test"), &bytes));
+ check!(fs::write(&tmpdir.join("test"), &bytes[..]));
3043
let v = check!(fs::read(&tmpdir.join("test")));
3044
assert!(v == &bytes[..]);
3045
0 commit comments