Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/lib.rs @ 44519:52d40f8fb82d
rust-matchers: add function to generate a regex matcher function
This function will be used to help build the upcoming `IncludeMatcher`. While
Re2 is still used and behind a feature flag, this function returns an error
meant for fallback in the default case.
Differential Revision: https://phab.mercurial-scm.org/D7922
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Fri, 17 Jan 2020 11:29:33 +0100 |
parents | d8d4fa9a7f18 |
children | 483fce658e43 |
comparison
equal
deleted
inserted
replaced
44518:b2e41723f886 | 44519:52d40f8fb82d |
---|---|
124 TooLong(usize), | 124 TooLong(usize), |
125 IO(std::io::Error), | 125 IO(std::io::Error), |
126 /// Needed a pattern that can be turned into a regex but got one that | 126 /// Needed a pattern that can be turned into a regex but got one that |
127 /// can't. This should only happen through programmer error. | 127 /// can't. This should only happen through programmer error. |
128 NonRegexPattern(IgnorePattern), | 128 NonRegexPattern(IgnorePattern), |
129 /// This is temporary, see `re2/mod.rs`. | |
130 /// This will cause a fallback to Python. | |
131 Re2NotInstalled, | |
129 } | 132 } |
130 | 133 |
131 impl ToString for PatternError { | 134 impl ToString for PatternError { |
132 fn to_string(&self) -> String { | 135 fn to_string(&self) -> String { |
133 match self { | 136 match self { |
145 } | 148 } |
146 PatternError::IO(e) => e.to_string(), | 149 PatternError::IO(e) => e.to_string(), |
147 PatternError::Path(e) => e.to_string(), | 150 PatternError::Path(e) => e.to_string(), |
148 PatternError::NonRegexPattern(pattern) => { | 151 PatternError::NonRegexPattern(pattern) => { |
149 format!("'{:?}' cannot be turned into a regex", pattern) | 152 format!("'{:?}' cannot be turned into a regex", pattern) |
153 } | |
154 PatternError::Re2NotInstalled => { | |
155 "Re2 is not installed, cannot use regex functionality." | |
156 .to_string() | |
150 } | 157 } |
151 } | 158 } |
152 } | 159 } |
153 } | 160 } |
154 | 161 |