book icon indicating copy to clipboard operation
book copied to clipboard

Make it clear that default traits do not require a separate empty impl block in Section 10.2

Open zkkv opened this issue 6 months ago • 0 comments

  • I have searched open and closed issues and pull requests for duplicates, using these search terms:

    • impl
    • 10.2
    • default
  • I have checked the latest main branch to see if this has already been fixed, in this file:

    • src/ch10-02-traits.md

URL to the section(s) of the book with this problem: https://rust-book.cs.brown.edu/ch10-02-traits.html#default-implementations

Description of the problem: I think the sentence below could be worded better.

To use a default implementation to summarize instances of NewsArticle, we specify an empty impl block with impl Summary for NewsArticle {}.

It can be helpful to emphasize that a trait containing both default and non-implemented methods doesn't require two impl blocks, one of which is empty.

Suggested fix: The phrasing that could be used:

To use a default implementation to summarize instances of NewsArticle, we must specify an empty impl block with impl Summary for NewsArticle {}, unless there's an existing impl block already.

zkkv avatar Aug 19 '24 19:08 zkkv