vmm: use Option::map and Option::cloned

It's more concise, more idiomatic Rust, and satisfies nightly clippy.

Signed-off-by: Gaelan Steele <gbs@canishe.com>
This commit is contained in:
Gaelan Steele
2021-03-28 23:16:35 -07:00
committed by Sebastien Boeuf
parent b16fdb1b3a
commit b161a570ec
2 changed files with 10 additions and 17 deletions

View File

@@ -3136,11 +3136,9 @@ impl DeviceManager {
}
pub fn interrupt_controller(&self) -> Option<Arc<Mutex<dyn InterruptController>>> {
if let Some(interrupt_controller) = &self.interrupt_controller {
Some(interrupt_controller.clone() as Arc<Mutex<dyn InterruptController>>)
} else {
None
}
self.interrupt_controller
.as_ref()
.map(|ic| ic.clone() as Arc<Mutex<dyn InterruptController>>)
}
pub fn console(&self) -> &Arc<Console> {