Skip to content
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

Add Lines::remainder #171

Closed
WaffleLapkin opened this issue Jan 31, 2023 · 6 comments
Closed

Add Lines::remainder #171

WaffleLapkin opened this issue Jan 31, 2023 · 6 comments
Labels
ACP-accepted API Change Proposal is accepted (seconded with no objections) api-change-proposal A proposal to add or alter unstable APIs in the standard libraries T-libs-api

Comments

@WaffleLapkin
Copy link
Member

Proposal

Add Lines::remainder similarly to other remainder methods on split iterators for strings (see tracking issue: rust-lang/rust#77998).

Problem statement

While most iterators that split strings allow to get the remainder, Lines does not.

Motivation, use-cases

It may be beneficial to get the remainder of an iterator, for example to process it differently. A rough sketch:

let lines = s.lines();

while let Some(line) = lines.next() {
    let command = line.parse::<Command>()?;
    // ...
    if command.is_end() {
        process_end(lines.remainder());
        break;
    }
}

Solution sketches

impl<'a> Lines<'a> {
    pub fn remainder(&self) -> Option<&'a str> { /* ... */ }
}

Links and related work

What happens now?

This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals in its weekly meeting. You should receive feedback within a week or two.

@WaffleLapkin WaffleLapkin added api-change-proposal A proposal to add or alter unstable APIs in the standard libraries T-libs-api labels Jan 31, 2023
@pitaj
Copy link

pitaj commented Jan 31, 2023

Seems like a fitting addition to me

@JohnCSimon
Copy link
Member

@WaffleLapkin Ping from triage: Can you post your status on this PR? This has sat idle for a few months.

@WaffleLapkin
Copy link
Member Author

@JohnCSimon it is waiting on review from libs-api (either the ACP or the PR)

@haberman
Copy link

haberman commented Dec 3, 2023

Any update? I found myself wanting this method today.

@WaffleLapkin
Copy link
Member Author

@haberman still waiting on T-libs-api. They are having problems with not having enough capacity.

@dtolnay
Copy link
Member

dtolnay commented Jan 26, 2024

This looks good to me, and I have accepted your PR. Thanks!

@dtolnay dtolnay added the ACP-accepted API Change Proposal is accepted (seconded with no objections) label Jan 26, 2024
@dtolnay dtolnay closed this as completed Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ACP-accepted API Change Proposal is accepted (seconded with no objections) api-change-proposal A proposal to add or alter unstable APIs in the standard libraries T-libs-api
Projects
None yet
Development

No branches or pull requests

5 participants