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

Method sub

crates/stdlib/src/re.rs:333–337  ·  view source on GitHub ↗
(&self, repl: PyStrRef, text: PyStrRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

331
332 #[pymethod]
333 fn sub(&self, repl: PyStrRef, text: PyStrRef, vm: &VirtualMachine) -> PyResult<PyStrRef> {
334 let replaced_text = self.regex.replace_all(text.as_bytes(), repl.as_bytes());
335 let replaced_text = String::from_utf8_lossy(&replaced_text).into_owned();
336 Ok(vm.ctx.new_str(replaced_text))
337 }
338
339 #[pymethod]
340 fn subn(&self, repl: PyStrRef, text: PyStrRef, vm: &VirtualMachine) -> PyResult {

Callers 4

generate_tests.pyFile · 0.45
back_advanceMethod · 0.45
back_skipMethod · 0.45
subnMethod · 0.45

Calls 3

into_ownedMethod · 0.80
as_bytesMethod · 0.45
new_strMethod · 0.45

Tested by

no test coverage detected