Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add as_slice to parent #9871

Merged
merged 5 commits into from
Sep 22, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions crates/bevy_hierarchy/src/components/parent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ impl Parent {
pub fn get(&self) -> Entity {
self.0
}

/// Get parent as a slice.
iiYese marked this conversation as resolved.
Show resolved Hide resolved
///
/// 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 get_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.
Expand Down