pub struct TodoList {
pub name: String,
pub list: Vec<Todo>,
}Expand description
Simple todo list structure.
Todos can be grouped together in so called todo lists (as in the real world).
Therefore, the TodoList struct can be used. It’s a simple data structure that holds a
number of Todo items and offers all basic functions for managing them.
Fields§
§name: StringName of the todo list.
list: Vec<Todo>The actual vector of Todo items.
Implementations§
Source§impl TodoList
impl TodoList
Sourcepub fn contains_id(&self, id: u32) -> TdoResult<usize>
pub fn contains_id(&self, id: u32) -> TdoResult<usize>
Check if the list contains a todo with the given ID.
This function returns a TdoResult, wich will contion a TodoError::NotInList
if the list does not contain any todo with the given ID or the position in the list.
Sourcepub fn done_id(&mut self, id: u32) -> TdoResult<()>
pub fn done_id(&mut self, id: u32) -> TdoResult<()>
Mark a todo from the list with the given ID as done.
This function returns a TdoResult, which will contain a TodoError::NotInList
if the list does not contain any todo with the given ID.
Sourcepub fn remove_id(&mut self, id: u32) -> TdoResult<Todo>
pub fn remove_id(&mut self, id: u32) -> TdoResult<Todo>
Remove a todo with the given ID from the list.
This function returns a TdoResult, which will contain the removed Todo itself or a
TodoError::NotInList if the list does not contain any todo with the given id.
Sourcepub fn list_undone(&self) -> Vec<Todo>
pub fn list_undone(&self) -> Vec<Todo>
Search for all undone todos in the list.
Returns a vector of all undone todos.
Sourcepub fn pop_id(&mut self, todo_id: u32) -> TdoResult<Todo>
pub fn pop_id(&mut self, todo_id: u32) -> TdoResult<Todo>
Remove a todo with a specific ID from the list.
Sourcepub fn insert_todo(&mut self, todo: Todo)
pub fn insert_todo(&mut self, todo: Todo)
Insert an existing todo into the list, preserving the ordering of the internal list.
Trait Implementations§
Source§impl Default for TodoList
Instanciates a default TodoList.
This function is invoked when a Tdo container structure is instanciated.
impl Default for TodoList
Instanciates a default TodoList.
This function is invoked when a Tdo container structure is instanciated.