book icon indicating copy to clipboard operation
book copied to clipboard

Section 15.2: ambiguity in description

Open xiaolongWangDev opened this issue 2 years ago • 0 comments

After the line "When we entered *y in Listing 15-9, behind the scenes Rust actually ran this code:" the code sample goes:

*(y.deref())

I understand this should be your intent after reading the paragraph about the ownership after it. However, the other paragraphs mentioned: Rust substitutes the * operator with a call to the deref method and then a plain dereference ... Note that the * operator is replaced with a call to the deref method and then a call to the * operator ... Since I understand the intent now, I know the and then part is important.

Maybe the following snippet is better to indicate what is going on?

*y

to

*(&y.0)

xiaolongWangDev avatar Nov 03 '22 05:11 xiaolongWangDev