|
1 | | -///! An encapsulation of `BufReader`'s buffer management logic. |
2 | | -/// |
3 | | -/// This module factors out the basic functionality of `BufReader` in order to protect two core |
4 | | -/// invariants: |
5 | | -/// * `filled` bytes of `buf` are always initialized |
6 | | -/// * `pos` is always <= `filled` |
7 | | -/// Since this module encapsulates the buffer management logic, we can ensure that the range |
8 | | -/// `pos..filled` is always a valid index into the initialized region of the buffer. This means |
9 | | -/// that user code which wants to do reads from a `BufReader` via `buffer` + `consume` can do so |
10 | | -/// without encountering any runtime bounds checks. |
| 1 | +//! An encapsulation of `BufReader`'s buffer management logic. |
| 2 | +//! |
| 3 | +//! This module factors out the basic functionality of `BufReader` in order to protect two core |
| 4 | +//! invariants: |
| 5 | +//! * `filled` bytes of `buf` are always initialized |
| 6 | +//! * `pos` is always <= `filled` |
| 7 | +//! Since this module encapsulates the buffer management logic, we can ensure that the range |
| 8 | +//! `pos..filled` is always a valid index into the initialized region of the buffer. This means |
| 9 | +//! that user code which wants to do reads from a `BufReader` via `buffer` + `consume` can do so |
| 10 | +//! without encountering any runtime bounds checks. |
| 11 | + |
11 | 12 | use crate::cmp; |
12 | 13 | use crate::io::{self, BorrowedBuf, Read}; |
13 | 14 | use crate::mem::MaybeUninit; |
|