Fix typos in insert_or_spawn_batch/spawn_batch methods (#12812)

# Objective

- The `bundles` parameter in `insert_or_spawn_batch` method has
inconsistent naming with docs (e.g. `bundles_iter`) since #11107.

## Solution

- Replace `bundles` with `bundles_iter`, as `bundles_iter` is more
expressive to its type.
This commit is contained in:
unknownue 2024-04-01 04:18:27 +08:00 committed by GitHub
parent 2ae7b4c7ac
commit 50699ecf76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -404,12 +404,12 @@ impl<'w, 's> Commands<'w, 's> {
/// Spawning a specific `entity` value is rarely the right choice. Most apps should use [`Commands::spawn_batch`]. /// Spawning a specific `entity` value is rarely the right choice. Most apps should use [`Commands::spawn_batch`].
/// This method should generally only be used for sharing entities across apps, and only when they have a scheme /// This method should generally only be used for sharing entities across apps, and only when they have a scheme
/// worked out to share an ID space (which doesn't happen by default). /// worked out to share an ID space (which doesn't happen by default).
pub fn insert_or_spawn_batch<I, B>(&mut self, bundles: I) pub fn insert_or_spawn_batch<I, B>(&mut self, bundles_iter: I)
where where
I: IntoIterator<Item = (Entity, B)> + Send + Sync + 'static, I: IntoIterator<Item = (Entity, B)> + Send + Sync + 'static,
B: Bundle, B: Bundle,
{ {
self.queue.push(insert_or_spawn_batch(bundles)); self.queue.push(insert_or_spawn_batch(bundles_iter));
} }
/// Pushes a [`Command`] to the queue for inserting a [`Resource`] in the [`World`] with an inferred value. /// Pushes a [`Command`] to the queue for inserting a [`Resource`] in the [`World`] with an inferred value.
@ -1037,13 +1037,13 @@ where
/// A [`Command`] that consumes an iterator of [`Bundle`]s to spawn a series of entities. /// A [`Command`] that consumes an iterator of [`Bundle`]s to spawn a series of entities.
/// ///
/// This is more efficient than spawning the entities individually. /// This is more efficient than spawning the entities individually.
fn spawn_batch<I, B>(bundles: I) -> impl Command fn spawn_batch<I, B>(bundles_iter: I) -> impl Command
where where
I: IntoIterator<Item = B> + Send + Sync + 'static, I: IntoIterator<Item = B> + Send + Sync + 'static,
B: Bundle, B: Bundle,
{ {
move |world: &mut World| { move |world: &mut World| {
world.spawn_batch(bundles); world.spawn_batch(bundles_iter);
} }
} }
@ -1051,13 +1051,13 @@ where
/// If any entities do not already exist in the world, they will be spawned. /// If any entities do not already exist in the world, they will be spawned.
/// ///
/// This is more efficient than inserting the bundles individually. /// This is more efficient than inserting the bundles individually.
fn insert_or_spawn_batch<I, B>(bundles: I) -> impl Command fn insert_or_spawn_batch<I, B>(bundles_iter: I) -> impl Command
where where
I: IntoIterator<Item = (Entity, B)> + Send + Sync + 'static, I: IntoIterator<Item = (Entity, B)> + Send + Sync + 'static,
B: Bundle, B: Bundle,
{ {
move |world: &mut World| { move |world: &mut World| {
if let Err(invalid_entities) = world.insert_or_spawn_batch(bundles) { if let Err(invalid_entities) = world.insert_or_spawn_batch(bundles_iter) {
error!( error!(
"Failed to 'insert or spawn' bundle of type {} into the following invalid entities: {:?}", "Failed to 'insert or spawn' bundle of type {} into the following invalid entities: {:?}",
std::any::type_name::<B>(), std::any::type_name::<B>(),