Skip to content

Commit

Permalink
Allow unsized types as mapped value in Ref::map (#8817)
Browse files Browse the repository at this point in the history
# Objective

- I can't map unsized type using `Ref::map` (for example `dyn Reflect`)

## Solution

- Allow unsized types (this is possible because `Ref` stores a reference
to `T`)
  • Loading branch information
nicopap authored Jun 12, 2023
1 parent 527d3a5 commit ea887d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/change_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ impl<'a, T: ?Sized> Ref<'a, T> {
///
/// This doesn't do anything else than call `f` on the wrapped value.
/// This is equivalent to [`Mut::map_unchanged`].
pub fn map<U>(self, f: impl FnOnce(&T) -> &U) -> Ref<'a, U> {
pub fn map<U: ?Sized>(self, f: impl FnOnce(&T) -> &U) -> Ref<'a, U> {
Ref {
value: f(self.value),
ticks: self.ticks,
Expand Down

0 comments on commit ea887d8

Please sign in to comment.