Skip to content

Commit

Permalink
Remove TypeRegistry re-export rename (#9807)
Browse files Browse the repository at this point in the history
# Objective

The rename is confusing. Each time I import `TypeRegistry` I have to
think at least 10 seconds about how to import it. And I've been working
a lot with bevy reflect, which multiplies the papercut.

In my crates, you can find lots of:

```rust
use bevy::reflect::{TypeRegistryInternal as TypeRegistry};
```

When I "go to definition" on `TypeRegistry` I get to `TypeRegistryArc`.
And when I mean `TypeRegistry` in my function signature, 100% of the
time I mean `TypeRegistry`, not the arc wrapper.

Rust has borrowing, and most use-cases of the TypeRegistry accepts
borrow of the registry, with no need to mutate it.

`TypeRegistryInternal` is also confusing. In bevy crates, it doesn't
exist. The bevy crate documentation often refers to `TypeRegistry` and
link to `TypeRegistryInternal`. It only exists in the bevy re-exports.
It makes it hard to understand which names qualifies which types.

## Solution

Remove the rename, keep the type names as they are in `bevy_reflect`

---

## Changelog

- Remove `TypeRegistry` and `TypeRegistryArc` renames from bevy
`bevy_reflect` re-exports.

## Migration Guide

- `TypeRegistry` as re-exported by the wrapper `bevy` crate is now
`TypeRegistryArc`
- `TypeRegistryInternal` as re-exported by the wrapper `bevy` crate is
now `TypeRegistry`
  • Loading branch information
nicopap committed Sep 14, 2023
1 parent 8192ac6 commit 5e00379
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions crates/bevy_internal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,8 @@ pub mod ptr {
}

pub mod reflect {
// TODO: remove these renames once TypeRegistryArc is no longer required
//! Type reflection used for dynamically interacting with rust types.
pub use bevy_reflect::{
TypeRegistry as TypeRegistryInternal, TypeRegistryArc as TypeRegistry, *,
};
pub use bevy_reflect::*;
}

#[cfg(feature = "bevy_scene")]
Expand Down

0 comments on commit 5e00379

Please sign in to comment.