[][src]Macro pair_macro::create_pair

macro_rules! create_pair {
    ( $name: tt; $($field: tt),* ) => { ... };
    ($(#[$attr: meta])* struct $name: tt; $($field: tt),* ) => { ... };
}

Creates a pair type. pair_macro::create_pair_prelude must be imported to use this.

Examples

Basic usage

use pair_macro::create_pair_prelude::*;

create_pair!(MyOwnPair; a, b, c, d);

let p = MyOwnPair::new(1, 2, 3, 4);
let q = MyOwnPair::new(5, 6, 7, 8);
let r = p + q;
assert_eq!(6, r.a);
assert_eq!(8, r.b);
assert_eq!(10, r.c);
assert_eq!(12, r.d);

With documentation comment

use pair_macro::create_pair_prelude::*;

// create a type with documentation comment.
create_pair!(
   /// My own pair type.
   struct MyOwnPair;
   a, b, c, d
);

let p = MyOwnPair::new(1, 2, 3, 4);
let q = MyOwnPair::new(5, 6, 7, 8);
let r = p + q;
assert_eq!(6, r.a);
assert_eq!(8, r.b);
assert_eq!(10, r.c);
assert_eq!(12, r.d);