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

Method py_split_whitespace

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

Source from the content-addressed store, hash-verified

1077 }
1078
1079 fn py_split_whitespace<F>(&self, maxsplit: isize, convert: F) -> Vec<PyObjectRef>
1080 where
1081 F: Fn(&Self) -> PyObjectRef,
1082 {
1083 let mut splits = Vec::new();
1084 let mut count = maxsplit;
1085 let mut haystack = self;
1086 while let Some(offset) = haystack.find_byteset(ASCII_WHITESPACES) {
1087 if offset != 0 {
1088 if count == 0 {
1089 break;
1090 }
1091 splits.push(convert(&haystack[..offset]));
1092 count -= 1;
1093 }
1094 haystack = &haystack[offset + 1..];
1095 }
1096 if !haystack.is_empty() {
1097 splits.push(convert(haystack));
1098 }
1099 splits
1100 }
1101
1102 fn py_rsplit_whitespace<F>(&self, maxsplit: isize, convert: F) -> Vec<PyObjectRef>
1103 where

Callers 1

splitMethod · 0.45

Calls 4

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

Tested by

no test coverage detected