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

Method partition

crates/vm/src/builtins/bytearray.rs:469–480  ·  view source on GitHub ↗
(&self, sep: PyBytesInner, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

467
468 #[pymethod]
469 fn partition(&self, sep: PyBytesInner, vm: &VirtualMachine) -> PyResult<PyTupleRef> {
470 // sep ALWAYS converted to bytearray even it's bytes or memoryview
471 // so its ok to accept PyBytesInner
472 let value = self.inner();
473 let (front, has_mid, back) = value.partition(&sep, vm)?;
474 Ok(vm.new_tuple((
475 vm.ctx.new_bytearray(front.to_vec()),
476 vm.ctx
477 .new_bytearray(if has_mid { sep.elements } else { Vec::new() }),
478 vm.ctx.new_bytearray(back.to_vec()),
479 )))
480 }
481
482 #[pymethod]
483 fn rpartition(&self, sep: PyBytesInner, vm: &VirtualMachine) -> PyResult<PyTupleRef> {

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
new_bytearrayMethod · 0.80
to_vecMethod · 0.80
innerMethod · 0.45
new_tupleMethod · 0.45

Tested by

no test coverage detected