Added helper methods to Bundles. (#17464)

Added `len`, `is_empty`, and `iter` methods to `Bundles`.

Separated out from #17331.

---------

Co-authored-by: shuo <shuoli84@gmail.com>
This commit is contained in:
AlephCubed 2025-01-20 18:19:02 -08:00 committed by GitHub
parent b34833f00c
commit 42b928b90e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1473,6 +1473,21 @@ pub struct Bundles {
}
impl Bundles {
/// The total number of [`Bundle`] registered in [`Storages`].
pub fn len(&self) -> usize {
self.bundle_infos.len()
}
/// Returns true if no [`Bundle`] registered in [`Storages`].
pub fn is_empty(&self) -> bool {
self.len() == 0
}
/// Iterate over [`BundleInfo`].
pub fn iter(&self) -> impl Iterator<Item = &BundleInfo> {
self.bundle_infos.iter()
}
/// Gets the metadata associated with a specific type of bundle.
/// Returns `None` if the bundle is not registered with the world.
#[inline]