From 51366441d2e0f32ac6be20be768f06ab2624a6cb Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 27 Dec 2021 16:37:47 +0100 Subject: [PATCH] lang: implement AsRef for Account<'a, T> (#1173) --- CHANGELOG.md | 1 + lang/src/accounts/account.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d6f694bb..48c0cb6cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` for `Account<'a, T>`([#1173](https://github.com/project-serum/anchor/pull/1173)) ### Breaking diff --git a/lang/src/accounts/account.rs b/lang/src/accounts/account.rs index 7ce20e36d..600346585 100644 --- a/lang/src/accounts/account.rs +++ b/lang/src/accounts/account.rs @@ -160,6 +160,14 @@ impl<'info, T: AccountSerialize + AccountDeserialize + Owner + Clone> AsRef AsRef + 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;