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

《Rust编程:入门、实战与进阶》第77页,第7行 #2

Open
chaijie2018 opened this issue Jun 2, 2021 · 0 comments
Open

Comments

@chaijie2018
Copy link

“所有权机制只针对在堆上分配的数据,而基本类型的存储都是在栈上,因此其没有所有权的概念。”

书中这段表述是不对的。let关键字将一个变量与一个值绑定在一起,这个变量就拥有了这个值的所有权。不管该变量是分配在栈上的基本数据类型,还是分配在堆上的数据类型,都是有所有权概念的。只不过一个是执行的是复制语义,一个执行的是移动语义。

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

No branches or pull requests

1 participant