MCPcopy Index your code
hub / github.com/RustPython/RustPython / do_match

Function do_match

crates/stdlib/src/re.rs:168–176  ·  view source on GitHub ↗
(pattern: &PyPattern, search_text: PyStrRef)

Source from the content-addressed store, hash-verified

166 }
167
168 fn do_match(pattern: &PyPattern, search_text: PyStrRef) -> Option<PyMatch> {
169 // I really wish there was a better way to do this; I don't think there is
170 let mut regex_text = r"\A".to_owned();
171 regex_text.push_str(pattern.regex.as_str());
172 let regex = Regex::new(&regex_text).unwrap();
173 regex
174 .captures(search_text.as_bytes())
175 .map(|captures| create_match(search_text.clone(), captures))
176 }
177
178 fn do_search(regex: &PyPattern, search_text: PyStrRef) -> Option<PyMatch> {
179 regex

Callers 2

match_Function · 0.85
match_Method · 0.85

Calls 9

newFunction · 0.85
create_matchFunction · 0.85
to_ownedMethod · 0.45
push_strMethod · 0.45
as_strMethod · 0.45
unwrapMethod · 0.45
mapMethod · 0.45
as_bytesMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected