@@ 16,15 16,15 @@ struct Node {
}
impl Node {
- fn find_focused(&self) -> Option<&Node> {
+ fn take_focused(self) -> Option<Node> {
if self.focused {
return Some(self);
}
self.nodes
- .iter()
- .chain(&self.floating_nodes)
- .find_map(Node::find_focused)
+ .into_iter()
+ .chain(self.floating_nodes)
+ .find_map(Node::take_focused)
}
}
@@ 83,11 83,9 @@ pub(crate) fn get_active_window_geom() -> Result<Rect, Error> {
.output()?;
let tree: Node = serde_json::from_slice(&output.stdout)?;
- let focused = tree.find_focused().ok_or(Error::NoFocusedWindow)?;
+ let focused = tree.take_focused().ok_or(Error::NoFocusedWindow)?;
- // XXX: Why do I need to clone?
- // Why Can't I extract the reference from the other stuff that's being dropped?
- Ok(focused.rect.clone())
+ Ok(focused.rect)
}
/// Returns the currently focused output rect.