lang: Add `AsRef` conversions for accounts to `AccountInfo` (#541)

This commit is contained in:
suscd 2021-07-21 16:54:35 -07:00 committed by GitHub
parent c4e3dd2b5f
commit c1109721b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -87,6 +87,12 @@ impl<'info, T: AccountDeserialize + Clone> ToAccountInfo<'info> for CpiAccount<'
}
}
impl<'info, T: AccountDeserialize + Clone> AsRef<AccountInfo<'info>> for CpiAccount<'info, T> {
fn as_ref(&self) -> &AccountInfo<'info> {
&self.info
}
}
impl<'a, T: AccountDeserialize + Clone> Deref for CpiAccount<'a, T> {
type Target = T;

View File

@ -162,6 +162,14 @@ impl<'info, T: AccountSerialize + AccountDeserialize + Clone> ToAccountInfo<'inf
}
}
impl<'info, T: AccountSerialize + AccountDeserialize + Clone> AsRef<AccountInfo<'info>>
for ProgramAccount<'info, T>
{
fn as_ref(&self) -> &AccountInfo<'info> {
&self.inner.info
}
}
impl<'a, T: AccountSerialize + AccountDeserialize + Clone> Deref for ProgramAccount<'a, T> {
type Target = T;