book
book copied to clipboard
Section 15.2: ambiguity in description
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)