-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
** Wrong Return Type in last_worker**
Problem:
The instructions require this function signature:
pub fn last_worker(&self) -> Option<(String, Role)>But the provided solution uses:
pub fn last_worker(&self) -> Option<(String, String)>This causes a mismatch with the tests, which expect a Role enum, not a String.
Fix:
Implement the Role enum and use it in both the Worker struct and the return type of last_worker.
3. Missing Role Enum
Problem:
Tests expect values like Role::CEO, Role::Manager, and Role::Worker.
The provided solution stores roles as String instead, which is incorrect.
Fix:
Define the Role enum as follows:
#[derive(Debug, PartialEq)]
pub enum Role {
CEO,
Manager,
Worker,
}
impl From<&str> for Role {
fn from(s: &str) -> Self {
match s {
"CEO" => Role::CEO,
"Manager" => Role::Manager,
_ => Role::Worker,
}
}
}Then update the Worker struct to use Role:
pub struct Worker {
pub role: Role,
pub name: String,
pub next: Link,
}Metadata
Metadata
Assignees
Labels
No labels