Skip to content

Eagerly derive Clone, Copy, where possible#341

Merged
cpu merged 2 commits into
rustls:mainfrom
lvkv:lvkv-add-traits-clone
May 15, 2025
Merged

Eagerly derive Clone, Copy, where possible#341
cpu merged 2 commits into
rustls:mainfrom
lvkv:lvkv-add-traits-clone

Conversation

@lvkv

@lvkv lvkv commented May 15, 2025

Copy link
Copy Markdown
Contributor

Coming from #340, this PR derives Clone and Copy to align rcgen more closely with Rust's API guidelines. Here's how I went about this:

  1. Derive Clone for as many types as possible in a full codebase pass (finding types by basically grepping for struct and enum ). Keep making passes until no more types can derive it.
  2. Ditto for Copy

I've intentionally opted to derive these traits eagerly at first so that types that we don't want to derive Clone or Copy for will come up in this review. I think most of these make sense, but I could see some being not desirable—e.g., Copy for SignatureAlgorithmParams.

@cpu

cpu commented May 15, 2025

Copy link
Copy Markdown
Member

ci / build-windows (pull_request)Started 10 minutes ago — This check has started...

FWIW I expect this to fail, it looks broken on main. Feel free to disregard for this branch.

@djc djc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This broadly looks good to me. Nit: I'd like the new additions to roughly appear in alphabetical order.

@lvkv

lvkv commented May 15, 2025

Copy link
Copy Markdown
Contributor Author

Nit: I'd like the new additions to roughly appear in alphabetical order.

Sure! I'll rework this while still keeping separate commits for Clone and Copy.

@lvkv lvkv force-pushed the lvkv-add-traits-clone branch from 3300290 to 38ceffc Compare May 15, 2025 19:46
@lvkv

lvkv commented May 15, 2025

Copy link
Copy Markdown
Contributor Author

@djc done—feel free to nit further, of course

@cpu cpu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice :-) Thank you

@est31

est31 commented May 15, 2025

Copy link
Copy Markdown
Member

Windows CI is broken but it doesn't seem to be fault of this patch.

@cpu cpu merged commit cc1f8e2 into rustls:main May 15, 2025
14 of 15 checks passed
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.

4 participants