in starlark/src/stdlib/string.rs [1075:1101]
fn splitlines(this: &str, ref keepends @ false: bool) -> anyhow::Result<Value<'v>> {
let mut s = this;
let mut lines = Vec::new();
loop {
if let Some(x) = s.find(|x| x == '\n' || x == '\r') {
let y = x;
let x = match s.get(y..y + 2) {
Some("\r\n") => y + 2,
_ => y + 1,
};
if keepends {
lines.push(heap.alloc(s.get(..x).unwrap()))
} else {
lines.push(heap.alloc(s.get(..y).unwrap()))
}
if x == s.len() {
return Ok(heap.alloc_list(&lines));
}
s = s.get(x..).unwrap();
} else {
if !s.is_empty() {
lines.push(heap.alloc(s));
}
return Ok(heap.alloc_list(&lines));
}
}
}