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

Move FuzzyEq into core::cmp and rename it to ApproxEq #6263

Closed
wants to merge 2 commits into from

Conversation

brendanzab
Copy link
Member

Moving the trait into core allows it to be added to the num::Float trait.

I have also added an assert_approx_eq! macro. This is useful fo making approximate assertions on types that implement the ApproxEq trait.

Examples:

// using the default epsilon value
assert_approx_eq!(1.0000001f, 1.0f);

// using a custom epsilon value
assert_approx_eq!(1.000001f, 1.0f, 1.0e-5);

// fails with: "left: 1.00001 does not approximately equal right: 1"
assert_approx_eq!(1.00001f, 1.0f);

bors added a commit that referenced this pull request May 6, 2013
Moving the trait into `core` allows it to be added to the `num::Float` trait.

I have also added and `assert_approx_eq!` macro. This is useful fo making approximate assertions on types that implement the `ApproxEq` trait.

Examples:

~~~rust
// using the default epsilon value
assert_approx_eq!(1.0000001f, 1.0f);

// using a custom epsilon value
assert_approx_eq!(1.000001f, 1.0f, 1.0e-5);

// fails with: "left: 1.00001 does not approximately equal right: 1"
assert_approx_eq!(1.00001f, 1.0f);
~~~
@bors bors closed this May 6, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Nov 3, 2020
use diff -u in driver.sh test

this changs the add/delete indication from
>
>
<
to
+
+
-
(same as git diff)

changelog: none
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.

3 participants