为了账号安全,请及时绑定邮箱和手机立即绑定

无法摆脱借来的内容

无法摆脱借来的内容

慕神8447489 2019-11-25 20:16:48
无法摆脱借来的内容我不明白这个错误cannot move out of borrowed content。我收到了很多次,我总是解决它,但我从来没有理解为什么。例如:for line in self.xslg_file.iter() {     self.buffer.clear();     for current_char in line.into_bytes().iter() {         self.buffer.push(*current_char as char);     }     println!("{}", line);}产生错误:error[E0507]: cannot move out of borrowed content   --> src/main.rs:31:33    | 31 |             for current_char in line.into_bytes().iter() {    |                                 ^^^^ cannot move out of borrowed content我通过克隆解决了这个问题line:for current_char in line.clone().into_bytes().iter() {即使在阅读其他帖子后我也不明白错误:无法从&mut self借用文件(错误信息:无法移出借来的内容)在Rust中更改树中的节点这种错误的起源是什么?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 377 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信