Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.2.3 代码清单4-18链表初始化语句有重复操作,报错信息有更新 #324

Open
pkubangbang opened this issue Aug 28, 2021 · 2 comments
Labels
第四章 第四章

Comments

@pkubangbang
Copy link

页码与行数

  • 第112页
  • 代码清单4-18
  • 第9行

代码错误

// 看起来,更像是Rc::new(Node { data: 2, next: None })
let second = Rc::new(Node { data: 2, next: Some(first.clone()) });

文本错误

接下来的编译报错信息,(新版本中?)是更友好的cannot assign
(不影响上文的改动)

   |
14 |     first.next = Some(second.clone());
   |     ^^^^^^^^^^ cannot assign
   |
   = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc<Node<i32>>`

Rust版本

stable version 1.54.0

rust playground link

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=eb1e39f17f47d3bdfe71df856692a673

@pkubangbang
Copy link
Author

另外,代码清单4-19中也有类似的问题:第15行看起来应该是next: None

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=ee9f6d708e7cb8cda738cb3efcefc51d

@ZhangHanDong ZhangHanDong added the 第四章 第四章 label Aug 29, 2021
@ZhangHanDong
Copy link
Owner

感谢反馈!代码之前是没有问题的,我回头再确认下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
第四章 第四章
Projects
None yet
Development

No branches or pull requests

2 participants