Skip to content

Don't operate on a collection and a range of indices if you can help it. #711

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
dabrahams opened this issue Jan 11, 2024 · 1 comment

Comments

@dabrahams
Copy link

I just noticed https://developer.apple.com/documentation/swift/customconsumingregexcomponent/consuming(_:startingat:in:)

In general APIs are cleaner if you just operate on collections and use slices to limit what you're looking at. Obviously if that's not possible in this case, please ignore. Otherwise, please apply as broadly as possible ;-)

@porglezomp
Copy link

Components may need to access outside the matched range to determine if they match. Consider for example a word boundary: it has to look at both the previous and current character to check if it matches at the current position, so a slice of the collection is not appropriate since you can't access it out-of-bounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants