lang: implement AsRef<T> for Account<'a, T> (#1173)

This commit is contained in:
Paul 2021-12-27 16:37:47 +01:00 committed by GitHub
parent b5827c1b24
commit 51366441d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -25,6 +25,7 @@ incremented for features.
* lang: Add `set_inner` method to `Account<'a, T>` to enable easy updates ([#1177](https://github.com/project-serum/anchor/pull/1177)).
* lang: Handle arrays with const as length ([#968](https://github.com/project-serum/anchor/pull/968)).
* ts: Add optional commitment argument to `fetch` and `fetchMultiple` ([#1171](https://github.com/project-serum/anchor/pull/1171)).
* lang: Implement `AsRef<T>` for `Account<'a, T>`([#1173](https://github.com/project-serum/anchor/pull/1173))
### Breaking

View File

@ -160,6 +160,14 @@ impl<'info, T: AccountSerialize + AccountDeserialize + Owner + Clone> AsRef<Acco
}
}
impl<'info, T: AccountSerialize + AccountDeserialize + Owner + Clone> AsRef<T>
for Account<'info, T>
{
fn as_ref(&self) -> &T {
&self.account
}
}
impl<'a, T: AccountSerialize + AccountDeserialize + Owner + Clone> Deref for Account<'a, T> {
type Target = T;