如何查看 Parity Substrate 中的宏生成的最终代码?

Sha*_*izi 3 blockchain substrate

Substrate 使用了很多宏来让编写运行时模块变得更加容易:

  • construct_runtime!
  • decl_module!
  • decl_storage!
  • decl_event!
  • ETC...

然而,很难理解这些宏实际上做了什么以及最终的代码是什么样的。我怎样才能更深入地研究这些宏和扩展?

小智 5

对我来说,最舒服的解决方案是使用cargo expand

https://github.com/dtolnay/cargo-expand

cargo install cargo-expand
Run Code Online (Sandbox Code Playgroud)

然后从你的箱子里调用它

cargo expand
Run Code Online (Sandbox Code Playgroud)