【发布时间】:2020-12-17 21:19:54
【问题描述】:
基板开发人员可能会遇到一个常见问题:开发自定义托盘以将映射存储到具有常见类型的存储中,例如 String。举个例子:
#[derive(Encode, Decode, Clone, Default, RuntimeDebug)]
pub struct ClusterMetadata {
ip_address: String,
namespace: String,
whitelisted_ips: String,
}
在构建运行时时,每个String 都会出现此错误:
|
21 | ip_address: String,
| ^^^^^^ not found in this scope
为什么Strings 不在范围内?和其他std 锈类型?
【问题讨论】:
-
有什么问题?
-
我将添加一个答案作为参考。问题是为什么会出现这个错误。在此处跟踪:github.com/substrate-developer-hub/recipes/issues/403
-
我看不出这个问题的答案将如何使 StackOverflow 中的当前知识库受益,因为存在以下问题:How can I use the format! macro in a no_std environment?、Is it possible to use Box with no_std?、When adding
#1[no_std]to a library, are there any disadvantages or complications for the users of that library?、Unable to compile Rust with no_std/lang_items。 -
感谢 Aplet123 提供这些参考资料。它对我帮助很大!我认为下面的答案更具体地说明了为什么这是一个问题,并使这个问题具有相关性。你同意吗?
标签: string rust substrate rust-no-std