Skip to main content

FormatTasks

Trait FormatTasks 

Source
pub trait FormatTasks {
    // Required methods
    fn format(&mut self) -> String;
    fn divide(&mut self, parts: usize) -> Vec<Vec<Task>>;
}
Expand description

Display formatting and partitioning for task collections.

use kasl::libs::task::{Task, FormatTasks};

let mut tasks = vec![
    Task::new("Task 1", "Description 1", Some(50)),
    Task::new("Task 2", "Description 2", Some(75)),
    Task::new("Task 3", "Description 3", Some(100)),
];

let formatted = tasks.format();
println!("{}", formatted);

let groups = tasks.divide(2);
for (i, group) in groups.iter().enumerate() {
    println!("Group {}: {} tasks", i, group.len());
}

Required Methods§

Source

fn format(&mut self) -> String

Renders one {name} ({completeness}%) line per task.

use kasl::libs::task::{Task, FormatTasks};

let mut tasks = vec![
    Task::new("Review PR", "Code review for auth changes", Some(25)),
    Task::new("Write tests", "Unit tests for API endpoints", Some(75)),
];

let output = tasks.format();
// Review PR (25%)
// Write tests (75%)
Source

fn divide(&mut self, parts: usize) -> Vec<Vec<Task>>

Splits the collection into parts groups differing by at most one task. A single task is duplicated into every group; fewer tasks than parts distributes round-robin.

use kasl::libs::task::{Task, FormatTasks};

let mut tasks = vec![
    Task::new("Task 1", "", None),
    Task::new("Task 2", "", None),
    Task::new("Task 3", "", None),
    Task::new("Task 4", "", None),
    Task::new("Task 5", "", None),
];

let groups = tasks.divide(3);

assert_eq!(groups.len(), 3);
assert_eq!(groups[0].len(), 2);
assert_eq!(groups[1].len(), 2);
assert_eq!(groups[2].len(), 1);

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FormatTasks for Vec<Task>

Source§

fn divide(&mut self, parts: usize) -> Vec<Vec<Task>>

Source§

fn format(&mut self) -> String

Implementors§