implements AsRef (instead of Borrow) for VoteAccounts (#19252)
According to the docs: > if you want to borrow only a single field of a struct you can > implement AsRef, but not Borrow. https://doc.rust-lang.org/std/convert/trait.AsRef.html
This commit is contained in:
@ -14,7 +14,7 @@ use {
|
|||||||
},
|
},
|
||||||
solana_stake_program::stake_state,
|
solana_stake_program::stake_state,
|
||||||
solana_vote_program::vote_state::VoteState,
|
solana_vote_program::vote_state::VoteState,
|
||||||
std::{borrow::Borrow, collections::HashMap, sync::Arc},
|
std::{collections::HashMap, sync::Arc},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Default, Clone, PartialEq, Debug, Deserialize, Serialize, AbiExample)]
|
#[derive(Default, Clone, PartialEq, Debug, Deserialize, Serialize, AbiExample)]
|
||||||
@ -212,7 +212,7 @@ impl Stakes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn vote_accounts(&self) -> &HashMap<Pubkey, (u64, VoteAccount)> {
|
pub fn vote_accounts(&self) -> &HashMap<Pubkey, (u64, VoteAccount)> {
|
||||||
self.vote_accounts.borrow()
|
self.vote_accounts.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn stake_delegations(&self) -> &HashMap<Pubkey, Delegation> {
|
pub fn stake_delegations(&self) -> &HashMap<Pubkey, Delegation> {
|
||||||
|
@ -7,7 +7,6 @@ use {
|
|||||||
},
|
},
|
||||||
solana_vote_program::vote_state::VoteState,
|
solana_vote_program::vote_state::VoteState,
|
||||||
std::{
|
std::{
|
||||||
borrow::Borrow,
|
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
collections::{hash_map::Entry, HashMap},
|
collections::{hash_map::Entry, HashMap},
|
||||||
iter::FromIterator,
|
iter::FromIterator,
|
||||||
@ -268,8 +267,8 @@ impl From<VoteAccountsHashMap> for VoteAccounts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Borrow<VoteAccountsHashMap> for VoteAccounts {
|
impl AsRef<VoteAccountsHashMap> for VoteAccounts {
|
||||||
fn borrow(&self) -> &VoteAccountsHashMap {
|
fn as_ref(&self) -> &VoteAccountsHashMap {
|
||||||
&self.vote_accounts
|
&self.vote_accounts
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user