decimal
decimal copied to clipboard
Implement d128! as a procedural macro
This is basically a rewrite of #16 using procedural macros which were stabilized in the 2018 edition (rustc 1.31.0).
There are a few things that I haven't addressed yet, since I wanted to propose the concept before spending too much time on it:
- [ ] The current
decimal
library can't export the new macro because the macro depends on it. This could be fixed by moving the existing implementation into adecimal-core
crate, and makingdecimal
a thin facade that re-exports everything fromdecimal-core
alongside the macro fromdecimal-macros
. - [ ] Because we're generating the underlying representation at compile-time, this might need special handling when cross-compiling because we may be calling
to_raw_bytes
andfrom_raw_bytes
on different architectures. - [ ] Tests for error cases would be nice to have, but are best implemented by using
proc_macro2
which I haven't done. At that point usingquote
to generate token streams might be easier (which I haven't done because not using it keeps the dependency count down).