| Crates.io | quickcheck-arbitrary-derive |
| lib.rs | quickcheck-arbitrary-derive |
| version | 0.2.7 |
| created_at | 2025-06-10 15:07:52.6388+00 |
| updated_at | 2025-06-12 01:31:52.649917+00 |
| description | Derive QuickCheck's Arbitrary trait |
| homepage | |
| repository | https://github.com/NathanSnail/quickcheck-derive |
| max_upload_size | |
| id | 1707219 |
| size | 24,953 |
A #[derive(QuickCheck)] macro to automatically implement QuickCheck’s Arbitrary (with arbitrary + shrink) for your types.
Dual-licensed under MIT or UNLICENSE
Add to your Cargo.toml:
quickcheck = "1.0.3" # quickcheck runtime
quickcheck-arbitrary-derive = "0.2.7" # this derive macro
#[derive(Clone, QuickCheck, Debug)]
struct Pair<T> {
first: T,
second: T,
}
#[cfg(test)]
mod test {
use crate::Pair;
#[quickcheck_macros::quickcheck]
fn fails(pair: Pair<isize>) {
assert_eq!(pair.first, pair.second);
}
}
You should see that the test fails, and that the minimal example produced is just (1, 0). The derive macro automatically implements both arbitrary and shrink so that the sample failing test cases are as simple as possible.
arbitrary and shrink#[quickcheck(recursive = Exponential)] enum variant attribute