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

书籍错误记录 #2

Open
anonymousGiga opened this issue May 29, 2023 · 5 comments
Open

书籍错误记录 #2

anonymousGiga opened this issue May 29, 2023 · 5 comments

Comments

@anonymousGiga
Copy link
Contributor

anonymousGiga commented May 29, 2023

本书错误记录

  • 3.3.2节,“Rust中,语句是执行一个写操作但不返回值的指令” ----- 群友tk
  • 3.2.2.2,演示数据定义的代码注释错误 ------ 云南青山老哥
@tk103331
Copy link
Contributor

3.7.1 所有权介绍

这两个图,我理解是为了说明不同的概念(所有权、浅拷贝),但同一个例子,两个图不一样,会不会有歧义

是不是可以为“浅拷贝”和“深拷贝”再分别提供一个例子

image

@tk103331
Copy link
Contributor

3.7.1 所有权介绍 7. Copy

按照Rust所有权规则第二条,在任意时刻,值有且仅有一个所有者。所以当let a = b发生时,就将变量b拥有的值移到了a上,此时a应该回到未初始状态,但实际情况并不一定。不一定的原因是,部分类型实现了Copy trait,在值移动时会对值进行自动拷贝,能让变量a仍拥有原来的值。

这里a和b反了

@cowboyliao
Copy link

3.17.4 typo
"main/src/lib.rs" 应改为 "main/src/main.rs"

@KoryXia
Copy link

KoryXia commented Feb 5, 2024

清楚 -> 清除

1. Box的基本使用方式

下面为Box使用的简单示例:

fn main() {
    let b = Box::new(5); //此时5存储在堆上而不是栈上,b本身存储于栈上
    println!("b = {}", b); //离开作用域时同时清楚堆和栈上的数据
}
//清楚 -> 清除

@fredlifeup
Copy link

https://github.com/RustyCab/LearnRustEasy/blame/4a3a874c44e9344b58c26b18717bbe7fd02db7e4/src/chapter_3/chapter_3_7_2.md#L39

#引用本质上是一个指针,它存储一个地址,通过它可以访问存储在该地址上属于其它变量的数据。与指针不同的是,引用确保指向某个特性类型的有效值。对于一个变量的引用就是在此变量前面加上&符合。

对于一个变量的引用就是在此变量前面加上&符合。-> 应该是
对于一个变量的引用就是在此变量前面加上&符号。

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

5 participants