Skip to content

Commit

Permalink
lang: implement AsRef<T> for Account<'a, T> (#1173)
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-schaaf committed Dec 27, 2021
1 parent b5827c1 commit 5136644
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions lang/src/accounts/account.rs
Expand Up @@ -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;

Expand Down

0 comments on commit 5136644

Please sign in to comment.