Giter Site home page Giter Site logo

Comments (2)

cristicbz avatar cristicbz commented on August 11, 2024 2

I rattled my brain for the better part of a day, and of course the moment I file the issue I figure it out. This library is so cool, the solution is really simple for everyone seeing this in future:

fn shrink(&self) -> Box<Iterator<Item=Foo>> {
    Box::new((self.bar.clone(), self.baz.clone()).shrink().map(|(bar, baz)| Foo { bar: bar, baz: baz }))
}

Boom! Tuples FTW!

from quickcheck.

BurntSushi avatar BurntSushi commented on August 11, 2024

Glad you got it figured out. Indeed, falling back to tuple implementations of Arbitrary is a key trick in the Haskell quickcheck library too. It is also useful when you want to test properties with more than four parameters (or otherwise add more impls of Testable, but that's a pain).

Using an associated type isn't really tenable, I think. As you said, you can't provide a default impl. More than that, it makes shrinkers tedious to write, because you have to write out the concrete iterator types, which is, in my experience, quite laborious.

from quickcheck.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.