#combine #struct #derive #macro

macro no-std derive-combine

A macro for combining multiple structs into one

1 unstable release

0.1.0 May 4, 2023

#1422 in Procedural macros

MIT license

5KB
66 lines

derive-combine

use derive_combine::Combine;

#[derive(Combine, Eq, PartialEq, Debug)]
struct Abc {
    a: Option<u8>,
    b: Vec<u8>,
    d: u16,
}

#[test]
fn test_combine() {
    let mut abc = Abc {
        a: Some(1),
        b: vec![2],
        d: 3,
    };

    let other = Abc {
        a: None,
        b: vec![4],
        d: 5,
    };

    abc.combine(other);

    let expected = Abc {
        a: Some(1),
        b: vec![2, 4],
        d: 3,
    };

    assert_eq!(abc, expected);
}

Dependencies

~0.4–0.8MB
~19K SLoC