Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong struct type in example comment #4269

Open
m3et opened this issue Mar 10, 2025 · 1 comment
Open

Wrong struct type in example comment #4269

m3et opened this issue Mar 10, 2025 · 1 comment

Comments

@m3et
Copy link

m3et commented Mar 10, 2025

  • I have searched open and closed issues and pull requests for duplicates, using these search terms:
    • enum struct mismatch
    • no-listing-04-structs-similar-to-message-enum
    • git blame
  • I have checked the latest main branch to see if this has already been fixed, in this file:
    • yes sir

URL to the section(s) of the book with this problem:

Description of the problem:
I would assume the comment should be of type String struct instead of Tuple struct. Please clarify if I’m mistaken in my assumption.

@m3et m3et changed the title Wrong struct type in example Wrong struct type in example comment Mar 10, 2025
@StefanSalewski
Copy link

Thanks for reporting. I think you are wrong. Regular structs have named fields like in C. Rust's tuple structs have fields with no names, accessed by constant index like my_struct.0 (first component). As your provided line of code defines a struct with just a data component (of type String) with no associated name, it is a tuple struct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants