Skip to content

Commit

Permalink
Rust 1.79: use inline const in color_block!().
Browse files Browse the repository at this point in the history
This has no great advantage; it's just fewer tokens for the macro to
emit.
  • Loading branch information
kpreid committed Jun 13, 2024
1 parent 6a24bb7 commit 849de74
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions all-is-cubes/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 849de74

Please sign in to comment.