Open Ora9 opened 2 months ago
Const floating-point arithmetic is going to be stabilized in Rust 1.82, which comes out in 3 weeks. But egui is still targeting 1.76 for now, and likely won't switch immediately. When it does switch, I suppose a const version of from_rgba_unmultiplied
could be written to make the macro const. The current implementation cannot be made const because it uses a lookup table to improve performance, and that can only be initialized at runtime.
Until then, maybe the documentation could be updated to reflect the fact that the macro is not actually const, but only has the advantage of generating a compilation error if the string literal is invalid.
It would be nice if
hex_color!()
macro would beconst
to be used in constant declaration and to define colors at compile timeBtw, the doc says that it's the case on
Color32::from_hex
method : « To parse hex colors at compile-time (e.g. for use in const contexts) use the macro crate::hex_color! instead. »But when trying on a test project with the latest egui git master, i get this error :
This is related to #1596, where this comment was saying that it wasn't possible at the time to make the macro const due to floating-point conversions. And that this could be soon fixed But this was in 2022, and looking at the code (here and here there are some functions that are not const yet (
linear_f32_from_gamma_u8
and friends) I'm quite new to rust, but is it still not possible to make the macro const ? That would be really handy