Flecs-Rust icon indicating copy to clipboard operation
Flecs-Rust copied to clipboard

Some examples broken after introducing runtime borrow checking

Open richardhozak opened this issue 10 months ago • 1 comments

Hello, I've tried to run the example queries/query_change_tracking_1.rs with latest master (c3da92c5e4f11981190b8baaef0e59ba61d785a5) and I've noticed that it fails on assertions.

The lines that trigger the assertions are these:

        let pos = it.field_mut::<Position>(0).unwrap();
        let parent_pos = it.field_mut::<Position>(1); // Optional
        let mut world_pos = it.field_mut::<WorldPosition>(2).unwrap();

We want to get position of entity and also the position of parent, but since they are the same component, the assertion gets triggered.

This code was previously this:

        let pos = it.field::<&Position>(0).unwrap();
        let parent_pos = it.field::<&Position>(1); // Optional
        let mut world_pos = it.field::<&mut WorldPosition>(2).unwrap();

Is there a way to do this now that runtime borrow checking is implemented? I've reverted to previous revision to mitigate this issue but I'd like to use latest master as it is easier to browse the examples and learn from them.

Thanks!

For those who are also experiencing this issue the latest revision before borrow checking is 6f89f9d20165b6e4c6e55667dbdc3a5fb7b501e7, that one works with the examples I've tested.

richardhozak avatar Mar 15 '25 20:03 richardhozak

There's planned followup work for multi source queries that will allow this. In the mean time if you want to work with RTBC you can get EntityViews & get the positions from each entity that way.

iiYese avatar Mar 16 '25 13:03 iiYese