Add as_slice to parent (#9871)
# Objective - Make it possible to write APIs that require a type or homogenous storage for both `Children` & `Parent` that is agnostic to edge direction. ## Solution - Add a way to get the `Entity` from `Parent` as a slice. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Joseph <21144246+JoJoJet@users.noreply.github.com>
This commit is contained in:
parent
5c884c5a15
commit
0181d40d83
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user