proptest/product_tuple.rs
1//-
2// Copyright 2017, 2018 The proptest developers
3//
4// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7// option. This file may not be copied, modified, or distributed
8// except according to those terms.
9
10//! Defines macros for product type creation, extraction, and the type signature
11//! itself. This version uses tuples. This mechanism is used to be very
12//! loosely coupled with `frunk_core` so that only `lib.rs` has to be changed
13//! in the event that Rust gets tuple-variadic generics.
14
15macro_rules! product_type {
16 ($factor: ty) => {
17 ($factor,)
18 };
19 ($($factor: ty),*) => {
20 ( $( $factor, )* )
21 };
22 ($($factor: ty),*,) => {
23 ( $( $factor, )* )
24 };
25}
26
27macro_rules! product_pack {
28 ($factor: expr) => {
29 ($factor,)
30 };
31 ($($factor: expr),*) => {
32 ( $( $factor ),* )
33 };
34 ($($factor: expr),*,) => {
35 ( $( $factor ),* )
36 };
37}
38
39macro_rules! product_unpack {
40 ($factor: pat) => {
41 ($factor,)
42 };
43 ($($factor: pat),*) => {
44 ( $( $factor ),* )
45 };
46 ($($factor: pat),*,) => {
47 ( $( $factor ),* )
48 };
49}