Rename StateWithExtensionsMut::get_extension()

This commit is contained in:
Michael Vines 2022-01-10 12:36:04 -08:00
parent 9aa859c929
commit 2caec406bc
1 changed files with 3 additions and 3 deletions

View File

@ -265,7 +265,7 @@ impl<'data, S: BaseState> StateWithExtensionsMut<'data, S> {
} }
} }
fn get_extension<V: Extension>(&mut self, init: bool) -> Result<&mut V, ProgramError> { fn init_or_get_extension<V: Extension>(&mut self, init: bool) -> Result<&mut V, ProgramError> {
if V::ACCOUNT_TYPE != S::ACCOUNT_TYPE { if V::ACCOUNT_TYPE != S::ACCOUNT_TYPE {
return Err(ProgramError::InvalidAccountData); return Err(ProgramError::InvalidAccountData);
} }
@ -296,7 +296,7 @@ impl<'data, S: BaseState> StateWithExtensionsMut<'data, S> {
/// Unpack a portion of the TLV data as the desired type /// Unpack a portion of the TLV data as the desired type
pub fn get_extension_mut<V: Extension>(&mut self) -> Result<&mut V, ProgramError> { pub fn get_extension_mut<V: Extension>(&mut self) -> Result<&mut V, ProgramError> {
self.get_extension(false) self.init_or_get_extension(false)
} }
/// Packs base state data into the base data portion /// Packs base state data into the base data portion
@ -308,7 +308,7 @@ impl<'data, S: BaseState> StateWithExtensionsMut<'data, S> {
/// Packs the extension data into an open slot if not already found in the /// Packs the extension data into an open slot if not already found in the
/// data buffer, otherwise overwrites itself /// data buffer, otherwise overwrites itself
pub fn init_extension<V: Extension>(&mut self) -> Result<&mut V, ProgramError> { pub fn init_extension<V: Extension>(&mut self) -> Result<&mut V, ProgramError> {
self.get_extension(true) self.init_or_get_extension(true)
} }
/// Write the account type into the buffer, done during the base /// Write the account type into the buffer, done during the base