rust_book_feedback icon indicating copy to clipboard operation
rust_book_feedback copied to clipboard

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

Open hyuuko1 opened this issue 5 years ago • 1 comments

应该改成

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 avatar Aug 04 '20 11:08 hyuuko1

P328 最后一段

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

应该改为:

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

hyuuko1 avatar Aug 06 '20 02:08 hyuuko1