Skip to content

Implement Regex::source_and_options_equals#1351

Open
dolezvo1 wants to merge 4 commits into
rust-lang:masterfrom
dolezvo1:dolezvo1_sourceAndOptionsEquals
Open

Implement Regex::source_and_options_equals#1351
dolezvo1 wants to merge 4 commits into
rust-lang:masterfrom
dolezvo1:dolezvo1_sourceAndOptionsEquals

Conversation

@dolezvo1

Copy link
Copy Markdown

Regex::source_and_options_equals provides API for testing regex equivalence while permitting false negatives (closes #1349)

Comment thread src/regex/string.rs Outdated

@BurntSushi BurntSushi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is on the right track. We'll want to add this to the other regex APIs (bytes, set and bytes set). And also regex-lite.

Comment thread src/regex/string.rs
/// assert!(!r1.source_and_options_equals(&r3));
/// ```
#[inline]
pub fn source_and_options_equals(&self, other: &Self) -> bool {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This naming will need work. I don't like how it is right now. But I don't have the spoons to come up with a better one at the moment.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think you're right that the name could be improved, but I'm not quite sure how. The _equals part I believe should stay. source_and_options could perhaps be replaced by compile_inputs or regex_info, but I'm not sure whether that is better. Replacing source by str or pattern could also make sense.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@BurntSushi Hello, did you happen to have any ideas about a better name?

Comment thread src/regex/string.rs Outdated
@dolezvo1 dolezvo1 requested a review from BurntSushi June 7, 2026 09:57
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.

Provide an API for comparing the equivalence of two Regex values (while permitting false negatives)

2 participants