问题描述
我克隆了底物库。在bin/node-template/runtime/src/lib.rs
中,调用construct_runtime!
创建运行时。我在construct_runtime
中找到了frame/support/procedural/src/construct_runtime/mod.rs
的定义。它会调用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
);
我有什么方法可以打印或检查由quote!
构建的传递给construct_runtime_parsed
的代码?
解决方法
您可以将cargo expand
指向runtime/src/lib.rs
文件,它将输出扩展的源代码。