Closed as not planned
Description
In the default_read_to_end
implementation, a parameter for size_hint
is available.
However, when doing the actual read_to_end
, it's initialized with None
.
When using the the below pattern to implement a custom iterator over a file, when the max possible line length is known, it would be helpful to make use of the size_hint
parameter, assuming it's a slightly faster path (?).
This will be, in spirit, a continuation of #89165, #89582, and #110655
impl<R: Read> Iterator for LineIter<R> {
type Item = io::Result<Vec<u8>>;
fn next(&mut self) -> Option<Self::Item> {
let mut data = Vec::with_capacity(MAX_LINE_LENGTH);
file.by_ref().take(x).read_to_end(&mut data)
In short, I'm asking if the ability to pass a size_hint
of x
(from the take
) into the read_to_end
function will be useful, and if it'd be slightly better performance wise?