Skip to content

[libs] Add Read::take_while #70920

Open
Open
@yoshuawuyts

Description

@yoshuawuyts

In #70772 I proposed adding BufRead::read_while. But as @HeroicKatora pointed out in #70772 (comment) Read::take_while would achieve many of the same benefits with fewer downsides. This would act as a counterpart to Read::take, similar to Iterator::take_while.

Examples

let mut param_name = vec![];
source
    .by_ref()
    .take_while(|b| !matches!(b, b';' | b'='))
    .read_to_end(&mut param_name)?;

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions