/// Deletes a task at index `number`. The index starts at 1.
Deletes a task at index `number`. The index starts at 1.
Deletes a task at index ` number ` . The index starts at 1 .
pub fn delete_task(number: u8) -> Result<()> {
  if fs::file_exists() {
    let contents = fs::load()?;
    let mut tasks = decode(&contents[..])?;
    tasks.sort();
    if (number - 1) as usize >= tasks.len() {
      bail!("Task {} does not exist!", number);
    }
    tasks.remove((number - 1) as usize);
    let encoded_tasks = encode(&tasks)?;
    fs::save(encoded_tasks)
  } else {
    bail!("Task list is empty!");
  }
}
pub fn delete_task ( number : u8 ) -> Result < ( ) > { if fs :: file_exists ( ) { let contents = fs :: load ( ) ? ; let mut tasks = decode ( & contents [ .. ] ) ? ; tasks . sort ( ) ; if ( number - 1 ) as usize >= tasks . len ( ) { bail ! ( " " number ) ; } tasks . remove ( ( number - 1 ) as usize ) ; let encoded_tasks = encode ( & tasks ) ? ; fs :: save ( encoded_tasks ) } else { bail ! ( " " ) ; } }
Deletes a task at index `number`.
Deletes a task at index ` number ` .
number
u8