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

Drop PartialEq impl for Regex (fixes #178) #212

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions src/re_unicode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,6 @@ impl From<Exec> for Regex {
}
}

/// Equality comparison is based on the original string. It is possible that
/// different regular expressions have the same matching behavior, but are
/// still compared unequal. For example, `\d+` and `\d\d*` match the same set
/// of strings, but are not considered equal.
impl PartialEq for Regex {
fn eq(&self, other: &Regex) -> bool {
self.as_str() == other.as_str()
}
}

impl Eq for Regex {}

impl FromStr for Regex {
type Err = Error;

Expand Down
6 changes: 0 additions & 6 deletions tests/api_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,3 @@ fn empty_match_unicode_captures_iter() {
.collect();
assert_eq!(vec![(0, 0), (3, 3), (4, 4), (7, 7), (8, 8)], ms);
}

#[test]
fn eq() {
use regex::Regex;
assert_eq!(regex!(r"[a-z]+"), Regex::new("[a-z]+").unwrap());
}
7 changes: 0 additions & 7 deletions tests/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use regex::Regex;

mat!(prefix_literal_match, r"^abc", r"abc", Some((0, 3)));
mat!(prefix_literal_nomatch, r"^abc", r"zabc", None);
mat!(one_literal_edge, r"abc", r"xxxxxab", None);

#[test]
fn eq() {
assert_eq!(regex!(r"[a-z]+"), Regex::new("[a-z]+").unwrap());
}