Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion address/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ rustdoc-args = ["--cfg=docsrs"]
[features]
atomic = ["dep:solana-atomic-u64"]
borsh = ["dep:borsh", "alloc"]
bytemuck = ["dep:bytemuck", "dep:bytemuck_derive"]
bytemuck = ["copy", "dep:bytemuck", "dep:bytemuck_derive"]
copy = []
curve25519 = ["dep:curve25519-dalek", "error", "sha2"]
decode = ["dep:five8", "dep:five8_const", "error"]
dev-context-only-utils = ["dep:arbitrary", "rand"]
Expand Down
7 changes: 4 additions & 3 deletions address/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ pub const PDA_MARKER: &[u8; 21] = b"ProgramDerivedAddress";
#[cfg_attr(feature = "bytemuck", derive(Pod, Zeroable))]
#[cfg_attr(feature = "dev-context-only-utils", derive(Arbitrary))]
#[cfg_attr(not(feature = "decode"), derive(Debug))]
#[derive(Clone, Copy, Default, Eq, Ord, PartialEq, PartialOrd)]
#[cfg_attr(feature = "copy", derive(Copy))]
#[derive(Clone, Default, Eq, Ord, PartialEq, PartialOrd)]
pub struct Address(pub(crate) [u8; 32]);

#[cfg(feature = "sanitize")]
Expand Down Expand Up @@ -126,7 +127,7 @@ impl Hash for Address {
impl From<&Address> for Address {
#[inline]
fn from(value: &Address) -> Self {
*value
Self(value.0)
}
}

Expand Down Expand Up @@ -256,7 +257,7 @@ impl Address {
Ok(Address::from(hash.to_bytes()))
}

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.

self.0
}

Expand Down
1 change: 1 addition & 0 deletions pubkey/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ alloc = ["solana-address/alloc"]
rand = { workspace = true, optional = true }
solana-address = { workspace = true, features = [
"atomic",
"copy",
"decode",
"error",
"sanitize",
Expand Down