当调用 `RawOrigin:Signed(who)` 时,`.into()` 做了什么?上下文如何影响它?

What does `.into()` do when called on `RawOrigin:Signed(who)` and how does the context affect it?

我看到 .into()frame_system::RawOrigin::Signed(who).into() 一样被使用了好几次。据我了解,它进行了一些转换,但我感兴趣的 docs for into do not make it clear (to me) how to know what it is converting to. For context a specific example 来自 sudo 模块中的 sudo_as()

        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));
        }

你是正确的,into 将 return "the right" 类型取决于调用它的上下文。在您提供的示例中,您可以查看 the docs for the dispatch function and see that it requires an Origin as a parameter. However, as you can see the who variable is being used to create a RawOrigin 类型。因此,into 函数用于将提供的类型 (RawOrigin) 转换为所需的任何类型(在本例中为 Origin)。