provide default impl of 'is_empty' (#24554)

This commit is contained in:
Jeff Washington (jwash) 2022-04-21 12:49:44 -05:00 committed by GitHub
parent 28ed2a9df4
commit 3f7b8d3d2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 7 deletions

View File

@ -16,7 +16,9 @@ pub trait StorableAccounts<'a, T: ReadableAccount + Sync>: Sync {
/// slot that all accounts are to be written to
fn target_slot(&self) -> Slot;
/// true if no accounts to write
fn is_empty(&self) -> bool;
fn is_empty(&self) -> bool {
self.len() == 0
}
/// # accounts to write
fn len(&self) -> usize;
/// are there accounts from multiple slots
@ -38,9 +40,6 @@ impl<'a, T: ReadableAccount + Sync> StorableAccounts<'a, T> for (Slot, &'a [(&'a
fn target_slot(&self) -> Slot {
self.0
}
fn is_empty(&self) -> bool {
self.1.is_empty()
}
fn len(&self) -> usize {
self.1.len()
}
@ -66,9 +65,6 @@ impl<'a, T: ReadableAccount + Sync> StorableAccounts<'a, T>
fn target_slot(&self) -> Slot {
self.0
}
fn is_empty(&self) -> bool {
self.1.is_empty()
}
fn len(&self) -> usize {
self.1.len()
}