(&self, f: impl Fn(CodePoint) -> bool)
| 1090 | } |
| 1091 | |
| 1092 | pub fn trim_end_matches(&self, f: impl Fn(CodePoint) -> bool) -> &Self { |
| 1093 | let mut iter = self.code_points(); |
| 1094 | loop { |
| 1095 | let old = iter.clone(); |
| 1096 | match iter.next_back().map(&f) { |
| 1097 | Some(true) => continue, |
| 1098 | Some(false) => { |
| 1099 | iter = old; |
| 1100 | break; |
| 1101 | } |
| 1102 | None => return iter.as_wtf8(), |
| 1103 | } |
| 1104 | } |
| 1105 | iter.as_wtf8() |
| 1106 | } |
| 1107 | |
| 1108 | pub fn trim_matches(&self, f: impl Fn(CodePoint) -> bool) -> &Self { |
| 1109 | self.trim_start_matches(&f).trim_end_matches(&f) |
no test coverage detected