Skip to content

Commit 6c69066

Browse files
committed
Add closing notes on File Handling to close out Chapter
1 parent c9bdd4b commit 6c69066

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

documentation2/B07-File-Handling.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,11 @@ cargo run
265265
```bash
266266
Appended content to a file
267267
```
268+
269+
Here, we import the `std::fs::OpenOptions` and `std::io::Write` modules for appending to a file.
270+
271+
The `OpenOptions::new()` and the `append(true)` method opens the file `data.txt` for appending.
272+
273+
Next, we use the `write()` method from the `File` object to write additional content `"I am learning Rust!"` to the file.
274+
275+
To deal with the errors, we chain the `expect()` method with a custom error message.

0 commit comments

Comments
 (0)