1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#[deny(missing_docs)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
pub struct Task {
pub number: usize,
pub title: String,
pub status: Status,
pub remaining_work: Option<u8>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ProjectTasks {
pub project_name: String,
pub tasks: Vec<Task>,
}
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq)]
pub enum Status {
Todo,
Doing,
Done,
}
impl Task {
pub fn new(number: usize, title: &str) -> Self {
Task {
number,
title: String::from(title),
status: Status::Todo,
remaining_work: None,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn new_should_set_status_to_todo() {
assert_eq!(Task::new(1, "").status, Status::Todo);
}
#[test]
fn new_should_not_set_remaining_work() {
assert_eq!(Task::new(1, "").remaining_work, None);
}
}