summaryrefslogtreecommitdiff
path: root/ex5_5/src
diff options
context:
space:
mode:
authorBrad Clawsie <brad@b7j0c.org>2026-11-05 09:56:04 -0600
committerBrad Clawsie <brad@b7j0c.org>2026-11-05 13:18:47 -0600
commit15d9096d2452e09756eee0d82a23dd9b7b9ffb9d (patch)
tree9c7047b018343aef975e9710a957f3eed234586f /ex5_5/src
parent0962a0b7416a828a1ebb00337f22b6679f34e233 (diff)
parent665dcfc1121c5911478e973d392023213183e6d7 (diff)
ex5
Diffstat (limited to 'ex5_5/src')
-rw-r--r--ex5_5/src/main.rs41
1 files changed, 41 insertions, 0 deletions
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")));
+ }
+}