[英]Create mutable iterator in nightly build after mut_iter removed
I downloaded the nightly build of Rust and attempted to build my code, but interestingly enough I realized mut_iter()
no longer exists. 我下载了每晚构建的Rust并尝试构建我的代码,但有趣的是,我意识到
mut_iter()
不再存在。 What was the reason for removing the ability to create mutable iterators for strings? 取消为字符串创建可变迭代器的功能的原因是什么? I have the function:
我有功能:
//invert hex picture, this is used in the print_bitmap function
// to save space and break apart one large code base.
pub fn invert_ascii_hex_string(line: &mut [std::ascii::Ascii]) {
for c in line.mut_iter() {
*c = match c.to_char() {
'x' => ' ',
_ => 'x'
}.to_ascii();
}
}
and now I'm not sure how to go about accomplishing this without a mutable iterator. 现在我不确定如何在没有可变迭代器的情况下完成此任务。 What could I now use to still iterate through the list and change each value?
我现在可以使用什么来遍历列表并更改每个值?
尝试使用iter_mut()
而不是mut_iter()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.