Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSupport lexical ordering for macro types and rects #234
Conversation
This allows using Euclid types in BTree collections.
|
This is mathematically iffy since lexical ordering has no geometrical motivation. It is how the native arrays and tuples work in Rust though. Feel free to reject if the mathematical interpretation part is a sticking point. |
|
Looks good to me, out of curiosity what use cases do you have in mind for ordering rects? |
|
I want to store them in a set and I want the set iteration order to be deterministic. I'm working on a procedural map generator for a game, and I need it to be deterministic for a given Rng state. Hash containers introduce unspecified iteration order which breaks this, BTree containers are deterministic. My current use case involves a set of Point2D values, so I don't have a need for Rects yet. I'm already using HashMap keys that contain Rects elsewhere in my code, so it's quite possible I'll come up with a map generator algorithm in the future that wants to store a bunch of rects in a set with a deterministic iteration order. |
|
Hmm, I don't see |
|
After making the PR I found out that it's reasonably painless to make a newtype wrapper with the lexical Ord implementation for the vector types, so there's maybe less need for this feature upstream than I originally thought. |
|
I am personally mostly indifferent as whether to implement arbitrary ordering for geometric types (erring on the side of "hm that's a bit weird"), @kvark has some reserves (understandably) but agrees to do this if there is a strong need. If you don't need it too much, perhaps we should not merge this for now, but agree to revisit in the future if it turns out that there are compelling use cases that aren't painlessly worked around by newtypes or something else. |
|
Yeah, maybe it's best to leave this unmerged for now and see if anyone else asks for this. |
|
Let's close this for now. |
rsaarelm commentedNov 18, 2017
•
edited by larsbergstrom
This allows using Euclid types in BTree collections.
This change is