BurntSushi / quickcheck

Automated property based testing for Rust (with shrinking).
The Unlicense
2.4k stars 149 forks source link

Implement the From<bool> trait for TestResult #298

Open schneiderfelipe opened 3 years ago

schneiderfelipe commented 3 years ago

Hi @BurntSushi, thank you for this very nice library!

This PR adds an implementation of From<bool> for TestResult. It allows using TestResult::from(true) everywhere, and true.into() when the TestResult type can be inferred from the context, which I believe improves ergonomics in some situations:

// From the README
fn prop(xs: Vec<isize>) -> TestResult {
    if xs.len() != 1 {
        return TestResult::discard()
    }
    (xs == reverse(&xs)).into() // Instead of `TestResult::from_bool(xs == reverse(&xs))`
}
schneiderfelipe commented 7 months ago

@BurntSushi can we get this merged? ❤️