From 5f866737a8c9463697caf9ed26ef56d4b1d75195 Mon Sep 17 00:00:00 2001 From: numzero Date: Sat, 14 Sep 2024 13:13:22 +0300 Subject: [PATCH] Replace a diverging match with an if let --- src/bin/flat/main.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/bin/flat/main.rs b/src/bin/flat/main.rs index 86908bb..d56aed3 100644 --- a/src/bin/flat/main.rs +++ b/src/bin/flat/main.rs @@ -148,14 +148,13 @@ fn draw_ray_2(gc: &mut Vec, space: &Space, base: Vec2, dir: Vec2) { hits.line_to(pos2.x + 1.0, pos2.y - 1.0); } let a = ray.pos; - ray = match ret.end { - Some(r) => r, - None => { - ray = ray.forward(1000.0 / DT); - gc.line_to(ray.pos.x, ray.pos.y); - break; - } - }; + if let Some(r) = ret.end { + ray = r + } else { + ray = ray.forward(1000.0 / DT); + gc.line_to(ray.pos.x, ray.pos.y); + break; + } for p in space.line(a, ray.pos, 10.0) { gc.line_to(p.x, p.y); }