29 lines
1.1 KiB
Rust
29 lines
1.1 KiB
Rust
// TODO: you have something to do in each of the modules in this crate!
|
|
mod description;
|
|
mod status;
|
|
mod title;
|
|
|
|
// A common pattern in Rust is to split code into multiple (private) modules
|
|
// and then re-export the public parts of those modules at the root of the crate.
|
|
//
|
|
// This hides the internal structure of the crate from your users, while still
|
|
// allowing you to organize your code however you like.
|
|
pub use description::TicketDescription;
|
|
pub use status::Status;
|
|
pub use title::TicketTitle;
|
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
|
// We no longer need to make the fields private!
|
|
// Since each field encapsulates its own validation logic, there is no risk of
|
|
// a user of `Ticket` modifying the fields in a way that would break the
|
|
// invariants of the struct.
|
|
//
|
|
// Careful though: if you had any invariants that spanned multiple fields, you
|
|
// would need to ensure that those invariants are still maintained and go back
|
|
// to making the fields private.
|
|
pub struct Ticket {
|
|
pub title: TicketTitle,
|
|
pub description: TicketDescription,
|
|
pub status: Status,
|
|
}
|