about summary refs log blame commit diff
path: root/users/wpcarro/scratch/rust/src/display/mod.rs
blob: 83846310919045cbbf922d4779d5c1739b35d35f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
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)
    }
}