From 23cddeb94043b99488b6d8a742ebf584c98bf224 Mon Sep 17 00:00:00 2001 From: numzero Date: Mon, 27 May 2024 19:24:12 +0300 Subject: [PATCH] Split! --- src/bin/flat.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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!") }