Struct tdtxt::Description [−][src]
pub struct Description { /* fields omitted */ }
Expand description
Represents the description part of a Task
.
Components like projects, contexts and custom tags are all implemented as byte range indices into the raw description text. This is done to avoid unnecessary allocations which in turn reduces the memory footprint.
Implementations
Creates a new description from s
.
During this process all projects, contexts and custom tags will be located.
Returns the text of the whole description.
Returns an iterator of all projects found within the description.
Returns an iterator of all contexts found within the description.
Returns an iterator of all custom tags found within the description.
pub fn components(&self) -> Components<'_>ⓘNotable traits for Components<'a>impl<'a> Iterator for Components<'a> type Item = Component<'a>;
pub fn components(&self) -> Components<'_>ⓘNotable traits for Components<'a>impl<'a> Iterator for Components<'a> type Item = Component<'a>;
impl<'a> Iterator for Components<'a> type Item = Component<'a>;
Returns an iterator of all the Component
’s of the description.
Examples
use tdtxt::{Description, Component};
let input = "Call Mom +Family +PeaceLoveAndHappiness @iphone @phone number:+1(111)111-7777";
let description = Description::new(input);
let mut components = description.components();
assert_eq!(components.next(), Some(Component::Text("Call Mom ")));
assert_eq!(components.next(), Some(Component::Project("+Family")));
assert_eq!(components.next(), Some(Component::Text(" ")));
assert_eq!(components.next(), Some(Component::Project("+PeaceLoveAndHappiness")));
assert_eq!(components.next(), Some(Component::Text(" ")));
assert_eq!(components.next(), Some(Component::Context("@iphone")));
assert_eq!(components.next(), Some(Component::Text(" ")));
assert_eq!(components.next(), Some(Component::Context("@phone")));
assert_eq!(components.next(), Some(Component::Text(" ")));
assert_eq!(components.next(), Some(Component::Custom {
key: "number",
separator: ":",
value: "+1(111)111-7777"
}));
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for Description
impl Send for Description
impl Sync for Description
impl Unpin for Description
impl UnwindSafe for Description
Blanket Implementations
Mutably borrows from an owned value. Read more