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

Closed
wants to merge 1 commit into from
Closed

Implement the From<bool> trait for TestResult #298

wants to merge 1 commit into from

Conversation

schneiderfelipe
Copy link
Contributor

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
Contributor Author

@BurntSushi can we get this merged? ❤️

@jhpratt
Copy link
Collaborator

jhpratt commented Mar 6, 2025

GitHub is being buggy, so I've merged this manually 👍

@jhpratt jhpratt closed this Mar 6, 2025
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.

2 participants