1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
//! Contains the EntryInformation struct that holds information about each
//! entry that can be sorted.
//-----------------------------------------------------------------------------
use std::fmt::Display;
//-----------------------------------------------------------------------------
/// Represents an individual with a Name, Age, and Height.
#[derive(Clone)]
pub struct EntryInformation {
    /// Name of this individual.
    pub name: String,
    /// Age of this individual, in years.
    pub age: i32,
    /// Height of this individual, in inches.
    pub height: i32,
}
impl EntryInformation {
    /// Constructor
    ///
    /// # Parameters
    /// - name
    ///
    ///   Name of an individual
    /// - age
    ///
    ///   Age of an individual (in years)
    /// - height
    ///
    ///   Height of an individual (in inches)
    ///
    /// # Returns
    /// Returns a new instance of the EntryInformation struct.
    pub fn new(name: &str, age: i32, height: i32) -> EntryInformation {
        EntryInformation {
            name: name.to_string(),
            age,
            height,
        }
    }
}
impl Display for EntryInformation {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_fmt(format_args!("{0:6} {1:3} {2:3}\"", self.name, self.age, self.height))
    }
}