Skip to content

Commit

Permalink
arbitrary: add feature gate for arrays implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
kurnevsky committed Jan 11, 2019
1 parent ac1a3dc commit 7ea5da4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ default = ["regex", "use_logging"]
unstable = []
use_logging = ["log", "env_logger"]
regex = ["env_logger/regex"]
arrays = []

[lib]
name = "quickcheck"
Expand Down
3 changes: 3 additions & 0 deletions src/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ impl_arb_for_tuples! {
(H, 7),
}

#[cfg(feature = "arrays")]
macro_rules! impl_arb_for_single_array {
($array_size:expr; $($index:expr,)*) => {
impl<T: Arbitrary> Arbitrary for [T; $array_size] {
Expand Down Expand Up @@ -276,6 +277,7 @@ macro_rules! impl_arb_for_single_array {
}
}

#[cfg(feature = "arrays")]
macro_rules! impl_arb_for_arrays {
(@internal [$($acc:expr,)*]) => { };
(@internal [$($acc:expr,)*] $array_size:expr, $($rest:expr,)*) => {
Expand All @@ -287,6 +289,7 @@ macro_rules! impl_arb_for_arrays {
}
}

#[cfg(feature = "arrays")]
impl_arb_for_arrays!(
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
Expand Down

0 comments on commit 7ea5da4

Please sign in to comment.