diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index e3d28144c..7d4d35518 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -52,11 +52,11 @@ pub trait ObjectIters<'r> { } /// Iterate over all global curves - fn global_curve_iter(&'r self) -> Iter<&'r GlobalCurve> { + fn global_curve_iter(&'r self) -> Iter<&'r Handle> { let mut iter = Iter::empty(); for object in self.referenced_objects() { - iter = iter.with(object.global_curve_iter()); + iter = iter.with_handles(object.global_curve_iter()); } iter @@ -187,7 +187,7 @@ impl<'r> ObjectIters<'r> for Handle { Vec::new() } - fn global_curve_iter(&'r self) -> Iter<&'r GlobalCurve> { + fn global_curve_iter(&'r self) -> Iter<&'r Handle> { Iter::from_object(self) } } @@ -337,6 +337,18 @@ impl Iter { } } +impl Iter<&'_ Handle> { + fn with_handles(mut self, other: Self) -> Self { + for handle in other { + if !self.0.iter().any(|h| h.id() == handle.id()) { + self.0.push_back(handle); + } + } + + self + } +} + impl Iterator for Iter { type Item = T;