From 72705e824ea12fc64737883dcd238d6e8a5509a0 Mon Sep 17 00:00:00 2001 From: Michael Sippel <micha@fragmental.art> Date: Wed, 2 Apr 2025 20:11:03 +0200 Subject: [PATCH] morphism type: add apply_subst() --- src/morphism_path_sugared.rs | 5 +---- src/morphism_sugared.rs | 7 +++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/morphism_path_sugared.rs b/src/morphism_path_sugared.rs index c2b6cf7..d6a6841 100644 --- a/src/morphism_path_sugared.rs +++ b/src/morphism_path_sugared.rs @@ -54,10 +54,7 @@ impl<'a, M:SugaredMorphism+Clone> SugaredShortestPathProblem<'a, M> { let mut creates_loop = false; let mut new_path = prev_path.clone(); - for n in new_path.morphisms.iter_mut() { - n.apply_subst(&morph_inst.get_subst()); - } - + new_path.apply_subst(&morph_inst.get_subst()); for m in new_path.morphisms.iter() { if m.get_type().src_type == dst_type { creates_loop = true; diff --git a/src/morphism_sugared.rs b/src/morphism_sugared.rs index 0f63191..f9c36eb 100644 --- a/src/morphism_sugared.rs +++ b/src/morphism_sugared.rs @@ -135,6 +135,13 @@ impl SugaredMorphismType { (x,y) => SugaredMorphismType { src_type: x.clone(), dst_type: y.clone() } } } + + pub fn apply_subst(&self, σ: &impl SugaredSubstitution) -> SugaredMorphismType { + SugaredMorphismType { + src_type: self.src_type.clone().apply_subst(σ).clone(), + dst_type: self.dst_type.clone().apply_subst(σ).clone() + } + } } pub trait SugaredMorphism : Sized {