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

[机工社 P254 P328] inner1 的类型应为 &i32 等问题 #48

Open
hyuuko1 opened this issue Aug 4, 2020 · 1 comment
Open

[机工社 P254 P328] inner1 的类型应为 &i32 等问题 #48

hyuuko1 opened this issue Aug 4, 2020 · 1 comment

Comments

@hyuuko1
Copy link

hyuuko1 commented Aug 4, 2020

应该改成

struct Closure<'a> {
    inner1: &'a i32,
}

impl<'a> Closure<'a> {
    fn call(&self, a: i32) -> i32 {
        self.inner1 + a
    }
}

fn main() {
    let x = 1_i32;
    let add_x = Closure { inner1: &x };
    let result = add_x.call(5);
    println!("result is {}", result);
}
@hyuuko1 hyuuko1 changed the title [机工社 P254] inner1 的类型应为 &i32 [机工社 P254 P328] inner1 的类型应为 &i32 等问题 Aug 6, 2020
@hyuuko1
Copy link
Author

hyuuko1 commented Aug 6, 2020

P328 最后一段

对 Mutex 内部的数据读写,RwLock 都是调用同样的 lock 方法;而对 RwLock 内部的数据读写,它分别提供了一个成员方法 read/write 来做这个事情。

应该改为:

对 Mutex 内部的数据读写,都是调用同样的 lock 方法;而对 RwLock 内部的数据读写,它分别提供了一个成员方法 read/write 来做这个事情。

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