diff --git a/sdk/program/src/account_info.rs b/sdk/program/src/account_info.rs index 1a49578eac..084e08c807 100644 --- a/sdk/program/src/account_info.rs +++ b/sdk/program/src/account_info.rs @@ -220,6 +220,12 @@ pub fn next_account_infos<'a, 'b: 'a>( Ok(accounts) } +impl<'a> AsRef> for AccountInfo<'a> { + fn as_ref(&self) -> &AccountInfo<'a> { + self + } +} + #[cfg(test)] mod tests { use super::*; @@ -260,4 +266,13 @@ mod tests { assert_eq!(k4, *info2_3_4[2].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); + } }