As mentioned in #17, it would be helpful to have a way of initialising integers at compile from a literal. Although the from_str method on the FromStr implementation on bnum integers can be made into a const function (although it would have to be a regular method rather than a trait method currently), this would only allow parsing of decimal literal values. Rust integers can be initialised from a decimal, octal, hexadecimal or binary literal, so it would be good to allow the compile-time parsing of bnum integers from the same bases.
The macro would most likely have to be a proc macro which would mean building a separate crate with this functionality.
As mentioned in #17, it would be helpful to have a way of initialising integers at compile from a literal. Although the
from_str
method on theFromStr
implementation on bnum integers can be made into aconst
function (although it would have to be a regular method rather than a trait method currently), this would only allow parsing of decimal literal values. Rust integers can be initialised from a decimal, octal, hexadecimal or binary literal, so it would be good to allow the compile-time parsing of bnum integers from the same bases.The macro would most likely have to be a proc macro which would mean building a separate crate with this functionality.
The macro syntax could look something like this:
The suffix of
uBITS
oriBITS
would be mandatory, unless an optional second argument was passed, indicating the type of the desired output.