From 6f2517c83012999a0253a782f3a72b32ca8a41f0 Mon Sep 17 00:00:00 2001 From: Wesley Irvin Date: Sun, 19 Nov 2023 15:05:47 -0500 Subject: [PATCH] Create Item Definition of an item struct. --- Cargo.lock | 7 +++++++ src/item.rs | 4 ++++ src/lib.rs | 18 ++++++++++++++++++ src/main.rs | 7 ++++++- 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Cargo.lock create mode 100644 src/item.rs create mode 100644 src/lib.rs diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..c9163c0 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "steel_saga" +version = "0.1.0" diff --git a/src/item.rs b/src/item.rs new file mode 100644 index 0000000..620a25c --- /dev/null +++ b/src/item.rs @@ -0,0 +1,4 @@ +pub struct Item { + pub name: String, + pub value: i32, +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..298078a --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,18 @@ +use std::error::Error; + +mod item; +use item::Item; + +pub fn run() -> Result<(), Box> { + let item = Item { + name: String::from("Test Item"), + value: 300, + }; + + println!( + "This item is {} and it's value is {}.", + item.name, item.value + ); + + Ok(()) +} diff --git a/src/main.rs b/src/main.rs index e7a11a9..f7c6a35 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,8 @@ +use std::process; + fn main() { - println!("Hello, world!"); + if let Err(e) = steel_saga::run() { + println!("Error: {e}"); + process::exit(1); + } } -- 2.49.1