From abaf277fb48fdf5aa4452fcac07a5d5ac0001e85 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Fri, 20 Jun 2025 14:25:10 -0700 Subject: [PATCH] [core] Use the matches! macro to calculate the value of Shape::is_promotable I learned about this macro a little while ago and it's better than writing out a match block by hand, and also doesn't require static or const data, like the previous implementation did. --- core/src/shapes.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/shapes.rs b/core/src/shapes.rs index 8184f1d..0cedc7c 100644 --- a/core/src/shapes.rs +++ b/core/src/shapes.rs @@ -71,7 +71,7 @@ impl Shape { #[must_use] pub fn is_promotable(&self) -> bool { - Self::PROMOTABLE_SHAPES.contains(self) + matches!(self, Self::Knight | Self::Bishop | Self::Rook | Self::Queen) } #[must_use]