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

impl RelativeEq for Option<T: RelativeEq>? #80

Open
johanhelsing opened this issue Nov 11, 2022 · 1 comment
Open

impl RelativeEq for Option<T: RelativeEq>? #80

johanhelsing opened this issue Nov 11, 2022 · 1 comment

Comments

@johanhelsing
Copy link

johanhelsing commented Nov 11, 2022

I'd like to be able to write the following code:

pub fn maybe_f32(foo: f32) -> Option<f32> {
    // ...
}

/// in test
let c = maybe_f32();
assert_relative_eq!(maybe_f32(123.0), None);

I could do:

assert!(maybe_f32().is_none());

However, the advantage with the first version, is that on failure I can also see the actual value that was returned from maybe_f32, speeding up debugging a little bit.

@johanhelsing
Copy link
Author

Oh, I see someone already did this in #57

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

No branches or pull requests

1 participant