繁体   English   中英

如何将来自不同HashMap的字段合并为一个?

[英]How can I merge the fields from different HashMaps into one?

我有以下结构:

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)>,
}

操场上观看它的动作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM