Skip to content

Commit 42b928b

Browse files
AlephCubedshuoli84
andauthored
Added helper methods to Bundles. (#17464)
Added `len`, `is_empty`, and `iter` methods to `Bundles`. Separated out from #17331. --------- Co-authored-by: shuo <[email protected]>
1 parent b34833f commit 42b928b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

crates/bevy_ecs/src/bundle.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,21 @@ pub struct Bundles {
14731473
}
14741474

14751475
impl Bundles {
1476+
/// The total number of [`Bundle`] registered in [`Storages`].
1477+
pub fn len(&self) -> usize {
1478+
self.bundle_infos.len()
1479+
}
1480+
1481+
/// Returns true if no [`Bundle`] registered in [`Storages`].
1482+
pub fn is_empty(&self) -> bool {
1483+
self.len() == 0
1484+
}
1485+
1486+
/// Iterate over [`BundleInfo`].
1487+
pub fn iter(&self) -> impl Iterator<Item = &BundleInfo> {
1488+
self.bundle_infos.iter()
1489+
}
1490+
14761491
/// Gets the metadata associated with a specific type of bundle.
14771492
/// Returns `None` if the bundle is not registered with the world.
14781493
#[inline]

0 commit comments

Comments
 (0)