Exercise 08 / 24: The spreadsheet export

// Iterators of Code 2026 — Day 08: The spreadsheet export
// Refactor data_lines using iterators. Skip initial comments (starting with #)
// and empty lines. Once data begins, preserve EVERY remaining line, even blanks
// and lines starting with #. Do not trim whitespace.

fn data_lines<'a>(lines: &[&'a str]) -> Vec<&'a str> {
    let mut result = Vec::new();
    let mut started = false;
    for &line in lines {
        if !started {
            if line.is_empty() || line.starts_with('#') {
                continue;
            }
            started = true;
        }
        result.push(line);
    }
    result
}

fn main() {
    assert_eq!(
        data_lines(&["# Exported today", "", "name,score", "Ada,42", "", "#end"]),
        ["name,score", "Ada,42", "", "#end"]
    );
    assert_eq!(data_lines(&[" ", "#data"]), [" ", "#data"]);
    assert!(data_lines(&["# Nothing here", ""]).is_empty());
    assert!(data_lines(&[]).is_empty());
}

Your solution

Standalone .rs / std only. Stored, not executed.

60 characters max. Not a login.

File overrides pasted code.

Maximum solution size: 64 KiB.

Editing access uses this browser's cookie. Clearing cookies loses access.