| 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 { |