Skip to content

Commit b902d5f

Browse files
committed
Add migration guide
1 parent 335c9d2 commit b902d5f

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: StaticBundle split off from Bundle
3+
pull_requests: [19491]
4+
---
5+
6+
The `StaticBundle` trait has been split off from the `Bundle` trait to avoid conflating the concept of a type whose values can be inserted into an entity (`Bundle`) with the concept of a statically known set of components (`StaticBundle`). This required the update of existing APIs that were using `Bundle` as a statically known set of components to use `StaticBundle` instead.
7+
8+
Changes for most users will be zero or pretty minimal, since `#[derive(Bundle)]` will automatically derive `StaticBundle` and most types that implemented `Bundle` will now also implement `StaticBundle`. The main exception will be generic APIs or types, which now will need to update or add a bound on `StaticBundle`. For example:
9+
10+
```rs
11+
// 0.16
12+
#[derive(Bundle)]
13+
struct MyBundleWrapper<T: Bundle> {
14+
inner: T
15+
}
16+
17+
fn my_register_bundle<T: Bundle>(world: &mut World) {
18+
world.register_bundle::<T>();
19+
}
20+
21+
22+
// 0.17
23+
#[derive(Bundle)]
24+
struct MyBundleWrapper<T: Bundle + StaticBundle> { // Add a StaticBundle bound
25+
inner: T
26+
}
27+
28+
fn my_register_bundle<T: StaticBundle>(world: &mut World) { // Replace Bundle with StaticBundle
29+
world.register_bundle::<T>();
30+
}
31+
```
32+
33+
The following APIs now require the `StaticBundle` trait instead of the `Bundle` trait:
34+
35+
- `World::register_bundle`, which has been renamed to `World::register_static_bundle`
36+
- the `B` type parameter of `EntityRefExcept` and `EntityMutExcept`
37+
- `EntityClonerBuilder::allow` and `EntityClonerBuilder::deny`
38+
- `EntityCommands::clone_components` and `EntityCommands::move_components`
39+
- `EntityWorldMut::clone_components` and `EntityWorldMut::move_components`
40+
- the `B` type parameter of `IntoObserverSystem`, `Trigger`, `App::add_observer`, `World::add_observer`, `Observer::new`, `Commands::add_observer`, `EntityCommands::observe` and `EntityWorldMut::observe`
41+
- `EntityWorldMut::remove_recursive` and `Commands::remove_recursive`
42+
- `EntityCommands::remove`, `EntityCommands::remove_if`, `EntityCommands::try_remove_if`, `EntityCommands::try_remove`, `EntityCommands::remove_with_requires`, `EntityWorldMut::remove` and `EntityWorldMut::remove_with_requires`
43+
- `EntityWorldMut::take`
44+
- `EntityWorldMut::retain` and `EntityCommands::retain`
45+
46+
The following APIs now require the `StaticBundle` trait in addition to the `Bundle` trait:
47+
48+
- `Commands::spawn_batch`, `Commands::insert_batch`, `Commands::insert_batch_if_new`, `Commands::try_insert_batch`, `Commands::try_insert_batch_if_new`, `bevy::ecs::command::spawn_batch`, `bevy::ecs::command::insert_batch`, `World::spawn_batch`, `World::insert_batch`, `World::insert_batch_if_new`, `World::try_insert_batch` and `World::try_insert_batch_if_new`
49+
- `ReflectBundle::new`, `impl FromType<B>` for `ReflectBundle` and `#[reflect(Bundle)]`
50+
- `ExtractComponent::Out`
51+
52+
Moreover, some APIs have been renamed:
53+
54+
- `World::register_bundle` has been renamed to `World::register_static_bundle`
55+
- the `DynamicBundle` trait has been renamed to `ComponentsFromBundle`

0 commit comments

Comments
 (0)