MCPcopy Index your code
hub / github.com/RustPython/RustPython / trim_end_matches

Method trim_end_matches

crates/wtf8/src/lib.rs:1092–1106  ·  view source on GitHub ↗
(&self, f: impl Fn(CodePoint) -> bool)

Source from the content-addressed store, hash-verified

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)

Callers 6

raise_indentation_errorFunction · 0.80
write_syntaxerrorMethod · 0.80
readlineMethod · 0.80
rstripMethod · 0.80
get_statementMethod · 0.80
trim_matchesMethod · 0.80

Calls 5

code_pointsMethod · 0.80
cloneMethod · 0.45
mapMethod · 0.45
next_backMethod · 0.45
as_wtf8Method · 0.45

Tested by

no test coverage detected