Skip to content

Conversation

@teohhanhui
Copy link
Contributor

@teohhanhui teohhanhui commented Sep 21, 2024

TilePos has a total order. See https://doc.rust-lang.org/stable/core/cmp/trait.Ord.html#corollaries

This allows using TilePos as key in BTreeMap or as value in BTreeSet, for example.

@ChristopherBiscardi
Copy link
Collaborator

glam's UVec2 doesn't implement Ord (or PartialOrd) and it feels weird to have an implementation here. That said, we already support PartialOrd so I'm fine adding this in but I think we should actually remove the PartialOrd in a future release

Specifically you say that "TilePos has a total order" but in the context of x/y positions I'm not sure that's accurate since there are multiple possible implementations (does x matter more or does y matter more?)

@ChristopherBiscardi ChristopherBiscardi merged commit 93a01d7 into StarArawn:main Nov 2, 2024
8 checks passed
@teohhanhui
Copy link
Contributor Author

Specifically you say that "TilePos has a total order" but in the context of x/y positions I'm not sure that's accurate since there are multiple possible implementations (does x matter more or does y matter more?)

I was just operating based on the existing derived PartialOrd impl, but also it'd be hardly surprising to anyone that (x,y) is sorted by well, x,y.

@teohhanhui teohhanhui deleted the fix/tile-pos-ord branch November 2, 2024 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants