diff options
Diffstat (limited to 'users/wpcarro/scratch/rust/src/display')
-rw-r--r-- | users/wpcarro/scratch/rust/src/display/mod.rs | 13 |
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 000000000000..838463109190 --- /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) + } +} |