-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make builder types take and return Self
#10001
Conversation
It looks like your PR is a breaking change, but you didn't provide a migration guide. Could you add some context on what users should update when this change get released in a new version of Bevy? |
88ce316
to
ca60db4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to TableBuilder are really only relevant when new archetypes are introduced, so it's probably not too big of a perf concern.
# Objective Closes bevyengine#9955. Use the same interface for all "pure" builder types: taking and returning `Self` (and not `&mut Self`). ## Solution Changed `DynamicSceneBuilder`, `SceneFilter` and `TableBuilder` to take and return `Self`. ## Changelog ### Changed - `DynamicSceneBuilder` and `SceneBuilder` methods in `bevy_ecs` now take and return `Self`. ## Migration guide When using `bevy_ecs::DynamicSceneBuilder` and `bevy_ecs::SceneBuilder`, instead of binding the builder to a variable, directly use it. Methods on those types now consume `Self`, so you will need to re-bind the builder if you don't `build` it immediately. Before: ```rust let mut scene_builder = DynamicSceneBuilder::from_world(&world); let scene = scene_builder.extract_entity(a).extract_entity(b).build(); ``` After: ```rust let scene = DynamicSceneBuilder::from_world(&world) .extract_entity(a) .extract_entity(b) .build(); ```
# Objective Closes bevyengine#9955. Use the same interface for all "pure" builder types: taking and returning `Self` (and not `&mut Self`). ## Solution Changed `DynamicSceneBuilder`, `SceneFilter` and `TableBuilder` to take and return `Self`. ## Changelog ### Changed - `DynamicSceneBuilder` and `SceneBuilder` methods in `bevy_ecs` now take and return `Self`. ## Migration guide When using `bevy_ecs::DynamicSceneBuilder` and `bevy_ecs::SceneBuilder`, instead of binding the builder to a variable, directly use it. Methods on those types now consume `Self`, so you will need to re-bind the builder if you don't `build` it immediately. Before: ```rust let mut scene_builder = DynamicSceneBuilder::from_world(&world); let scene = scene_builder.extract_entity(a).extract_entity(b).build(); ``` After: ```rust let scene = DynamicSceneBuilder::from_world(&world) .extract_entity(a) .extract_entity(b) .build(); ```
# Objective Closes bevyengine#9955. Use the same interface for all "pure" builder types: taking and returning `Self` (and not `&mut Self`). ## Solution Changed `DynamicSceneBuilder`, `SceneFilter` and `TableBuilder` to take and return `Self`. ## Changelog ### Changed - `DynamicSceneBuilder` and `SceneBuilder` methods in `bevy_ecs` now take and return `Self`. ## Migration guide When using `bevy_ecs::DynamicSceneBuilder` and `bevy_ecs::SceneBuilder`, instead of binding the builder to a variable, directly use it. Methods on those types now consume `Self`, so you will need to re-bind the builder if you don't `build` it immediately. Before: ```rust let mut scene_builder = DynamicSceneBuilder::from_world(&world); let scene = scene_builder.extract_entity(a).extract_entity(b).build(); ``` After: ```rust let scene = DynamicSceneBuilder::from_world(&world) .extract_entity(a) .extract_entity(b) .build(); ```
Objective
Closes #9955.
Use the same interface for all "pure" builder types: taking and returning
Self
(and not&mut Self
).Solution
Changed
DynamicSceneBuilder
,SceneFilter
andTableBuilder
to take and returnSelf
.Changelog
Changed
DynamicSceneBuilder
andSceneBuilder
methods inbevy_ecs
now take and returnSelf
.Migration guide
When using
bevy_ecs::DynamicSceneBuilder
andbevy_ecs::SceneBuilder
, instead of binding the builder to a variable, directly use it. Methods on those types now consumeSelf
, so you will need to re-bind the builder if you don'tbuild
it immediately.Before:
After: