1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#[derive(Debug, Clone)] pub struct Logger { debug: bool } impl Logger { pub fn new(debug: bool) -> Self { Logger { debug, } } pub fn out(&self, message: String) { if self.debug { println!("{}", message); } } }