pub fn add(&mut self, todo: &ToDo) -> DataResult<Vec<ToDo>>  {
        println!("Add {:?}", todo);
        if todo.id > -1 {
            Err(DataError::new(format!("An item with the id {} already exists", todo.id)))
        } else {
            let adding = ToDo {
                id: self.max_id() + 1,
                complete: todo.complete,
                action: todo.action.clone(),
            };
            self.todos.push(adding);
            self.save_and_get()
        }
    }
/// Add a new item to our todo list (id must be -1)
Add a new item to our todo list (id must be -1)
Add a new item to our todo list ( id must be - 1 )
pub fn add(&mut self, todo: &ToDo) -> DataResult<Vec<ToDo>>  {
        println!("Add {:?}", todo);
        if todo.id > -1 {
            Err(DataError::new(format!("An item with the id {} already exists", todo.id)))
        } else {
            let adding = ToDo {
                id: self.max_id() + 1,
                complete: todo.complete,
                action: todo.action.clone(),
            };
            self.todos.push(adding);
            self.save_and_get()
        }
    }
pub fn add ( & mut self , todo : & ToDo ) -> DataResult < Vec < ToDo > > { println ! ( " " todo ) ; if todo . id > - 1 { Err ( DataError :: new ( format ! ( " " todo id ) ) ) } else { let adding = ToDo { id : self . max_id ( ) + 1 , complete : todo . complete , action : todo . action . clone ( ) , } ; self . todos . push ( adding ) ; self . save_and_get ( ) } }
Add a new item to our todo list (id must be -1)
Add a new item to our todo list ( id must be - 1 )
&mut self
todo
&ToDo
&mut self
todo
&ToDo