The Cairo language has some plugins that allow developers to simplify their code. They are called inline_macros and are a way of writing code that generates other code.

consteval_int! Macro

在某些情况下,开发人员可能需要声明一个常量,该常量是整数计算的结果。为了在编译时计算常量表达式并使用其结果,需要使用consteval_int! 宏。

下面是 consteval_int!的示例:

const a: felt252 = consteval_int!(2 * 2 * 2);

编译器将解释为 const a: felt252 = 8

selector! Macro

selector!("function_name") macro generates the entry point selector for the given function name.

Please refer to the Printing page.

array! Macro

Please refer to the Arrays page.

panic! Macro

See Unrecoverable Errors with panic page.

assert! and assert_xx! Macros

See How to Write Tests page.

format! Macro

See Printing page.

write! and writeln! Macros

See Printing page.

get_dep_component!, get_dep_component_mut and component! Macros

Please refer to the Composability and Components chapter.