(&self)
| 729 | |
| 730 | #[pymethod] |
| 731 | fn capitalize(&self) -> Wtf8Buf { |
| 732 | match self.as_str_kind() { |
| 733 | PyKindStr::Ascii(s) => { |
| 734 | let mut s = s.to_owned(); |
| 735 | if let [first, rest @ ..] = s.as_mut_slice() { |
| 736 | first.make_ascii_uppercase(); |
| 737 | ascii::AsciiStr::make_ascii_lowercase(rest.into()); |
| 738 | } |
| 739 | s.into() |
| 740 | } |
| 741 | PyKindStr::Utf8(s) => { |
| 742 | let mut chars = s.chars(); |
| 743 | let mut out = String::with_capacity(s.len()); |
| 744 | if let Some(c) = chars.next() { |
| 745 | out.extend(c.to_titlecase()); |
| 746 | out.push_str(&chars.as_str().to_lowercase()); |
| 747 | } |
| 748 | out.into() |
| 749 | } |
| 750 | PyKindStr::Wtf8(s) => { |
| 751 | let mut out = Wtf8Buf::with_capacity(s.len()); |
| 752 | let mut chars = s.code_points(); |
| 753 | if let Some(ch) = chars.next() { |
| 754 | match ch.to_char() { |
| 755 | Some(ch) => out.extend(ch.to_titlecase()), |
| 756 | None => out.push(ch), |
| 757 | } |
| 758 | out.push_wtf8(&chars.as_wtf8().to_lowercase()); |
| 759 | } |
| 760 | out |
| 761 | } |
| 762 | } |
| 763 | } |
| 764 | |
| 765 | #[pymethod] |
| 766 | fn split(zelf: &Py<Self>, args: SplitArgs, vm: &VirtualMachine) -> PyResult<Vec<PyObjectRef>> { |
nothing calls this directly
no test coverage detected