Open
Description
This one seems completely disconnected from the parallel text. Unwrapping is not necessarily involved, at all, in solving the problem. It's not even particularly suggested by the way the problem is presented.
// TODO: `easy_ticket` should panic when the title is invalid.
// When the description is invalid, instead, it should use a default description:
// "Description not provided".
fn easy_ticket(title: String, description: String, status: Status) -> Ticket {
// Validate title and panic if invalid
if title.is_empty() {
panic!("Title cannot be empty");
}
if title.len() > 50 {
panic!("Title cannot be longer than 50 bytes");
}
// Use default description if description is invalid
let final_description = if description.is_empty() || description.len() > 500 {
"Description not provided".to_string()
} else {
description
};
Ticket {
title,
description: final_description,
status,
}
}
Metadata
Metadata
Assignees
Labels
No labels