legion
legion copied to clipboard
Make KnownLength public
- Make the
KnownLengthtrait public aslegion::storage::KnownLength. - Fix lints and use
Iterator::reduceinstead of the deprecatedItertools::fold1.
Motivation and Context
Closes issue https://github.com/amethyst/legion/issues/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:
- [x] 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.
- [x] 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.