如何打印运行时通过construct_runtime生成的代码



我克隆了底物库。在bin/node-template/runtime/src/lib.rs中,调用construct_runtime!来创建运行时。我在frame/support/procedural/src/construct_runtime/mod.rs中找到了construct_runtime的定义。它调用construct_runtime_parsed,后者在运行时构建一个代码块。

let res = quote!(
#scrate_decl
#[derive(Clone, Copy, PartialEq, Eq, #scrate::sp_runtime::RuntimeDebug)]
pub struct #name;
impl #scrate::sp_runtime::traits::GetNodeBlockType for #name {
type NodeBlock = #node_block;
}
impl #scrate::sp_runtime::traits::GetRuntimeBlockType for #name {
type RuntimeBlock = #block;
}
#outer_event
#outer_origin
#all_modules
#module_to_index
#dispatch
#metadata
#outer_config
#inherent
#validate_unsigned
#integrity_test
);

有什么方法可以打印或检查传递给construct_runtime_parsed构建的quote!的代码吗?

您可以将cargo expand指向runtime/src/lib.rs文件,它将输出扩展的源代码。

最新更新