binary_wrapper

Macro binary_wrapper 

Source
binary_wrapper!() { /* proc-macro */ }
Expand description

The binary_wrapper! macro generates implementations for the core binary operations onto a generic wrapper type. It supports both tuple structs and structs with named fields.

extern crate rspace_macros as macros;

pub struct Wrapper<T>(pub T);

macros::binary_wrapper! {
    impl Wrapper {
        Add.add,
        Sub.sub,
        Mul.mul,
        Div.div,
        Rem.rem,
    }
}

or, for transparent structs with a named field:

extern crate rspace_macros as macros;

pub struct Wrapper<T> {
    pub field: T,
}

macros::binary_wrapper! {
    impl Wrapper.field {
        Add.add,
        Sub.sub,
        Mul.mul,
        Div.div,
        Rem.rem,
    }
}