push: Panic on Regex construction error

This commit is contained in:
Kévin Commaille 2023-04-24 16:55:08 +02:00 committed by Kévin Commaille
parent ed7c26ff9f
commit 4105169577

View File

@ -392,7 +392,8 @@ impl StrExt for str {
// The word characters in ASCII compatible mode (with the `-u` flag) match the
// definition in the spec: any character not in the set `[A-Za-z0-9_]`.
let regex = format!(r"(?-u:^|\W|\b){}(?-u:\b|\W|$)", chunks.concat());
Regex::new(&regex).ok().filter(|re| re.is_match(self.as_bytes())).is_some()
let re = Regex::new(&regex).expect("regex construction should succeed");
re.is_match(self.as_bytes())
} else {
match self.find(pattern) {
Some(start) => {