* Add AsRef<AccountInfo> for AccountInfo (cherry picked from commit930465e67c
) * add test for AsRef (cherry picked from commitd10e37a829
) Co-authored-by: Kirill Fomichev <fanatid@ya.ru>
This commit is contained in:
@ -220,6 +220,12 @@ pub fn next_account_infos<'a, 'b: 'a>(
|
|||||||
Ok(accounts)
|
Ok(accounts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> AsRef<AccountInfo<'a>> for AccountInfo<'a> {
|
||||||
|
fn as_ref(&self) -> &AccountInfo<'a> {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
@ -260,4 +266,13 @@ mod tests {
|
|||||||
assert_eq!(k4, *info2_3_4[2].key);
|
assert_eq!(k4, *info2_3_4[2].key);
|
||||||
assert_eq!(k5, *info5.key);
|
assert_eq!(k5, *info5.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_account_info_as_ref() {
|
||||||
|
let k = Pubkey::new_unique();
|
||||||
|
let l = &mut 0;
|
||||||
|
let d = &mut [0u8];
|
||||||
|
let info = AccountInfo::new(&k, false, false, l, d, &k, false, 0);
|
||||||
|
assert_eq!(info.key, info.as_ref().key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user