Skip to content

Conversation

@febo
Copy link
Contributor

@febo febo commented Sep 26, 2025

Problem

As described in #342 , deriving Copy by default makes it easier to create more copies than expected, in particular when writing on-chain programs.

Solution

Add a feature "copy" so the derive is opt-in.

Closes #342

@febo febo added the breaking PR contains breaking changes label Sep 26, 2025
@febo febo marked this pull request as ready for review September 26, 2025 12:06
@joncinque
Copy link
Collaborator

Looks great! We just need to have a firm idea of how to release it. I think it's the perfect time for the semver trick

}

pub const fn to_bytes(self) -> [u8; 32] {
pub const fn to_bytes(&self) -> [u8; 32] {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Taking a reference avoids breaking code that relied on address being Copy.

Copy link
Collaborator

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

This one still looks good to me! The changes are consistent with the Copy changes from Hash since we don't add it as a default feature, and to_bytes has been modified to take a reference.

Edit: it just needs a rebase

Copy link
Collaborator

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Copy link
Contributor

@rustopian rustopian left a comment

Choose a reason for hiding this comment

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

👍

@joncinque joncinque merged commit 521c28f into anza-xyz:master Oct 17, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking PR contains breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

address: Only derive Copy if a crate feature is enabled

3 participants