// Iterators of Code 2026 — Day 10: TODO Line Numbers // Challenge: Return the 1-based line numbers containing the exact text "TODO". // Blank lines still count. Refactor without maintaining a manual line counter. fn todo_lines(source: &str) -> Vec { let mut matches = Vec::new(); let mut line_number = 1; for line in source.lines() { if line.contains("TODO") { matches.push(line_number); } line_number += 1; } matches } fn main() { let source = "fn main() {\n\n // TODO: log failures\n run();\n // TODO: retry\n}"; assert_eq!(todo_lines(source), vec![3, 5]); // A line with two reminders is reported only once. assert_eq!(todo_lines("TODO: tests; TODO: docs"), vec![1]); assert_eq!(todo_lines("ready\r\nTODO: deploy\r\n"), vec![2]); assert_eq!(todo_lines("\nTODO\n"), vec![2]); assert!(todo_lines("todo: lowercase\nall done").is_empty()); assert!(todo_lines("\n\n").is_empty()); assert!(todo_lines("").is_empty()); }