Extending approx with derive macros

I recently had a problem when using the approx crate: I was tired of implementing the AbsDiffEq trait by hand for every struct that I wrote. This I came up with this proc-macro crate which extends the approx-derive crate by useful derive macros with additional functionality.

Example

# use approx_derive::AbsDiffEq;

#[derive(AbsDiffEq, PartialEq, Debug)]
struct Player {
    pos_x: f64,
    pos_y: f64,
    #[approx(skip)]
    id: u64,
}

let p1 = Player {
    pos_x: 1.0,
    poy_y: 2.0,
    id: 10,
};
let p2 = Player {
    x: 1.1,
    y: 1.9,
    id: 749,
};

approx::assert_abs_diff_eq!(p1, p2, epsilon = 0.2);

What are you interested in? How would you improve this crate? Let me hear your feedback! :slight_smile:

View the code here:

And the documentation here:

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.