Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the From<bool> trait for TestResult #298

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Implement the From<bool> trait for TestResult #298

wants to merge 1 commit into from

Conversation

schneiderfelipe
Copy link

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
Copy link
Author

@BurntSushi can we get this merged? ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant