pub fn parse_task_line(line: &str, line_number: u32) -> Option<Task>Expand description
Parses a single line as a task, returning None if it is not one.
line_number is stored verbatim in Task::line; callers are responsible
for it being 1-based.
§Depth
Indentation is measured in columns with a tab counting as four, then halved:
depth = columns / 2. Markdown nesting is two-or-four spaces depending on the
author (and a tab depending on the editor), and there is no way to recover the
author’s intent from a single line. All this value has to be is monotonic
for display indentation, so the cheap halving is enough — it maps both the
two-space and the four-space convention onto increasing levels, and it never
panics because it saturates at u8::MAX.
§Examples
use mbr_core::tasks::{TaskStatus, parse_task_line};
assert!(parse_task_line("not a task", 1).is_none());
assert!(parse_task_line("- [y] unknown marker", 1).is_none());
let task = parse_task_line(" * [x] done thing @done(2026-08-04 12:11 PM)", 3).unwrap();
assert_eq!(task.status, TaskStatus::Done);
assert_eq!(task.depth, 1);
assert_eq!(task.text, "done thing");
assert!(task.done_has_time);