diff --git a/crates/bevy_hierarchy/src/components/parent.rs b/crates/bevy_hierarchy/src/components/parent.rs index 7bccf33ed6e1e..68ba8c7c91ed0 100644 --- a/crates/bevy_hierarchy/src/components/parent.rs +++ b/crates/bevy_hierarchy/src/components/parent.rs @@ -23,6 +23,16 @@ impl Parent { pub fn get(&self) -> Entity { self.0 } + + /// Gets the parent [`Entity`] as a slice of length 1. + /// + /// Useful for making APIs that require a type or homogenous storage + /// for both [`Children`] & [`Parent`] that is agnostic to edge direction. + /// + /// [`Children`]: super::children::Children + pub fn as_slice(&self) -> &[Entity] { + std::slice::from_ref(&self.0) + } } // TODO: We need to impl either FromWorld or Default so Parent can be registered as Reflect.