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

Method rsplit

crates/vm/src/builtins/str.rs:811–824  ·  view source on GitHub ↗
(zelf: &Py<Self>, args: SplitArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

809
810 #[pymethod]
811 fn rsplit(zelf: &Py<Self>, args: SplitArgs, vm: &VirtualMachine) -> PyResult<Vec<PyObjectRef>> {
812 let mut elements = zelf.as_wtf8().py_split(
813 args,
814 vm,
815 || zelf.as_object().to_owned(),
816 |v, s, vm| v.rsplit(s).map(|s| vm.ctx.new_str(s).into()).collect(),
817 |v, s, n, vm| v.rsplitn(n, s).map(|s| vm.ctx.new_str(s).into()).collect(),
818 |v, n, vm| v.py_rsplit_whitespace(n, |s| vm.ctx.new_str(s).into()),
819 )?;
820 // Unlike Python rsplit, Rust rsplitn returns an iterator that
821 // starts from the end of the string.
822 elements.reverse();
823 Ok(elements)
824 }
825
826 #[pymethod]
827 fn strip(&self, chars: OptionalOption<PyStrRef>) -> Self {

Callers 1

find_signatureFunction · 0.45

Calls 10

py_splitMethod · 0.80
collectMethod · 0.80
rsplitnMethod · 0.80
as_wtf8Method · 0.45
to_ownedMethod · 0.45
as_objectMethod · 0.45
mapMethod · 0.45
new_strMethod · 0.45
py_rsplit_whitespaceMethod · 0.45
reverseMethod · 0.45

Tested by

no test coverage detected