Skip to main content

parse_task_query

Function parse_task_query 

Source
pub fn parse_task_query(q: &str) -> QueryTerms
Expand description

Splits a filter string into words and tags.

A token beginning with # and carrying at least one more character is a tag token; everything else is a bare word. Matching is case-insensitive, so both are lowercased here.

Bare words match the display text or a tag. Annotations are stripped out of Task::text, so a task rendered as review #work has the literal text review — a user who sees the #work pill and types work would otherwise get nothing back.

§Examples

use mbr_core::task_query::parse_task_query;

let terms = parse_task_query("Report  #Work");
assert_eq!(terms.words, ["report"]);
assert_eq!(terms.tags, ["work"]);

// A lone `#` is not a tag token.
assert_eq!(parse_task_query("#").words, ["#"]);