Converts a Subpattern to an equivalent regular expression and writes it to a given string.
(&self, r: &mut String)
| 221 | impl Subpattern { |
| 222 | /// Converts a Subpattern to an equivalent regular expression and writes it to a given string. |
| 223 | fn write_regex_to(&self, r: &mut String) { |
| 224 | match self.consume { |
| 225 | 0 => { |
| 226 | if self.many { |
| 227 | r.push_str(".*"); |
| 228 | } |
| 229 | } |
| 230 | 1 => { |
| 231 | r.push('.'); |
| 232 | if self.many { |
| 233 | r.push('+'); |
| 234 | } |
| 235 | } |
| 236 | n => { |
| 237 | r.push_str(".{"); |
| 238 | write!(r, "{}", n); |
| 239 | if self.many { |
| 240 | r.push(','); |
| 241 | } |
| 242 | r.push('}'); |
| 243 | } |
| 244 | } |
| 245 | regex_syntax::escape_into(&self.suffix, r); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | fn is_match_subpatterns(subpatterns: &[Subpattern], mut text: &str) -> bool { |