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

Function do_sub

crates/stdlib/src/re.rs:161–166  ·  view source on GitHub ↗
(pattern: &PyPattern, repl: PyStrRef, search_text: PyStrRef, limit: usize)

Source from the content-addressed store, hash-verified

159 }
160
161 fn do_sub(pattern: &PyPattern, repl: PyStrRef, search_text: PyStrRef, limit: usize) -> String {
162 let out = pattern
163 .regex
164 .replacen(search_text.as_bytes(), limit, repl.as_bytes());
165 String::from_utf8_lossy(&out).into_owned()
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

Callers 1

subFunction · 0.85

Calls 3

replacenMethod · 0.80
into_ownedMethod · 0.80
as_bytesMethod · 0.45

Tested by

no test coverage detected