approx icon indicating copy to clipboard operation
approx copied to clipboard

`impl RelativeEq for Option<T: RelativeEq>`?

Open johanhelsing opened this issue 1 year ago • 1 comments

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 avatar Nov 11 '22 13:11 johanhelsing