Skip to content

Commit

Permalink
fixing compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
zommiommy committed Aug 5, 2024
1 parent bc63ca6 commit c5780b4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
28 changes: 27 additions & 1 deletion graph/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,40 @@ pub struct Edge{
pub dst: String,
pub edge_type: Option<String>,
pub weight: Option<WeightT>,
};
}

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 {
(self.src == other.src) && (self.dst == other.dst) && (self.edge_type == other.edge_type) && (self.weight.zip(other.weight).map(|(a, b)| a == b).unwrap_or(true))
}
}

impl core::hash::Hash for Edge {
fn hash<H: core::hash::Hasher>(&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::<usize>.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 {
Expand Down
2 changes: 0 additions & 2 deletions graph/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@
#![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)]
#![feature(sync_unsafe_cell)]
#![feature(pattern)]
#![deny(unconditional_recursion)]
#![type_length_limit = "3764086"]
#![feature(exclusive_range_pattern)]

use std::sync::Arc;

Expand Down

0 comments on commit c5780b4

Please sign in to comment.