I wrote:
fn split_whitespace(string: &str) -> Vec<String> {
let mut line = 1;
let mut position = 1;
GitHub CoPilot wrote:
let mut tokens = Vec::new();
let mut current_token = String::new();
for c in string.chars() {
if c == '\n' {
line += 1;
position = 1;
} else {
position += 1;
}
if c.is_whitespace() {
if !current_token.is_empty() {
tokens.push(current_token);
current_token = String::new();
}
} else {
current_token.push(c);
}
}
if !current_token.is_empty() {
tokens.push(current_token);
}
tokens
}