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

regex: expose lower level search APIs #493

Merged
merged 1 commit into from
Jul 18, 2018

Conversation

BurntSushi
Copy link
Member

This commit exposes two new areas of API surface:

  1. A new captures_read method which provides a way to access the
    offsets of submatches while amortizing the allocation of the
    space required to store those offsets. Callers should still of
    course prefer to use the higher level captures method, but if
    performance dictates, this lower level API may be useful.
  2. New "at" variants of
    shortest_match/is_match/find/captures/captures_read that permit
    controlling where the start of a search begins within a slice.
    This is typically useful for controlling the match semantics of
    look-around operators such as ^ and $, and are necessary for
    implementing non-overlapping iterators.

Fixes #219

@BurntSushi
Copy link
Member Author

cc @raphlinus I think you mentioned looking for these APIs at one point in the long ago. These have been available as undocumented APIs for quite a while, but now I actually need them for another project and I think they've mostly served me well.

This commit exposes two new areas of API surface:

  1. A new `captures_read` method which provides a way to access the
     offsets of submatches while amortizing the allocation of the
     space required to store those offsets. Callers should still of
     course prefer to use the higher level `captures` method, but if
     performance dictates, this lower level API may be useful.
  2. New "at" variants of
     shortest_match/is_match/find/captures/captures_read that permit
     controlling where the start of a search begins within a slice.
     This is typically useful for controlling the match semantics of
     look-around operators such as `^` and `$`, and are necessary for
     implementing non-overlapping iterators.

Fixes rust-lang#219
@BurntSushi
Copy link
Member Author

I've been using these new APIs for a bit now and everything feels OK to me. So I'm going to bring this in and push out a new release.

@BurntSushi BurntSushi merged commit 2918aab into rust-lang:master Jul 18, 2018
@BurntSushi BurntSushi deleted the ag/low-level-apis branch July 18, 2018 13:07
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

Successfully merging this pull request may close these issues.

1 participant