我有以下结构:
pub struct Resource {
name: String,
info: HashMap<String, i32>,
info_float: HashMap<String, f32>,
info_string: HashMap<String, String>,
}
有没有办法将 3 个具有不同值的 HashMap
合并到一个 HashMap
中?
最佳答案
你可以使用元组:
pub struct Resource {
name: String,
info: HashMap<String, (i32, f32, String)>,
}
在 playground 查看它的运行情况.
关于struct - 如何将来自不同 HashMap 的字段合并为一个?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53530339/