Imagine I am doing an embedded-only physical calculator.
Actually, what I am trying to do here is to write a uconst![12345] that gets promoted (pasted into the source code) to ::typenum::consts::U12345 at compile time.
This part is not so difficult.
The more difficult part is to support #![no_std] evaluator of arithmetic operations on &'source str expressions (e.g. 5 + 67; should return 72 as what your faithful calculator does). Hence, something like this should work:
I have finished writing the part of the proc-macro where it parses a literal integer and returns a typenum::Uint/PInt/NInt depending on the sign of the literal number you had passed into the macro. The macro can also be used in #![no_std].
I have noted typenum::op, it uses the type level integers to do operations on them, which is cool, but I am just thinking if there is some #![no_std] arithmetic expressions-evaluation libraries that I can bootstrap on to enable tnconst![+ { 5 + 11 }] to give typenum::consts::P16.
I am using syn, quote and proc-macro2 crates, they do not seem to support #![no_std] but I aspire my attribute macro to be #![no_std], is it even possible?
The code for those crates will only run on the host system during compilation, which needs to have std support anyway. As long as your proc macro emits nostd compatible code, the macro should be usable in nostd projects without issue.
Can I interpret your response as: a proc-macro crate can depend on std even if downstream crates that use the said proc-macro crate use #![no_std] in their lib.rs? (because the compilation of #![no_std] crates will eventually rely on rustc on host machine during codegen phase and would require std anyway)