BufReader/Writer extension methods: is_empty, buffer · Issue #45323 · rust-lang/rust (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@fintelia

Description

@fintelia

Update: this is the tracking issue for:

impl<R: Read> BufReader { pub fn buffer(&self) -> &[u8] {…}

#[rustc_deprecated(since = "1.26.0", reason = "use .buffer().is_empty() instead")]
pub fn is_empty(&self) -> bool {…}

}

is_empty is both unstable and deprecated, it should be removed.


There is currently no way to tell whether there is any data buffered inside a BufReader. This is unfortunate because it means that an application has no way to know whether calls to read() and fill_buffer() will return instantly or trigger a potentially expensive call to the underlying Reader. I propose adding an is_empty() method to BufReader to fill this gap.