From 849de74c6db2e13233ecbccfc05f8e9a4c4c2fa7 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Thu, 13 Jun 2024 11:09:40 -0700 Subject: [PATCH] Rust 1.79: use inline const in `color_block!()`. This has no great advantage; it's just fewer tokens for the macro to emit. --- all-is-cubes/src/block.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/all-is-cubes/src/block.rs b/all-is-cubes/src/block.rs index acfd130e2..9bd8ad2e4 100644 --- a/all-is-cubes/src/block.rs +++ b/all-is-cubes/src/block.rs @@ -49,12 +49,11 @@ use crate::universe::{Handle, HandleVisitor, VisitHandles}; // Must declare this macro before child modules, so they can use it. #[macro_export] macro_rules! color_block { - ($color:expr) => {{ - const PRIMITIVE: &$crate::block::Primitive = - &$crate::block::Primitive::from_color($color.with_alpha_one_if_has_no_alpha()); - - $crate::block::Block::from_static_primitive(PRIMITIVE) - }}; + ($color:expr) => { + $crate::block::Block::from_static_primitive(const { + &$crate::block::Primitive::from_color($color.with_alpha_one_if_has_no_alpha()) + }) + }; ($r:literal, $g:literal, $b:literal $(,)?) => { $crate::color_block!($crate::math::rgb_const!($r, $g, $b))