program::message::AccountKeys: `Clone`, `Default`, `Debug`, `Eq` (#33749)
It is a pretty standard set of traits to implement on most types. Both `Pubkey` and `LoadedAddresses` contained within the `AccountKeys` already implement them. Doing the same for `AccountKeys` could simplify unit tests and/or some common value manipulation logic.
This commit is contained in:
parent
e96678b302
commit
84c2f9de55
|
@ -4,11 +4,12 @@ use {
|
|||
message::{v0::LoadedAddresses, CompileError},
|
||||
pubkey::Pubkey,
|
||||
},
|
||||
std::{collections::BTreeMap, ops::Index},
|
||||
std::{collections::BTreeMap, iter::zip, ops::Index},
|
||||
};
|
||||
|
||||
/// Collection of static and dynamically loaded keys used to load accounts
|
||||
/// during transaction processing.
|
||||
#[derive(Clone, Default, Debug, Eq)]
|
||||
pub struct AccountKeys<'a> {
|
||||
static_keys: &'a [Pubkey],
|
||||
dynamic_keys: Option<&'a LoadedAddresses>,
|
||||
|
@ -138,6 +139,12 @@ impl<'a> AccountKeys<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl PartialEq for AccountKeys<'_> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
zip(self.iter(), other.iter()).all(|(a, b)| a == b)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use {super::*, crate::instruction::AccountMeta};
|
||||
|
|
Loading…
Reference in New Issue