Skip to content

Commit ded7a7e

Browse files
authored
Rollup merge of rust-lang#50624 - adevore:fs-write-str-example, r=steveklabnik
fs::write: Add example writing a &str This adds an example to the documentation for `fs::write` that demonstrates the use of the `AsRef<[u8]>` implementation for &str. Experienced users should already recognize the possibility from the type signature, but new users may not recognize the significance.
2 parents 91abeac + 2ae8acc commit ded7a7e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/libstd/fs.rs

+1
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ pub fn read_to_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
331331
///
332332
/// fn main() -> std::io::Result<()> {
333333
/// fs::write("foo.txt", b"Lorem ipsum")?;
334+
/// fs::write("bar.txt", "dolor sit")?;
334335
/// Ok(())
335336
/// }
336337
/// ```

0 commit comments

Comments
 (0)