Skip to content

[libs] Add Read::take_while #70920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
yoshuawuyts opened this issue Apr 8, 2020 · 0 comments
Open

[libs] Add Read::take_while #70920

yoshuawuyts opened this issue Apr 8, 2020 · 0 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@yoshuawuyts
Copy link
Member

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)?;
@jonas-schievink jonas-schievink added C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants