about summary refs log tree commit diff
path: root/users/wpcarro/scratch/rust/src/display/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'users/wpcarro/scratch/rust/src/display/mod.rs')
-rw-r--r--users/wpcarro/scratch/rust/src/display/mod.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/users/wpcarro/scratch/rust/src/display/mod.rs b/users/wpcarro/scratch/rust/src/display/mod.rs
new file mode 100644
index 0000000000..8384631091
--- /dev/null
+++ b/users/wpcarro/scratch/rust/src/display/mod.rs
@@ -0,0 +1,13 @@
+use std::fmt;
+
+pub struct Person {
+    pub fname: String,
+    pub lname: String,
+    pub age: i8,
+}
+
+impl fmt::Display for Person {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        write!(f, "{}, {} ({} years old)", self.lname, self.fname, self.age)
+    }
+}