avoid confusion about built-in type
MuhammadAbdullahWarraich opened this issue · comments
- I have searched open and closed issues and pull requests for duplicates, using these search terms:
- cons
- I have checked the latest
main
branch to see if this has already been fixed, in this file:
URL to the section(s) of the book with this problem:
https://doc.rust-lang.org/stable/book/ch15-01-box.html
Description of the problem:
The section "Enabling Recursive Types with Boxes" uses Cons as the name of a variant of the list enum, but does not emphasize on the fact that the name of the "Cons" variant is purely due to semantic reasons and could have been any other name, like say, "Pair" or "LinkedListElement". This may lead some readers to get confused about whether or not Cons is a built-in feature of Rust-lang. This may seem like a minor issue, but it did confuse me, and I had to Google it to clear my doubt.
Suggested fix:
Only a line needs to be added after listing 15.2 stating that it is not compulsory for the variant name to be Cons, but it makes more sense to the reader of the code.
Sorry, I think it's clear enough with text such as "The cons list type we’ll define" and "Listing 15-2 contains an enum definition for a cons list." You were also able to resolve your confusion. Thanks though!
Oh yes, I remember, I had the same issue with the "Cons" term for first reading the book. I did a Google search to clarify -- when I remember correctly, Cons has some special meaning in same programming languages (was it LISP?). Was confusing for me first.