在 Substrate 模块中输入?,rust,substrate"/>

首页 > 解决方案 > 有没有办法让我使用标准结果在 Substrate 模块中输入?

问题描述

Substrate 已经将它自己的结果类型定义为Result<(), &'static str>并且不允许我使用泛型类型。如何使用 Rust 标准Result<T, E>类型?

标签: rustsubstrate

解决方案


可以在模块的私有函数中使用 Rust 标准 Result 类型,但不能在可调度函数中使用。

您需要先导入它use rstd::result,然后使用它result::Result<your-value-type, your-error-type>


推荐阅读