algebra icon indicating copy to clipboard operation
algebra copied to clipboard

Proc macro #[cfg_const] constant substitution from .toml file

Open jon-chuang opened this issue 4 years ago • 0 comments

The point of this proc macro library is to control all marked constants from a single cfg file in your dir. This makes it easier for people to tweak constants for their local devices/specific needs.

In exchange, the constants need to be well named, even though their namespaces will be prefixed by the module path in the toml.

I will call the toml ConstConfig.toml.

The behaviour is as follows:

  • If the .toml does not contain that const, it will add the const name and it's value in the .toml based on the declared value in the .rs file.
  • if the .toml does contain the const, it will update the .rs file with the value from the .toml.

Alternate to proc macro, use lazy static to load a global config struct. But this is manual and not so nice.

jon-chuang avatar May 07 '21 03:05 jon-chuang