Skip to content

Commit

Permalink
Added helper methods to Bundles. (#17464)
Browse files Browse the repository at this point in the history
Added `len`, `is_empty`, and `iter` methods to `Bundles`.

Separated out from #17331.

---------

Co-authored-by: shuo <[email protected]>
  • Loading branch information
AlephCubed and shuoli84 authored Jan 21, 2025
1 parent b34833f commit 42b928b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions crates/bevy_ecs/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 42b928b

Please sign in to comment.