【发布时间】:2022-08-09 12:44:15
【问题描述】:
我正在尝试完成一些相当简单的事情,但不确定如何在 Rust 中完成。
我有一个 Vec<&Vec>,类似于下面的示例。
[
[\"a1\", \"b2\", \"c3\"],
[\"d1\", \"e2\", \"f3\"],
[\"g1\", \"h2\", \"i3\"]
]
我想在每个向量的末尾添加一个额外的字符串。
[
[\"a1\", \"b2\", \"c3\", \"something\"],
[\"d1\", \"e2\", \"f3\", \"something\"],
[\"g1\", \"h2\", \"i3\", \"something\"]
]
到目前为止我尝试过的内容如下:
vec_of_strings
.iter_mut()
.map(|x| x.clone().push(\"something\".to_string()))
.collect::<Vec<_>>();
println!(\"{:?}\", vec_of_strings);
但是输出显示没有附加任何内容。