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

doc: add a doctest to demonstrate a separately-compiled regex set #861

Merged
merged 1 commit into from
Jul 5, 2022

Conversation

cosmicexplorer
Copy link
Contributor

It took me a while to understand the recommendation for how to get Match objects when using a RegexSet. I tried to rewrite that part and added a doctest to make it super clear!

Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The substance looks good, but there are some details that I'd like to see fixed before merging.

Also, I do think these restrictions have a very good chance of being lifted in the future with new APIs on RegexSet. But it's still a long ways off so I agree it's worth clarifying the docs here for now.

src/re_set.rs Outdated
/// scan the exact same input a second time with those independently compiled
/// patterns:
/// ```rust
/// # use regex::{Regex, RegexSet};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be commented. Other examples in this crate don't comment use lines out anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I have uncommented it! However, it looks like all the other examples in this file (re_set.rs) have this use statement commented out -- should I fix those, too? e.g.

/// # use regex::RegexSet;

src/re_set.rs Outdated Show resolved Hide resolved
src/re_set.rs Outdated Show resolved Hide resolved
src/re_set.rs Show resolved Hide resolved
src/re_set.rs Outdated Show resolved Hide resolved
src/re_set.rs Show resolved Hide resolved
@BurntSushi
Copy link
Member

Also, please squash down to one commit.

@cosmicexplorer cosmicexplorer force-pushed the regex-set-matches branch 3 times, most recently from 40c7985 to fe6dede Compare May 31, 2022 03:17
@cosmicexplorer
Copy link
Contributor Author

@BurntSushi:

Also, I do think these restrictions have a very good chance of being lifted in the future with new APIs on RegexSet

That's awesome to hear!! Turned on notifs for this repo!

- explicitly link to and describe the operations that aren't available
- reflow text and uncomment use statement
@cosmicexplorer
Copy link
Contributor Author

Ping!

@BurntSushi BurntSushi merged commit 039bb4d into rust-lang:master Jul 5, 2022
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.

2 participants