Flecs-Rust
Flecs-Rust copied to clipboard
Sorting causes segfault
Version: db1b212
Minimal setup to reproduce:
use core::cmp::Ordering;
use flecs_ecs::prelude::*;
#[derive(Component)]
struct Foo(u8);
fn foo_cmp(_: Entity, a: &&Foo, _: Entity, b: &&Foo) -> i32 {
match a.0.cmp(&b.0) {
Ordering::Less => -1,
Ordering::Greater => 1,
Ordering::Equal => 0,
}
}
fn main() {
let mut world = World::new();
world.entity().set(Foo(0));
world.entity().set(Foo(1));
system!("foo_sort", world, &Foo)
.kind::<flecs::pipeline::OnStore>()
.order_by::<&Foo>(foo_cmp)
.each(|_| {});
world.progress();
}
tldr of discord conversation, it's because &T is passed in the order_by function instead of just T, which changes the function signature to &&T which causes the segfault. Need to patch this issue.
fixed in #d2f3b511