diff --git a/src/bin/flat.rs b/src/bin/flat.rs index 1d70cf3..0659f7f 100644 --- a/src/bin/flat.rs +++ b/src/bin/flat.rs @@ -96,6 +96,10 @@ impl Space { Location { pos: p, rot: corr * loc.rot } } + fn trace_iter(&self, ray: Ray) -> impl Iterator + '_ { + std::iter::successors(Some(ray), |&ray| Some(self.trace_step(ray))) + } + fn trace_inner(&self, ray: Ray) -> Ray { assert_eq!(self.which_subspace(ray.pos), Inner); let cell = RectInside { rect: self.rect }; @@ -116,7 +120,7 @@ impl Space { fn trace_boundary(&self, ray: Ray) -> Ray { assert_eq!(self.which_subspace(ray.pos), Boundary); - std::iter::successors(Some(ray), |&ray| Some(self.trace_step(ray))) + self.trace_iter(ray) .find(|&ray| self.which_subspace(ray.pos) != Boundary) .expect("Can't get outta the wall!") }