~whynothugo/shotman

6203d32410cb65fb00f0485f1d6cee2ba0e7151f — Hugo Osvaldo Barrera 5 months ago c8bf05f
Remove pointless clone
1 files changed, 6 insertions(+), 8 deletions(-)

M src/sway.rs
M src/sway.rs => src/sway.rs +6 -8
@@ 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.