@@ -9,21 +9,21 @@ use crate::io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom,
9
9
IoSliceMut } ;
10
10
use crate :: memchr;
11
11
12
- /// The `BufReader` struct adds buffering to any reader.
12
+ /// The `BufReader<R> ` struct adds buffering to any reader.
13
13
///
14
14
/// It can be excessively inefficient to work directly with a [`Read`] instance.
15
15
/// For example, every call to [`read`][`TcpStream::read`] on [`TcpStream`]
16
- /// results in a system call. A `BufReader` performs large, infrequent reads on
16
+ /// results in a system call. A `BufReader<R> ` performs large, infrequent reads on
17
17
/// the underlying [`Read`] and maintains an in-memory buffer of the results.
18
18
///
19
- /// `BufReader` can improve the speed of programs that make *small* and
19
+ /// `BufReader<R> ` can improve the speed of programs that make *small* and
20
20
/// *repeated* read calls to the same file or network socket. It does not
21
21
/// help when reading very large amounts at once, or reading just one or a few
22
22
/// times. It also provides no advantage when reading from a source that is
23
23
/// already in memory, like a `Vec<u8>`.
24
24
///
25
- /// When the `BufReader` is dropped, the contents of its buffer will be
26
- /// discarded. Creating multiple instances of a `BufReader` on the same
25
+ /// When the `BufReader<R> ` is dropped, the contents of its buffer will be
26
+ /// discarded. Creating multiple instances of a `BufReader<R> ` on the same
27
27
/// stream can cause data loss.
28
28
///
29
29
/// [`Read`]: ../../std/io/trait.Read.html
@@ -56,7 +56,7 @@ pub struct BufReader<R> {
56
56
}
57
57
58
58
impl < R : Read > BufReader < R > {
59
- /// Creates a new `BufReader` with a default buffer capacity. The default is currently 8 KB,
59
+ /// Creates a new `BufReader<R> ` with a default buffer capacity. The default is currently 8 KB,
60
60
/// but may change in the future.
61
61
///
62
62
/// # Examples
@@ -76,7 +76,7 @@ impl<R: Read> BufReader<R> {
76
76
BufReader :: with_capacity ( DEFAULT_BUF_SIZE , inner)
77
77
}
78
78
79
- /// Creates a new `BufReader` with the specified buffer capacity.
79
+ /// Creates a new `BufReader<R> ` with the specified buffer capacity.
80
80
///
81
81
/// # Examples
82
82
///
@@ -177,7 +177,7 @@ impl<R> BufReader<R> {
177
177
& self . buf [ self . pos ..self . cap ]
178
178
}
179
179
180
- /// Unwraps this `BufReader`, returning the underlying reader.
180
+ /// Unwraps this `BufReader<R> `, returning the underlying reader.
181
181
///
182
182
/// Note that any leftover data in the internal buffer is lost.
183
183
///
@@ -304,7 +304,7 @@ impl<R: Seek> Seek for BufReader<R> {
304
304
/// Seek to an offset, in bytes, in the underlying reader.
305
305
///
306
306
/// The position used for seeking with `SeekFrom::Current(_)` is the
307
- /// position the underlying reader would be at if the `BufReader` had no
307
+ /// position the underlying reader would be at if the `BufReader<R> ` had no
308
308
/// internal buffer.
309
309
///
310
310
/// Seeking always discards the internal buffer, even if the seek position
@@ -355,16 +355,16 @@ impl<R: Seek> Seek for BufReader<R> {
355
355
/// It can be excessively inefficient to work directly with something that
356
356
/// implements [`Write`]. For example, every call to
357
357
/// [`write`][`TcpStream::write`] on [`TcpStream`] results in a system call. A
358
- /// `BufWriter` keeps an in-memory buffer of data and writes it to an underlying
358
+ /// `BufWriter<W> ` keeps an in-memory buffer of data and writes it to an underlying
359
359
/// writer in large, infrequent batches.
360
360
///
361
- /// `BufWriter` can improve the speed of programs that make *small* and
361
+ /// `BufWriter<W> ` can improve the speed of programs that make *small* and
362
362
/// *repeated* write calls to the same file or network socket. It does not
363
363
/// help when writing very large amounts at once, or writing just one or a few
364
364
/// times. It also provides no advantage when writing to a destination that is
365
365
/// in memory, like a `Vec<u8>`.
366
366
///
367
- /// It is critical to call [`flush`] before `BufWriter` is dropped. Though
367
+ /// It is critical to call [`flush`] before `BufWriter<W> ` is dropped. Though
368
368
/// dropping will attempt to flush the the contents of the buffer, any errors
369
369
/// that happen in the process will be ignored. Calling ['flush'] ensures that
370
370
/// the buffer is empty and all errors have been observed.
@@ -386,7 +386,7 @@ impl<R: Seek> Seek for BufReader<R> {
386
386
///
387
387
/// Because we're not buffering, we write each one in turn, incurring the
388
388
/// overhead of a system call per byte written. We can fix this with a
389
- /// `BufWriter`:
389
+ /// `BufWriter<W> `:
390
390
///
391
391
/// ```no_run
392
392
/// use std::io::prelude::*;
@@ -401,7 +401,7 @@ impl<R: Seek> Seek for BufReader<R> {
401
401
/// stream.flush().unwrap();
402
402
/// ```
403
403
///
404
- /// By wrapping the stream with a `BufWriter`, these ten writes are all grouped
404
+ /// By wrapping the stream with a `BufWriter<W> `, these ten writes are all grouped
405
405
/// together by the buffer and will all be written out in one system call when
406
406
/// the `stream` is flushed.
407
407
///
@@ -448,7 +448,7 @@ pub struct BufWriter<W: Write> {
448
448
pub struct IntoInnerError < W > ( W , Error ) ;
449
449
450
450
impl < W : Write > BufWriter < W > {
451
- /// Creates a new `BufWriter` with a default buffer capacity. The default is currently 8 KB,
451
+ /// Creates a new `BufWriter<W> ` with a default buffer capacity. The default is currently 8 KB,
452
452
/// but may change in the future.
453
453
///
454
454
/// # Examples
@@ -464,7 +464,7 @@ impl<W: Write> BufWriter<W> {
464
464
BufWriter :: with_capacity ( DEFAULT_BUF_SIZE , inner)
465
465
}
466
466
467
- /// Creates a new `BufWriter` with the specified buffer capacity.
467
+ /// Creates a new `BufWriter<W> ` with the specified buffer capacity.
468
468
///
469
469
/// # Examples
470
470
///
@@ -565,7 +565,7 @@ impl<W: Write> BufWriter<W> {
565
565
& self . buf
566
566
}
567
567
568
- /// Unwraps this `BufWriter`, returning the underlying writer.
568
+ /// Unwraps this `BufWriter<W> `, returning the underlying writer.
569
569
///
570
570
/// The buffer is written out before returning the writer.
571
571
///
0 commit comments