derive-combine

Crates.ioderive-combine
lib.rsderive-combine
version0.1.0
sourcesrc
created_at2023-05-04 21:58:03.084386
updated_at2023-05-04 21:58:03.084386
descriptionA macro for combining multiple structs into one
homepage
repositoryhttps://github.com/andrewgazelka/derive-combine
max_upload_size
id857130
size4,768
Andrew Gazelka (andrewgazelka)

documentation

README

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);
}
Commit count: 1

cargo fmt