bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Remove second generic from `.add_before`, `.add_after`

Open benfrankel opened this issue 1 year ago • 0 comments

Objective

// Currently:
builder.add_after::<FooPlugin, _>(BarPlugin);
// After this PR:
builder.add_after::<FooPlugin>(BarPlugin);

This removes some weirdness and better parallels the rest of the PluginGroupBuilder API.

Solution

Define a helper method type_id_of_val to use in .add_before and .add_after instead of TypeId::of::<T> (which requires the plugin type to be nameable, preventing impl Plugin from being used).

Testing

Ran cargo run -p ci lints successfully.

Migration Guide

Removed second generic from PluginGroupBuilder methods: add_before and add_after.

// Before:
DefaultPlugins
    .build()
    .add_before::<WindowPlugin, _>(FooPlugin)
    .add_after::<WindowPlugin, _>(BarPlugin)

// After:
DefaultPlugins
    .build()
    .add_before::<WindowPlugin>(FooPlugin)
    .add_after::<WindowPlugin>(BarPlugin)

benfrankel avatar Jul 11 '24 20:07 benfrankel