(&self)
| 1011 | |
| 1012 | #[pymethod] |
| 1013 | fn title(&self) -> Wtf8Buf { |
| 1014 | let mut title = Wtf8Buf::with_capacity(self.data.len()); |
| 1015 | let mut previous_is_cased = false; |
| 1016 | for c_orig in self.as_wtf8().code_points() { |
| 1017 | let c = c_orig.to_char_lossy(); |
| 1018 | if c.is_lowercase() { |
| 1019 | if !previous_is_cased { |
| 1020 | title.extend(c.to_titlecase()); |
| 1021 | } else { |
| 1022 | title.push_char(c); |
| 1023 | } |
| 1024 | previous_is_cased = true; |
| 1025 | } else if c.is_uppercase() || c.is_titlecase() { |
| 1026 | if previous_is_cased { |
| 1027 | title.extend(c.to_lowercase()); |
| 1028 | } else { |
| 1029 | title.push_char(c); |
| 1030 | } |
| 1031 | previous_is_cased = true; |
| 1032 | } else { |
| 1033 | previous_is_cased = false; |
| 1034 | title.push(c_orig); |
| 1035 | } |
| 1036 | } |
| 1037 | title |
| 1038 | } |
| 1039 | |
| 1040 | #[pymethod] |
| 1041 | fn swapcase(&self) -> Wtf8Buf { |
nothing calls this directly
no test coverage detected