简体   繁体   English

删除mut_iter之后,在每晚的构建中创建可变迭代器

[英]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.

相关问题 可迭代、.iter(&mut self) 和可变借用不可变数据 - Iterable, .iter(&mut self) and mutable borrow from immutable data 在 `iter_mut().map(..)` 中修改 self,也就是可变函数集合操作 - Modifying self in `iter_mut().map(..)`, aka mutable functional collection operations 为结构创建* mut * mut - Create *mut *mut to a struct 如何为数据结构实现非消耗可变 std::iter::Iterator - How to implement a non-consuming mutable std::iter::Iterator for a data structure 我可以从单个字节(u8)创建可变切片&mut [u8]吗? - Can I create a mutable slice &mut [u8] from a single byte (u8)? 在 Rust 中,如何在 `iter_mut` 上使用 `find()` - In Rust, how to use `find()` on a `iter_mut` 调用&'a mut self方法后,一次不能多次借用可变变量 - Cannot borrow variable as mutable more than once at a time after calling a &'a mut self method 构建失败并出现错误:Pear 需要 rustc 的“dev”或“nightly”版本,即使在每晚成功设置 rustup 覆盖之后也是如此 - Build fails with Error: Pear requires a 'dev' or 'nightly' version of rustc even after a successful rustup override set nightly 可以从迭代器中收集&mut吗? - It is possible to collect a &mut from an iterator? 在向迭代器借为可变后,在循环内借为不可变 - Borrow as immutable inside the loop after borrowed as mutable to the iterator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM