@@ -31,6 +31,11 @@ use crate::time::SystemTime;
31
31
/// on closing are ignored by the implementation of `Drop`. Use the method
32
32
/// [`sync_all`] if these errors must be manually handled.
33
33
///
34
+ /// `File` objects do not buffer reads and writes by default. For efficiency,
35
+ /// consider wrapping the file in a [`BufReader`] or [`BufWriter`] when performing
36
+ /// multiple [`read`] or [`write`] calls, unless unbuffered reads and writes
37
+ /// are required.
38
+ ///
34
39
/// # Examples
35
40
///
36
41
/// Creates a new file and write bytes to it (you can also use [`write()`]):
@@ -61,8 +66,7 @@ use crate::time::SystemTime;
61
66
/// }
62
67
/// ```
63
68
///
64
- /// It can be more efficient to read the contents of a file with a buffered
65
- /// [`Read`]er. This can be accomplished with [`BufReader<R>`]:
69
+ /// Using a buffered [`Read`]er:
66
70
///
67
71
/// ```no_run
68
72
/// use std::fs::File;
@@ -93,8 +97,11 @@ use crate::time::SystemTime;
93
97
/// perform synchronous I/O operations. Therefore the underlying file must not
94
98
/// have been opened for asynchronous I/O (e.g. by using `FILE_FLAG_OVERLAPPED`).
95
99
///
96
- /// [`BufReader<R>`]: io::BufReader
100
+ /// [`BufReader`]: io::BufReader
101
+ /// [`BufWriter`]: io::BufReader
97
102
/// [`sync_all`]: File::sync_all
103
+ /// [`write`]: File::write
104
+ /// [`read`]: File::read
98
105
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
99
106
#[ cfg_attr( not( test) , rustc_diagnostic_item = "File" ) ]
100
107
pub struct File {
0 commit comments