(&self, other: &Box<dyn Value>)
| 264 | } |
| 265 | |
| 266 | fn like_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> { |
| 267 | let pattern_text = other.as_text().unwrap(); |
| 268 | let pattern = &format!( |
| 269 | "^{}$", |
| 270 | pattern_text |
| 271 | .to_lowercase() |
| 272 | .replace('%', ".*") |
| 273 | .replace('_', ".") |
| 274 | ); |
| 275 | |
| 276 | let regex_builder = RegexBuilder::new(pattern) |
| 277 | .multi_line(true) |
| 278 | .unicode(true) |
| 279 | .build(); |
| 280 | |
| 281 | match regex_builder { |
| 282 | Ok(regex) => { |
| 283 | let is_match = regex.is_match(&self.value.to_lowercase()); |
| 284 | Ok(Box::new(BoolValue { value: is_match })) |
| 285 | } |
| 286 | Err(error_message) => Err(error_message.to_string()), |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | fn glob_op(&self, other: &Box<dyn Value>) -> Result<Box<dyn Value>, String> { |
| 291 | let pattern_text = other.as_text().unwrap(); |
no test coverage detected