jonaspleyer / approx-derive

Derive traits used in the approx crate.
https://github.com/jonaspleyer/approx-derive
Apache License 2.0
0 stars 1 forks source link

Support exact equality on some fields #3

Open Sufflope opened 1 week ago

Sufflope commented 1 week ago

Hello, just like you can currently skip fields, for my use case I would need some fields to be compared with ==. Example case would be a struct like:

struct Prediction {
    category: String,
    confidence: f64
}

where I want approx equality for confidence but exact equality for category.

I'm taking the opportunity to say that unfortunately, between my first usage of approx 2 years ago when I didn't feel the need for a derive, and the last one this summer where the urge kicked in, I didn't notice that you started this project, so I started mine :sweat_smile:. Maybe you could be interested in having a look : https://github.com/brendanzab/approx/pull/89

I think you might be interested in darling (e.g. the problem solved by https://github.com/jonaspleyer/approx-derive/pull/1 would not happen with it instead of manual (and tedious IMO) parsing).

I took a few diverging design options based on my use-case which seems a bit different than yours, but maybe we can work something out?

jonaspleyer commented 1 week ago

Hi and thanks for taking the time to give this feedback. Comparing with the == operator makes sense as you point out. I will look into this and add it as soon as possible.

Concerning the integration into mainline: I think from a practical perspective it is much more favorable to have the derive macros under a feature flag in the main crate. I will have a look and see if we can reuse some of my code there.

I have come across darling in the past but was occupied with too much other work to truly give it a go. If I find the time and feel the need to to do, I will come back to this. Thanks for pointing this out to me though!