jweinst1
5/3/2019 - 11:41 PM

implement consumer and display for rust

implement consumer and display for rust

use std::fmt;
// Rust prototype for a consumer model

struct Consumer {
    uid:u32,
    demand:f32,
    supply:f32
}

impl fmt::Display for Consumer {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "({}) | demand: {} supply: {}|",  self.uid, self.demand, self.supply)
    }
}


fn main() {
   
   let cus = Consumer {uid:45, demand:1.753, supply:0.08};
   println!("{}", cus);
}