diff options
| author | Brad Clawsie <brad@b7j0c.org> | 2026-11-05 08:23:11 -0600 |
|---|---|---|
| committer | Brad Clawsie <brad@b7j0c.org> | 2026-11-05 08:23:11 -0600 |
| commit | e6922247c0380dc8a9e9faac4c9a53d3f281bb36 (patch) | |
| tree | e36b4c194f1ce27f314cb82479c2dd9e6d42347d /ex5_6/src/main.rs | |
| parent | 6c6aaeb8925bea2e7425159415680a589ab1e9b2 (diff) | |
feat: ex5_6
commit 0bc064fcbccfa1dab91a7eda07c3be8c72f5584b
Author: Brad Clawsie <brad@b7j0c.org>
Date: Thu Nov 5 08:22:58 2026 -0600
feat: ex5_6
Diffstat (limited to 'ex5_6/src/main.rs')
| -rw-r--r-- | ex5_6/src/main.rs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/ex5_6/src/main.rs b/ex5_6/src/main.rs new file mode 100644 index 0000000..5ca49f2 --- /dev/null +++ b/ex5_6/src/main.rs @@ -0,0 +1,46 @@ +#[derive(Debug, PartialEq)] +struct Ticket { + title: String, + description: String, + status: Status, +} + +#[derive(Debug, PartialEq)] +enum Status { + ToDo, + InProgress { assigned_to: String }, + Done, +} + +impl Ticket { + fn new(title: &str, description: &str, status: Status) -> Result<Ticket, String> { + if title.is_empty() { + return Err(String::from("title is empty")); + } + Ok( + Ticket { + title: String::from(title), + description: String::from(description), + status, + } + ) + } +} + +fn main() { + println!("Hello, world!"); +} + +#[cfg(test)] +mod tests { + use crate::*; + + #[test] + fn t0() { + assert_eq!(Ticket::new( + "", + "d", + Status::Done, + ).is_err(), true); + } +} |
