From 3e2228644c9324e8c241fb998327ca7cff093d94 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Fri, 16 Dec 2022 15:31:29 -0500 Subject: [PATCH] Fix clippy with Rust 1.66.0 (#762) The recent release of Rust 1.66.0 [1] added new on by default clippy rules which are causing failures when we run the clippy CI job with the new rust version. This commit updates the code to fix the issues that clippy has identified which will unblock CI. [1] https://blog.rust-lang.org/2022/12/15/Rust-1.66.0.html --- src/digraph.rs | 6 +++--- src/graph.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/digraph.rs b/src/digraph.rs index 1702fa714..9394577e1 100644 --- a/src/digraph.rs +++ b/src/digraph.rs @@ -2688,14 +2688,14 @@ impl PyDiGraph { } fn __getitem__(&self, idx: usize) -> PyResult<&PyObject> { - match self.graph.node_weight(NodeIndex::new(idx as usize)) { + match self.graph.node_weight(NodeIndex::new(idx)) { Some(data) => Ok(data), None => Err(PyIndexError::new_err("No node found for index")), } } fn __setitem__(&mut self, idx: usize, value: PyObject) -> PyResult<()> { - let data = match self.graph.node_weight_mut(NodeIndex::new(idx as usize)) { + let data = match self.graph.node_weight_mut(NodeIndex::new(idx)) { Some(node_data) => node_data, None => return Err(PyIndexError::new_err("No node found for index")), }; @@ -2704,7 +2704,7 @@ impl PyDiGraph { } fn __delitem__(&mut self, idx: usize) -> PyResult<()> { - match self.graph.remove_node(NodeIndex::new(idx as usize)) { + match self.graph.remove_node(NodeIndex::new(idx)) { Some(_) => Ok(()), None => Err(PyIndexError::new_err("No node found for index")), } diff --git a/src/graph.rs b/src/graph.rs index 022fd8050..dd4610698 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -1746,7 +1746,7 @@ impl PyGraph { } fn __delitem__(&mut self, idx: usize) -> PyResult<()> { - match self.graph.remove_node(NodeIndex::new(idx as usize)) { + match self.graph.remove_node(NodeIndex::new(idx)) { Some(_) => Ok(()), None => Err(PyIndexError::new_err("No node found for index")), }