Skip to content

BufReader/Writer extension methods: is_empty, buffer #45323

Closed
@fintelia

Description

@fintelia

Update: this is the tracking issue for:

impl<R: Read> BufReader<R> {
    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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions