[][src]Crate pair_macro

pair

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

This crate runs on no-std environment.

Examples

Use a provided type Pair.

use pair_macro::Pair;

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

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

Create a new pair type.

use pair_macro::create_pair_prelude::*;

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

let p = MyOwnPair::new(1, 2, 3, 4); // MyOwnPair<i32>
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);

Modules

create_pair_prelude

This is required to create a pair type.

Macros

create_pair

Creates a pair type. When this macro is used out of this crate, pair_macro::create_pair_prelude must be imported.

Structs

Pair

Represents a pair consisting of the same-type values.

Triplet

Represents a pair consisting of the same-type values.