Skip to content

Add compile-time dyn compatible checks for DynEq, DynHash #17254

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

Merged
merged 2 commits into from
Jan 9, 2025

Conversation

mgi388
Copy link
Contributor

@mgi388 mgi388 commented Jan 9, 2025

Objective

Solution

  • Removes assert_object_safe from bevy_utils by using a compile time check instead.

Testing

  • CI.

Migration Guide

assert_object_safe is no longer exported by bevy_utils. Instead, you can write a compile time check that your trait is "dyn compatible":

/// Assert MyTrait is dyn compatible
const _: Option<Box<dyn MyTrait>> = None;

@BenjaminBrienen
Copy link
Contributor

Very clean

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it A-Utils Utility functions and types labels Jan 9, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 9, 2025
Merged via the queue into bevyengine:main with commit b20e23d Jan 9, 2025
32 checks passed
@mgi388 mgi388 deleted the rm-assert_object_safe branch January 9, 2025 09:09
mrchantey pushed a commit to mrchantey/bevy that referenced this pull request Feb 4, 2025
…gine#17254)

# Objective

- Shrink `bevy_utils` more.
- Refs bevyengine#11478

## Solution

- Removes `assert_object_safe` from `bevy_utils` by using a compile time
check instead.

## Testing

- CI.

---

## Migration Guide

`assert_object_safe` is no longer exported by `bevy_utils`. Instead, you
can write a compile time check that your trait is "dyn compatible":

```rust
/// Assert MyTrait is dyn compatible
const _: Option<Box<dyn MyTrait>> = None;
```

---------

Co-authored-by: Alice Cecile <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events A-Utils Utility functions and types C-Code-Quality A section of code that is hard to understand or change S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants