diff options
| author | Brad Clawsie <brad@b7j0c.org> | 2026-11-05 07:50:43 -0600 |
|---|---|---|
| committer | Brad Clawsie <brad@b7j0c.org> | 2026-11-05 07:50:43 -0600 |
| commit | 6c6aaeb8925bea2e7425159415680a589ab1e9b2 (patch) | |
| tree | d34ba59f8103a6d7e2f1aaf22f75c4047d65a3db | |
| parent | 92142fcea7c057f19c7dae1912b6d4a79fd8e8a4 (diff) | |
feat: ex5_5
commit 72926e5115e909569a4a509623e00b2f95750df8
Author: Brad Clawsie <brad@b7j0c.org>
Date: Thu Nov 5 07:50:26 2026 -0600
feat: ex5_5
| -rw-r--r-- | ex5_5/Cargo.lock | 7 | ||||
| -rw-r--r-- | ex5_5/Cargo.toml | 6 | ||||
| -rw-r--r-- | ex5_5/src/main.rs | 41 |
3 files changed, 54 insertions, 0 deletions
diff --git a/ex5_5/Cargo.lock b/ex5_5/Cargo.lock new file mode 100644 index 0000000..1d2f1ef --- /dev/null +++ b/ex5_5/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "ex5_5" +version = "0.1.0" diff --git a/ex5_5/Cargo.toml b/ex5_5/Cargo.toml new file mode 100644 index 0000000..ca7d7ea --- /dev/null +++ b/ex5_5/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "ex5_5" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/ex5_5/src/main.rs b/ex5_5/src/main.rs new file mode 100644 index 0000000..4741c3e --- /dev/null +++ b/ex5_5/src/main.rs @@ -0,0 +1,41 @@ +#[derive(Debug, PartialEq)] +struct Ticket { + title: String, + description: String, + status: Status, +} + +#[derive(Debug, PartialEq)] +enum Status { + ToDo, + InProgress { assigned_to: String }, + Done, +} + +impl Ticket { + pub fn assigned_to(&self) -> Option<String> { + match self.status { + Status::InProgress { ref assigned_to } => Some(assigned_to.clone()), + _ => None, + } + } +} + +fn main() { + println!("Hello, world!"); +} + +#[cfg(test)] +mod tests { + use crate::*; + + #[test] + fn t0() { + let t = Ticket{ + title: String::from("t"), + description: String::from("d"), + status: Status::InProgress { assigned_to: String::from("me")}, + }; + assert_eq!(t.assigned_to(), Some(String::from("me"))); + } +} |
