我见过.into()
用过几次就好了frame_system::RawOrigin::Signed(who).into()
。据我了解,它进行了一些转换,但into 的文档并没有明确(对我而言)如何知道它正在转换为什么。对于上下文,我感兴趣的一个特定示例sudo_as()
来自sudo 模块。
fn sudo_as(origin, who: <T::Lookup as StaticLookup>::Source, call: Box<<T as Trait>::Call>) {
// This is a public call, so we ensure that the origin is some signed account.
let sender = ensure_signed(origin)?;
ensure!(sender == Self::key(), Error::<T>::RequireSudo);
let who = T::Lookup::lookup(who)?;
let res = match call.dispatch(frame_system::RawOrigin::Signed(who).into()) {
Ok(_) => true,
Err(e) => {
sp_runtime::print(e);
false
}
};
Self::deposit_event(RawEvent::SudoAsDone(res));
}