Hands-On Rust: Explain Read<xxx> introduced at end of chapter 7

Title: Hands-On Rust (End of chapter 7)

the query to acquire movers is changed to add Entity (that seems obvious), but point was changed from &mut Point to Read<Point>. ( I understand it’s not necessary to be mutable anymore), and &MovingRandomly is changed to Read<MovingRandomly>.

I don’t recall seeing the Read<xxx> stuff before and think it could use elaboration here.

That’s a bug! Read<xxx> was required in the version of Legion I started with. I thought I’d found all of those! Beta 2 just started its trip to production, so I’ll flag this as a beta-3 issue. Thank you!

So, both should just use & then?

(Sorry, realized I could answer my own question, and, yep &'s work)

1 Like

Yes, please. Prior to version 0.3, Legion used a rather wordy syntax that required you to mark every component as Read<MyComponent> or Write<MyComponent>. I’m VERY glad they made it easier to use - but it changed mid-way through the book so everything got updated to the new syntax - or should have done. I’ll do another pass searching for that one.