Skip to content

Commit

Permalink
Rollup merge of rust-lang#50624 - adevore:fs-write-str-example, r=ste…
Browse files Browse the repository at this point in the history
…veklabnik

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.
  • Loading branch information
kennytm authored May 12, 2018
2 parents 91abeac + 2ae8acc commit ded7a7e
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ pub fn read_to_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
///
/// fn main() -> std::io::Result<()> {
/// fs::write("foo.txt", b"Lorem ipsum")?;
/// fs::write("bar.txt", "dolor sit")?;
/// Ok(())
/// }
/// ```
Expand Down

0 comments on commit ded7a7e

Please sign in to comment.