File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -343,9 +343,12 @@ impl File {
343
343
///
344
344
/// ```no_run
345
345
/// use std::fs::File;
346
+ /// use std::io::Read;
346
347
///
347
348
/// fn main() -> std::io::Result<()> {
348
349
/// let mut f = File::open("foo.txt")?;
350
+ /// let mut data = vec![];
351
+ /// f.read_to_end(&mut data)?;
349
352
/// Ok(())
350
353
/// }
351
354
/// ```
@@ -368,9 +371,11 @@ impl File {
368
371
///
369
372
/// ```no_run
370
373
/// use std::fs::File;
374
+ /// use std::io::Write;
371
375
///
372
376
/// fn main() -> std::io::Result<()> {
373
377
/// let mut f = File::create("foo.txt")?;
378
+ /// f.write_all(&1234_u32.to_be_bytes())?;
374
379
/// Ok(())
375
380
/// }
376
381
/// ```
@@ -397,9 +402,11 @@ impl File {
397
402
/// #![feature(file_create_new)]
398
403
///
399
404
/// use std::fs::File;
405
+ /// use std::io::Write;
400
406
///
401
407
/// fn main() -> std::io::Result<()> {
402
408
/// let mut f = File::create_new("foo.txt")?;
409
+ /// f.write_all("Hello, world!".as_bytes())?;
403
410
/// Ok(())
404
411
/// }
405
412
/// ```
@@ -426,9 +433,11 @@ impl File {
426
433
///
427
434
/// ```no_run
428
435
/// use std::fs::File;
436
+ /// use std::io::Write;
429
437
///
430
438
/// fn main() -> std::io::Result<()> {
431
439
/// let mut f = File::options().append(true).open("example.log")?;
440
+ /// writeln!(&mut f, "new line")?;
432
441
/// Ok(())
433
442
/// }
434
443
/// ```
You can’t perform that action at this time.
0 commit comments