pair_macro Build Status

Create types consisting of the same type values such that Pair, Triplet, and so on.

This crate runs on no-std environment.

Import

In your Cargo.toml: pair_macro = "0.1.2"

Examples

Use a provided type Pair.

```rust use pair_macro::Pair;

let p = Pair::new(1.0, 2.0); // Pair let q = p.map(|v| v * 2.0);

asserteq!(Pair::new(2.0, 4.0), q); asserteq!(2.0, q.x); assert_eq!(4.0, q.y); ```

Create a new pair type.

```rust use pairmacro::createpair_prelude::*;

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

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

Features

Pair types support serialize/deserialize by enabling serde feature.
In your Cargo.toml: pair_macro = { version = "0.1.2", features = ["serde"] }