impl SceneList for Vec<Box<dyn SceneList>>#24242
Open
chronicl wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
Actually, a better solution that can avoid #[derive(Deref, DerefMut)]
struct VecSceneList<S>(pub Vec<S>);
impl<S: SceneList> SceneList for VecSceneList<S> { ... }
// Convenience method for when the `SceneList` types aren't homogenous (and thus Box is required)
impl VecSceneList<Box<dyn SceneList>> {
fn push_box(&mut self, scene_list: impl SceneList) { self.push(Box::new(scene_list) }
}but this can be implemented in user land. I'm not sure if bevy wants to provide these kind of helper types? |
|
It should be possible to pass |
Contributor
Author
I need // We already have
impl<S: Scene> SceneList for Vec<S>
// so we can't also have
impl<S: SceneList> SceneList for Vec<S>
// because there could be types that are S: Scene + SceneList and rust doesn't have specialization |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
I couldn't figure out a way to spawn a variable amount of
SceneLists asChildren.This came up when trying to make a variable row grid layout, each row being a
SceneListbecause it has columns that need to be inserted directly into the gridNode:Solution
This can be implemented in user land by creating a wrapper type for
Vec<Box<dyn SceneList>>, so I don't feel strongly about actually merging this PR.Testing
None so far.