forge
Explore
Log in

Don't you dare go Hollow

niri

Clone
★ 0

0 watching0 forksRustGPL-3.012.1 MiB055a94dIvan Molodetskikh1 year ago2247 commits

utils.rs23 lines, 473 bytesHistoryRawDownload
1use std::str::FromStr;
2
3use regex::Regex;
4
5/// `Regex` that implements `PartialEq` by its string form.
6#[derive(Debug, Clone)]
7pub struct RegexEq(pub Regex);
8
9impl PartialEq for RegexEq {
10 fn eq(&self, other: &Self) -> bool {
11 self.0.as_str() == other.0.as_str()
12 }
13}
14
15impl Eq for RegexEq {}
16
17impl FromStr for RegexEq {
18 type Err = <Regex as FromStr>::Err;
19
20 fn from_str(s: &str) -> Result<Self, Self::Err> {
21 Regex::from_str(s).map(Self)
22 }
23}