patched

Crates.iopatched
lib.rspatched
version0.3.0
created_at2025-02-16 14:04:00.257993+00
updated_at2025-02-18 19:55:39.47255+00
descriptionMacro for patch like structure
homepage
repositoryhttps://github.com/tguichaoua/patched
max_upload_size
id1557758
size31,719
Tristan Guichaoua (tguichaoua)

documentation

README

Patched

github Latest version Documentation MIT Apache

A macro that generates patch struct.

use patched::Patch;

#[derive(Patch)]
struct Foo {
    a: u8,
    b: String,
}

// Will generates

struct FooPatch {
    a: Option<u8>
    b: Option<String>,
}

impl Default for FooPatch {
    /* ... */
}

impl Patch<FooPatch> for Foo {
    /* ... */
}

Usage example:

let mut value = Foo {
    a: 10,
    b: String::from("Hello");
}

value.patch(FooPatch {
    a: Some(99),
    ..Default::default()
});

assert_eq!(
    value,
    Foo {
        a: 99,
        b: String::from("Hello");
    }
);
Commit count: 12

cargo fmt