(
regex: &'strings str,
flags: Option<&'strings str>,
regex_cache: &'cache mut HashMap<(&'strings str, Option<&'strings str>), Regex>,
)
| 129 | } |
| 130 | |
| 131 | pub fn compile_and_cache_regex<'strings, 'cache>( |
| 132 | regex: &'strings str, |
| 133 | flags: Option<&'strings str>, |
| 134 | regex_cache: &'cache mut HashMap<(&'strings str, Option<&'strings str>), Regex>, |
| 135 | ) -> Result<&'cache Regex, ArrowError> |
| 136 | where |
| 137 | 'strings: 'cache, |
| 138 | { |
| 139 | let result = match regex_cache.entry((regex, flags)) { |
| 140 | Entry::Occupied(occupied_entry) => occupied_entry.into_mut(), |
| 141 | Entry::Vacant(vacant_entry) => { |
| 142 | let compiled = compile_regex(regex, flags)?; |
| 143 | vacant_entry.insert(compiled) |
| 144 | } |
| 145 | }; |
| 146 | Ok(result) |
| 147 | } |
| 148 | |
| 149 | pub fn compile_regex(regex: &str, flags: Option<&str>) -> Result<Regex, ArrowError> { |
| 150 | let pattern = match flags { |
no test coverage detected
searching dependent graphs…