Skip to content

Idiomatic: Various tweaks and cleanup to common traits section#3163

Merged
mgeisler merged 4 commits intogoogle:mainfrom
randomPoison:common-traits-cleanup
Apr 28, 2026
Merged

Idiomatic: Various tweaks and cleanup to common traits section#3163
mgeisler merged 4 commits intogoogle:mainfrom
randomPoison:common-traits-cleanup

Conversation

@randomPoison
Copy link
Copy Markdown
Contributor

Various tweaks and cleanup to the "Implementing Common Traits" section of Idiomatic based on my first time teaching the class.

  • Remove the "When to implement" notes from the slides. I found these to be unhelpful, as the answer for "when do I implement this trait" is always "when you need to". I would generally not encourage people to implement traits, even derivable ones, just because they can do so. Where necessary we have speaker notes that call out more specifically when there are extra caveats to implementing a trait, which I think better covers the nuances here.
  • Remove the commented-out code showing the definition of the traits. This is cruft that adds visual noise, and I'd prefer to just pull up the standard library docs to show students what the trait API looks like.
  • Add main function with example code to a few slides that were not demonstrating the behavior of the traits.
  • Fix various issues with markdown formatting in slides and speaker notes.
  • copy.md
    • Note that Copy is an implicit operation, whereas Clone is an explicit, user-defined operation.
    • Note that Copy and Clone should be derived together.
    • Note that Copy types cannot impl Drop, and reorganize notes so that they render more clearly in the speaker notes.
  • display.md - Remove reference to the Error trait and shift focus to highlight the differences between Debug and Display. I don't think mentioning Error is bad per se, but I think it's the wrong thing to focus on here.\
  • from-into.md
    • Rename ObviousImplementation to Wrapper to make things more concise and easier to read.
    • Change From impls to be for &str and i32, to better demonstrate how From can support conversions from multiple unrelated types.
    • Add example code showing how Into is a more natural trait bound than From.

Comment thread src/idiomatic/foundations-api-design/predictable-api/common-traits/copy.md Outdated
@mgeisler mgeisler enabled auto-merge (squash) April 20, 2026 21:53
auto-merge was automatically disabled April 21, 2026 20:05

Head branch was pushed to by a user without write access

@randomPoison randomPoison requested a review from mgeisler April 21, 2026 20:05
@mgeisler mgeisler enabled auto-merge (squash) April 28, 2026 16:04
@mgeisler mgeisler merged commit 0290c13 into google:main Apr 28, 2026
37 checks passed
@randomPoison randomPoison deleted the common-traits-cleanup branch April 28, 2026 16:26
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

Successfully merging this pull request may close these issues.

2 participants