-
Notifications
You must be signed in to change notification settings - Fork 36
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
Automatically deriving implementations #43
Comments
Is the last blanket impl necessary? You could always just create a macro to create the implementation for foreign types if needed |
Here's a pretty quick and dirty example of the sort of thing needed: https://gist.github.com/tylerreisinger/886e56379beffabddaff7bad6a232f06. It can only handles structs and won't insert type bounds on generics, but otherwise works. |
Also, there is no clean way to deal with both non-primitive Epsilon types and a mix of f32/f64 types without TryFrom, which is currently unstable. I used |
A nice thing to have would be a derive-proc-macro, so you could do #[derive(AbsDiffEq)]
struct MyStruct { ... } thus avoiding all the repetitive boilerplate on a per-struct basis. |
This would be really great to have! Approximately comparing nested |
@joshburkart It's not ready for a PR yet, but I can work on it a bit this weekend and see if I can get something working. TryFrom being stabilized helps with an issue implementing it. |
Yeah, having this would be really nice! I know it'll be a bit annoying with the epsilon though, and haven't had much time at the moment to look into it. |
I've created a repository at https://github.com/tylerreisinger/approx_derive to implement it. When it is production ready, I can transfer ownership or merge it into the approx repo with a cargo workspace. |
I'd love to have this as well! |
Big woops, didn't see https://github.com/jonaspleyer/approx-derive created between my first usage of Some pretty big differences in design choices so I'll see how to best contribute to it, but at least linking it here for visibility to at least avoid having a third person going full xkcd 927 😅 |
Hey everyone, I have just recently updated my From briefly looking over the suggestions made by @Sufflope it seems that it would be a good idea to use |
To summarize the functionalities of my crate. It solves some of the problems already encountered by users:
|
Is there any outlook on automatic derivations of the traits in this crate?
I tried to write a derive crate, but got stuck. Deriving for example
AbsDiffEq
for structs could be done by callingAbsDiffEq::abs_diff_eq
on all fields, in combination with animpl<T: Eq> AbsDiffEq for T
. This last trait implementation collides however with the existing derivation implementations such asimpl<'a, T: AbsDiffEq> AbsDiffEq for &'a T
. I don't know how to solve this problem without removing these trait derivations, or until this work is finished.The text was updated successfully, but these errors were encountered: