Expand description
Derive macros for automatic algebraic law verification.
These macros generate #[cfg(test)] modules containing proptest-based
property tests that verify algebraic laws for user-defined types.
§Usage
ⓘ
use karpal_proof_derive::VerifySemigroup;
#[derive(Clone, Debug, PartialEq, VerifySemigroup)]
#[verify(strategy = "0u32..100")]
struct MyWrapper(u32);§Attributes
-
#[verify(strategy = "...")]— Required. A proptest strategy expression that generates values of the annotated type. Examples:"0u32..100"for numeric ranges"any::<MyType>()"for types implementingArbitrary"(0i32..50).prop_map(MyWrapper)"for newtype wrappers
-
#[verify(epsilon = "1e-10")]— Optional. Use approximate floating-point comparison instead of exactPartialEq. The generated tests will use(left - right).abs() < epsiloninstead ofprop_assert_eq!.
Derive Macros§
- Verify
Commutative - Derive
VerifyCommutative: generates proptest for commutativity ofcombine. - Verify
Group - Derive
VerifyGroup: generates proptest for left/right inverse. - Verify
Lattice - Derive
VerifyLattice: generates proptests for associativity, commutativity, idempotency, and absorption ofmeet/join. - Verify
Monoid - Derive
VerifyMonoid: generates proptest for left/right identity ofempty. - Verify
Ring - Derive
VerifyRing: generates proptest for additive inverse (negate). - Verify
Semigroup - Derive
VerifySemigroup: generates proptest for associativity ofcombine. - Verify
Semiring - Derive
VerifySemiring: generates proptests for additive monoid, multiplicative monoid, distributivity, and zero annihilation.