structural-convert 0.13.0

Derive conversion traits (From, Into, TryFrom, TryInto) when fields are structurally similar in enums or structs
Documentation
use structural_convert::StructuralConvert;

#[test]
fn variant_is_named_default_to_field() {
    #[derive(Debug, PartialEq)]
    struct Rhs {
        z: i8,
        x: u32,
    }

    #[derive(Debug, PartialEq, StructuralConvert)]
    #[convert(try_from(Rhs))]
    struct Lhs {
        z: i32,
        x: u32,
        #[convert(try_from(default))]
        y: u8,
    }

    assert_eq!(
        Lhs {
            z: 1,
            x: 2,
            y: Default::default()
        },
        Rhs { z: 1, x: 2 }.try_into().unwrap()
    );
}