(&self, chars: OptionalOption<PyStrRef>)
| 825 | |
| 826 | #[pymethod] |
| 827 | fn strip(&self, chars: OptionalOption<PyStrRef>) -> Self { |
| 828 | match self.as_str_kind() { |
| 829 | PyKindStr::Ascii(s) => s |
| 830 | .py_strip( |
| 831 | chars, |
| 832 | |s, chars| { |
| 833 | let s = s |
| 834 | .as_str() |
| 835 | .trim_matches(|c| memchr::memchr(c as _, chars.as_bytes()).is_some()); |
| 836 | unsafe { AsciiStr::from_ascii_unchecked(s.as_bytes()) } |
| 837 | }, |
| 838 | |s| s.trim(), |
| 839 | ) |
| 840 | .into(), |
| 841 | PyKindStr::Utf8(s) => s |
| 842 | .py_strip( |
| 843 | chars, |
| 844 | |s, chars| s.trim_matches(|c| chars.contains(c)), |
| 845 | |s| s.trim(), |
| 846 | ) |
| 847 | .into(), |
| 848 | PyKindStr::Wtf8(w) => w |
| 849 | .py_strip( |
| 850 | chars, |
| 851 | |s, chars| s.trim_matches(|c| chars.code_points().contains(&c)), |
| 852 | |s| s.trim(), |
| 853 | ) |
| 854 | .into(), |
| 855 | } |
| 856 | } |
| 857 | |
| 858 | #[pymethod] |
| 859 | fn lstrip( |
nothing calls this directly
no test coverage detected