ZhangHanDong / tao-of-rust-codes

《Rust编程之道》随书源码
https://ruststudy.github.io/tao_of_rust_docs/tao_of_rust/
MIT License
1.18k stars 170 forks source link

[代码错误] 6.3 迭代器 代码清单6-80 #320

Open bytemain opened 3 years ago

bytemain commented 3 years ago

页码与行数

第一版 第七次印刷


代码错误

代码清单6-80,第4行

- fold(0, |acc, x| acc+x)
+ fold(0, |acc, &x| acc+x)

此处使不使用引用都可以。

但是因为下一页的第一段说:代码 6-80 中 fold 传入的是一个引用,并且后面都是介绍为什么是一个引用的参数。 所以这里的代码应该就是 &x