viridia / bevy_reactor

Fine-grained reactivity framework for Bevy.
100 stars 4 forks source link

remove `AnyResource` trait in favor of fn pointer #1

Closed atornity closed 9 months ago

atornity commented 9 months ago

I don't think the AnyResource trait does anything here other than erasing the generic type of TrackedResource so I removed it and added a fn pointer to TrackedResource instead.

I also removed the PartialEq and Eq derives, not sure if those were intended to be used somewhere or not?

This change is kinda pointless but it removes some lines of code :D

viridia commented 9 months ago

OK so I learned something new from this. I did not know that you could capture a generic function in a non-generic struct. I imagine that there are lots of other places in the code which could also be simplified with a better understanding of Rust types.

I'm going to accept this, but you should know that this code is going to be replaced soon - Bevy just a few days ago added the ability to get change ticks for a resource by id, so we won't need the type erasure any more.

Thanks for doing this!

atornity commented 9 months ago

Glad you learned something new! Yeah, it's pretty OP.

It's great that they're adding that, I was a bit confused when I couldn't find that function earlier.