add House struct
This commit is contained in:
@@ -32,13 +32,11 @@ impl Room {
|
||||
}
|
||||
|
||||
pub fn print_status(&self) {
|
||||
println!("{}", "=".repeat(16));
|
||||
println!("{}:", self.name);
|
||||
println!("{}", "-".repeat(16));
|
||||
println!("ROOM '{}':", self.name);
|
||||
println!("{}", "-".repeat(24));
|
||||
for d in self.devices.iter() {
|
||||
d.print_status();
|
||||
}
|
||||
println!("{}", "=".repeat(16));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,9 +58,8 @@ mod tests {
|
||||
assert_eq!(format!("{}", room.get_device(0).display()), "DEV:PowerSocket[ OFF : 0.0 ]");
|
||||
assert_eq!(format!("{}", room.get_device(1).display()), "DEV:Thermometer[ 21.6 ]");
|
||||
|
||||
let power_socket = match room.get_device_mut(0) {
|
||||
Device::PowerSocket(ps) => ps,
|
||||
_ => unreachable!(),
|
||||
let Device::PowerSocket(power_socket) = room.get_device_mut(0) else {
|
||||
unreachable!()
|
||||
};
|
||||
power_socket.set_on(true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user