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

Method rstrip

crates/vm/src/builtins/str.rs:878–894  ·  view source on GitHub ↗
(
        zelf: PyRef<Self>,
        chars: OptionalOption<PyStrRef>,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

876
877 #[pymethod]
878 fn rstrip(
879 zelf: PyRef<Self>,
880 chars: OptionalOption<PyStrRef>,
881 vm: &VirtualMachine,
882 ) -> PyRef<Self> {
883 let s = zelf.as_wtf8();
884 let stripped = s.py_strip(
885 chars,
886 |s, chars| s.trim_end_matches(|c| chars.contains_code_point(c)),
887 |s| s.trim_end(),
888 );
889 if s == stripped {
890 zelf
891 } else {
892 vm.ctx.new_str(stripped)
893 }
894 }
895
896 #[pymethod]
897 fn endswith(&self, options: anystr::StartsEndsWithArgs, vm: &VirtualMachine) -> PyResult<bool> {

Callers

nothing calls this directly

Calls 6

py_stripMethod · 0.80
trim_end_matchesMethod · 0.80
contains_code_pointMethod · 0.80
trim_endMethod · 0.80
as_wtf8Method · 0.45
new_strMethod · 0.45

Tested by

no test coverage detected