completed most of 05 ticket v2

This commit is contained in:
2025-03-17 06:39:58 +05:30
parent 8d1342c831
commit 8413518a84
14 changed files with 132 additions and 27 deletions

View File

@@ -2,7 +2,25 @@
// 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 {
todo!()
let tick = Ticket::new(title.clone(), description.clone(), status.clone());
match tick {
Ok(res) => return res,
Err(err) => {
match err.as_str() {
"Description cannot be empty" | "Description cannot be longer than 500 bytes" => {
return Ticket {
title: title.clone(),
description: "Description not provided".to_string(),
status: status.clone(),
};
}
_ => {
panic!("{err}");
}
};
}
}
}
#[derive(Debug, PartialEq, Clone)]