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

Ch17-03 Mentions Object Safety with Little Explanation #3949

Open
LukeFranceschini opened this issue Jun 3, 2024 · 1 comment
Open

Ch17-03 Mentions Object Safety with Little Explanation #3949

LukeFranceschini opened this issue Jun 3, 2024 · 1 comment

Comments

@LukeFranceschini
Copy link
Contributor

URL to the section(s) of the book with this problem:
https://doc.rust-lang.org/book/ch17-03-oo-design-patterns.html

Description of the problem:
The book references object safety in chapter 17.3 without mentioning it anywhere else in the entire book. The duplicate logic section explains that the duplication is necessary to maintain object safety as if the user should be aware of the meaning of object safety. However, the object safety section was removed in 727ef10 after discussion in #2787 and #2790. This removed section would have given some background context for the duplicate logic paragraph in chapter 17.3. Without that section, this paragraph about duplicate implementation is quite confusing, requiring the reader (or at least me) to Google what object safety means to understand the issue.

Suggested fix:
I'm not sure what would make the most sense here:

  • giving a slightly longer paragraph explaining why the compiler needs to know the size of the object at compile time
  • saying the duplicate logic is required for a handwaved reason about the way traits are implemented that you can read about in the reference (with a link to the relevant section of the reference)
  • removing this paragraph like the rest of the section about object safety

The next paragraph talks about duplicate implementation anyway, so there would still be discussion about that issue if the object safety paragraph was removed. I know there were several other pull requests and issues discussing the object safety section, and it was slowly reduced in size until it was removed entirely. Maybe this would just be the final nail in the object safety coffin.

In any case, I thought I'd bring it up after the confusion it caused me when reading this section. I'd be happy to help with any changes that need to be made, but I figured I'd check to see what we think the best course of action is first. Thanks!

@chriskrycho
Copy link
Contributor

Ah, interesting bit of evolution of the text there—thanks for opening this! We will think on the best way to proceed.

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