-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask_manager.rs
78 lines (67 loc) · 1.95 KB
/
task_manager.rs
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
66
67
68
69
70
71
72
73
74
75
76
77
78
use std::collections::HashMap;
#[derive(Debug)]
enum Priority {
Low,
Medium,
High,
}
#[derive(Debug)]
enum Status {
Todo,
InProgress(String), // Stores assignee
Done(String), // Stores completion date
Blocked(String), // Stores reason
}
#[derive(Debug)]
struct Task {
description: String,
priority: Priority,
status: Status,
}
fn main() {
let mut tasks = HashMap::new();
// Create some sample tasks
tasks.insert(
1,
Task {
description: String::from("Implement login system"),
priority: Priority::High,
status: Status::InProgress(String::from("Alice")),
},
);
tasks.insert(
2,
Task {
description: String::from("Update documentation"),
priority: Priority::Low,
status: Status::Todo,
},
);
tasks.insert(
3,
Task {
description: String::from("Fix security bug"),
priority: Priority::High,
status: Status::Blocked(String::from("Waiting for security audit")),
},
);
// Process tasks using if let
for (id, task) in &tasks {
print!("Task {}: {} - ", id, task.description);
// Check high priority tasks
if let Priority::High = task.priority {
print!("[URGENT] ");
}
// Print status with details
match &task.status {
Status::Todo => println!("Not started"),
Status::InProgress(assignee) => println!("Being worked on by {}", assignee),
Status::Done(date) => println!("Completed on {}", date),
Status::Blocked(reason) => println!("Blocked: {}", reason),
}
// Special handling for blocked high-priority tasks
if let (Priority::High, Status::Blocked(reason)) = (&task.priority, &task.status) {
println!("⚠️ ATTENTION: High priority task is blocked: {}", reason);
}
}
}