SQ in silver chrome letters, a lab's gear stacked against the S: a rack, two oscilloscopes, pizza boxes and a six-pack. Strange Query Lab
Chapters

rust-cardiac

  1. Contents
  2. Lexical structure
  3. Macros
  4. Items
  5. Attributes
  6. Statements and expressions
  7. Patterns
  8. Types
  9. Memory
  10. Panic
  11. Unsafety
  12. Constant evaluation
  13. The runtime
  14. Appendix: The core library

CARDIAC › rust-cardiac › Language Reference › Macros

Macros

What's different on CARDIAC

  • println!, print!, format_args! and write! are refused, because CARDIAC prints only numbers. Use out().
  • format! and vec! are refused, because there is no heap.
  • A panic's message keeps its literal text but not the values a formatted message would print.

Macros by example

macro_rules! works. A macro is expanded by rustc before cargo-cardiac sees the program, so it costs only what its expansion costs.

Macros from the standard library

These work:

  • matches!, cfg!, concat!, stringify!, file! and line!.
  • assert!, assert_eq!, assert_ne!, debug_assert! and its kin, panic!(), unreachable!(), todo!() and unimplemented!(), with a literal message or a formatted one. The panic map keeps the message's literal text, without the values. See Panic.

These are refused:

RefusedWhyInstead
println!, print!, format_args!, write!CARDIAC prints only numbers.out()
format!, vec!They need the heap, and every value's cell is fixed when the program is built.Fixed-size arrays
compile_error!It stops the build everywhere, natively too.

Feature tests: macros.