bevy/crates/bevy_reflect/src
Gino Valente 2b4180ca8f
bevy_reflect: Function reflection terminology refactor (#14813)
# Objective

One of the changes in #14704 made `DynamicFunction` effectively the same
as `DynamicClosure<'static>`. This change meant that the de facto
function type would likely be `DynamicClosure<'static>` instead of the
intended `DynamicFunction`, since the former is much more flexible.

We _could_ explore ways of making `DynamicFunction` implement `Copy`
using some unsafe code, but it likely wouldn't be worth it. And users
would likely still reach for the convenience of
`DynamicClosure<'static>` over the copy-ability of `DynamicFunction`.

The goal of this PR is to fix this confusion between the two types.

## Solution

Firstly, the `DynamicFunction` type was removed. Again, it was no
different than `DynamicClosure<'static>` so it wasn't a huge deal to
remove.

Secondly, `DynamicClosure<'env>` and `DynamicClosureMut<'env>` were
renamed to `DynamicFunction<'env>` and `DynamicFunctionMut<'env>`,
respectively.

Yes, we still ultimately kept the naming of `DynamicFunction`, but
changed its behavior to that of `DynamicClosure<'env>`. We need a term
to refer to both functions and closures, and "function" was the best
option.


[Originally](https://discord.com/channels/691052431525675048/1002362493634629796/1274091992162242710),
I was going to go with "callable" as the replacement term to encompass
both functions and closures (e.g. `DynamciCallable<'env>`). However, it
was
[suggested](https://discord.com/channels/691052431525675048/1002362493634629796/1274653581777047625)
by @SkiFire13 that the simpler "function" term could be used instead.

While "callable" is perhaps the better umbrella term—being truly
ambiguous over functions and closures— "function" is more familiar, used
more often, easier to discover, and is subjectively just
"better-sounding".

## Testing

Most changes are purely swapping type names or updating documentation,
but you can verify everything still works by running the following
command:

```
cargo test --package bevy_reflect
```
2024-08-19 21:52:36 +00:00
..
enums Making DynamicEnum::is_dynamic() return true (#14732) 2024-08-15 14:10:52 +00:00
func bevy_reflect: Function reflection terminology refactor (#14813) 2024-08-19 21:52:36 +00:00
impls reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00
path reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00
serde reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00
array.rs reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00
attributes.rs Fix intra-doc links and make CI test them (#14076) 2024-07-11 13:08:31 +00:00
fields.rs reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00
from_reflect.rs reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00
lib.rs bevy_reflect: Function reflection terminology refactor (#14813) 2024-08-19 21:52:36 +00:00
list.rs reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00
map.rs reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00
reflect.rs bevy_reflect: Reflect remote types (#6042) 2024-08-12 19:12:53 +00:00
remote.rs bevy_reflect: Reflect remote types (#6042) 2024-08-12 19:12:53 +00:00
set.rs reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00
std_traits.rs fix nightly clippy warnings (#6395) 2022-10-28 21:03:01 +00:00
struct_trait.rs reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00
tuple.rs Use #[doc(fake_variadic)] to improve docs readability (#14703) 2024-08-12 18:54:33 +00:00
tuple_struct.rs reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00
type_info.rs reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00
type_path.rs Add on_unimplemented Diagnostics to Most Public Traits (#13347) (#13662) 2024-06-04 00:31:34 +00:00
type_registry.rs reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00
utility.rs reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00