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

Method istitle

crates/vm/src/builtins/str.rs:1253–1278  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

1251
1252 #[pymethod]
1253 fn istitle(&self) -> bool {
1254 if self.data.is_empty() {
1255 return false;
1256 }
1257
1258 let mut cased = false;
1259 let mut previous_is_cased = false;
1260 for c in self.as_wtf8().code_points().map(CodePoint::to_char_lossy) {
1261 if c.is_uppercase() || c.is_titlecase() {
1262 if previous_is_cased {
1263 return false;
1264 }
1265 previous_is_cased = true;
1266 cased = true;
1267 } else if c.is_lowercase() {
1268 if !previous_is_cased {
1269 return false;
1270 }
1271 previous_is_cased = true;
1272 cased = true;
1273 } else {
1274 previous_is_cased = false;
1275 }
1276 }
1277 cased
1278 }
1279
1280 #[pymethod]
1281 fn count(&self, args: FindArgs) -> usize {

Callers

nothing calls this directly

Calls 6

code_pointsMethod · 0.80
is_emptyMethod · 0.45
mapMethod · 0.45
as_wtf8Method · 0.45
is_uppercaseMethod · 0.45
is_lowercaseMethod · 0.45

Tested by

no test coverage detected