Skip to content

Commit

Permalink
fn impls to explicit generics
Browse files Browse the repository at this point in the history
  • Loading branch information
E-gy committed May 20, 2021
1 parent b9a1143 commit fea8b9c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ where
d % 2 == 0 && (!DIRESPECT || d >= 0)
}
/// Find shortest path between 2 points
pub fn pathfind<Weight, const DIRESPECT: bool>(&self, n1: NId, n2: NId, weight: impl Fn(&Rc<E>) -> Option<Weight>) -> Option<Vec<Rc<E>>>
pub fn pathfind<Weight, FW, const DIRESPECT: bool>(&self, n1: NId, n2: NId, weight: FW) -> Option<Vec<Rc<E>>>
where
Weight: Clone + Copy + Ord + Default + std::ops::Add<Weight, Output = Weight> + std::ops::Neg<Output = Weight>
Weight: Clone + Copy + Ord + Default + std::ops::Add<Weight, Output = Weight> + std::ops::Neg<Output = Weight>,
FW: Fn(&Rc<E>) -> Option<Weight>,
{
let mut dp: HashMap<NId, (Weight, Option<Rc<E>>)> = HashMap::new();
dp.insert(n1.clone(), (Weight::default(), None));
Expand Down Expand Up @@ -124,9 +125,10 @@ where
None
}
/// Find shortest path between 2 regions
pub fn pathfind_regions<Weight, const DIRESPECT: bool>(&self, n1: &HashSet<NId>, n2: &HashSet<NId>, weight: impl Fn(&Rc<E>) -> Option<Weight>) -> Option<(NId, NId, Vec<Rc<E>>)>
pub fn pathfind_regions<Weight, FW, const DIRESPECT: bool>(&self, n1: &HashSet<NId>, n2: &HashSet<NId>, weight: FW) -> Option<(NId, NId, Vec<Rc<E>>)>
where
Weight: Clone + Copy + Ord + Default + std::ops::Add<Weight, Output = Weight> + std::ops::Neg<Output = Weight>
Weight: Clone + Copy + Ord + Default + std::ops::Add<Weight, Output = Weight> + std::ops::Neg<Output = Weight>,
FW: Fn(&Rc<E>) -> Option<Weight>,
{
if n1.is_empty() || n2.is_empty() {
return None;
Expand Down

0 comments on commit fea8b9c

Please sign in to comment.