From c5780b413dd362708446221a0d76b4da8d599af3 Mon Sep 17 00:00:00 2001 From: Tommaso Fontana Date: Mon, 5 Aug 2024 17:03:34 +0200 Subject: [PATCH] fixing compilation --- graph/src/builder.rs | 28 +++++++++++++++++++++++++++- graph/src/lib.rs | 2 -- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/graph/src/builder.rs b/graph/src/builder.rs index 58e185afee83..26ee583155e4 100644 --- a/graph/src/builder.rs +++ b/graph/src/builder.rs @@ -11,7 +11,14 @@ pub struct Edge{ pub dst: String, pub edge_type: Option, pub weight: Option, -}; +} + +impl Edge { + // dummy method so the code analysis don't break because no methods for this struct + pub fn is_selfloop(&self) -> bool { + self.src == self.dst + } +} impl PartialEq for Edge { fn eq(&self, other: &Self) -> bool { @@ -19,6 +26,25 @@ impl PartialEq for Edge { } } +impl core::hash::Hash for Edge { + fn hash(&self, state: &mut H) { + self.src.hash(state); + self.dst.hash(state); + self.edge_type.hash(state); + if let Some(x) = self.weight { + crate::hash::hash_f32(x, state); + } else { + None::.hash(state); + } + } +} + +impl std::string::ToString for Edge { + fn to_string(&self) -> String { + format!("{} -> {} (type: {:?}, weight: {:?})", self.src, self.dst, self.edge_type, self.weight) + } +} + impl Eq for Edge {} impl PartialOrd for Edge { diff --git a/graph/src/lib.rs b/graph/src/lib.rs index 4918ba3fa06e..5b25811eb2f3 100644 --- a/graph/src/lib.rs +++ b/graph/src/lib.rs @@ -10,7 +10,6 @@ #![warn(unused_macros)] #![feature(iter_advance_by)] #![feature(impl_trait_in_assoc_type)] -#![feature(is_sorted)] #![feature(string_remove_matches)] #![feature(exit_status_error)] #![feature(core_intrinsics)] @@ -18,7 +17,6 @@ #![feature(pattern)] #![deny(unconditional_recursion)] #![type_length_limit = "3764086"] -#![feature(exclusive_range_pattern)] use std::sync::Arc;