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

Give NewlinePattern a method that returns a configurable splitter on a given string #3

Open
jwodder opened this issue May 9, 2024 · 0 comments
Labels
enhancement New feature or request therefor
Milestone

Comments

@jwodder
Copy link
Owner

jwodder commented May 9, 2024

  • Method name: split()?

  • The method takes a &'a str and returns a Splitter<'a> (Name not fixed), which implements DoubleEndedIterator<Item=&'a str> (or just implements IntoIterator returning a separate DoubleEndedIterator type?)

  • Splitter has the following methods for configuring its behavior:

    • inclusive(self) -> Self — Causes terminating patterns to be included in the strings yielded by the iterator and once()
    • something for controlling whether a pattern at the end of the input should result in the iterator yielding a final empty string (default: no)
      • This includes yielding just "" when the input is the empty string.
    • limit(self, n: usize) -> Self — cf. str::splitn()
    • once(self) -> Option<(&'a str, &'a str)> — Splits the input string only on the first occurrence of the pattern

Cf. the API of https://crates.io/crates/str_splitter

@jwodder jwodder added the enhancement New feature or request therefor label May 9, 2024
@jwodder jwodder added this to the v0.1.0 milestone May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request therefor
Projects
None yet
Development

No branches or pull requests

1 participant