rust - 有没有办法让我使用标准结果在 Substrate 模块中输入?
问题描述
Substrate 已经将它自己的结果类型定义为Result<(), &'static str>
并且不允许我使用泛型类型。如何使用 Rust 标准Result<T, E>
类型?
解决方案
可以在模块的私有函数中使用 Rust 标准 Result 类型,但不能在可调度函数中使用。
您需要先导入它use rstd::result
,然后使用它result::Result<your-value-type, your-error-type>
。
推荐阅读
- c# - 更改现有 PDF 中的元素颜色
- arrays - 如何从数组中仅打印一次某些值
- oracle - 为什么此 db 链接链仅在匿名块内导致“同义词循环链”错误?
- c# - 保存到现有的 excel 文件而不打开新的 excel 文件
- c# - 如何在启动类上传递一些属性并在控制器上初始化它
- python - 如果两列值相等,则在 Python 中创建具有 True 和 False 值的第三列
- javascript - Puppeteer:TimeoutError:等待选择器
- ios - iOS 订阅计划选项不针对特定用户显示
- javascript - 无法在 JavaScript 中调用 Jump Game 函数
- r - dyplot.prophet 科学记数法