Update src/04_pinning/01_chapter.md
Lines 243 and 244
a: test1, b: test1
a: test1, b: test1
show test1's state before and after swap, "naively". "Naively" thinking, it should be
a: test1, b: test1
a: test2, b: test2
as test1's fields are occupied by test2's field values, "naively".
Lines 250 and 251
// given as in async-book
a: test1, b: test1
a: test1, b: test2
are supposed to show the actual state of test1 after swap. The actual state of test1 before and after swap is given by
println!("a: {}, b: {}", test1.a(), test1.b());
std::mem::swap(&mut test1, &mut test2);
println!("a: {}, b: {}", test1.a(), test1.b());
// println!("a: {}, b: {}", test2.a(), test2.b());
which shows lines 250 and 251 to be rectified to
$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/pinning-4`
a: test1, b: test1
a: test2, b: test1
Given lines 250 and 251 are instead reproduced by
println!("a: {}, b: {}", test1.a(), test1.b());
std::mem::swap(&mut test1, &mut test2);
// println!("a: {}, b: {}", test1.a(), test1.b());
println!("a: {}, b: {}", test2.a(), test2.b());
which is not the desired code for the situation in Line 240:
Naively, we could think that what we should get a debug print of
test1two times like this:
Sorry first time contributing
PS it's really late at night where I live, please nobody pick this up lol
I'll do this tomorrow
EDIT: Proposing a change where lines 240-252 talk about test2 rather than test1