Compare commits
4 Commits
dfcb9736b2
...
d3b4c0d653
| Author | SHA1 | Date | |
|---|---|---|---|
| d3b4c0d653 | |||
| 8b78ea3a83 | |||
| 0e5cdc6d10 | |||
| 1d876eff10 |
@@ -1,6 +1,6 @@
|
|||||||
fn intro() -> &'static str {
|
fn intro() -> &'static str {
|
||||||
// TODO: fix me 👇
|
// TODO: fix me 👇
|
||||||
"I'm ready to __!"
|
"I'm ready to start modelling a software ticket!"
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -4,6 +4,16 @@
|
|||||||
//
|
//
|
||||||
// It should also have a method named `is_available` that returns a `true` if the quantity is
|
// It should also have a method named `is_available` that returns a `true` if the quantity is
|
||||||
// greater than 0, otherwise `false`.
|
// greater than 0, otherwise `false`.
|
||||||
|
struct Order {
|
||||||
|
price: u8,
|
||||||
|
quantity: u8,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Order {
|
||||||
|
fn is_available(self) -> bool {
|
||||||
|
self.quantity > 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
mod helpers {
|
mod helpers {
|
||||||
// TODO: Make this code compile, either by adding a `use` statement or by using
|
// TODO: Make this code compile, either by adding a `use` statement or by using
|
||||||
// the appropriate path to refer to the `Ticket` struct.
|
// the appropriate path to refer to the `Ticket` struct.
|
||||||
|
use super::Ticket;
|
||||||
|
|
||||||
fn create_todo_ticket(title: String, description: String) -> Ticket {
|
fn create_todo_ticket(title: String, description: String) -> Ticket {
|
||||||
Ticket::new(title, description, "To-Do".into())
|
Ticket::new(title, description, "To-Do".into())
|
||||||
|
|||||||
Reference in New Issue
Block a user