decimal icon indicating copy to clipboard operation
decimal copied to clipboard

const literals?

Open sthornington opened this issue 3 years ago • 3 comments

How are folks dealing with the need to have const/static d128 literals? It seems like it might be possible these days to have the d128!() macro and things like zero() be const fn?

sthornington avatar Apr 18 '22 18:04 sthornington

this code has not been integrated into the crate or published to crates.io but might be of use if you need a solution quickly: https://github.com/jonathanstrong/decimal-macros. if you're interested in this perhaps we could publish it to crates.io or integrate into decimals.

jonathanstrong avatar Apr 18 '22 18:04 jonathanstrong

Yeah that looks perfect!

sthornington avatar Apr 18 '22 20:04 sthornington

There was an old PR that did this (#16), and I've just proposed a newer implementation in #72.

If from_raw_bytes were turned into a const fn (which I think is a trivial change), then one of these macros could be used to initialize const values.

tari avatar Jul 13 '22 05:07 tari