bevy/crates/bevy_reflect/src
Gino Valente 1674938c49
bevy_reflect: Split up the std module (#18939)
> [!important]
> To **maintainers**: we should wait to merge this one in until after
#18944 lands so that cherry-picking the latter for 0.16.1 is simpler.

# Objective

The `std` module is where we implement the reflection traits for types
that are exported from `std` (including `core` and `alloc`). Over time,
this file has grown increasingly large, making it difficult to navigate
and a pain point for merge conflicts.

The goal of this PR is to break up the module into smaller chunks.

## Solution

The `std` module has been split into many submodules:
- `alloc`
- `bevy_platform`
- `core`
- `std`

Each of these new modules is comprised of submodules that closely
resemble the actual module. For example, the impls for
`::alloc::vec::Vec` have been moved to
`bevy_reflect::impls::alloc::vec::Vec`.

Some liberties were taken. For example, `Cow<'static, Path>` was kept in
`bevy_reflect::impls::std::path` rather than
`bevy_reflect::impls::alloc::borrow`.

You may ask: _Isn't this a little overkill? Why does the one-line impl
for `TypeId` need its own file?_

And yes, it is partly overkill. But the benefit with this approach is
that where an `std`-related type should live is mostly unambiguous. If
we wanted to reflect `::core::net::Ipv4Addr`, it's very clear that it
should be done in `bevy_reflect::impls::core::net`.

We can discuss better ways of breaking this up if people have other
ideas or opinions, but I think this is a pretty straightforward way of
doing it.

### Note to Reviewers

The code is pretty much copy-paste from the mega module to the new
submodules. It's probably best to focus efforts on reviewing the general
module structure, as well as maybe which impls are included where.

You _can_ review the code contained within each impl, but I promise you
the only thing I touched were the paths in the macros so they could be
more hygienic :)

## Testing

You can just check that everything compiles still:

```
cargo check -p bevy_reflect --tests
```
2025-05-26 19:10:47 +00:00
..
enums Deprecated Begone! 0.16 Cleanup (#19108) 2025-05-07 18:17:41 +00:00
func bevy_reflect: Split up the std module (#18939) 2025-05-26 19:10:47 +00:00
impls bevy_reflect: Split up the std module (#18939) 2025-05-26 19:10:47 +00:00
path Harden proc macro path resolution and add integration tests. (#17330) 2025-02-09 19:45:45 +00:00
serde Rename bevy_platform_support to bevy_platform (#18813) 2025-04-11 23:13:28 +00:00
array.rs Deprecated Begone! 0.16 Cleanup (#19108) 2025-05-07 18:17:41 +00:00
attributes.rs Harden proc macro path resolution and add integration tests. (#17330) 2025-02-09 19:45:45 +00:00
error.rs bevy_reflect: Reflection-based cloning (#13432) 2025-03-11 06:02:59 +00:00
fields.rs Rename bevy_platform_support to bevy_platform (#18813) 2025-04-11 23:13:28 +00:00
from_reflect.rs bevy_reflect: Apply #[deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17092) 2025-01-03 22:22:34 +00:00
generics.rs Rename bevy_platform_support to bevy_platform (#18813) 2025-04-11 23:13:28 +00:00
kind.rs Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00
lib.rs bevy_reflect: Split up the std module (#18939) 2025-05-26 19:10:47 +00:00
list.rs Deprecated Begone! 0.16 Cleanup (#19108) 2025-05-07 18:17:41 +00:00
map.rs Deprecated Begone! 0.16 Cleanup (#19108) 2025-05-07 18:17:41 +00:00
reflect.rs bevy_reflect: Split up the std module (#18939) 2025-05-26 19:10:47 +00:00
reflectable.rs bevy_reflect: Add Reflectable trait (#5772) 2024-09-18 00:36:41 +00:00
remote.rs Add no_std support to bevy_reflect (#16256) 2024-12-05 21:15:21 +00:00
set.rs Deprecated Begone! 0.16 Cleanup (#19108) 2025-05-07 18:17:41 +00:00
std_traits.rs Add no_std support to bevy_reflect (#16256) 2024-12-05 21:15:21 +00:00
struct_trait.rs Deprecated Begone! 0.16 Cleanup (#19108) 2025-05-07 18:17:41 +00:00
tuple_struct.rs Deprecated Begone! 0.16 Cleanup (#19108) 2025-05-07 18:17:41 +00:00
tuple.rs Deprecated Begone! 0.16 Cleanup (#19108) 2025-05-07 18:17:41 +00:00
type_info_stack.rs Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00
type_info.rs bevy_reflect: Deprecate PartialReflect::clone_value (#18284) 2025-03-14 19:33:57 +00:00
type_path.rs Add no_std support to bevy_reflect (#16256) 2024-12-05 21:15:21 +00:00
type_registry.rs Rename bevy_platform_support to bevy_platform (#18813) 2025-04-11 23:13:28 +00:00
utility.rs Rename bevy_platform_support to bevy_platform (#18813) 2025-04-11 23:13:28 +00:00