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

Method py_rsplit_whitespace

crates/vm/src/bytes_inner.rs:1102–1123  ·  view source on GitHub ↗
(&self, maxsplit: isize, convert: F)

Source from the content-addressed store, hash-verified

1100 }
1101
1102 fn py_rsplit_whitespace<F>(&self, maxsplit: isize, convert: F) -> Vec<PyObjectRef>
1103 where
1104 F: Fn(&Self) -> PyObjectRef,
1105 {
1106 let mut splits = Vec::new();
1107 let mut count = maxsplit;
1108 let mut haystack = self;
1109 while let Some(offset) = haystack.rfind_byteset(ASCII_WHITESPACES) {
1110 if offset + 1 != haystack.len() {
1111 if count == 0 {
1112 break;
1113 }
1114 splits.push(convert(&haystack[offset + 1..]));
1115 count -= 1;
1116 }
1117 haystack = &haystack[..offset];
1118 }
1119 if !haystack.is_empty() {
1120 splits.push(convert(haystack));
1121 }
1122 splits
1123 }
1124}
1125
1126#[derive(FromArgs)]

Callers 1

rsplitMethod · 0.45

Calls 5

newFunction · 0.85
convertFunction · 0.50
lenMethod · 0.45
pushMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected