solution to exercise 03_02
This commit is contained in:
parent
0e5cdc6d10
commit
8b78ea3a83
@ -17,7 +17,22 @@ impl Ticket {
|
|||||||
// as well as some `String` methods. Use the documentation of Rust's standard library
|
// as well as some `String` methods. Use the documentation of Rust's standard library
|
||||||
// to find the most appropriate options -> https://doc.rust-lang.org/std/string/struct.String.html
|
// to find the most appropriate options -> https://doc.rust-lang.org/std/string/struct.String.html
|
||||||
fn new(title: String, description: String, status: String) -> Self {
|
fn new(title: String, description: String, status: String) -> Self {
|
||||||
todo!();
|
if status != "To-Do" && status != "In Progress" && status != "Done" {
|
||||||
|
panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed")
|
||||||
|
}
|
||||||
|
if title.is_empty() {
|
||||||
|
panic!("Title cannot be empty")
|
||||||
|
}
|
||||||
|
if description.is_empty() {
|
||||||
|
panic!("Description cannot be empty")
|
||||||
|
}
|
||||||
|
if title.len() > 50 {
|
||||||
|
panic!("Title cannot be longer than 50 bytes")
|
||||||
|
}
|
||||||
|
if description.len() > 500 {
|
||||||
|
panic!("Description cannot be longer than 500 bytes")
|
||||||
|
}
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user