如何制作带有struct in rust的哈希地图
我是Rust的新手,我希望像这样在结构中实现我的hashmap,
#[derive(Clone, Data)]
struct CheckState {
cool: String,
int_cool: i32,
hashmap_cool: HashMap<i32, String>
}
但是我一直在收回错误代码错误[E0277]:特征绑定了`hashmap&lt; i32,std :: string :: string :: string&gt;::: string&gt; ::数据“不满足
,我不明白为什么,帮助没有太大帮助的
生锈,
help: the following other types implement trait `Data`:
&'static str
()
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
(T0, T1, T2, T3, T4, T5)
(T0,)
and 87 others
= note: this error originates in the derive macro `Data` (in Nightly builds, run with -Z macro-backtrace for more info)
请忽略变量名称,它们在我的代码中并不相同
I am new to rust and I am looking to implement my hashmap in my struct like so
#[derive(Clone, Data)]
struct CheckState {
cool: String,
int_cool: i32,
hashmap_cool: HashMap<i32, String>
}
But i keep recieving the error code error[E0277]: the trait bound `HashMap<i32, std::string::String>: Data` is not satisfied
and i do not understand why and the help is not much help
the rust help
help: the following other types implement trait `Data`:
&'static str
()
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
(T0, T1, T2, T3, T4, T5)
(T0,)
and 87 others
= note: this error originates in the derive macro `Data` (in Nightly builds, run with -Z macro-backtrace for more info)
please ignore variable names they are not the same in my code
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有关简单的修复添加:
请参阅 druid文档更好的理解:
For a simple fix add:
See the druid documentation for a better understanding: