Allow types generated with prop_extractor!
to implement Hash
, PartialEq
, and Eq
trivially
#447
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.
Implements
Hash
,PartialEq
andEq
onExtratorField
whereR::Type
also implements that trait, and enables theprop_extractor!
macro to accept zero or more attributes preceding the type definition.Rationale: Makes implementing these traits as simple as it would be in an ordinary
struct
declaration.Use-case: In my particular case, I have some expensive-to-recompute bezier paths which are computed once in my
View
'slayout
function; and some relatively trivial to recompute coordinates that change more often, and indicator which points to some position on those paths. By keeping a hash of those properties that could require recomputation of the path (line size, component size, things like that) I can avoid recomputing the more expensive things unless something really changed that invalidates the cached value.Originally this code was simply a standalone struct type, but since many of the properties make sense as style properties, I'm attempting to migrate this code to use style properties where possible - and the ability to simply add
#[derive(PartialEq, Eq, Hash)]
just inside theprop_extractor!
invocation simplifies the implementation.