greyblake / nutype

Rust newtype with guarantees 🇺🇦 🦀

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support Arbitrary for `any` types

greyblake opened this issue · comments

Specs

  • Add ArbitraryArbitrary variant to AnyDeriveTrait enum.
  • Adjust to_any_derive_trait() validation function to return AnyDeriveTrait::ArbitraryArbitrary
  • Add module nutype_macros/src/any/gen/traits/arbitrary.rs
  • Implement there a derive of ::arbitrary::Arbitrary crate
    • If type has custom validation set with predicate = , then it should return a compile error, saying that derive of Arbitrary is not possible
    • If inner type implements Arbitrary it should work (though, it's not possible to know at the compile time if the inner type implements Arbitrary`
  • Create a new example in any_arbitrary that demos derive of Arbitrary. See integer_arbitrary for example.