ndk: Implement common traits where sensible, and drop some Ord
#483
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Provided traits in the
ndk
crate are all over the place. Some pointer wrappers and regular enumerations derive(Partial)Ord
even though there is no sense in using an ordering for these types. Others don't derive(Partial)Eq
andHash
which makes it hard to compare if objects are the same (by-pointer) or to store them inside i.e.HashMap
. Deriving these types follows Rust's C-COMMON-TRAITS convention.Additionally, sort
derives
by their relation, followed by sorting them alphabetically.Note that
Hash
may not be all too useful to store owned types as keys inHashMap
, in case you have to temporarily increase the refcount on a pointer (i.e. aNativeWindow
inside a callback viaNativeWindow::clone_from_ptr()
) just to extract the element with that pointer, but that is hopefully something we can revise with #309. Additionally, some ways of solving that issue may involve addingClone, Copy
to some non-refcounted types (assuming they have an external lifetime guarding it).TODO
ndk-sys
to be able to implement them on structures that ownffi
structures;Iter
wrappers?Ord
on pointer wrappers after all, to store them in i.e.BTreeMap
even though their ordering has no useful definition?CC @daxpedda for suggestions based on rust-windowing/winit#3796 :)