File tree 2 files changed +16
-0
lines changed
2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 10
10
11
11
use regex:: { Regex , NoExpand } ;
12
12
13
+ #[ test]
14
+ fn eq ( ) {
15
+ assert_eq ! ( regex!( r"[a-z]+" ) , Regex :: new( "[a-z]+" ) . unwrap( ) ) ;
16
+ }
17
+
13
18
#[ test]
14
19
fn splitn ( ) {
15
20
let re = regex ! ( r"\d+" ) ;
Original file line number Diff line number Diff line change @@ -159,6 +159,17 @@ impl fmt::Debug for Regex {
159
159
}
160
160
}
161
161
162
+ /// Equality comparison is based on the original string. It is possible that different regular
163
+ /// expressions have the same matching behavior, but are still compared unequal. For example,
164
+ /// `\d+` and `\d\d*` match the same set of strings, but are not considered equal.
165
+ impl PartialEq for Regex {
166
+ fn eq ( & self , other : & Regex ) -> bool {
167
+ self . as_str ( ) == other. as_str ( )
168
+ }
169
+ }
170
+
171
+ impl Eq for Regex { }
172
+
162
173
impl FromStr for Regex {
163
174
type Err = parse:: Error ;
164
175
You can’t perform that action at this time.
0 commit comments