-
-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Derive Ord
and PartialOrd
for ClassName
#928
Conversation
Thanks a lot! I'm wondering, would the expectation here not be lexicographical ordering? Otherwise operations like |
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-928 |
Not sure if this might be counter-intuitive, but implication here is about ID stability only within a single run, without lexicographical order. |
What do you mean with "ID stability"? Ordering? If yes, I'm aware that this is the implication -- my argument was that this isn't necessarily a good implication 😉 even more so if undocumented.
Could you elaborate the use case you encountered? Btw, clippy error is fixed in #929, you can rebase after I merge that. |
Ord
and PartialOrd
for ClassName
5e17a80
to
84581d2
Compare
Maybe as prior art regarding the "non-lexicographical ordering dilemma", I'm not sure if this would make sense here, too -- arguably the expectations for strings to be lexicographic is still higher than for class names, although "name" may have some of that connotation, as well. Either way, we should definitely provide the fast ordering check based on indices. But it should at the very least be documented (c.f. |
I'm implementing a child node hook auto-registration mechanism, where parent node keeps It's possible to use |
Just to be clear, you're not looking for one of the following properties, right?
With "linear", do you mean
If yes, that's definitely a valid use case. Do you have any input on my API comment above? |
Sorry for not being clear on what I've meant by "linear".
Yeah, that's what I've meant.
I agree that it might feel confusing, and type wrapper solution might be preferable, since my case is pretty a niche one. But I also wonder - may it be somewhat more logical to name
|
Hm, very good points 🤔 Historically, it used to be a simple For this PR, you can go ahead with deriving |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Can you apply the suggestion and squash the commits? Then it should be ready to go 🙂
This PR adds two simple derives (Ord and PartialOrd) to allow the storage of ClassName type in ordered maps (BTreeSet/BTreeMap etc.). Co-authored-by: Jan Haller <[email protected]>
e81fcdb
to
be6a075
Compare
Thanks a lot for your contribution! 😊 |
This PR adds two simple derives (
Ord
andPartialOrd
) to allow the storage ofClassName
type values in ordered maps (BTreeSet
/BTreeMap
etc.).