#partial-eq #extra #partial #eq #derive

macro derive-partial-eq-extras

More customisable #[derive(PartialEq)]

4 releases

0.2.0 Mar 1, 2024
0.1.2 Jan 27, 2023
0.1.1 Jan 24, 2023
0.1.0 Dec 19, 2021

#14 in #extra

Download history 39/week @ 2024-06-06 34/week @ 2024-06-13 53/week @ 2024-06-20 23/week @ 2024-06-27 32/week @ 2024-07-04 27/week @ 2024-07-11 26/week @ 2024-07-18 61/week @ 2024-07-25 71/week @ 2024-08-01 54/week @ 2024-08-08 35/week @ 2024-08-15 17/week @ 2024-08-22 92/week @ 2024-08-29 10/week @ 2024-09-05 20/week @ 2024-09-12 5/week @ 2024-09-19

127 downloads per month
Used in 4 crates (via ezno-parser)

MIT license

9KB
137 lines

Derive partial eq extras

crates.io badge docs.rs badge

More customisable #[derive(PartialEq)]

Adds ability to ignore/skip fields

#[partial_eq_ignore]

use derive_partial_eq_extras::PartialEqExtras;

#[derive(PartialEqExtras)]
struct A {
    x: u32,
    #[partial_eq_ignore]
    y: String,
}

Here the y field is ignored when comparing As. e.g A { x: 4, y: "Hello".into() } == A { x: 4, y: "World".into() } is true

#[partial_eq_ignore_types]

use derive_partial_eq_extras::PartialEqExtras;

#[derive(PartialEqExtras)]
#[partial_eq_ignore_types(u32)]
struct Numbers {
    name: String,
    x: u32,
    y: u32,
    z: u32,
}

Here the x, y and z fields are ignored because they have type u32 which is marked on a top level attribute as something to ignore. This becomes a shorthand for defining #[partial_eq_ignore] on all fields with u32 types

Dependencies

~340–790KB
~19K SLoC