derive-partial-eq-extras

Crates.ioderive-partial-eq-extras
lib.rsderive-partial-eq-extras
version0.2.0
sourcesrc
created_at2021-12-19 22:52:33.006031
updated_at2024-03-01 09:35:06.841653
descriptionMore customisable #[derive(PartialEq)]
homepage
repositoryhttps://github.com/kaleidawave/derive-partial-eq-extras
max_upload_size
id500527
size13,216
Ben (kaleidawave)

documentation

README

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

Commit count: 6

cargo fmt