Skip to content

Conversation

gliderkite
Copy link

@gliderkite gliderkite commented Dec 30, 2021

  • Make the KnownLength trait public as legion::storage::KnownLength.
  • Fix lints and use Iterator::reduce instead of the deprecated Itertools::fold1.

Motivation and Context

Closes issue #274

CommandBuffer allows to push components for a new entity, but its signature constraints the components arguments with several traits. One of this is KownLength which at the moment is private. This unfortunately prevents from defining systems which take generic arguments as input that can be then used to create the entity components with `CommandBuffer.

For example, in my specific case I am in a situation where I'd like to be able to do something like the following:

#[system]
fn clone<EntityBuilder, Components>(cmd: &mut CommandBuffer)
where
    EntityBuilder: MyBuilderTrait<Components = Components> + Sync,
    Option<Components>: IntoComponentSource + 'static,
    <Option<Components> as IntoComponentSource>::Source: Send + Sync + KnownLength,
{
     let builder = EntityBuilder::new(...);
     let components = builder.build();

     cmd.push(components);
}

How Has This Been Tested?

Running cargo test on this branch is successful.

Checklist:

  • Acknowledged that by making this pull request I release this code under an MIT/Apache 2.0 dual licensing scheme.
  • My code follows the code style of this project.
  • If my change required a change to the documentation I have updated the documentation accordingly.
  • I have updated the content of the book if this PR would make the book outdated.
  • I have added tests to cover my changes.
  • My code is used in an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant