I have a hard time understanding the current state of const fn
, so maybe someone can point of if 1) I can do what I want right now with it, and 2) if it will be possible at some somewhat-known point in the future.
I have some static
structs, that contain sequences of (u8, Enum)
, where Enum
is a flat C-like enum with a Enum -> &'static str
implementation. For each entry of the sequence, I need to take the u8
and make a computation involving the &'static str
to pad the said &'static str
with dashes. After that, I need to concatenate all those things into a larger &'static str
.
As a example, the sequence might be (8, IDNOD), (16, X)
, and the Enum -> &'static str
function is just the trivial thing. I'll then need to produce ---IDNOD
(padded to 8) and
---------------X
(padded to 16), so that in the end this produces
---IDNOD---------------X
So, theoretically, all this info is present at compile time. The question is, can I make this a compile time computation? If so, how can I ensure that it's really done? I might be able to just put const
before all functions, but does that guarantee it's not done at runtime?
Thanks for any pointers