Skip to content

[libs] Add Read::take_while #70920

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)?;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libsRelevant to the library 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