Repository: bevyengine/bevy
File: crates/bevy_ecs/src/world/entity_ref.rs (Rust)

Code before:
            .has_component_write(id)
            // SAFETY: We have write access
            .then(|| unsafe { self.entity.get_mut() })
            .flatten()
    }

    /// Gets mutable access to the component of type `T` for the current entity.
    /// Returns `None` if the entity does not have a component of type `T` or if
    /// the access does not include write access to `T`.
    ///
    /// This only requires `&self`, and so may be used to get mutable access to multiple components.
    ///
    /// # Example
    ///
    /// ```
    /// # use bevy_ecs::{prelude::*, world::FilteredEntityMut};
    /// #
    /// #[derive(Component)]
    /// struct X(usize);
    /// #[derive(Component)]
    /// struct Y(usize);
    ///
    /// # let mut world = World::default();
    /// let mut entity = world.spawn((X(0), Y(0))).into_mutable();
    ///
    /// // This gives the `FilteredEntityMut` access to `&mut A` and `&mut B`.
    /// let mut query = QueryBuilder::<FilteredEntityMut>::new(&mut world)
    ///     .data::<(&mut X, &mut Y)>()
    ///     .build();
    ///
    /// let mut filtered_entity: FilteredEntityMut = query.single_mut(&mut world).unwrap();
    ///
    /// // Get mutable access to two components at once
    /// // SAFETY: We don't take any other references to `X` from this entity
    /// let mut x = unsafe { filtered_entity.get_mut_unchecked::<X>() }.unwrap();
    /// // SAFETY: We don't take any other references to `Y` from this entity
    /// let mut y = unsafe { filtered_entity.get_mut_unchecked::<Y>() }.unwrap();
    /// *x = X(1);
    /// *y = Y(1);
    /// ```
    ///
    /// # Safety
    ///
    /// No other references to the same component may exist at the same time as the returned reference.
    ///
    /// # See also
    ///
    /// - [`get_mut`](Self::get_mut) for the safe version.
    #[inline]
    pub unsafe fn get_mut_unchecked<T: Component<Mutability = Mutable>>(
        &self,

Review comment (suggestion):
```suggestion
    /// // This gives the `FilteredEntityMut` access to `&mut X` and `&mut Y`.
```

Code after:

    /// Gets mutable access to the component of type `T` for the current entity.
    /// Returns `None` if the entity does not have a component of type `T` or if
    /// the access does not include write access to `T`.
    ///
    /// This only requires `&self`, and so may be used to get mutable access to multiple components.
    ///
    /// # Example
    ///
    /// ```
    /// # use bevy_ecs::{prelude::*, world::FilteredEntityMut};
    /// #
    /// #[derive(Component)]
    /// struct X(usize);
    /// #[derive(Component)]
    /// struct Y(usize);
    ///
    /// # let mut world = World::default();
    /// let mut entity = world.spawn((X(0), Y(0))).into_mutable();
    ///
    /// // This gives the `FilteredEntityMut` access to `&mut X` and `&mut Y`.
    /// let mut query = QueryBuilder::<FilteredEntityMut>::new(&mut world)
    ///     .data::<(&mut X, &mut Y)>()
    ///     .build();
    ///
    /// let mut filtered_entity: FilteredEntityMut = query.single_mut(&mut world).unwrap();
    ///
    /// // Get mutable access to two components at once
    /// // SAFETY: We don't take any other references to `X` from this entity
    /// let mut x = unsafe { filtered_entity.get_mut_unchecked::<X>() }.unwrap();
    /// // SAFETY: We don't take any other references to `Y` from this entity
    /// let mut y = unsafe { filtered_entity.get_mut_unchecked::<Y>() }.unwrap();
    /// *x = X(1);
    /// *y = Y(1);
    /// ```
    ///
    /// # Safety
    ///
    /// No other references to the same component may exist at the same time as the returned reference.
    ///
    /// # See also
    ///
    /// - [`get_mut`](Self::get_mut) for the safe version.
    #[inline]
    pub unsafe fn get_mut_unchecked<T: Component<Mutability = Mutable>>(
        &self,
    ) -> Option<Mut<'_, T>> {
        let id = self
            .entity
            .world()
            .components()