Macro malachite_base::exhaustive_unions
source ยท macro_rules! exhaustive_unions { ( ($($vis:tt)*), $union: ident, $lex_struct: ident, $exhaustive_struct: ident, $lex_fn: ident, $exhaustive_fn: ident, $n: expr, $([$i: expr, $t: ident, $it: ident, $variant: ident, $xs: ident, $xs_done:ident]),* ) => { ... }; }
Expand description
Defines exhaustive union generators.
Malachite provides lex_union2s
and exhaustive_union2s
, but you can also define
lex_union3s
, lex_union4s
, and so on, and exhaustive_union3s
, exhaustive_union4s
, and so
on, in your program using the code below. The documentation for lex_union2s
and
exhaustive_union2s
describes these other functions as well.
See usage examples here and here.
use malachite_base::unions::UnionFromStrError;
use malachite_base::{exhaustive_unions, union_struct};
use std::fmt::{self, Display, Formatter};
use std::str::FromStr;
union_struct!(
(pub(crate)),
Union3,
Union3<T, T, T>,
[A, A, 'A', a],
[B, B, 'B', b],
[C, C, 'C', c]
);
union_struct!(
(pub(crate)),
Union4,
Union4<T, T, T, T>,
[A, A, 'A', a],
[B, B, 'B', b],
[C, C, 'C', c],
[D, D, 'D', d]
);
union_struct!(
(pub(crate)),
Union5,
Union5<T, T, T, T, T>,
[A, A, 'A', a],
[B, B, 'B', b],
[C, C, 'C', c],
[D, D, 'D', d],
[E, E, 'E', e]
);
union_struct!(
(pub(crate)),
Union6,
Union6<T, T, T, T, T, T>,
[A, A, 'A', a],
[B, B, 'B', b],
[C, C, 'C', c],
[D, D, 'D', d],
[E, E, 'E', e],
[F, F, 'F', f]
);
union_struct!(
(pub(crate)),
Union7,
Union7<T, T, T, T, T, T, T>,
[A, A, 'A', a],
[B, B, 'B', b],
[C, C, 'C', c],
[D, D, 'D', d],
[E, E, 'E', e],
[F, F, 'F', f],
[G, G, 'G', g]
);
union_struct!(
(pub(crate)),
Union8,
Union8<T, T, T, T, T, T, T, T>,
[A, A, 'A', a],
[B, B, 'B', b],
[C, C, 'C', c],
[D, D, 'D', d],
[E, E, 'E', e],
[F, F, 'F', f],
[G, G, 'G', g],
[H, H, 'H', h]
);
exhaustive_unions!(
(pub(crate)),
Union3,
LexUnion3s,
ExhaustiveUnion3s,
lex_union3s,
exhaustive_union3s,
3,
[0, X, I, A, xs, xs_done],
[1, Y, J, B, ys, ys_done],
[2, Z, K, C, zs, zs_done]
);
exhaustive_unions!(
(pub(crate)),
Union4,
LexUnion4s,
ExhaustiveUnion4s,
lex_union4s,
exhaustive_union4s,
4,
[0, X, I, A, xs, xs_done],
[1, Y, J, B, ys, ys_done],
[2, Z, K, C, zs, zs_done],
[3, W, L, D, ws, ws_done]
);
exhaustive_unions!(
(pub(crate)),
Union5,
LexUnion5s,
ExhaustiveUnion5s,
lex_union5s,
exhaustive_union5s,
5,
[0, X, I, A, xs, xs_done],
[1, Y, J, B, ys, ys_done],
[2, Z, K, C, zs, zs_done],
[3, W, L, D, ws, ws_done],
[4, V, M, E, vs, vs_done]
);
exhaustive_unions!(
(pub(crate)),
Union6,
LexUnion6s,
ExhaustiveUnion6s,
lex_union6s,
exhaustive_union6s,
6,
[0, X, I, A, xs, xs_done],
[1, Y, J, B, ys, ys_done],
[2, Z, K, C, zs, zs_done],
[3, W, L, D, ws, ws_done],
[4, V, M, E, vs, vs_done],
[5, U, N, F, us, us_done]
);
exhaustive_unions!(
(pub(crate)),
Union7,
LexUnion7s,
ExhaustiveUnion7s,
lex_union7s,
exhaustive_union7s,
7,
[0, X, I, A, xs, xs_done],
[1, Y, J, B, ys, ys_done],
[2, Z, K, C, zs, zs_done],
[3, W, L, D, ws, ws_done],
[4, V, M, E, vs, vs_done],
[5, U, N, F, us, us_done],
[6, T, O, G, ts, ts_done]
);
exhaustive_unions!(
(pub(crate)),
Union8,
LexUnion8s,
ExhaustiveUnion8s,
lex_union8s,
exhaustive_union8s,
8,
[0, X, I, A, xs, xs_done],
[1, Y, J, B, ys, ys_done],
[2, Z, K, C, zs, zs_done],
[3, W, L, D, ws, ws_done],
[4, V, M, E, vs, vs_done],
[5, U, N, F, us, us_done],
[6, T, O, G, ts, ts_done],
[7, S, P, H, ss, ss_done]
);