From e6922247c0380dc8a9e9faac4c9a53d3f281bb36 Mon Sep 17 00:00:00 2001 From: Brad Clawsie Date: Thu, 5 Nov 2026 08:23:11 -0600 Subject: feat: ex5_6 commit 0bc064fcbccfa1dab91a7eda07c3be8c72f5584b Author: Brad Clawsie Date: Thu Nov 5 08:22:58 2026 -0600 feat: ex5_6 --- ex5_6/Cargo.lock | 7 +++++++ ex5_6/Cargo.toml | 6 ++++++ ex5_6/src/main.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 ex5_6/Cargo.lock create mode 100644 ex5_6/Cargo.toml create mode 100644 ex5_6/src/main.rs diff --git a/ex5_6/Cargo.lock b/ex5_6/Cargo.lock new file mode 100644 index 0000000..2b2e409 --- /dev/null +++ b/ex5_6/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_6" +version = "0.1.0" diff --git a/ex5_6/Cargo.toml b/ex5_6/Cargo.toml new file mode 100644 index 0000000..0d3aa10 --- /dev/null +++ b/ex5_6/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "ex5_6" +version = "0.1.0" +edition = "2024" + +[dependencies] 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 { + 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); + } +} -- cgit v1.2.3