Skip to content

Commit 23863d5

Browse files
authored
Do not require mut on ParsedPath::element_mut (#8891)
# Objective `ParsedPath` does not need to be mut to access a field of a `Reflect`. Be that access mutable or not. Yet `element_mut` requires a mutable borrow on `self`. ## Solution - Make `element_mut` take a `&self` over a `&mut self`. #8887 fixes this, but this is a major limitation in the API and I'd rather see it merged before 0.11. --- ## Changelog - `ParsedPath::element_mut` and `ParsedPath::reflect_element_mut` now accept a non-mutable `ParsedPath` (only the accessed `Reflect` needs to be mutable)
1 parent e6b655f commit 23863d5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/bevy_reflect/src/path.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ impl ParsedPath {
371371
///
372372
/// See [`element_mut`](Self::element_mut) for a typed version of this method.
373373
pub fn reflect_element_mut<'r, 'p>(
374-
&'p mut self,
374+
&'p self,
375375
root: &'r mut dyn Reflect,
376376
) -> Result<&'r mut dyn Reflect, ReflectPathError<'p>> {
377377
let mut current = root;
@@ -402,7 +402,7 @@ impl ParsedPath {
402402
///
403403
/// See [`reflect_element_mut`](Self::reflect_element_mut) for an untyped version of this method.
404404
pub fn element_mut<'r, 'p, T: Reflect>(
405-
&'p mut self,
405+
&'p self,
406406
root: &'r mut dyn Reflect,
407407
) -> Result<&'r mut T, ReflectPathError<'p>> {
408408
self.reflect_element_mut(root).and_then(|p| {

0 commit comments

Comments
 (0)