decimal icon indicating copy to clipboard operation
decimal copied to clipboard

Implement d128! as a procedural macro

Open tari opened this issue 1 year ago • 0 comments

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 a decimal-core crate, and making decimal a thin facade that re-exports everything from decimal-core alongside the macro from decimal-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 and from_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 using quote to generate token streams might be easier (which I haven't done because not using it keeps the dependency count down).

tari avatar Jul 13 '22 04:07 tari