From 007a155c456df3f48d34ea3a3e1c69c465be8097 Mon Sep 17 00:00:00 2001 From: Ivan Carvalho Date: Mon, 20 Nov 2023 22:19:30 -0500 Subject: [PATCH 1/2] Fix dijkstra's error occurrences --- rustworkx-core/src/shortest_path/dijkstra.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rustworkx-core/src/shortest_path/dijkstra.rs b/rustworkx-core/src/shortest_path/dijkstra.rs index c2f59fe20..e44937211 100644 --- a/rustworkx-core/src/shortest_path/dijkstra.rs +++ b/rustworkx-core/src/shortest_path/dijkstra.rs @@ -117,8 +117,8 @@ where let zero_score = K::default(); scores.put_item(start, zero_score); visit_next.push(MinScored(zero_score, start)); - if path.is_some() { - path.as_mut().unwrap().insert(start, vec![start]); + if let Some(path_mut) = &mut path { + path_mut.insert(start, vec![start]); } while let Some(MinScored(node_score, node)) = visit_next.pop() { if visited.is_visited(&node) { @@ -139,10 +139,10 @@ where if next_score < *current_score { scores.put_item(next, next_score); visit_next.push(MinScored(next_score, next)); - if path.is_some() { - let mut node_path = path.as_mut().unwrap().get(&node).unwrap().clone(); + if let Some(path_mut) = &mut path { + let mut node_path = path_mut.get(&node).unwrap().clone(); node_path.push(next); - path.as_mut().unwrap().entry(next).and_modify(|new_vec| { + path_mut.entry(next).and_modify(|new_vec| { *new_vec = node_path; }); } @@ -151,10 +151,10 @@ where None => { scores.put_item(next, next_score); visit_next.push(MinScored(next_score, next)); - if path.is_some() { - let mut node_path = path.as_mut().unwrap().get(&node).unwrap().clone(); + if let Some(path_mut) = &mut path { + let mut node_path = path_mut.get(&node).unwrap().clone(); node_path.push(next); - path.as_mut().unwrap().entry(next).or_insert(node_path); + path_mut.entry(next).or_insert(node_path); } } } From 8615443754d6a73d09397bc0fa68b2dbbdbe12e7 Mon Sep 17 00:00:00 2001 From: Ivan Carvalho Date: Mon, 20 Nov 2023 22:20:44 -0500 Subject: [PATCH 2/2] Fix clippy in score.rs --- src/score.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/score.rs b/src/score.rs index 95e0d5bea..49765ee4e 100644 --- a/src/score.rs +++ b/src/score.rs @@ -10,7 +10,7 @@ // License for the specific language governing permissions and limitations // under the License. #![allow(clippy::derive_partial_eq_without_eq)] -#![allow(clippy::incorrect_partial_ord_impl_on_ord_type)] +#![allow(clippy::non_canonical_partial_ord_impl)] use std::cmp::Ordering; use std::ops::{Add, AddAssign};