| Crates.io | derive-quickcheck-arbitrary |
| lib.rs | derive-quickcheck-arbitrary |
| version | 0.1.3 |
| created_at | 2023-07-31 12:24:27.049434+00 |
| updated_at | 2023-09-13 11:00:22.438505+00 |
| description | derive quickcheck::Arbitrary |
| homepage | |
| repository | https://github.com/aatifsyed/derive-quickcheck-arbitrary |
| max_upload_size | |
| id | 930814 |
| size | 18,936 |
Derive macro for quickcheck::Arbitrary.
Expands to calling Arbitrary::arbitrary
on every field of a struct.
use derive_quickcheck_arbitrary::Arbitrary;
#[derive(Clone, Arbitrary)]
struct Yakshaver {
id: usize,
name: String,
}
You can customise field generation by either:
&mut quickcheck::Gen.#[derive(Clone, Arbitrary)]
struct Yakshaver {
/// Must be less than 10_000
#[arbitrary(gen(|g| num::clamp(usize::arbitrary(g), 0, 10_000) ))]
id: usize,
name: String,
#[arbitrary(default)]
always_false: bool,
}
You can skip enum variants:
#[derive(Clone, Arbitrary)]
enum YakType {
Domestic {
name: String,
},
Wild,
#[arbitrary(skip)]
Alien,
}
You can add bounds for generic structs:
#[derive(Clone, Arbitrary)]
#[arbitrary(where(T: Arbitrary))]
struct GenericYak<T> {
name: T,
}