homework: extract print_status into a separate trait
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use crate::PrintStatus;
|
||||
use std::fmt::Display;
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -17,10 +18,6 @@ impl Device {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_status(&self) {
|
||||
println!("{}", self.display());
|
||||
}
|
||||
}
|
||||
|
||||
impl From<super::Thermometer> for Device {
|
||||
@@ -35,6 +32,12 @@ impl From<super::PowerSocket> for Device {
|
||||
}
|
||||
}
|
||||
|
||||
impl PrintStatus for Device {
|
||||
fn print_status(&self) {
|
||||
println!("{}", self.display());
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user